GraphStream Users

Archives de la liste Aide


Re: How to make a png or a jpg with a Graph?


Chronologique Discussions 
  • From: guilhelm savin <guilhelm.savin AT gmail.com>
  • To: graphstream-users AT litislab.fr
  • Subject: Re: How to make a png or a jpg with a Graph?
  • Date: Tue, 7 Jun 2011 19:13:39 +0200
  • Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=BhjBr8GuIVpqOVdQ/7zUBRnJW88I1o/aCNKBFioLWiVcme9lkRvFgxjM4Wgdq21LWA Su5NOqC9rPmr9TZdw/4DdpJZ4ve8Wz+PKQMOE2wmyKlMiQ7TjXD/cli3MRHD7Yw3WPBE kQwB8eRrzGzUzKl1HHpVmy7/7N7FIl8Ca0+i8=

Hi Rodrigo,

I think I can help you :)

The way you want to use FileSinkImages (using writeAll()) is not
implemented ! But it is interesting and missing way to produce
images and I think I will add it soon.

FileSinkImages is done to output images according to some events,
for example in your code images are outputed when a step begins
(OutputPolicy.ByStepOutput). But there is no step in your graph
so no image are produced.

The first solution I can tell you is to introduce a step at the
end of your build :

Graph graph = new SingleGraph("Tutorial 1");
FileSinkImages fsi = new FileSinkImages("simples", OutputType.JPG,
Resolutions.VGA, OutputPolicy.ByStep);
fsi.setLayoutPolicy(LayoutPolicy.ComputedAtNewImage);
graph.addSink(fsi);

graph.addNode("A");
graph.getNode("A").setAttribute("ui.label", "A");
graph.addNode("B");
graph.getNode("B").setAttribute("ui.label", "B");
graph.addNode("C");
graph.getNode("C").setAttribute("ui.label", "C");
graph.addEdge("AB", "A", "B");
graph.addEdge("BC", "B", "C");
graph.addEdge("CA", "C", "A");

graph.stepBegins(1);

For the second solution, you have to checkout the sources of gs-core
from github with the last commit I have just done which change the
visibility of the 'outputNewImage()' method of FileSinkImages.

Note thatin new version of FileSinkImages, enum constant names have
been changedto follow the convention, so for example,
OutputPolicy.ByStepOutputbecomes OutputPolicy.BY_STEP.

There is still lot of work to do on this sink, and I really thank you
to report your problem because this helps to improve the features. I
will add the writeAll() feature on FileSinkImages.

Hope this help. If not, please ask for more help :)
Regards.


2011/6/7 Rodrigo Lins <lins.oliveira AT gmail.com>
Thank you Guilhelm for your help.
But i'm facing a lot of problems to finish my application.
I'm making some test to find a better Graph API and I realy like GraphStream but I can't print a simple image.

I have this test class:
package sandboxie.graphstream;

import java.io.IOException;

import org.graphstream.graph.Graph;
import org.graphstream.graph.implementations.SingleGraph;
import org.graphstream.stream.file.FileSinkImages;
import org.graphstream.stream.file.FileSinkImages.LayoutPolicy;
import org.graphstream.stream.file.FileSinkImages.OutputPolicy;
import org.graphstream.stream.file.FileSinkImages.OutputType;
import org.graphstream.stream.file.FileSinkImages.Resolutions;


public class GsCoreTeste
{
public static void main(String[] args)
{
Graph graph = new SingleGraph("Tutorial 1");
FileSinkImages fsi = new FileSinkImages("simples", OutputType.JPG, Resolutions.VGA, OutputPolicy.ByStepOutput);
fsi.setLayoutPolicy(LayoutPolicy.ComputedAtNewImage);
graph.addSink(fsi);

graph.addNode("A");
graph.getNode("A").setAttribute("ui.label", "A");
graph.addNode("B");
graph.getNode("B").setAttribute("ui.label", "B");
graph.addNode("C" );
graph.getNode("C").setAttribute("ui.label", "C");
graph.addEdge("AB", "A", "B");
graph.addEdge("BC", "B", "C");
graph.addEdge("CA", "C", "A");

graph.display();


try
{
fsi.writeAll(graph, "123");
} catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}

}

and I want to export a image form the graph to exibit on a web page or i need to be able to do a Applet to show the graph drawing.
I don't find in the documentation how to do it.
I realy appreciate if you or someone help me.

Thanks for all!

Rodrigo Lins.


On Mon, May 30, 2011 at 5:16 PM, guilhelm savin <guilhelm.savin AT gmail.com> wrote:

Dear Rodrigo Lins,

Thanks for the interest you have to graphstream.
You can find a tutorial about images here : http://graphstream-project.org/doc/Tutorials/Creating-a-movie-with-FileSinkImages_1.0/

If something is missing according to what you want to do, please tell me what, I will be really happy to help you.

Best regards.
Guilhelm

Le 30 mai 2011 19:41, "Rodrigo Lins" <lins.oliveira AT gmail.com> a crit:

> I'm using the Graph Stream and it is awsome!
> But i need to generate an image with my graph and i don't know how to do it
> and I don't find any example to do this.
>
> Thanks for your help.
>
> Rodrigo Lins




--
Guilhelm Savin
PhD Student of Computer Science




Archives gérées par MHonArc 2.6.16.

Top of page