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.
Hi Steve, > I had almost given up on Java for scientific visualization of data, until we > stumbled across VisAD. Outstanding work, and a thank you to all involved. > I now won't have to go back to C++ and Matlab... > > I need to be able to select out data in 2D using drag rectangles and > polygons. I noticed a user a few months back had the same need--excerpt > from that message is below: > Has anyone already done this, and is willing to share the code? > I am using the DisplayListener with the getID() method to determine the type > of mouse event. While DisplayEvent.MouseClicked, MouseReleased, etc work > fine, DisplayEvent.MOUSE_DRAG doesn't seem to work. Actually, from Java I > would expect MouseMotionListener to be a separate interface from > MouseListener--how do I detect mouseMotion events?? The easiest way to do this is to use visad/bom/RubberBandBoxRendererJ3D.java connected to a CellImpl, and avoid dealing directly with MouseEvents. To do this, you'll need to use DisplayImplJ3D (which uses Java3D) - you can get 2-D display in Java3D using the constructor signature: new DisplayImplJ3D("display", new TwoDDisplayRendererJ3D()) You have to program the data selection in the doAction() method of your CellImpl, based on the bounds of the rectangle (see the main() method of RubberBandBoxRendererJ3D.java for an example of accessing these bounds. In order to capture MOUSE_DRAG events you'll need to supply your own extsension of MouseHelper. There are new signatures for DefaultDisplayRendererJ3D and TwoDDisplayRendererJ3D constructors that allow you to specify your extension of MouseBehaviorJ3D and a new signature of MouseBehaviorJ3D that your super() can invoke to specify your extension of MouseHelper. In your extension of MouseHelper, you can process MOUSE_DRAG events any way you like. 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
visad
archives: