bug? ImageFigure with border and localCoordinates [message #205943] |
Fri, 23 December 2005 10:35 |
Jason Grant Messages: 77 Registered: July 2009 |
Member |
|
|
[GEF 3.2.0 and also GEF CVS head]
I have an ImageFigure subclass which returns true from
useLocalCoordinates(). I also set a border on this ImageFigure.
When the ImageFigure repaints, the image top-left corner is rendered at
(0, 0), and so the image is overlapped by the top & left borders, and
whitespace shows between the image and the bottom & right borders.
I suspect this is a bug; I think the implementation of
ImageFigure.paintFigure() should not call:
graphics.drawImage(getImage(), x, y);
but instead:
graphics.drawImage(getImage(), x + getInsets().left, y + getInsets().top);
Does that sound correct, or am I doing something silly?
Thanks,
Jason.
|
|
|
|
Re: bug? ImageFigure with border and localCoordinates [message #206226 is a reply to message #206074] |
Tue, 27 December 2005 04:55 |
Eclipse User |
|
|
|
Originally posted by: none.us.ibm.com
ImageFigure should work with a border. You've found a bug in that
getClientArea should not be called from paintFigure(). Please open a bug
report.
The fix is something like:
Rect area = getBounds().getCropped(getInsets());
"Jason Grant" <junk@logular.com> wrote in message
news:pan.2005.12.24.00.50.41.462026@logular.com...
> For the benefit of others, I just created a new Figure that does much of
> what ImageFigure already does (although I removed support for alignment),
> and my paintFigure() method is shown below. Seems to work well for my
> needs, which has a border and local coordinates, and with the parent
> figure containing many of these children in a FlowLayout.
>
> /**
> * Paint the image, after first translating the client area
> * to the parent's coordinate system.
> */
> protected void paintFigure(Graphics graphics) {
> super.paintFigure(graphics);
> if (getImage() == null)
> return;
> Rectangle area = getClientArea();
> translateToParent(area);
> graphics.drawImage(getImage(), area.getTopLeft());
> }
>
|
|
|
Powered by
FUDForum. Page generated in 0.03355 seconds