GraphStream Users

Archives de la liste Aide


Tricky click (and click and drag) events


Chronologique Discussions 
  • From: Andrew Curtis-Black <acu27 AT uclive.ac.nz>
  • To: "graphstream-users AT litislab.fr" <graphstream-users AT litislab.fr>
  • Subject: Tricky click (and click and drag) events
  • Date: Wed, 27 Aug 2014 06:30:58 +0000
  • Accept-language: en-NZ, en-US

Hi,

I’m interested in adding some additional functionality to a GraphStream graph. I’d like to to be able to double click on the graph to create a new node at that point, double click and drag from one node to another to create a new edge, click on an edge to select it (and then press delete to delete it), and drag and drop a node onto an edge to insert it between the parent/child nodes.

Double clicking to create a new node
Using a combination of a mouse listener on the View object, a ViewerListener and findNodeOrSpriteAt() I can tell whether or not the user clicked on a node or on the graph background, so I think i can manage this one, but my method does seem a little circuitous. Is there a better way?

Selecting an edge to delete it
I’m  not so sure how to approach this one. How can I tell if the user has clicked on an edge? I can indicate selection by adding a style attribute to the edge to match a value in the graph stylesheet, so that part’s not such a problem. As for removing the edge with a press of the delete key, I seem to remember coming across something about a key manager in the documentation. Would that be the right direction to go in?

Double click and drag to create a new edge
I’d like to draw in an edge which follows the mouse pointer until the user releases the mouse over another node, at which point a new edge should be created. I can tell when the user double clicks a node with the ViewerListener, but I’m not so sure about the rest. How do I handle drawing in a new edge which follows the mouse pointer? When the mouse is released I can tell if it was released over a node using findNodeOrSpriteAt() as before, but how can I tell *which* node it was?

Drag and drop a node onto an edge to insert it at that point
Dragging a node is handled by default, but how can I tell if the user has dragged a node over/near an edge? (Ideally the edge would highlight to give feedback to the user - I’ll do this by setting a style attribute on the edge and using a shadow as a second stroke around the edge). 

Thank you very much for any and all help, Andrew


  • Tricky click (and click and drag) events, Andrew Curtis-Black, 27/08/2014

Archives gérées par MHonArc 2.6.16.

Top of page