Skip to main content

ShapePainter resize bug?

No replies
Anonymous

I'm not sure if this is a bug, but it doesn't seem to be what I expect.
ShapePainter has a resize property that if set to anything other than
BOTH will cause whatever dimension is NOT being resized to be 1. If I
set resize to HORIZONTAL, for example, then my vertical size will always
be 1. I see in the code that the bounds of the shape are queried, but
then never used. Here is the suspect code (in the paintBackground method):

//resize the shape if necessary
Shape shape = getShape();
Rectangle2D bounds = shape.getBounds2D();
double width = 1;
double height = 1;
Resize resize = getResize();
if (resize == Resize.HORIZONTAL || resize == Resize.BOTH) {
width = component.getWidth() - 1;
}
if (resize == Resize.VERTICAL || resize == Resize.BOTH) {
height = component.getHeight() - 1;
}

The "bounds" variable is not used anywhere in the code. Maybe the code
wants to look like this?

//resize the shape if necessary
Shape shape = getShape();
Rectangle2D bounds = shape.getBounds2D();
double width = bounds.getWidth(); <<-- Changed
double height = bounds.getHeight(); <<-- Changed
Resize resize = getResize();
if (resize == Resize.HORIZONTAL || resize == Resize.BOTH) {
width = component.getWidth() - 1;
}
if (resize == Resize.VERTICAL || resize == Resize.BOTH) {
height = component.getHeight() - 1;
}

- Andy

---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net
For additional commands, e-mail: jdnc-help@jdnc.dev.java.net