Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [udig-devel] trap coordinates of mouse movement

Finally I guess I'm able to close this thread :)

The way seems to be:
- register to the map ViewPortPane
IMap map = ApplicationGIS.getActiveMap();

if (map != null) {
((ViewportPane)
map.getRenderManager().getMapDisplay()).addMouseMotionListener(panel);
}

- implement the MapMouseMotionListener

- use the coordinates
public void mouseMoved( MapMouseEvent event ) {
IMap map = ApplicationGIS.getActiveMap();

if (map != null) {
            Coordinate coord =
map.getViewportModel().pixelToWorld(event.x, event.y);

etc. etc.


Ciao
Andrea






Andrea Antonello probaly wrote:
> Alright, after fiddling a bit around I figure out that it isn't even as
> I thought below :)
> 
> So my question now is: if I need the mouse coordinates from somewhere
> in my code, and I need to listen to them changeing, what should I do?
> I would like to have a behaviour like the statusbar and the  moving
> coordinates... is it possible to add a listener somewhere?
> 
> Ciao
> Andrea
> 
> 
> Andrea Antonello probaly wrote:
>> Hi, to trap mouse coordinates to be used inside a view, I have to
>> implement a tool like in the distance example and use that inside the
>> view to update the mouse position?
>>
>> Or is there another way?
>>
>> Thanks,
>> Andrea
>> _______________________________________________
>> User-friendly Desktop Internet GIS (uDig)
>> http://udig.refractions.net
>> http://lists.refractions.net/mailman/listinfo/udig-devel
>>
> _______________________________________________
> User-friendly Desktop Internet GIS (uDig)
> http://udig.refractions.net
> http://lists.refractions.net/mailman/listinfo/udig-devel
> 


Back to the top