Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Creating an Image of the figures
Creating an Image of the figures [message #148806] Fri, 27 August 2004 16:24 Go to next message
Eclipse UserFriend
Originally posted by: gupolet.ulb.ac.be

Hi,

Hi,

I was wondering how I could draw all the figures contained in my editor onto
an image. I used to do this:

IFigure figure = null;
if (root.getContents() instanceof FloorEditPart) //Always true in my
case
figure = ((FloorEditPart)root.getContents()).getFigure();
else
figure=root.getFigure();//Doesn't work either

Image img = new Image(null, figure.getPreferredSize().width,
figure.getPreferredSize().height);

GC gc = new GC(img);
Graphics graphics = new SWTGraphics(gc);
figure.paint(graphics);
graphics.dispose();
gc.dispose();
return img;

but I discovered that if the figures are bigger than the displayable area,
then only the visible parts of the figures appear on the image. How can I
get the whole thing?

Thank you very much, Guillaume
Re: Creating an Image of the figures [message #148822 is a reply to message #148806] Fri, 27 August 2004 17:50 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

You should be getting the PRINTABLE_LAYERS from the LayerManager, and
creating an image the same size as it, don't ask preferred size.

"Guillaume Polet" <gupolet@ulb.ac.be> wrote in message
news:cgnn1g$db8$1@eclipse.org...
> Hi,
>
> Hi,
>
> I was wondering how I could draw all the figures contained in my editor
onto
> an image. I used to do this:
>
> IFigure figure = null;
> if (root.getContents() instanceof FloorEditPart) //Always true in
my
> case
> figure = ((FloorEditPart)root.getContents()).getFigure();
> else
> figure=root.getFigure();//Doesn't work either
>
> Image img = new Image(null, figure.getPreferredSize().width,
> figure.getPreferredSize().height);
>
> GC gc = new GC(img);
> Graphics graphics = new SWTGraphics(gc);
> figure.paint(graphics);
> graphics.dispose();
> gc.dispose();
> return img;
>
> but I discovered that if the figures are bigger than the displayable area,
> then only the visible parts of the figures appear on the image. How can I
> get the whole thing?
>
> Thank you very much, Guillaume
>
>
Re: Creating an Image of the figures [message #148837 is a reply to message #148806] Fri, 27 August 2004 17:56 Go to previous messageGo to next message
Pratik Shah is currently offline Pratik ShahFriend
Messages: 1077
Registered: July 2009
Senior Member
Do you mean that the Image you are creating is bigger than the screen? You
can scale images.

"Guillaume Polet" <gupolet@ulb.ac.be> wrote in message
news:cgnn1g$db8$1@eclipse.org...
> Hi,
>
> Hi,
>
> I was wondering how I could draw all the figures contained in my editor
onto
> an image. I used to do this:
>
> IFigure figure = null;
> if (root.getContents() instanceof FloorEditPart) //Always true in
my
> case
> figure = ((FloorEditPart)root.getContents()).getFigure();
> else
> figure=root.getFigure();//Doesn't work either
>
> Image img = new Image(null, figure.getPreferredSize().width,
> figure.getPreferredSize().height);
>
> GC gc = new GC(img);
> Graphics graphics = new SWTGraphics(gc);
> figure.paint(graphics);
> graphics.dispose();
> gc.dispose();
> return img;
>
> but I discovered that if the figures are bigger than the displayable area,
> then only the visible parts of the figures appear on the image. How can I
> get the whole thing?
>
> Thank you very much, Guillaume
>
>
Re: Creating an Image of the figures [message #148845 is a reply to message #148822] Sat, 28 August 2004 01:03 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: gupolet.ulb.ac.be

I tried that but unfortunately, I couldn't get i to work, it gives the same
result as before. Maybe I'm not coding something right:
IFigure figure =root.getLayer(LayerConstants.PRINTABLE_LAYERS);

Image img = new Image(null, figure.getSize().width,
figure.getSize().height);

GC gc = new GC(img);
Graphics graphics = new SWTGraphics(gc);
figure.paint(graphics);
graphics.dispose();
gc.dispose();
return img;

root is a ScalableFreeFormRootEditPart and I use a FreeFormLayer as the
container for the child figures.

@Pratik :
The image I'am creating might be bigger than the screen but it doesn't
matter in this case. The problem is that the editor displays only a small
part of the whole thing. And the image I get after running the code up
there, is only what is displayed (the small part), not the rest of it.

Thank you in advance,

Guillaume

"Randy Hudson" <none@us.ibm.com> a
Re: Creating an Image of the figures [message #149033 is a reply to message #148845] Mon, 30 August 2004 17:03 Go to previous message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

"Guillaume Polet" <gupolet@ulb.ac.be> wrote in message
news:cgoldt$lj1$1@eclipse.org...
> I tried that but unfortunately, I couldn't get i to work, it gives the
same
> result as before. Maybe I'm not coding something right:
> IFigure figure =root.getLayer(LayerConstants.PRINTABLE_LAYERS);
>
> Image img = new Image(null, figure.getSize().width,
> figure.getSize().height);
>
> GC gc = new GC(img);
> Graphics graphics = new SWTGraphics(gc);
graphics.translate(figure.getLocation());
> figure.paint(graphics);
> graphics.dispose();
> gc.dispose();
> return img;
>
Previous Topic:Creation Tool Bug in GEF?
Next Topic:Paste action location
Goto Forum:
  


Current Time: Mon Sep 23 16:25:16 GMT 2024

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

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

Back to the top