GraphStream Users

Archives de la liste Aide


Re: Graphstream - Displaying graph on AWT / SWT


Chronologique Discussions 
  • From: "Yoann Pigné" <yoann.pigne AT gmail.com>
  • To: "Johannes Spreemann" <johannesspreemann AT outlook.com>, users AT graphstream-project.org
  • Subject: Re: Graphstream - Displaying graph on AWT / SWT
  • Date: Wed, 21 Aug 2013 15:04:48 +0200

Johannes, I forwarded your answer to the mailing to give you more chances to get a solution.

The line:
graphstreamLayout.setStabilizationLimit(0);
means that the layout will never stop. So depending on the shape of your graph, you may indeed end-up with a forever spinning graph. Try to put a value greater than 0 and up to 1 on this method.

Also you may uncomment the line:
// graphstreamView = graphstreamViewer.addDefaultView(true);
to actually create the view.

It is just a guess, but the flickering problem may indeed come from the interaction with the SWT/AWT component for which we have very few expertise right now.

Good luck,


Yoann


On 21 Aug 2013, at 14:23, Johannes Spreemann wrote:

Hi Yoann,
I'm using the newest version 1.2 with the 1.2 GUI. I disabled the AutoLayout now. Without this setting the graph keeps moving and spinning around from the start. It also stops the flickering, but when I move a node with the mouse the complete graph jumps and all nodes flicker again.
I'm giving you the complete method I use to create the view (some refactoring needs to be done):
public void generateGraph(Frame frame, String networkName) { graph = new SingleGraph(networkName);
graph.setStrict(false); graph.setAutoCreate(true);
setActualEditedNetwork(getByName(networkName));
for (Sensor s : getActualEditedIvn().getSensors()) { graph.addNode(s.getId());
Node n = graph.getNode(s.getId()); n.addAttribute("ui.label", s.getId()); n.setAttribute("ui.class", s.getClass().getSimpleName()); n.setAttribute("x", s.getPosition().x); n.setAttribute("y", s.getPosition().y); } for (Actuator a : getActualEditedIvn().getActuators()) { graph.addNode(a.getId());
Node n = graph.getNode(a.getId()); n.addAttribute("ui.label", a.getId()); n.setAttribute("ui.class", a.getClass().getSimpleName()); n.setAttribute("x", a.getPosition().x); n.setAttribute("y", a.getPosition().y); } for (Function f : getActualEditedIvn().getFunctions()) { graph.addNode(f.getId());
Node n = graph.getNode(f.getId()); n.addAttribute("ui.label", f.getId()); n.setAttribute("ui.class", f.getClass().getSimpleName()); n.setAttribute("x", f.getPosition().x); n.setAttribute("y", f.getPosition().y); } for (Message m : getActualEditedIvn().getMessages()) { graph.addNode(m.getId());
Node n = graph.getNode(m.getId()); n.addAttribute("ui.label", m.getId()); n.setAttribute("ui.class", m.getClass().getSimpleName()); n.setAttribute("x", m.getPosition().x); n.setAttribute("y", m.getPosition().y); }
for (Edge e : getActualEditedIvn().getEdges()) { graph.addEdge(e.getId(), e.getSource().getId(), e.getDestination() .getId(), true);
org.graphstream.graph.Edge gse = graph.getEdge(e.getId()); gse.setAttribute("ui.class", e.getClass().getSimpleName()); gse.addAttribute("ui.label", e.getTokenNumber()); }
String styleSheet = "node.Sensor { fill-color: blue; shape: circle; size-mode: dyn-size; size: 0.25gu; stroke-mode: plain; stroke-color: black; }\n"; styleSheet += "node.Actuator { fill-color: red; shape: circle; size-mode: dyn-size; size: 0.25gu; stroke-mode: plain; stroke-color: black; }\n"; styleSheet += "node.Function { fill-color: yellow; shape: box; size-mode: dyn-size; size: 0.25gu; stroke-mode: plain; stroke-color: black; }\n"; styleSheet += "node.Message { fill-color:
green; shape: diamond; size-mode: dyn-size; size: 0.25gu; stroke-mode: plain; stroke-color: black; }"; styleSheet += "edge { arrow-shape: arrow; }"; graph.addAttribute("ui.stylesheet", styleSheet);
graph.addAttribute("ui.quality");
graph.addAttribute("ui.antialias");
graphstreamViewer = new Viewer(graph, Viewer.ThreadingModel.GRAPH_IN_ANOTHER_THREAD); graphstreamViewer.setCloseFramePolicy(CloseFramePolicy.CLOSE_VIEWER);
graphstreamLayout = new SpringBox(); graphstreamLayout.setStabilizationLimit(0);
// graphstreamViewer.enableAutoLayout(graphstreamLayout); graphstreamViewer.disableAutoLayout();
// graphstreamView = graphstreamViewer.addDefaultView(true); graphstreamRender = Viewer.newGraphRenderer(); graphstreamView = new DefaultView(graphstreamViewer, "view2", graphstreamRender);
graphstreamViewer.addView(graphstreamView);
frame.add(graphstreamView);
frame.setVisible(true); }

Kind regardsJohannes

From:
yoann.pigne AT gmail.com
To:
users AT graphstream-project.org;

johannesspreemann AT outlook.com
Subject: Fwd: Graphstream - Displaying graph on AWT / SWT
Date: Wed, 21 Aug 2013 13:05:00 +0200

Dear Johannes,

Allow me to forward your question to the GraphStream Mailing List.

What version of gs-core do you use (1.0, 1.1, 1.2) ? There used to be
flickering problems with older versions. It should be OK with v1.2 now.

Are you using the advanced GUI (gs-ui) ?

How do you retrieve the view from GraphStream ? It should be something
like :

Viewer viewer = new Viewer(graph,
Viewer.ThreadingModel.GRAPH_IN_ANOTHER_THREAD);
View view = viewer.addDefaultView(false); // false indicates "no
JFrame".
myJFrame.add(view);

Let us know.

Best regards,

Yoann

Forwarded message:

From: Johannes Spreemann
<johannesspreemann AT outlook.com>
To:
yoann.pigne AT graphstream-project.org
<yoann.pigne AT graphstream-project.org>
Subject: Graphstream - Displaying graph on AWT / SWT
Date: Wed, 21 Aug 2013 10:05:28 +0200

Dear Yoann,
I'm actual developing a Eclipse 4 RCP application that uses basically
SWT components. Your Graphstream library works very well, but I have
one issue. I try to integrate the graph output in a SWT composite as
follows:
awtFrame = AWT_SWT.new_Frame(composite);
...awtFrame.add(graphStreamView);awtFrame.setVisible(true);
The graph is displayed in the frame, but it keeps spinning around and
the image is flickering because the AWT frame misses Double Buffering.
Does your team have any suggestions or ideas to solve this problem?

Kind regards
Johannes




Archives gérées par MHonArc 2.6.16.

Top of page