-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
1.2.1
-
sparc
-
solaris_2.5
Name: saC57035 Date: 03/18/99
java.awt.Polygon.getBounds() returns senseless values in case of
Polygon.npoints=0 and in subsequent calls.
Javadoc doesn't cover this case at all.
Here is the test demonstrating the bug:
-----------------qq.java------------------------
import java.awt.*;
public class qq {
public static void main(String[] args) {
Polygon p = new Polygon();
for (i=0; i<5; i++){
System.out.println("npoints=" + p.npoints + " rectangle=" +
p.getBounds());
p.addPoint(i,i);
}
}
---------Output from the test---------------------
npoints=0 rectangle=java.awt.Rectangle[x=2147483647,y=2147483647,width=1,height=1]
npoints=1 rectangle=java.awt.Rectangle[x=0,y=0,width=-2147483648,height=-2147483648]
npoints=2 rectangle=java.awt.Rectangle[x=0,y=0,width=1,height=1]
npoints=3 rectangle=java.awt.Rectangle[x=0,y=0,width=2,height=2]
npoints=4 rectangle=java.awt.Rectangle[x=0,y=0,width=3,height=3]
--------------------------------------------------
======================================================================
- duplicates
-
JDK-4194956 Polygon.getBounds() works wrong for empty polygons
- Resolved