GraphStream Users

Archives de la liste Aide

Trouble with MouseListeners

Chronologique Discussions 
  • From: "Hargitt, Eric" <ehargitt AT>
  • To: "graphstream-users AT" <graphstream-users AT>
  • Subject: Trouble with MouseListeners
  • Date: Wed, 4 May 2016 14:00:55 +0000
  • Accept-language: en-US
  • Authentication-results:; dkim=none (message not signed) header.d=none;; dmarc=none action=none;
  • Spamdiagnosticmetadata: NSPM
  • Spamdiagnosticoutput: 1:23

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