NOTICE: This version of the NSF Unidata web site (archive.unidata.ucar.edu) is no longer being updated.
Current content can be found at unidata.ucar.edu.

To learn about what's going on, see About the Archive Site.

Re: Shapes, text rendering,

John,
 
> I would like to enable a user select one of my graphic elements from the
> graph by clicking on it with the mouse. I'd like to highlight the
> selected map element, as well. Are these actions doable? And if so, how
> do I go about it? I've perused the examples and the source, etc. In your
> examples utilizing DirectManipulationDisplayRenderer3D (I think) I've
> seen mouse coord's displayed on-screen. I'd like to capture the mouse
> coord when the mouse is initially clicked, determine which map element
> is under the mouse (this part I can do, of course), and then display it
> in a different color or in some other way highlight its appearance. I am
> using TwoDDisplayRenderer3D at this point given its better performance
> for translating and zooming.
 
This discussion is relative to the examples/Rivers.java program.
The way to do this is to create a RealTuple 'cursor' object whose
RealTupleType is the same as the domain of your Sets ('earth' in
examples/Rivers.java).  Display this using DirectManipulationRendererJ3D
and some ConstantMaps to make a large yellow point (or whatever
size and color you like), then link change events from this cursor
to a CellImpl that selects the appropriate river and displays it
with a special color.  Something like this:
 
  // create cursor
  RealTuple cursor = new RealTuple(earth, new double[] {0.0, 0.0});
  final DataReferenceImpl cursor_ref = new DataReferenceImpl("cursor");
  cursor.setData(cursor);
  display.addReferences(new DirectManipulationRendererJ3D(),
                        cursor_ref, new ConstantMap[]
                         {ConstantMap(4.0, Display.PointSize),
                          ConstantMap(1.0, Display.Red),
                          ConstantMap(1.0, Display.Green),
                          ConstantMap(0.0, Display.Blue)});
  // create DataReference for selected data element to be
  // rendered in color
  final DataReferenceImpl select_ref = new DataReferenceImpl("select");
  display.addReference(select_ref, new ConstantMap[]
                        {ConstantMap(select_red, Display.Red),
                         ConstantMap(select_green, Display.Green),
                         ConstantMap(select_blue, Display.Blue)});
  // create CellImpl to handle cursor events
  CellImpl cell = new CellImpl() {
    public void doAction() throws VisADException, RemoteException {
      RealTuple cursor = (RealTuple) cursor_ref.getData();
      double latitude = ((Real) cursor.getComponent(0)).getValue();
      double longitude = ((Real) cursor.getComponent(1)).getValue();
      // here you've got the latitude and longitude of the cursor
      // each time the user moves the large yellow dot - use it to
      // select a data element (Gridded2DSet?) 'set'
      Gridded2DSet set = ...
      select_ref.setData(set);
    }
  };
  cell.addReference(cursor_ref);
 
The one complexity is if the selected 'set' is already displayed
as part of the rivers UnionSet in another color, this may interfere
with the dislay via select_ref.  If this is a problem, you might
be able to fix it by changing the order in which you invoke
addReference for rivers_ref and select_ref.  If that doesn't
work, you may need to construct a new UnionSet for rivers_ref
that does not include the selected 'set'.
 
Good luck,
Bill
 
----------------------------------------------------------
Bill Hibbard, SSEC, 1225 W. Dayton St., Madison, WI  53706
whibbard@xxxxxxxxxxxxx  608-263-4427  fax: 608-263-6738
http://www.ssec.wisc.edu/~billh/vis.html
 
"kill cross-platform Java by growing the polluted Java market"
   - from an internal Microsoft planning document
 

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