public static class Polygon2D.Float extends Polygon2D implements java.io.Serializable
Float class defines a polygon with
coordinates stored in float precision floating point.Polygon2D.Double, Polygon2D.Float| Modifier and Type | Field and Description |
|---|---|
protected java.awt.geom.Rectangle2D.Float |
bounds
The bounds of this
Polygon. |
float[] |
xpoints
The array of X coordinates.
|
float[] |
ypoints
The array of Y coordinates.
|
| Constructor and Description |
|---|
Float() |
Float(float[] xpoints,
float[] 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. |
void |
addPoint(float x,
float y) |
boolean |
contains(double x,
double y) |
boolean |
contains(double x,
double y,
double w,
double h) |
boolean |
contains(float x,
float y) |
boolean |
contains(float x,
float y,
float w,
float 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) |
boolean |
intersects(float x,
float y,
float w,
float 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. |
void |
translate(float deltaX,
float deltaY) |
add, contains, contains, contains, contains, getPathIterator, intersects, resetpublic float[] 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 float[] 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.Float bounds
Polygon.
This value can be null.public Float()
public Float(float[] xpoints,
float[] 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
Polygonjava.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 translate(float deltaX,
float deltaY)
public void invalidate()
Polygon2DPolygon.
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 Polygon2DPolygon.getBounds()public boolean contains(double x,
double y)
Polygon2Dpublic boolean contains(float x,
float y)
public boolean intersects(double x,
double y,
double w,
double h)
Polygon2Dintersects in interface java.awt.Shapeintersects in class Polygon2Dpublic boolean intersects(float x,
float y,
float w,
float h)
public void addPoint(double x,
double y)
Polygon2DPolygon.
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 void addPoint(float x,
float y)
public java.awt.Rectangle getBounds()
Polygon2DPolygon.
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()
Polygon2DgetBounds2D in interface java.awt.ShapegetBounds2D in class Polygon2Dpublic boolean contains(double x,
double y,
double w,
double h)
Polygon2Dpublic boolean contains(float x,
float y,
float w,
float h)
public java.awt.geom.PathIterator getPathIterator(java.awt.geom.AffineTransform at)
Polygon2DPolygon 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.ShapegetPathIterator in class Polygon2Dat - 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.