Modifier and Type | Field and Description |
---|---|
int |
npoints
The total number of points.
|
int[] |
xpoints
The array of x coordinates.
|
int[] |
ypoints
The array of y coordinates.
|
Constructor and Description |
---|
Polygon()
Creates an empty polygon.
|
Polygon(int[] xpoints,
int[] ypoints,
int npoints)
Constructs and initializes a
Polygon from the specified
parameters. |
public int npoints
npoints
represents the number of valid points in this Polygon
and might be less than the number of elements in
xpoints
or ypoints
.
This value can be NULL.addPoint(int, int)
public int[] xpoints
Polygon
. The extra elements allow new points
to be added to this Polygon
without re-creating this
array. The value of npoints
is equal to the
number of valid points in this Polygon
.addPoint(int, int)
public int[] ypoints
Polygon
. The extra elements allow new points
to be added to this Polygon
without re-creating this
array. The value of npoints
is equal to the
number of valid points in this Polygon
.addPoint(int, int)
public Polygon()
public Polygon(int[] xpoints, int[] ypoints, int npoints)
Polygon
from the specified
parameters.xpoints
- an array of x coordinatesypoints
- an array of y coordinatesnpoints
- the total number of points in the
Polygon
java.lang.NegativeArraySizeException
- if the value of
npoints
is negative.java.lang.IndexOutOfBoundsException
- if npoints
is
greater than the length of xpoints
or the length of ypoints
.java.lang.NullPointerException
- if xpoints
or
ypoints
is null
.public void addPoint(int x, int y)
Polygon
.
If an operation that calculates the bounding box of this
Polygon
has already been performed, such as
getBounds
or contains
, then this
method updates the bounding box.
x
- the specified x coordinatey
- the specified y coordinatePolygon.getBounds()
public Rectangle getBounds()
getBounds
in interface Shape
Shape.getBounds()
public Shape translate(int tx, int ty)
Shape
translate
in interface Shape
tx
- the distance by which coordinates are translated in the
X axis directionty
- the distance by which coordinates are translated in the
Y axis directionShape.translate(int, int)
© Copyright SyncRO Soft SRL 2002 - 2014. All rights reserved.