java JGraphx save as an image
Asked Answered
G

1

6

Does anyone know how to export JGraphx as an image in any format? If not, then does anyone know any other java library that will let me create simple diagrams and then save it as an image?

Gib answered 25/8, 2013 at 18:17 Comment(0)
N
10

This should do it for PNG format:

BufferedImage image = mxCellRenderer.createBufferedImage(graph, null, 1, Color.WHITE, true, null);
ImageIO.write(image, "PNG", new File("C:\\Temp\\graph.png"));

Where

  • graph is your mxGraph object. (Note mxCellRenderer is a reference to a class not a variable, so mxCellRenderer.createBufferedImage is a static method call).
  • "PNG" is the format, and can be JPEG, PNG, GIF, BMP and WBMP out of the box. See here for more details.
Ngocnguyen answered 2/9, 2013 at 12:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.