Creating an Image of the figures [message #148806] |
Fri, 27 August 2004 16:24 |
Eclipse User |
|
|
|
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 |
Eclipse User |
|
|
|
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 #148845 is a reply to message #148822] |
Sat, 28 August 2004 01:03 |
Eclipse User |
|
|
|
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 |
Eclipse User |
|
|
|
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;
>
|
|
|
Powered by
FUDForum. Page generated in 0.04296 seconds