Re: Displayed Data

Hi Bill and everyone,

Here's a quick update on my results from my question. With Bill's advice and looking at Cicero Augusto Wollmann Zandoná's test program "TestEvaluate.java" in the email archives, I wrote the following code snippet which retrieves the visible min/max of your Display's ScalarMaps.

variable/object used:

ScalarMaps: latMap, lonMap (for a 2D lat/lon display)
DisplayImpl: display
DisplayRenderer: dr
Component: disp_comp

This updates the min/max lat/lon visible whenever you pan or zoom or resize the window. I have a feeling that it might be a bit more complex with a 3D display.

I hope this is useful.

-kevin.


   display.addDisplayListener( new DisplayListener()
   {
     public void displayChanged(DisplayEvent e)
     {
       if (e.getId() == DisplayEvent.FRAME_DONE)
       {
         VisADRay ray = dr.getMouseBehavior().findRay(0,0);
         float[] lon_0 = lonMap.inverseScaleValues(
                        new float[] {(float)ray.position[0]});
         float[] lat_0 = latMap.inverseScaleValues(
                        new float[] {(float)ray.position[1]});
         Rectangle rect = disp_comp.getBounds();
         int x = (int) rect.getWidth();
         int y = (int) rect.getHeight();
         ray = dr.getMouseBehavior().findRay(x, y);
         float[] lon_1 = lonMap.inverseScaleValues(
                        new float[] {(float)ray.position[0]});
         float[] lat_1 = latMap.inverseScaleValues(
                        new float[] {(float)ray.position[1]});
         label0.setText("Frame Done X: 0, " + rect.getWidth() +
                       " / Y: 0, " + rect.getHeight() );
label1.setText(" Lat/Lon (top left) : " + lat_0[0] + "/" + lon_0[0]
                       + ", Lat/Lon (bottom right) : "
                       + lat_1[0] + "/" + lon_1[0] );
       }
     }
   });


Bill Hibbard wrote:

Hi Kevin,

If/when I zoom in on my displayed data, can I obtain the max and min
values of the data that are being displayed.

For example, let's sat that I have

(latitude, longitude)->(altitude)

projected in 2D with altitude is depicted as RGB.  If I zoom in
(shift+left click), am I able to get the "ranges" of the visible domain
values?  I.e.

x1 < lat < y1
x2 < lon < y2

I thought that I could do this with the DataRenderer getRanges()
method.  Would this be correct?  If so, is there a way to get the
default DataRender from the DisplayImpl, or do I created one and add it
to the Display?

I doubt you can rely on DataRenderer.getRanges() - it is
used for flow rendering and may not give reliable results
when you call it (e.g., when there is no flow rendering).

What you want to do is pretty complex. I'd call
MouseBehavior.findRay(int screen_x, int screen_y) (using
the MouseBehaviorJ3D of your Display) for the four corners
of your screen, intersect the rays with the plain where
your data lie (usually z = 0), then unmap the x and y
coordinates of the intersection through your spatial
ScalarMaps. That can give the lat and lon bounds. From
there you can find Field ranges.

Good luck,
Bill



--
+------------------------------------------------------------+
Kevin L. Manross        [KD5MYD] <><          (405)-366-0557
CIMMS Research Associate               kevin.manross@xxxxxxxx
[NSSL-WRDD/SWATN]           http://www.cimms.ou.edu/~kmanross

"My opinions are my own and not representative of CIMMS, NSSL,
NOAA or any affiliates"
+------------------------------------------------------------+