GraphStream Users

Archives de la liste Aide

Re: Trouble with MouseListeners

Chronologique Discussions 
  • From: guilhelm savin <guilhelm.savin AT>
  • To: "Hargitt, Eric" <ehargitt AT>, graphstream-users AT
  • Subject: Re: Trouble with MouseListeners
  • Date: Wed, 4 May 2016 16:18:41 +0200

Hi Éric,

Maybe you should have a look to this alternative MouseManager that handle mouse over/exited events on elements :

By the way, Viewer contains all views. You can retrieve a view you add in the viewer using Viewer#getView(viewId). But a "View" is a view of the whole graph, not of a single element. That is why there is usually only the default view.

Hope it helps...

Le 4 mai 2016 4:01 PM, "Hargitt, Eric" <ehargitt AT> a écrit :

Hello everyone,


I read many things about how to attach a ViewerListener to a to the ViewerPipe, and was able to successfully retrieve button clicks. Here is that code:


public NetworkGraph()
"gs.ui.renderer", "org.graphstream.ui.j2dviewer.J2DGraphRenderer");

graph = new DefaultGraph(UUID.randomUUID().toString());

String styleSheet = ""
+ "graph {padding: 125px;}"
+ "node {size: 250px, 50px, 0px; shape: rounded-box; text-alignment: center; text-size: 20; text-color: #78DE57;}"
+ "node.accessPoint {icon-mode: at-left; icon: url('./resources/access_point.png');}"
+ "edge {shape: line; size: 5; arrow-size: 30,10; fill-color: #55CBF2;}"
+ "";
graph.addAttribute("ui.stylesheet", styleSheet);

deviceMap = new HashMap<>();

viewer = new Viewer(graph, Viewer.ThreadingModel.GRAPH_IN_GUI_THREAD);

mouseListener = new NetworkViewerListener(this);
ViewerPipe fromViewer = viewer.newViewerPipe();

pumpTimer = new Timer();
pumpTimer.scheduleAtFixedRate(new TimerTask()
public void run()
, 60, 60);

graphView = viewer.addDefaultView(false);


My problem is that I want to act on mouseEntered and mouseExited events using a MouseInputAdapter. Currently my implementation of ViewerListener extends MouseInputAdapter. Here is the code where I try to add a MouseInputAdapter:


private void addComputerNode(NetworkDevice device)
    Node child =
child.addAttribute("ui.label", device.getMacAddress());
Node parent = graph.getNode(device.getParentId());
graph.addEdge(UUID.randomUUID().toString(), parent, child);

private void addListeners(final Node input)
new Runnable()
public void run()
            View view =


I expected to find the Views in the Viewer, but the Viewer only contains the DefaultView. By the time addListeners() gets called, there are already like 7 nodes and 6 edges attached to the graph. Am I doing something fundamentally wrong? All I want to do is add standard mouse listeners to my nodes. Thanks for your help on this.


Eric Hargitt

Archives gérées par MHonArc 2.6.16.

Top of page