Zest:将图形输出到图像/ pdf [英] Zest: export diagram to an image/pdf

查看:88
本文介绍了Zest:将图形输出到图像/ pdf的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用zest框架创建了一个网络视图,这使用SWT显示/ shell来显示UI。我想将UI导出为图像/ pdf。
怎么办?任何想法?

I have created a network view diagram using zest framework, this uses SWT display/shell to display the UI. I want to export the UI to an image/pdf. How to do it? Any ideas?

推荐答案

您可以使用SWT GC.copyArea()方法将控件的内容复制到图像,然后将图像保存到文件。例如,如果您有Zest GraphViewer,查看器,以下代码将其内容复制到名为 out.png 的PNG文件。

You can use the SWT GC.copyArea() method to copy the contents of a Control to an Image, then save the Image to file. For example, if you have a Zest GraphViewer, viewer, the following code will copy its contents to a PNG file named out.png.

GC gc = new GC(viewer.getControl());
Rectangle bounds = viewer.getControl().getBounds();
Image image = new Image(viewer.getControl().getDisplay(), bounds);
try {
    gc.copyArea(image, 0, 0);
    ImageLoader imageLoader = new ImageLoader();
    imageLoader.data = new ImageData[] { image.getImageData() };
    imageLoader.save("c:\\out.png", SWT.IMAGE_PNG);
} finally {
    image.dispose();
    gc.dispose();
}

这篇关于Zest:将图形输出到图像/ pdf的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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