I've built a desktop application based on an example shipped with Jung2 that displays graphs on a frame. The application lets the user move selected nodes around using the EditingModalGraphMouse
class.
However, when the user clicks and drags a node from an area where there's a lot of nodes on top of each other, the application actually selects the node on the bottom of the pile (which is not visible) instead of picking the one on top (which is visible to the user).
I'm trying to dig through the classes to verify where the node picking is actually done, but I'm a bit confused. I think the action takes place at the PickingGraphMousePlugin.mousePressed(...)
method with the pickSupport
object returned by vv.getPickSupport()
.
My question is: How can I make my application move the node on top when the user picks a node from a pile? And what are the classes responsible for managing that?
I'm using Jung version 2.0.1.
To answer my own question, one just have to use the ShapePickSupport.Style.HIGHEST
, as in the code below (generics parameters were changed for clarity):
VisualizationViewer<V, E> vv = new VisualizationViewer<V, E>(visualizationModel, preferredSize);
...
ShapePickSupport pickSupport = (ShapePickSupport) vv.getPickSupport();
pickSupport.setStyle(ShapePickSupport.Style.HIGHEST);
Also, here's useful resource that is related to the matter: