Exporting JGraphT graphs to PNG via JGraph

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
Report Content as Inappropriate

Exporting JGraphT graphs to PNG via JGraph

Dimitri Pissarenko

I'm trying to export a JGraphT-created JGraph to a file using the
following piece of code:

import org.jgraph.pad.GPConverter;
import org.jgraph.pad.GPGraph;
GPGraph gpGraph=null;
BufferedImage img = null;
gpGraph=new GPGraph(graph.getModel());
img = GPConverter.toImage(gpGraph);
ImageIO.write(img, "png", new File(selectedFileName));
catch (IOException exception)
this.logger.error("", exception);

graph is a JGraph, which was created from JGraphT.

The code above works fine for JGraphs, which were created without
JGraphT. With JGraphT, it produces an empty (white) PNG image.

How can I export a JGraphT-JGraph to some common image format (PNG or