tl;dr how to get closest GraphicElement coordinates given MouseEvent coordinates?
I created a big graph that represents the road map of a certain region using Graphstream and I'm trying to find the closest node to an occuring MouseEvent.
My problem is that the MouseEvent coordinates are relative to the frame resulotion while my GraphicElement's coordinates are longitude and latitude of real location.
For example, when clicking on a Node and get it using MouseManager with the following code:
@Override
public void mouseReleased(MouseEvent e) {
super.mouseReleased(e);
GraphicElement graphicElement = view.findNodeOrSpriteAt(e.getX(), e.getY());
if(graphicElement!= null){
System.out.println( "node "+graphicElement.getLabel()+ ", xy ("+graphicElement.getX() +","+ graphicElement.getY()+").");
System.out.println( "MouseEvent xy ("+e.getX() +","+e.getY()+").");
}
}
the output will be:
node 2, xy (34.7811627,32.0528169).
MouseEvent xy (281,489).
Is there a GraphStream built-in method or someother way I can translate the frame's coordinates to my coordinates?