Thanks a lot, yes that fixed the issue. Maybe I missed that in documentation. Is it possible to look at the source code of video demonstrations?
Hi,
I guess you forgot to activate the layout algorithm :
viewer.enableAutoLayout();
Regards,
Yoann
> Le 9 juin 2017 à 12:02, imran AT elogic.pk a écrit :
>
> Dear List,
>
> Just trying out how to draw the graphs in a Swing component, e.g JFrame. The graph does appear but the extent is not correct unlike when we use the default viewer of GS Stream. The graph appears to be zoomed out such extreme level that all nodes appear as one node.
>
> Below is my code
>
> Graph graph = new SingleGraph("Tutorial 1");
>
> //Graph graph = new MultiGraph("embedded");
>
> System.setProperty("org.graphstream.ui.renderer", "org.graphstream.ui.j2dviewer.J2DGraphRenderer");
>
>
>
> Viewer viewer = new Viewer(graph, Viewer.ThreadingModel.GRAPH_IN_ANOTHER_THREAD);
> View view = viewer.addDefaultView(false);
> JFrame mainJFrame = new JFrame("test");
> mainJFrame.setSize(800, 600);
> mainJFrame.add((JPanel)view);
> mainJFrame.setVisible(true);
> mainJFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
>
> graph.addNode("A");
> graph.addNode("B");
> graph.addNode("C");
>
> graph.addEdge("AB", "A", "B");
> graph.addEdge("BC", "B", "C");
> graph.addEdge("CA", "C", "A");
>
> I am using version 1.3 and JDK 1.8. Have I done anything wrong?
>
> Regards,
> Imran
>
> Sent from Mail for Windows 10