GraphStream Users

Archives de la liste Aide


Re: Help request for generating an SVG export


Chronologique Discussions 
  • From: Xavier Roger-Machart <xrogermachart AT gmail.com>
  • To: guilhelm savin <guilhelm.savin AT gmail.com>
  • Cc: graphstream-users AT litislab.fr
  • Subject: Re: Help request for generating an SVG export
  • Date: Tue, 27 Mar 2012 10:33:35 +0200

Thanks, I'll give it a try in the coming days and get back to you.

2012/3/26 guilhelm savin <guilhelm.savin AT gmail.com>
Hi Xavier,

You can try to use the new FileSinkSVG2 that I have
just 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 you
meet 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 Science





Archives gérées par MHonArc 2.6.16.

Top of page