Hi Xavier,You can try to use the new FileSinkSVG2 that I havejust pushed :|| import org.graphstream.stream.file.FileSinkSVG2;|| ...|| String path = "C:\\test.svg";
|
| Graph graph = new SingleGraph("GraphStream");
||| // If there is no layout computed, you need to| // compute one :|| SpringBox sb = new SpringBox();| graph.addSink(sb);|| // -------------------------------------------|| graph.addNode("A");
| graph.addNode("B");| graph.addNode("C");
| graph.addEdge("AB", "A", "B");
| graph.addEdge("BC", "B", "C");
| graph.addEdge("CA", "C", "A");|| // Compute the layout|| sb.addAttributeSink(graph);| sb.shake();| sb.compute();|| while (sb.getStabilization() < 1)| sb.compute();|| // ------------------||
| FileSink out = new FileSinkSVG2();
|
| try {
| out.writeAll(graph, path);
| } catch (IOException ex) {
| Logger.getLogger(App.class.getName()).log(Level.SEVERE, null, ex);
| return;
| }|
This is a really draft version so tell me bugs youmeet and I will try to fix them.Hope this helps ...Guilhelm--2012/3/21 Xavier Roger-Machart <xrogermachart AT gmail.com>
Hello,
I'm trying to create an SVG export of a simple graph, however I could not find a way to have a working image yet. Here's roughly what I wrote :
String path = "C:\\test.svg";
Graph graph = new SingleGraph("GraphStream");
graph.addNode("A");
graph.addNode("B");
graph.addNode("C");
graph.addEdge("AB", "A", "B");
graph.addEdge("BC", "B", "C");
graph.addEdge("CA", "C", "A");
FileSink out = FileSinkFactory.sinkFor(path);
try {
out.writeAll(graph, path);
out.flush();
} catch (IOException ex) {
Logger.getLogger(App.class.getName()).log(Level.SEVERE, null, ex);
return;
}
This will generate an SVG file that actually contains some lines, but it seems they've not been organized yet or something. Also it contains lines not no points :
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<svg xmlns:svg="http://www.w3.org/2000/svg" width="100%" height="100%">
<g id="AB">
<line x1="0.000000" y1="0.000000" x2="0.000000" y2="0.000000"/>
</g>
<g id="BC">
<line x1="0.000000" y1="0.000000" x2="0.000000" y2="0.000000"/>
</g>
<g id="CA">
<line x1="0.000000" y1="0.000000" x2="0.000000" y2="0.000000"/>
</g>
What am I doing wrong here, and is there any documentation I missed out on that particular subject ?
Thanks
Xavier
Guilhelm Savin
PhD Student of Computer ScienceLITIS, University of Le Havre
\/\/\/\/\/\/
Archives gérées par MHonArc 2.6.16.