| 
| Creating an Image of the figures [message #148806] | Fri, 27 August 2004 12: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 #149033 is a reply to message #148845] | Mon, 30 August 2004 13: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.04497 seconds