GraphStream Users

Archives de la liste Aide


How to use GraphicGraph


Chronologique Discussions 
  • From: Stefan Balev <stefan.balev AT gmail.com>
  • To: graphstream-users AT litislab.fr
  • Subject: How to use GraphicGraph
  • Date: Tue, 2 Aug 2011 13:39:12 +0200

Hello,

I have an application that dynamically recomputes the coordinates of the nodes of a graph :

Graph g = ...
g.display(false);
new Steiner(g).compute();

At the beginning I naively thought that when the user drags a node in the viewer, this will change the "xyz" attribute of the node in g. Then I realized that dragging a node actually changes the "xyz" attribute of the node in the GraphicGraph associated to the viewer. In order to have the coordinate changes back to g I tried something like this:

Graph g = ...
g.display(false).getGraphicGraph().addSink(g);
new Steiner(g).compute();

Now almost everything works fine, but sometimes I have random exceptions like this:

Exception in thread "AWT-EventQueue-0" java.util.NoSuchElementException
at java.util.LinkedList.remove(LinkedList.java:788)
at java.util.LinkedList.removeFirst(LinkedList.java:134)
at java.util.LinkedList.remove(LinkedList.java:481)
at org.graphstream.stream.SourceBase.manageEvents(SourceBase.java:837)
[ ... stack trace too long to paste it entirely ... ]
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

Is it because of the "Caution : Use the returned graph only in the Swing thread !!" warning that we can read in Javadoc of getGraphicGraph()? If yes, what is the easiest proper way to do what I am trying to? Thanks for your help.

Btw, everything works great when I use FileSinkImages. Here is a small video showing this.

Best,

--
Stefan




Archives gérées par MHonArc 2.6.16.

Top of page