GraphStream Users

Archives de la liste Aide


Re: integrating viewer and communication between viewer and graph


Chronologique Discussions 
  • From: guilhelm savin <guilhelm.savin AT gmail.com>
  • To: "graphstream-users AT litislab.fr" <graphstream-users AT litislab.fr>, Gergely Zahoransky-Kohalmi <gzahoransky-kohalmi AT salud.unm.edu>
  • Subject: Re: integrating viewer and communication between viewer and graph
  • Date: Thu, 12 Dec 2013 22:26:18 +0100

Dear Gergely,

1. You need a ViewerPipe created by the viewer and connected to the original graph to retrieve ui events. Click() example does this connection.

2. Viewer is not a ui component, it contains all the element linked to this ui. However, View is a JPanel. So, if you are using the "display()" method, just call "viewer.getDefaultView();" to get this JPanel. Or, create a viewer, using "Viewer(graph, Viewer.ThreadingModel.GRAPH_IN_ANOTHER_THREAD);", then call the "addDefaultView(openInAFrame);" method of this viewer to get the JPanel.

Regards.

Guilhelm


2013/12/12 Gergely Zahoransky-Kohalmi <gzahoransky-kohalmi AT salud.unm.edu>
Dear List,


I'd like to ask for your help in the following issues.




My goal is to have a Swing integrated View of the graph (preferably as a separate thread from the main thread)
in which changes made to nodes are propagated back to the underlying graph.


Here is what I tried:


1. I initiated my viewer as viewer = graph.display() , and it works fine as far as selecting nodes
(they change color, I can select and deselect them with right mouse click or by dragging mouse).
However, when a node (actually the representation of the node in the viewer) is selected, i.e. the element
gets the attribute ui.selected, when I loop through the nodes of the graph, none of the nodes has the attribute
ui.selected. I think this is due to the lack of the backwards communication from the viewer to the graph.
With other word, no matter what change is made in the viewer, it's not reflected in the graph itself.
As far as I understand, this is the way it should work, according to the tutorial on Views.
So how can I change this? Or how can I access nodes of the graph that have a ui.selected attribute in the view?


2. I tried the Click() example in the tutorial, and it worked fine. So how can I integrate this as a separate
GUI thread in a Swing GUI application? The Click() example creates the view via graph.display() and
not via "Viewer(graph, Viewer.ThreadingModel.GRAPH_IN_ANOTHER_THREAD);".
I think the conflict here is that integration into Swing requires a JPanel class (like the View is a
subclass of JPanel), but the synchronized viewer-graph class is not a JPanel subclass.


Any help would be greatly appreciated! Thanks a lot!


Best,


Gergely






--
Guilhelm Savin
PhD Student of Computer Science



Archives gérées par MHonArc 2.6.16.

Top of page