java JGraphx另存为图像 [英] java JGraphx save as an image

查看:96
本文介绍了java JGraphx另存为图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道如何将JGraphx导出为任何格式的图像吗?如果不是,那么还有人知道其他任何Java库,可以让我创建简单的图并将其另存为图像吗?

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?

推荐答案

这应该用于PNG格式:

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"));

哪里

  • graph是您的mxGraph对象. (注意mxCellRenderer是对类的引用,而不是变量,因此mxCellRenderer.createBufferedImage是静态方法调用).
  • "PNG"是格式,开箱即用可以是JPEG,PNG,GIF,BMP和WBMP.有关更多详细信息,请参见此处.
  • 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.

这篇关于java JGraphx另存为图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆