|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.batik.ext.awt.geom.Polygon2D
public class Polygon2D
This class is a Polygon with float coordinates.
Field Summary | |
---|---|
protected Rectangle2D |
bounds
Bounds of the Polygon2D. |
int |
npoints
The total number of points. |
float[] |
xpoints
The array of x coordinates. |
float[] |
ypoints
The array of x coordinates. |
Constructor Summary | |
---|---|
Polygon2D()
Creates an empty Polygon2D. |
|
Polygon2D(float[] xpoints,
float[] ypoints,
int npoints)
Constructs and initializes a Polygon2D from the specified
parameters. |
|
Polygon2D(int[] xpoints,
int[] ypoints,
int npoints)
Constructs and initializes a Polygon2D from the specified
parameters. |
|
Polygon2D(Polygon pol)
Constructs and initializes a Polygon2D from the specified
Polygon. |
|
Polygon2D(Rectangle2D rec)
Constructs and initializes a Polygon2D from the specified
Rectangle2D. |
Method Summary | |
---|---|
void |
addPoint(float x,
float y)
Appends the specified coordinates to this Polygon2D . |
void |
addPoint(Point2D p)
|
Object |
clone()
|
boolean |
contains(double x,
double y)
Determines if the specified coordinates are inside this Polygon . |
boolean |
contains(double x,
double y,
double w,
double h)
Tests if the interior of this Polygon entirely
contains the specified set of rectangular coordinates. |
boolean |
contains(int x,
int y)
Determines whether the specified coordinates are inside this Polygon . |
boolean |
contains(Point p)
Determines whether the specified Point is inside this
Polygon . |
boolean |
contains(Point2D p)
Tests if a specified Point2D is inside the boundary of this
Polygon . |
boolean |
contains(Rectangle2D r)
Tests if the interior of this Polygon entirely
contains the specified Rectangle2D . |
Rectangle |
getBounds()
|
Rectangle2D |
getBounds2D()
Returns the high precision bounding box of the Shape . |
PathIterator |
getPathIterator(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 . |
PathIterator |
getPathIterator(AffineTransform at,
double flatness)
Returns an iterator object that iterates along the boundary of the Polygon2D and provides access to the geometry of the
outline of the Shape . |
Polygon |
getPolygon()
|
Polyline2D |
getPolyline2D()
|
boolean |
intersects(double x,
double y,
double w,
double h)
Tests if the interior of this Polygon intersects the
interior of a specified set of rectangular coordinates. |
boolean |
intersects(Rectangle2D r)
Tests if the interior of this Polygon intersects the
interior of a specified Rectangle2D . |
void |
reset()
Resets this Polygon object to an empty polygon. |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public int npoints
npoints
represents the number of valid points in this Polygon
.
public float[] xpoints
npoints
is equal to the
number of points in this Polygon2D
.
public float[] ypoints
npoints
is equal to the
number of points in this Polygon2D
.
protected Rectangle2D bounds
getBounds()
Constructor Detail |
---|
public Polygon2D()
public Polygon2D(Rectangle2D rec)
Polygon2D
from the specified
Rectangle2D.
rec
- the Rectangle2D
NullPointerException
- rec is null
.public Polygon2D(Polygon pol)
Polygon2D
from the specified
Polygon.
pol
- the Polygon
NullPointerException
- pol is null
.public Polygon2D(float[] xpoints, float[] ypoints, int npoints)
Polygon2D
from the specified
parameters.
xpoints
- an array of x coordinatesypoints
- an array of y coordinatesnpoints
- the total number of points in the Polygon2D
NegativeArraySizeException
- if the value of
npoints
is negative.
IndexOutOfBoundsException
- if npoints
is
greater than the length of xpoints
or the length of ypoints
.
NullPointerException
- if xpoints
or
ypoints
is null
.public Polygon2D(int[] xpoints, int[] ypoints, int npoints)
Polygon2D
from the specified
parameters.
xpoints
- an array of x coordinatesypoints
- an array of y coordinatesnpoints
- the total number of points in the Polygon2D
NegativeArraySizeException
- if the value of
npoints
is negative.
IndexOutOfBoundsException
- if npoints
is
greater than the length of xpoints
or the length of ypoints
.
NullPointerException
- if xpoints
or
ypoints
is null
.Method Detail |
---|
public void reset()
Polygon
object to an empty polygon.
public Object clone()
clone
in class Object
public Polyline2D getPolyline2D()
public Polygon getPolygon()
public void addPoint(Point2D p)
public void addPoint(float x, float y)
Polygon2D
.
x
- the specified x coordinatey
- the specified y coordinatepublic boolean contains(Point p)
Point
is inside this
Polygon
.
p
- the specified Point
to be tested
true
if the Polygon
contains the
Point
; false
otherwise.contains(double, double)
public boolean contains(int x, int y)
Polygon
.
x
- the specified x coordinate to be testedy
- the specified y coordinate to be tested
true
if this Polygon
contains
the specified coordinates, (x, y);
false
otherwise.public Rectangle2D getBounds2D()
Shape
.
getBounds2D
in interface Shape
Rectangle2D
that precisely
bounds the Shape
.public Rectangle getBounds()
getBounds
in interface Shape
public boolean contains(double x, double y)
Polygon
. For the definition of
insideness, see the class comments of Shape
.
contains
in interface Shape
x
- the specified x coordinatey
- the specified y coordinate
true
if the Polygon
contains the
specified coordinates; false
otherwise.public boolean contains(Point2D p)
Point2D
is inside the boundary of this
Polygon
.
contains
in interface Shape
p
- a specified Point2D
true
if this Polygon
contains the
specified Point2D
; false
otherwise.contains(double, double)
public boolean intersects(double x, double y, double w, double h)
Polygon
intersects the
interior of a specified set of rectangular coordinates.
intersects
in interface Shape
x
- the x coordinate of the specified rectangular
shape's top-left cornery
- the y coordinate of the specified rectangular
shape's top-left cornerw
- the width of the specified rectangular shapeh
- the height of the specified rectangular shape
true
if the interior of this
Polygon
and the interior of the
specified set of rectangular
coordinates intersect each other;
false
otherwise.public boolean intersects(Rectangle2D r)
Polygon
intersects the
interior of a specified Rectangle2D
.
intersects
in interface Shape
r
- a specified Rectangle2D
true
if this Polygon
and the
interior of the specified Rectangle2D
intersect each other; false
otherwise.public boolean contains(double x, double y, double w, double h)
Polygon
entirely
contains the specified set of rectangular coordinates.
contains
in interface Shape
x
- the x coordinate of the top-left corner of the
specified set of rectangular coordinatesy
- the y coordinate of the top-left corner of the
specified set of rectangular coordinatesw
- the width of the set of rectangular coordinatesh
- the height of the set of rectangular coordinates
true
if this Polygon
entirely
contains the specified set of rectangular
coordinates; false
otherwise.public boolean contains(Rectangle2D r)
Polygon
entirely
contains the specified Rectangle2D
.
contains
in interface Shape
r
- the specified Rectangle2D
true
if this Polygon
entirely
contains the specified Rectangle2D
;
false
otherwise.contains(double, double, double, double)
public PathIterator getPathIterator(AffineTransform at)
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 Shape
at
- an optional AffineTransform
to be applied to the
coordinates as they are returned in the iteration, or
null
if untransformed coordinates are desired
PathIterator
object that provides access to the
geometry of this Polygon
.public PathIterator getPathIterator(AffineTransform at, double flatness)
Polygon2D
and provides access to the geometry of the
outline of the Shape
. Only SEG_MOVETO, SEG_LINETO, and
SEG_CLOSE point types are returned by the iterator.
Since polygons are already flat, the flatness
parameter
is ignored.
getPathIterator
in interface Shape
at
- an optional AffineTransform
to be applied to the
coordinates as they are returned in the iteration, or
null
if untransformed coordinates are desiredflatness
- the maximum amount that the control points
for a given curve can vary from colinear before a subdivided
curve is replaced by a straight line connecting the
endpoints. Since polygons are already flat the
flatness
parameter is ignored.
PathIterator
object that provides access to the
Shape
object's geometry.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |