Hi Tolga,
I am about to leave for 2 weeks travel so won't be able
to look into this for a while. However, if it really is
true (i.e., do you really get 12 messages on the 12th new
grid?) then a test program would be useful to help us
recreate the problem.
Cheers,
Bill
----------------------------------------------------------
Bill Hibbard, SSEC, 1225 W. Dayton St., Madison, WI 53706
hibbard@xxxxxxxxxxxxxxxxx 608-263-4427 fax: 608-263-6738
http://www.ssec.wisc.edu/~billh/vis.html
On Sun, 24 Jun 2001, Tolga Sakman wrote:
> Dear Don, Curtis and ALL,
>
> Thanks to Don's on and off line help, I was able to get the new grid to show
> on the display. What I had to do was to do:
>
> display.removeAllReferences(); //display is a DisplayImplJ2D
> display.clearMaps();
> before attempting to display the new grid. However, I realized the following
> -rather interesting- behavior: In the system.out of the following:
>
> display.addDisplayListener(new DisplayListener() {
> public void displayChanged(DisplayEvent e) {
> if(e.getId() == DisplayEvent.MOUSE_PRESSED_CENTER) { //
> click left-right mouse buttons simultaneously.
> xval = (float)displayRenderer.getDirectAxisValue(row);
> yval = (float)displayRenderer.getDirectAxisValue(column);
> System.out.println( "> " + "X : " + xval + "\t\tY: " +
> yval );
> }
> }
> });
>
> I get one line with the initial grid, however, I get 2 lines (same line) with
> the second grid read, 3 lines with the third grid read, so on and so forth.
> So a click with the second grid gives:
>
> > X : 1.1516435 Y: -0.0683177
> > X : 1.1516435 Y: -0.0683177
>
> as if all the displays are somehow on different layers, and the event is
> caught by all of them, although they all have the ScalarMap range of the last
> one read.
>
> Can you give some pointers as to what may be going on?
>
> Thanks,
>
> Tolga
>
>
>
>
> ----- Original Message -----
> From: Don Murray
> To: Tolga Sakman
> Cc: visad-list@xxxxxxxxxxxxx
> Sent: Friday, June 22, 2001 10:48 AM
> Subject: Re: Refreshing DisplayImplJ2D after loading a new file
>
>
> Hi Tolga-
>
> > Tolga Sakman wrote:
> > My application creates a DisplayImplJ2D, reads a simple grid from a
> > default file and displays it. What it is is basically a square with
> > axes labeled "X" and "Y", used as a placeholder for the grid that will
> > be loaded.
> >
> > Then I use my custom container's (a swing gui) controls to select a
> > file and feed it into my visaddisplay. What I want is the old display
> > to disappear, and the new one show up. Apparently, just changing the
> > dataset won't cut it; there are complications. Here's a stack trace:
> >
> > It gives a "visad.TypeException: ScalarType: name already used"
> > stemming from ScalarType.java:186. Apparently it did not like the fact
> > that I am trying to use the same row and column with the same names
> > such as:
> > row = new RealType("X", SI.meter, null);
> > column = new RealType("Y", SI.meter, null);
> > I presume the name "X" is where it cracks.
>
> RealTypes must be unique in VisAD. If you try to create a new RealType
> of the same name, you will get the exception. One way around this is to
> use the static RealType.getRealType() method which will return the
> existing RealType or create a new one if there is not one yet defined.
> If your data will always end up with RealTypes of row and column, then
> you only need to create them once in the constructor as you did.
>
> > Then I try to "null"ify these objects if they != null, it does not
> > work.
> >
> > Then I take these into the initial constructor so that they are not
> > called when a new file is loaded. This does not throw exceptions, but
> > does not display my new grid either. row and column still have their
> > old ways, so does myDisplay (the DisplayImplJ2D reference).
> >
> > I try to myDisplay.destroy() if myDisplay != null, but it apparently
> > never reaches there.
>
> How are you setting the data? You should just be able to call the
> setData method on your DataReference with the new Data object. In this
> case, the display should automatically update.
>
> > So after spending 4 hours of my night and bulk of this morning on
> > this, my question is: How do you clear the display and show new data
> > without killing the reference within the GUI and constructing a new
> > one with the new chosen file?
>
> When you select the file, read it in and create a VisAD Data object and
> then call setData with that object on your DataReference. The new data
> should automatically appear in the display.
>
> Don
> *************************************************************
> Don Murray UCAR Unidata Program
> dmurray@xxxxxxxxxxxxxxxx P.O. Box 3000
> (303) 497-8628 Boulder, CO 80307
> http://www.unidata.ucar.edu/staff/donm
> *************************************************************
>