Re: question on DisplayRendering - setSize question

John,

I've included the source for a small Java class that sets the
preferred size of a 2-D display's panel.  This code should cause
an empty display of size 600 x 400 to pop up in its own frame.

If it doesn't work for you, first try getting the latest release
of VisAD, just in case some odd bug got fixed recently (although
I don't think that's the case).

If it still doesn't work after that, let me know and I'll look
into it.  There might be a bug in VisAD that only appears on
some systems (e.g., a race condition) that is resetting the
preferred size somewhere.

If the code below does work for you, then something else must be
causing the problem you are experiencing.  First, make sure you
are calling pack() on the parent Frame before you display it.
Second, check out the layout manager you are using.  Some of
them have really strange quirks.  I recommend sticking to
Swing's BoxLayout if possible.  You definitely do not need to
use a different constructor for your displays.

In any case, if you can provide a code sample that demonstrates
the problem you are having, I'll gladly take a look at it.

Curtis

----------
// BEGIN BigDisplay.java
import java.awt.Dimension;
import java.rmi.RemoteException;
import javax.swing.JFrame;
import visad.VisADException;
import visad.java2d.*;

public class BigDisplay {

  public static void main(String[] args)
    throws VisADException, RemoteException
  {
    DisplayImplJ2D display = new DisplayImplJ2D("display");
    DisplayPanelJ2D panel = (DisplayPanelJ2D) display.getComponent();
    panel.setPreferredSize(new Dimension(600, 400));
    JFrame frame = new JFrame();
    frame.setContentPane(panel);
    frame.pack();
    frame.show();
  }

}
// END BigDisplay.java
----------

At 13:06 3/21/00 -0500, you wrote:
>Hi Curtis,
>i was able to get projection control & the aspect ratio to work O.K. but
>still not able to reset the default size (i've tried your example as below
>but it still has no effect on the display size).  something must be
>ignoring the DisplayPanelJ2D in DisplayImplJ2D - do i need to use another
>default display renderer (i.e., one of the other constructors for
>DisplayImplJ2D?
>
>i'm missing something for sure.
>
>-john
>
>P.S. also thanks tomw, you got me out of the stuck mode & re-started.  i
>have been looking at/using the examples - both the NCEP & Test58, but
>thought there might be a way to change the default size.
>
>RE:
>
>
>>At 09:33 3/21/00 -0500, you wrote:
>>>Hello Folks,
>>>how can i set the default display size and still use the VisAD 2D
>>>implementation?  i'd like to set it at 360 by 180 (i,e, to depict a
>>>rectangular latlon grid rather than a square).
>>>
>>>i'm having a little trouble understanding whether i can reference the
>>>setPreferredSize method in DisplayPanelJ2D.  is this possible?
>>>
>>>thanks,
>>>-john
>
>
>>John,
>>
>>There are two parts to what you want to do.  First you must set the
>>size of the actual DisplayPanelJ2D component to at least 360 x 180.
>>>From your message, it sounds like you are not having any trouble
>>with this part.  You're right that you can use
>>DisplayPanelJ2D.setPreferredSize() to accomplish this:
>>
>>DisplayImplJ2D display = new DisplayImplJ2D("display");
>>DisplayPanelJ2D panel = (DisplayPanelJ2D) display.getComponent();
>>panel.setPreferredSize(new Dimension(400, 200));
>>
>>Secondly, follow TomW's instructions for setting the aspect ratio
>>of the display.  For a Java2D example, see visad/examples/Test58,
>>which sets the aspect ratio in Java2D to a rectangular region like
>>you describe.
>>
>>Curtis
>
>
>John F. Moses
>Computer Sciences Corp.
>EOSDIS Science Operations, ESDIS Project Code 423
>BLD 32, E209I
>Goddard Space Flight Center, Greenbelt, Maryland, 20771
>Voice @ GSFC:  (301) 614-5308
>FAX @ GSFC:    (301) 614-5267
>Email:          John.F.Moses@xxxxxxxxxxxxx
>Email:          jfmoses@xxxxxxxxxxxxxxxxxxxx


  • 2000 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the visad archives: