public static class Polygon2D.Double extends Polygon2D implements java.io.Serializable
Double
class defines a polygon with
coordinates stored in double precision floating point.Polygon2D.Double, Polygon2D.Float
Modifier and Type | Field and Description |
---|---|
protected java.awt.geom.Rectangle2D.Double |
bounds
The bounds of this
Polygon . |
double[] |
xpoints
The array of X coordinates.
|
double[] |
ypoints
The array of Y coordinates.
|
Constructor and Description |
---|
Double() |
Double(double[] xpoints,
double[] ypoints,
int npoints)
Constructs and initializes a
Polygon from the specified
parameters. |
Modifier and Type | Method and Description |
---|---|
void |
addPoint(double x,
double y)
Appends the specified coordinates to this
Polygon . |
boolean |
contains(double x,
double y) |
boolean |
contains(double x,
double y,
double w,
double h) |
java.awt.Rectangle |
getBounds()
Gets the bounding box of this
Polygon . |
java.awt.geom.Rectangle2D |
getBounds2D() |
java.awt.geom.PathIterator |
getPathIterator(java.awt.geom.AffineTransform at)
Returns an iterator object that iterates along the boundary of this
Polygon and provides access to the geometry
of the outline of this Polygon . |
boolean |
intersects(double x,
double y,
double w,
double h) |
void |
invalidate()
Invalidates or flushes any internally-cached data that depends
on the vertex coordinates of this
Polygon . |
void |
translate(double deltaX,
double deltaY)
Translates the vertices of the
Polygon by
deltaX along the x axis and by
deltaY along the y axis. |
add, contains, contains, contains, contains, getPathIterator, intersects, reset
public double[] 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
.public double[] 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
.protected java.awt.geom.Rectangle2D.Double bounds
Polygon
.
This value can be null.public Double()
public Double(double[] xpoints, double[] 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 translate(double deltaX, double deltaY)
Polygon
by
deltaX
along the x axis and by
deltaY
along the y axis.public void invalidate()
Polygon2D
Polygon
.
This method should be called after any direct manipulation
of the coordinates in the xpoints
or
ypoints
arrays to avoid inconsistent results
from methods such as getBounds
or contains
that might cache data from earlier computations relating to
the vertex coordinates.invalidate
in class Polygon2D
Polygon.getBounds()
public boolean contains(double x, double y)
Polygon2D
public boolean intersects(double x, double y, double w, double h)
Polygon2D
intersects
in interface java.awt.Shape
intersects
in class Polygon2D
public void addPoint(double x, double y)
Polygon2D
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.
public java.awt.Rectangle getBounds()
Polygon2D
Polygon
.
The bounding box is the smallest Rectangle
whose
sides are parallel to the x and y axes of the
coordinate space, and can completely contain the Polygon
.public java.awt.geom.Rectangle2D getBounds2D()
Polygon2D
getBounds2D
in interface java.awt.Shape
getBounds2D
in class Polygon2D
public boolean contains(double x, double y, double w, double h)
Polygon2D
public java.awt.geom.PathIterator getPathIterator(java.awt.geom.AffineTransform at)
Polygon2D
Polygon
and provides access to the geometry
of the outline of this Polygon
. An optional
AffineTransform
can be specified so that the coordinates
returned in the iteration are transformed accordingly.getPathIterator
in interface java.awt.Shape
getPathIterator
in class Polygon2D
at
- an optional AffineTransform
to be applied to the
coordinates as they are returned in the iteration, or
null
if untransformed coordinates are desiredPathIterator
object that provides access to the
geometry of this Polygon
.