- From: "Gergely Zahoransky-Kohalmi" <gzahoransky-kohalmi AT salud.unm.edu>
- To: <guilhelm.savin AT gmail.com>,<graphstream-users AT litislab.fr>
- Subject: Re: integrating viewer and communication between viewer and graph
- Date: Fri, 13 Dec 2013 00:51:52 -0700
Dear Guilhelm,
Thank you for your quick answer!
I tried to add the ViewerPipe but I still could not get it working the way I
want. I am sure, however, that there are some confusion on my end.
To start with: does the class that implements ViewerListener need to be the
main class (i.e. the class of the program, like Clicks () in the example)?
When I tried to adopt the example to my class (which is not the "main" class)
then I things got hung up when I included the loop part (with the
"fromViewer.pump()" from the example). If I did not include the pump, only
called it when I thought I needed it, then I got an error. This error was
related to creating nodes that already existed. This was weird, because only
change that happened in the view was that I selected some nodes. Then I
wanted to list the nodeIDs of the selected nodes by a function (which called
invoked the pump) and this is how I got that error.
I also tried not to define a ViewerListener subclass but I kept everything
else (i.e. I set up a VieverPipe, added the graph as sink to it, included the
lop), but in that case nothing really happens. But there's no hung up,
meaning that everything is visualized, and I did not get that weird error
message despite the pump was invoked...
I am not sure if this is related or not, but I defined a MouseManager that
basically inactivates the click on sprites by checking for a specific
attribute that I add to sprites.
I wonder if you have any suggestion.
Thanks,
Gergely
>
>> guilhelm savin 12/12/13 2:26 PM >>>
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
>
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
LITIS, University of Le Havre
\/\/\/\/\/\/
http://g savin.lewub.org
http://d3-project.org
http://iscn.univ-lehavre.fr
http://graphstream-project.org
/\/\/\/\/\/\
Archives gérées par MHonArc 2.6.16.