Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Exporting as Image
Exporting as Image [message #238373] Fri, 07 September 2007 19:49 Go to next message
Eclipse UserFriend
Originally posted by: vb.prismtech.com

Hi,
I have an editor that has a FreeFormLayer with custom editparts and
connections.
I want to export this as an image ( JPEG ).

I used the code snippet found here:
http://dev.eclipse.org/newslists/news.eclipse.tools.gef/msg0 5012.html

I don't see the connections in the exported image.

What do I need in order to do that?

Thanks
Re: Exporting as Image [message #238433 is a reply to message #238373] Mon, 10 September 2007 06:27 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: puneet82sri.sify.com

You must have saved the figure before being displayed over editor.
Save it once your editor/shell is opened.
Re: Exporting as Image [message #238438 is a reply to message #238433] Mon, 10 September 2007 15:47 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: vb.prismtech.com

The editor was open.

"Puneet Srivastava" <puneet82sri@sify.com> wrote in message
news:872872833.6311189405675520.JavaMail.root@cp9.dzone.com...
> You must have saved the figure before being displayed over editor.
> Save it once your editor/shell is opened.
Re: Exporting as Image [message #238450 is a reply to message #238373] Mon, 10 September 2007 20:57 Go to previous messageGo to next message
Felix L J Mayer is currently offline Felix L J MayerFriend
Messages: 202
Registered: July 2009
Senior Member
Here is a piece of code that works for me. At the end you have ImageData in
your display color depth that can be saved or processed further.

GraphicalViewer viewer = (GraphicalViewer)
getWorkbenchPart().getAdapter( GraphicalViewer.class );
LayerManager layers = (LayerManager) viewer.getEditPartRegistry().get(
LayerManager.ID );
IFigure figure = layers.getLayer( LayerConstants.PRINTABLE_LAYERS );
Rectangle bounds = figure.getBounds();
if( figure instanceof FreeformFigure) {
bounds = ((FreeformFigure) figure).getFreeformExtent();
}
Image image = new Image( Display.getDefault(), bounds.width,
bounds.height );
boolean antialiasing = false;
GC gc = new GC( image );
gc.setAntialias( antialiasing ? SWT.ON : SWT.OFF );
gc.setTextAntialias( antialiasing ? SWT.ON : SWT.OFF );
Graphics graphics = new SWTGraphics( gc );
graphics.translate( bounds.getLocation().negate() );
figure.paint( graphics );
graphics.dispose();
gc.dispose();
ImageData imageData = image.getImageData();
image.dispose();


"Vikram" <vb@prismtech.com> wrote in message
news:fbsa1s$aq9$1@build.eclipse.org...
> Hi,
> I have an editor that has a FreeFormLayer with custom editparts and
> connections.
> I want to export this as an image ( JPEG ).
>
> I used the code snippet found here:
> http://dev.eclipse.org/newslists/news.eclipse.tools.gef/msg0 5012.html
>
> I don't see the connections in the exported image.
>
> What do I need in order to do that?
>
> Thanks
>
>
Re: Exporting as Image [message #238473 is a reply to message #238450] Tue, 11 September 2007 18:34 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: vb.prismtech.com

Thanks.

"Felix L J Mayer" <felix.mayer@objectaid.com> wrote in message
news:fc4b4h$1q6$1@build.eclipse.org...
> Here is a piece of code that works for me. At the end you have ImageData
> in your display color depth that can be saved or processed further.
>
> GraphicalViewer viewer = (GraphicalViewer)
> getWorkbenchPart().getAdapter( GraphicalViewer.class );
> LayerManager layers = (LayerManager)
> viewer.getEditPartRegistry().get( LayerManager.ID );
> IFigure figure = layers.getLayer( LayerConstants.PRINTABLE_LAYERS );
> Rectangle bounds = figure.getBounds();
> if( figure instanceof FreeformFigure) {
> bounds = ((FreeformFigure) figure).getFreeformExtent();
> }
> Image image = new Image( Display.getDefault(), bounds.width,
> bounds.height );
> boolean antialiasing = false;
> GC gc = new GC( image );
> gc.setAntialias( antialiasing ? SWT.ON : SWT.OFF );
> gc.setTextAntialias( antialiasing ? SWT.ON : SWT.OFF );
> Graphics graphics = new SWTGraphics( gc );
> graphics.translate( bounds.getLocation().negate() );
> figure.paint( graphics );
> graphics.dispose();
> gc.dispose();
> ImageData imageData = image.getImageData();
> image.dispose();
>
>
> "Vikram" <vb@prismtech.com> wrote in message
> news:fbsa1s$aq9$1@build.eclipse.org...
>> Hi,
>> I have an editor that has a FreeFormLayer with custom editparts and
>> connections.
>> I want to export this as an image ( JPEG ).
>>
>> I used the code snippet found here:
>> http://dev.eclipse.org/newslists/news.eclipse.tools.gef/msg0 5012.html
>>
>> I don't see the connections in the exported image.
>>
>> What do I need in order to do that?
>>
>> Thanks
>>
>>
>
>
Re: Exporting as Image [message #238519 is a reply to message #238450] Mon, 17 September 2007 10:24 Go to previous message
Eclipse UserFriend
Originally posted by: puneet82sri.sify.com

Hi Felix,
Can we save the draw2d figure with out showing it in editor/shell ?

thanks
Puneet
Previous Topic:Display a Figure in front of the others
Next Topic:Problems with UndoablePropertySheetEntry and Tabbed Properties View
Goto Forum:
  


Current Time: Sat Apr 27 01:50:22 GMT 2024

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

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

Back to the top