GraphStream Users

Archives de la liste Aide

Re: FileSinkImages and Graph

Chronologique Discussions 
  • From: guilhelm savin <guilhelm.savin AT>
  • To: graphstream-users AT, laoheike AT
  • Subject: Re: FileSinkImages and Graph
  • Date: Wed, 9 May 2012 14:24:10 +0200

Hi and welcome on the mailing list,

OutputPolicy is documented in the tutorial :

It allows to define when images are produced. For example, setting
output policy to BY_STEP will produce image at each step of the graph.

There are two issues that can lead to your problem :

1. If no image are produced, problem is linked to the output policy. Default
   policy is None, so no images are produced. Set it to BY_STEP and insert a
   step when you want to have an image produced :

| Graph g = ... ;
| FileSinkImages img = new FileSinkImages();
| g.addSink(img);
| img.setOutputPolicy(OutputPolicy.BY_STEP);
| g.addNode("A");
| g.addNode("B");
| g.addNode("C");
| g.stepBegins(0); // Produces an image

2. But the previous code will produce blank images and this is
   the second issue : nodes do not have any coordinates, so you
   have to enable a layout :

| img.setLayoutPolicy(LayoutPolicy.COMPUTED_FULLY_AT_NEW_IMAGE);

If this does not solve your problem, please post the code you
are using and I will try to help you more.



2012/5/9 <laoheike AT>

I would like to create a movie out of a graph. However, I'm a little bit lost.

I'm using version 1.1 and I followed the tutorial
with minor fixes for version 1.1.

I start with an empty graph, then instanciate a FileSinkImage and assign it as
a sink to the graph. After that I add nodes and edges to the graph and it is
supposed to output the images. However, I've nothing in the folder... The code
compiles, but I don't know why it's not doing what I want. I tried to look into
the API, but things are not well documented (for instance, what
"FileSinkImages.OutputPolicy.BY_STEP" is for?) So I played around and it seems
the only things working is with .BY_EVENT...

Could you please explain more what are these output policies about?

Thanks for your help,

Hei Ke

Here is my code:

               DefaultGraph g = new DefaultGraph("Awesome graph");

               // FileSinkImages arguments
               OutputPolicy outputPolicy = OutputPolicy.BY_STEP;
               String prefix = "images/prefix_";
               OutputType type = OutputType.PNG;
               Resolution resolution = Resolutions.HD720;

               FileSinkImages fsi = new FileSinkImages(type, resolution);

               // Optional configuration
               fsi.setStyleSheet("graph { padding: 50px; fill-color: black; }"
+ "node { fill-color: #3d5689; }" + "edge { fill-color: white; }");

               // Images production
               try {
                       g.addEdge("AB", "A", "B");
                       g.addEdge("AC", "A", "C");
                       g.addEdge("BC", "B", "C");
               } catch (IOException e) {
                       // TODO Auto-generated catch block

Guilhelm Savin
PhD Student of Computer Science

Archives gérées par MHonArc 2.6.16.

Top of page