Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » bug? ImageFigure with border and localCoordinates
bug? ImageFigure with border and localCoordinates [message #205943] Fri, 23 December 2005 10:35 Go to next message
Jason Grant is currently offline Jason GrantFriend
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 #206074 is a reply to message #205943] Sat, 24 December 2005 00:50 Go to previous messageGo to next message
Jason Grant is currently offline Jason GrantFriend
Messages: 77
Registered: July 2009
Member
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());
}
Re: bug? ImageFigure with border and localCoordinates [message #206226 is a reply to message #206074] Tue, 27 December 2005 04:55 Go to previous message
Eclipse UserFriend
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());
> }
>
Previous Topic:Something about ActionBarcontributor and action of movement
Next Topic:GEF shapes sample
Goto Forum:
  


Current Time: Tue Apr 16 15:47:23 GMT 2024

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

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

Back to the top