Java JGraphx save as image

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

+4
source share
1 answer

This should be done 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 call to a static method).
  • "PNG" is a format and can be JPEG, PNG, GIF, BMP and WBMP out of the box. See here for more details.
+8
source

Source: https://habr.com/ru/post/1498855/


All Articles