Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Exporting to Image (Again)
Exporting to Image (Again) [message #202858] Mon, 14 November 2005 12:22 Go to next message
Fabian Wolf is currently offline Fabian WolfFriend
Messages: 96
Registered: July 2009
Member
Hi all,


I'm facing the problem, that exporting editor content to an image is cut off
at the left coordinate (0,0). Objects dragged beyond that coordinate to the
negative area do not increase the ClientArea.

What am I doing wrong here?

public void doSaveAsJPG(String dir, String filename) {
IFigure figure =
((ScalableFreeformRootEditPart)getGraphicalViewer().getRootE ditPart()).getLayer(LayerConstants.PRINTABLE_LAYERS);

RectangleFigure backgroundFigure = new RectangleFigure();
backgroundFigure.setBounds(new Rectangle(-1, -1,
figure.getClientArea().width, figure.getClientArea().height));
backgroundFigure.setBackgroundColor(ColorConstants.white);

ImageData data = new ImageData(figure.getClientArea().width,
figure.getClientArea().height, 24, new PaletteData(0xFF, 0xFF00, 0xFF000));
Image image = new Image(Display.getCurrent(), data);
GC gc = new GC(image);
Graphics g = new SWTGraphics(gc);

backgroundFigure.paint(g);
figure.paint(g);

ImageLoader loader = new ImageLoader();
loader.data = new ImageData[] { image.getImageData() };

loader.save(dir + File.separatorChar + filename, SWT.IMAGE_JPEG);

image.dispose();
gc.dispose();
g.dispose();
}


Thanks a lot!

Fabian
Re: Exporting to Image (Again) [message #203176 is a reply to message #202858] Fri, 18 November 2005 19:34 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.unknown.com

The figure's trying to paint to the negative coordinates of the image, but
since there are none, it gets clipped. You need to translate the graphics
so that the figure's origin () matches the image's origin (0,0). Try
something like:
g.translate(-figure.getBounds().x, -figure.getBounds().y)

"Fabian Wolf" <Fabian.Wolf@informatik.uni-ulm.de> wrote in message
news:dl9vic$v9f$1@news.eclipse.org...
> Hi all,
>
>
> I'm facing the problem, that exporting editor content to an image is cut
off
> at the left coordinate (0,0). Objects dragged beyond that coordinate to
the
> negative area do not increase the ClientArea.
>
> What am I doing wrong here?
>
> public void doSaveAsJPG(String dir, String filename) {
> IFigure figure =
>
((ScalableFreeformRootEditPart)getGraphicalViewer().getRootE ditPart()).getLa
yer(LayerConstants.PRINTABLE_LAYERS);
>
> RectangleFigure backgroundFigure = new RectangleFigure();
> backgroundFigure.setBounds(new Rectangle(-1, -1,
> figure.getClientArea().width, figure.getClientArea().height));
> backgroundFigure.setBackgroundColor(ColorConstants.white);
>
> ImageData data = new ImageData(figure.getClientArea().width,
> figure.getClientArea().height, 24, new PaletteData(0xFF, 0xFF00,
0xFF000));
> Image image = new Image(Display.getCurrent(), data);
> GC gc = new GC(image);
> Graphics g = new SWTGraphics(gc);
>
> backgroundFigure.paint(g);
> figure.paint(g);
>
> ImageLoader loader = new ImageLoader();
> loader.data = new ImageData[] { image.getImageData() };
>
> loader.save(dir + File.separatorChar + filename, SWT.IMAGE_JPEG);
>
> image.dispose();
> gc.dispose();
> g.dispose();
> }
>
>
> Thanks a lot!
>
> Fabian
Re: Exporting to Image (Again) [message #203191 is a reply to message #203176] Sat, 19 November 2005 00:18 Go to previous messageGo to next message
Fabian Wolf is currently offline Fabian WolfFriend
Messages: 96
Registered: July 2009
Member
Thanks Pratik!
I solved it by looking at the Thumbnail code ;) Thanks though!

Pratik Shah wrote:
> The figure's trying to paint to the negative coordinates of the image, but
> since there are none, it gets clipped. You need to translate the graphics
> so that the figure's origin () matches the image's origin (0,0). Try
> something like:
> g.translate(-figure.getBounds().x, -figure.getBounds().y)
>
> "Fabian Wolf" <Fabian.Wolf@informatik.uni-ulm.de> wrote in message
> news:dl9vic$v9f$1@news.eclipse.org...
>> Hi all,
>>
>>
>> I'm facing the problem, that exporting editor content to an image is cut
> off
>> at the left coordinate (0,0). Objects dragged beyond that coordinate to
> the
>> negative area do not increase the ClientArea.
>> ...
Re: Exporting to Image (Again) [message #716442 is a reply to message #203191] Wed, 17 August 2011 12:23 Go to previous message
Martin Missing name is currently offline Martin Missing nameFriend
Messages: 14
Registered: June 2011
Junior Member
6 years later... Smile
Can you please explain how you solved this?

Br
Martin

Fabian Wolf wrote on Fri, 18 November 2005 19:18
Thanks Pratik!
I solved it by looking at the Thumbnail code Wink Thanks though!

Pratik Shah wrote:
> The figure's trying to paint to the negative coordinates of the image, but
> since there are none, it gets clipped. You need to translate the graphics
> so that the figure's origin () matches the image's origin (0,0). Try
> something like:
> g.translate(-figure.getBounds().x, -figure.getBounds().y)
>
> "Fabian Wolf" <Fabian.Wolf@informatik.uni-ulm.de> wrote in message
> news:dl9vic$v9f$1@news.eclipse.org...
>> Hi all,
>>
>>
>> I'm facing the problem, that exporting editor content to an image is cut
> off
>> at the left coordinate (0,0). Objects dragged beyond that coordinate to
> the
>> negative area do not increase the ClientArea.
>> ...

[Updated on: Wed, 17 August 2011 12:23]

Report message to a moderator

Previous Topic:Drag and drop
Next Topic:Layout Role for connection childs
Goto Forum:
  


Current Time: Thu Mar 28 23:29:29 GMT 2024

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

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

Back to the top