-
Bug
-
Resolution: Fixed
-
P4
-
1.2.2
-
beta
-
generic
-
generic
Name: tb29552 Date: 01/17/2000
java version "1.2.2"
HotSpot VM (1.0.1, mixed mode, build c)
java.awt.Polygon.xpoints (or .ypoints) has more elements than the npoints. The extra
points have all (0,0) coordinate. If this is intentional (to provide extra
reserve space ), it should have been stated in the API-documentation for
java.awt.Polygon
Example:
import java.awt.*;
public class PolygonTest {
// MAIN
public static void main(String[] args) {
// possible corners of the polygon
int n = 0;
if(args.length>0){
try{
n = (new Integer(args[0])).intValue();
} catch(Exception e){
prt("can't convert it to int...");
prt("integer expected. ");
}
}
// minimum 3 sides
n = (n<2) ? 3:n;
// an empty polygon
Polygon pol = new Polygon();
// populated with n corners
for(int i=0;i<n;i++){
pol.addPoint(i+1,i+1);
}
// npoints is correct
prt("There are "+n+" sides. (npoints)" );
// x- and y-coordinates
int [] x = pol.xpoints;
int [] y = pol.ypoints;
// should this not be equal to n?
int m = x.length;
prt("xpoints.length = "+m+" !");
// printing the coordinates of the polygon
// where do the extra corners with (0,0) come from?
for(int i=0;i<m;i++){
prt("Node "+i+": X="+x[i]+" Y="+y[i]);
}
}
// println
public static void prt(String s){
System.out.println(s);
}
}
(Review ID: 99960)
======================================================================
- relates to
-
JDK-4299586 java.awt.Polygon.Polygon(int[], int[], int) has incomplete spec
-
- Closed
-