GraphStream Users

Archives de la liste Aide


Jframe issue


Chronologique Discussions 
  • From: <imran AT elogic.pk>
  • To: "users AT graphstream-project.org " <users AT graphstream-project.org>
  • Subject: Jframe issue
  • Date: Fri, 9 Jun 2017 03:02:13 -0700
  • Importance: normal

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

 




Archives gérées par MHonArc 2.6.16.

Top of page