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: Changing mouse behavior in VisAD

<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>&nbsp;<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).&nbsp; Instead, take a look at the
displayChanged() method<br>
of visad.bio.LinePool.&nbsp; It obtains the 2-D coordinates of a mouse
click upon LEFT mouse<br>
button release.&nbsp; 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.&nbsp; The key line
is:<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp; 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.&nbsp;
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>


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