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.
<html> <blockquote><font size=2 color="#000080">Hi Tolga,<br> <blockquote type=cite cite> <dl> <dd>where I add the DisplayListener at the first display. Now when I do the LEFT+RIGHT mouse buttons pressed (it says CENTER but my middle mouse button does not do this, don't know why) I get xval and yval and everything is working fine. </font> <dd> <font size=2 color="#000080"> <dd>Now when I change this to e.getId() = DisplayEvent.MOUSE_PRESSED_RIGHT, I get NaN for xval and yval. Interestingly, RIGHT+LEFT still is caught (although I do not catch it) and y and x values are shown on the left top corner, updating constantly, as long as I hold RIGHT+LEFT. Now this is what I mean by unexpected behavior. I want to be able to control that constant display, so that I can do it with MOUSE_MOVED event.</font></blockquote></blockquote> </dl><br> </blockquote>The getDirectAxisValue() method is probably not what you want here (it appears to be<br> dependent on RIGHT+LEFT clicks). Instead, take a look at the displayChanged() method<br> of visad.bio.LinePool. It obtains the 2-D coordinates of a mouse click upon LEFT mouse<br> button release. It is a bit complicated but you should be able to copy and adapt most<br> of the code from LinePool to suit your purposes. The key line is:<br> <br> double[] coords cursorToDomain(pixelToCursor(x, y));<br> <br> Along with the corresponding cursorToDomain() and pixelToCursor() methods.<br> <br> Unfortunately, VisAD does not currently have a DisplayEvent.MOUSE_MOVED event,<br> so it is difficult to continuously track values as the mouse moves. Perhaps you could do<br> it with a MouseMotionListener (I haven't tried it), but I have a feeling Java3D would interfere<br> with that and eat the events.<br> <br> -Curtis<br> </html>
visad
archives: