I've been looking around for solutions to my question, but nothing does exactly what I want.
What I want to do is save a whole JUNG graph (with custom vertex and edge rendering) to an image (PNG or JPEG). When I save the VisualizationViewer to a BufferedImage, it only takes the visible part. I want to save the whole graph, so that's not an option.
Does anyone have an idea on how to render my whole graph to an image?
Thanks in advance!
My experience with capturing images the way dylan202 suggested, was that the quality of images was not up to the mark. Since I needed the images for my presentation.
Another way to get high quality images of your Jung network is to use VectorGraphics library from FreeHEP.
I used this library to generate images in a pdf file. Afterwards I took snapshots of the image from the pdf to my presentation.
It is also possible to generate JPEG or other type of files. For example to generate SVG files only one line needs to be changed:
For more information see the manual.
Zoomed in snapshot from the PDF file
There is no such a method named "getGraphLayout" of Graph class but of a visualizationviewer.
I finally found the solution to my problem, using a
VisualizationImageServer
. Here is an example of how to create an image from a whole JUNG graph, for others struggling with it:You might want to have a look at the StandardPrint class I put together a while back:
http://tus.svn.sourceforge.net/viewvc/tus/tjacobs/print/
You can render any component (or anything, using SpecialPrint) to an image, using preview()