- From: guilhelm savin <guilhelm.savin AT gmail.com>
- To: graphstream-users AT litislab.fr, Zacharie ALES <zacharie.ales AT gmail.com>
- Subject: Re: nodePosition(Graph, String) returns (0,0,0)
- Date: Wed, 12 Sep 2012 15:48:29 +0200
Hi Zacharie,
Coordinates are stored on the GraphicGraph, not on your Graph object.
So, you have these alternatives :
- you can use the graphic graph of your viewer
- you have to redirect attribute modifications happening on the graphic graph to your own graph
For the first solution, here is an example :
|
| Graph g = new AdjacencyListGraph("g");
| g.addNode("A");
| g.addNode("B");
| g.addEdge("AB", "A", "B");
|
| Viewer v = g.display(true);
|
| Thread.sleep(1000);
|
| double[] d = org.graphstream.ui.graphicGraph.GraphPosLengthUtils.nodePosition(v.getGraphicGraph(),"A");
| System.out.println(d[0] + ", " + d[1] + ", " + d[2]);
|
And for the second (this is a draft example) :
|
| Graph g = new AdjacencyListGraph("g");
| g.addNode("A");
| g.addNode("B");
| g.addEdge("AB", "A", "B");
|
| Viewer v = g.display(true);
|
| v.enableXYZfeedback(true);
| v.getGraphicGraph().addAttributeSink(g);
|
| Thread.sleep(1000);
|
| double[] d = org.graphstream.ui.graphicGraph.GraphPosLengthUtils.nodePosition(g,"A");
| System.out.println(d[0] + ", " + d[1] + ", " + d[2]);
|
Regards.
2012/9/12 Zacharie ALES
<zacharie.ales AT gmail.com>
Hello,
I recently switched to the nightly build version. Everything works fine except the nodePosition function that I am using to center the view on one specific node.
An exemple :
public void centerView(String id)
double[] d = org.graphstream.ui.graphicGraph.GraphPosLengthUtils.nodePosition(myGraph,id);
System.out.println(d[0] + ", " + d[1] + ", " + d[2]); // Display "position : 0.0, 0.0, 0.0"
}
I checked the id and it is correct (myGraph.getNode(id) == null returns false). Is it a bug or do I miss something ?
Thanks in advance for your help.
--
Zacharie ALES.
--
Guilhelm Savin
PhD Student of Computer ScienceLITIS, University of Le Havre
\/\/\/\/\/\/
- nodePosition(Graph, String) returns (0,0,0), Zacharie ALES, 12/09/2012
- Re: nodePosition(Graph, String) returns (0,0,0), guilhelm savin, 12/09/2012
Archives gérées par MHonArc 2.6.16.