Menu

Edge and Node Event

andy
2011-09-23
2013-05-29
  • andy

    andy - 2011-09-23

    How do I add an edge or node event, say popping out a dialog box when I click on the edge/node?

     
  • Tom Nelson

    Tom Nelson - 2011-09-23

    GraphEditorDemo does this. The source code is with the downloads and in the CVS repository.

     
  • andy

    andy - 2011-10-05

    Hi Tomnelson, thanks for the reply, but the demo only shows how to label the node/edges, what if I want to add in some custom events, like writing the edge information to a text file when I double click the edge?

     
  • andy

    andy - 2011-10-05

    Oh I have found the PickingGraphMousePlugin that can do the job

     
  • andy

    andy - 2011-10-05

    But it seems to have a predefined set of behaviors, is there a way to modify these behaviors without changing the source code?

     
  • Jelle Fresen

    Jelle Fresen - 2011-11-25

    There are two types of behaviors you can change: 1) which meta keys must be pressed before the PickingGraphMousePlugin detects the click and 2) the code that needs to be executed when a vertex/edge is picked (clicked, selected).

    You can control 1) by passing the mouse mask for the meta keys in the constructor of PickingGraphMousePlugin:

    PickingGraphMousePlugin gm = new PickingGraphMousePlugin(InputEvent.BUTTON1_MASK | InputEvent.CTRL_MASK);
    

    This creates a graphmouse that only respond to clicks if the ctrl key is pressed.

    You can control 2) by adding an ItemListener to the PickedVertexState or PickedEdgeState of the BasicVisualizationServer (or any subclass of course):

    VisualizationViewer<MyVertex, MyEdge> vv = new VisualizationViewer<MyVertex, MyEdge>(layout);
    vv.getPickedVertexState().addItemListener(new MyVertexListener());
    
     

Log in to post a comment.