-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
1.3.0
-
x86
-
windows_2000
Name: boT120536 Date: 04/10/2001
java version "1.3.1-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1-beta-b15)
Java HotSpot(TM) Client VM (build 1.3.1beta-b15, mixed mode)
public class GetBoundsTest {
public static void main(String[] args) {
Line2D line = new Line2D.Float(0, 6, 10, 6);
Area area = new Area(line);
System.out.println(area.getBounds2D().getWidth());
// bug: above statement prints out zero
}
}
If I knew what the dimensions were, I wouldn't need to call
getRectangle2D(). Believe me, there's no other reasonable way around this
quandry. I have a GeneralPath, and I don't know what it was originally
(because it may have originated from another type that was
AffineTransform'ed), therefore I must use the Area class to get a tightly
bounding box, because it may have originally been a quad or cubic. But if it
turns out that it was originally a Line2D, then I'll get the wrong answer.
And if I just use the old getBounds2D, I'll get the wrong answer if it was
originally a cubic or quad. Besides, all this makes for an enormous
headache, particularly given how important it is to know the size of the
graphic you're dealing with. The only way I see around it is to have a giant
switch statement that checks every object to see if it's a Line2D,
Ellipse2D, etc., and that calls the different methods accordingly, and that
ALSO checks to see if it's a GeneralPath, then if it's a general path, I
have ANOTHER giant switch statement in which I go inside of GeneralPath to
see what the constants are (curveTo, quadTo, lineTo, etc.)... do you see
what I mean?
(Review ID: 120378)
======================================================================
- duplicates
-
JDK-8176501 Method Shape.getBounds2D() incorrectly includes Bezier control points in bounding box
-
- Resolved
-