GraphStream Users

Archives de la liste Aide


Few questions about the graphs' display


Chronologique Discussions 
  • From: Nicolas Quattropani <nicolas.quattropani AT gmail.com>
  • To: graphstream-users AT litislab.fr
  • Subject: Few questions about the graphs' display
  • Date: Fri, 8 Jul 2011 17:06:23 +0200

Hi again.

I am doing an internship and I have to integrate GraphStream in an application. Now that my work is almost done, my supervisor asks me to export it in different formats, from .jpg through .dot to .svg.

I have made a lot of tests and together we found some questions :

#

package testTuto;

 

import org.graphstream.graph.implementations.DefaultGraph;

 

public class ExportTest {

 

      public static void main(String args[]) {

           

            DefaultGraph g = new DefaultGraph("export");  

            g.display();

            g.addNode("A");

            g.addNode("B");

            g.addEdge("AB", "A", "B", true);

 

            g.addAttribute("ui.screenshot", "exportJPG.jpg");

      }

}

-------------- 

package testTuto;

 

import org.graphstream.graph.implementations.DefaultGraph;

 

public class ExportTest {

 

      public static void main(String args[]) {

           

            DefaultGraph g = new DefaultGraph("export");  

           

            g.addNode("A");

            g.addNode("B");

            g.addEdge("AB", "A", "B", true);

 

g.display();

            g.addAttribute("ui.screenshot", "exportJPG.jpg");

      }

}


For each case, the graph is well displayed in the swing window but in the 1st one the file "exportJPG.jpg" is empty whereas in the seconde case there is no problems. 
What is the logic behind this behaviour ?

#
I try to export my graph but it seems like some css aspects of my style sheet are not taken in consideration. The image "exportJPG.jpg" seems to be the same that the displayed graph but without the css additions ...
So, what is taken in consideration about the css style into the export of the images with FileSinkImages ?

Here are my code and the stylesheet : 

package testTuto;

 

import java.io.IOException;

import java.net.URL;

 

import org.graphstream.graph.implementations.DefaultGraph;

import org.graphstream.stream.file.FileSinkImages;

import org.graphstream.stream.file.FileSinkImages.LayoutPolicy;

import org.graphstream.stream.file.FileSinkImages.OutputType;

import org.graphstream.stream.file.FileSinkImages.Resolutions;

 

public class ExportTest {

 

      public static void main(String args[]) {

            new ExportTest();

           

      }

 

      public ExportTest() {

            System.setProperty("gs.ui.renderer",

                        "org.graphstream.ui.j2dviewer.J2DGraphRenderer");

 

            DefaultGraph g = new DefaultGraph("export");

 

            URL stylesheet;

            stylesheet = getClass().getResource("styleSheet");

            String styleSheetpath = stylesheet.getPath();

            g.addAttribute("ui.stylesheet", "url('file://" + styleSheetpath

                        + "')\"");

           

            FileSinkImages pic = new FileSinkImages(OutputType.JPG, Resolutions.VGA);

            pic.setLayoutPolicy(LayoutPolicy.COMPUTED_AT_NEW_IMAGE);

            pic.setStyleSheet("url('file://" + styleSheetpath + "')\"");

 

            g.addNode("A");

            g.addNode("B");

            g.addNode("C");

            g.addEdge("AB", "A", "B");

            g.addEdge("AC", "A", "C");

            g.addEdge("BC", "B", "C");

 

            g.display();

            try {

                  pic.writeAll(g, "exportJPG.jpg");

            } catch (IOException e) {

                  e.printStackTrace();

            }

      }

}

 

edge {

 shape: cubic-curve;

 arrow-shape: arrow;

 arrow-size: 12px, 4px;

}

 

node {

 size-mode: fit; 

 shape: rounded-box;

 fill-color: white;

 stroke-mode: plain;

 padding: 4px, 4px;

 icon-mode: at-left;

 icon: url('images/noeud.png');

}


Thanks for helping.

Regards,


Nicolas.





Archives gérées par MHonArc 2.6.16.

Top of page