|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--java.awt.Polygon
A polygon consists of a list of x and y coordinates.
| Field Summary | |
int |
npoints
The total number of points. |
int[] |
xpoints
The array of x coordinates. |
int[] |
ypoints
The array of y coordinates. |
| Constructor Summary | |
Polygon()
Creates an empty polygon. |
|
Polygon(int[] xpoints,
int[] ypoints,
int npoints)
Constructs and initializes a Polygon from the specified parameters. |
|
| Method Summary | |
void |
addPoint(int x,
int y)
Appends a point to a polygon. |
Rectangle |
getBoundingBox()
Determines the area spanned by this Polygon. |
boolean |
inside(int x,
int y)
Determines whether the point (x,y) is inside the Polygon. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public int npoints
public int[] xpoints
public int[] ypoints
| Constructor Detail |
public Polygon()
public Polygon(int[] xpoints,
int[] ypoints,
int npoints)
xpoints - the array of x coordinatesypoints - the array of y coordinatesnpoints - the total number of points in the Polygon| Method Detail |
public void addPoint(int x,
int y)
x - the x coordinate of the pointy - the y coordinate of the pointpublic Rectangle getBoundingBox()
public boolean inside(int x,
int y)
x - the X coordinate of the point to be testedy - the Y coordinate of the point to be tested
Based on code by Hanpeter van Vliet
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||