Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » [ZEST] png export
[ZEST] png export [message #1077152] Thu, 01 August 2013 09:58 Go to next message
Low Coupling is currently offline Low CouplingFriend
Messages: 30
Registered: June 2013
I'd like to programmatically create a zest diagram and export it as a png.
I have managed to create the diagram by means of a GraphViewer instance having as composite parent a shell instaniated this way:
Shell shell = new Shell(Display.getDefault()); 

Note that the graph is not shown.
I can't see now how to export the graph in a png file. Is there any way to do that?

[Updated on: Thu, 01 August 2013 09:59]

Report message to a moderator

Re: [ZEST] png export [message #1077268 is a reply to message #1077152] Thu, 01 August 2013 13:08 Go to previous message
Zoltan Ujhelyi is currently offline Zoltan UjhelyiFriend
Messages: 338
Registered: July 2015
Senior Member

yes, it is possible to export the contents of the graph as a png. See the following snippet (we have used this in the VIATRA2 project in; it does not need to be defined inside a GraphViewer, it only needs a reference to the Graph widget.

Graph g = (Graph) getControl();
Rectangle bounds = g.getContents().getBounds();
Point size = new Point(g.getContents().getSize().width, g.getContents()
org.eclipse.draw2d.geometry.Point viewLocation = g.getViewport()
final Image image = new Image(null, size.x, size.y);
GC gc = new GC(image);
SWTGraphics swtGraphics = new SWTGraphics(gc);

swtGraphics.translate(-1 * bounds.x + viewLocation.x, -1 * bounds.y
	+ viewLocation.y);
gc.copyArea(image, 0, 0);
ImageLoader loader = new ImageLoader(); = new ImageData[] { image.getImageData() };, format);

Hope this helps. Cheers,
Previous Topic:Threading Job issue when Graphical editor has large number of editparts.
Next Topic:Drawing a Shape
Goto Forum:

Current Time: Wed May 23 05:38:00 GMT 2018

Powered by FUDForum. Page generated in 0.01977 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top