Re: detecting which dataRef the mouse is over

Paul-

Unfortunately, as Bill says, VisAD is hardwired so that mouse
manipulation is
done only with the right mouse button and the PickManipulationRenderer
only works in 3D displays.   However, you can listen to mouse events
without extending MouseHelper by enabling the events for a display
(2D or 3D):

    display.enableEvent(DisplayEvent.MOUSE_MOVED);
    display.enableEvent(DisplayEvent.MOUSE_DRAGGED);

(see javadoc for DisplayEvent to see a list of events and which you
can enable/disable). This is a recent addition to the package.  
_From these events, you can get the mouse x,y position and use:

        VisADRay ray       
           
display.getDisplayRenderer().getMouseBehavior().findRay(x,y);

which will give you the x,y(,z) positions in the VisAD box.  But still,
from there, you'd have to work backwards to find out what data object
this relates to as Bill says.

It would be nice if the MouseHelper could be configurable so direct
manipulation could be done with any mouse button, but that's not
the case.

Don Murray

Bill Hibbard wrote:
> 
> Hi Paul,
> 
> > In a simple 2D plotter built with visad, I'd like to detect which
> > line (or lines) the mouse is over.  I have registered a DisplayListener
> > on the Display, but I am uncertain how to do two things:
> >
> >    - detect mouse motion events (now I just get MOUSE_PRESSED and RELEASEd)
> >    - figure out which line the mouse is over
> >    - display a small tooltip-like tranisent window on top of the display,
> >      announcing the name of the line.
> >
> > Tips on any of these points will be most welcome!
> 
> You need to extend visad.MouseHelper to process mouse move
> events in a similar way that it processes mouse right
> button click events, then extend your MouseBehaviorJ*D
> (either J2D or J3D) to use your extension of MouseHelper.
> See:
> 
>   http://www.unidata.ucar.edu/glimpse/visad-list/2255
> 
> for a basic explanation of at least how to extend. Note
> the findRay() method of MouseBehaviorJ*D will compute
> a Ray in 3-D coordinates from a mouse screen location,
> then you need to invert ScalarMap scalings and any
> CoordinateSstems, as in visad.DataRenderer.drag_direct().
> 
> Its all a bit complex, I'm afraid.
> 
> If your users were willing to click right mouse buttons
> on Data depictions, you could just use
> visad.bom.PickManipulationRendererJ3D (asssuming you
> are doing 2-D in a DisplayImplJ3D).
> 
> Good luck,
> Bill

-- 
*************************************************************
Don Murray                               UCAR Unidata Program
dmurray@xxxxxxxxxxxxxxxx                        P.O. Box 3000
(303) 497-8628                              Boulder, CO 80307
http://www.unidata.ucar.edu/staff/donm
*************************************************************