|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectmath.geom2d.polygon.Polygon2D
public class Polygon2D
Represent a polygonal domain whose boundary is a single closed polyline.
| Field Summary | |
|---|---|
protected java.util.ArrayList<Point2D> |
points
The inner ordered list of vertices. |
| Fields inherited from interface math.geom2d.Shape2D |
|---|
ACCURACY, defaultClipWindow, EMPTY_SET |
| Constructor Summary | |
|---|---|
Polygon2D()
Empty constructor: no vertex. |
|
Polygon2D(java.util.Collection<? extends Point2D> points)
|
|
Polygon2D(double[] xcoords,
double[] ycoords)
Constructor from two arrays, one for each coordinate. |
|
Polygon2D(Point2D[] tab)
Constructor from an array of points |
|
| Method Summary | |
|---|---|
void |
addPoint(Point2D point)
Add a point as the last vertex. |
void |
clearPoints()
remove all the vertices of the polygon. |
Shape2D |
clip(Box2D box)
Return the shape formed by the polygon clipped by the given box. |
boolean |
contains(double x,
double y)
Return true if the point (x, y) lies inside the polygon, with precision given by Shape2D.ACCURACY. |
boolean |
contains(double x,
double y,
double w,
double h)
return false, because a line cannot contain a rectangle. |
boolean |
contains(java.awt.geom.Point2D p)
Return true if the point p lies inside the polygon, with precision given by Shape2D.ACCURACY. |
boolean |
contains(java.awt.geom.Rectangle2D r)
return false, because a line cannot contain a rectangle. |
boolean |
equals(java.lang.Object obj)
Test if the two polygons are equal. |
double |
getArea()
Computes area of the polygon, by returning the absolute value of the signed area. |
Boundary2D |
getBoundary()
Returns a closed polyline, which encloses the polygon. |
Box2D |
getBoundingBox()
Return the bounding box of the polygon. |
java.awt.Rectangle |
getBounds()
Return bounding box of the shape. |
java.awt.geom.Rectangle2D |
getBounds2D()
Return more precise bounds for the shape. |
Point2D |
getCentroid()
Computes the centroid (center of mass) of the polygon. |
Shape2D |
getClippedShape(Box2D box)
Return the shape formed by the polygon clipped by the given box. |
double |
getDistance(double x,
double y)
Get the distance of the point to the polygon. |
double |
getDistance(java.awt.geom.Point2D p)
Get the distance of the point to the polygon. |
java.util.Collection<LineSegment2D> |
getEdges()
Return the set of edges, as a collection of LineSegment2D. |
java.awt.geom.GeneralPath |
getGeneralPath()
Return a general path iterator. |
java.awt.geom.PathIterator |
getPathIterator(java.awt.geom.AffineTransform trans)
Return pathiterator for this polygon. |
java.awt.geom.PathIterator |
getPathIterator(java.awt.geom.AffineTransform trans,
double flatness)
Return pathiterator for this polygon. |
java.util.Iterator<Point2D> |
getPoints()
Deprecated. use getVertices() instead. |
double |
getSignedArea()
Computes the signed area of the polygon. |
double |
getSignedDistance(double x,
double y)
Get the signed distance of the shape to the given point : this distance is positive if the point lies outside the shape, and is negative if the point lies inside the shape. |
double |
getSignedDistance(java.awt.geom.Point2D p)
Get the signed distance of the shape to the given point : this distance is positive if the point lies outside the shape, and is negative if the point lies inside the shape. |
java.util.Collection<Point2D> |
getVertices()
Returns the points of the polygon. |
int |
getVerticesNumber()
Return the number of vertices. |
int |
getWindingNumber(double x,
double y)
Computes the winding number of the polygon. |
boolean |
intersects(double x,
double y,
double w,
double h)
Tests if the Polygon intersects the interior of a specified rectangular area. |
boolean |
intersects(java.awt.geom.Rectangle2D r)
Tests if the Polygon intersects the interior of a specified rectangle2D. |
boolean |
isBounded()
Always returns true if polygon is oriented counter-clockwise, false otherwise. |
void |
removePoint(Point2D point)
Remove a vertex of the polygon. |
Polygon2D |
transform(AffineTransform2D trans)
Return the new Polygon created by an affine transform of this polygon. |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected java.util.ArrayList<Point2D> points
| Constructor Detail |
|---|
public Polygon2D()
public Polygon2D(Point2D[] tab)
tab - the vertices stored in an array of Point2D
public Polygon2D(double[] xcoords,
double[] ycoords)
xcoords - the x coordinate of each vertexycoords - the y coordinate of each vertexpublic Polygon2D(java.util.Collection<? extends Point2D> points)
| Method Detail |
|---|
public void addPoint(Point2D point)
public void removePoint(Point2D point)
point - the vertex to be removed.public double getArea()
public double getSignedArea()
public Point2D getCentroid()
public int getWindingNumber(double x,
double y)
x - the x-coordinate of the pointy - the y-coordinate of the point
public java.util.Iterator<Point2D> getPoints()
public java.util.Collection<Point2D> getVertices()
getVertices in interface PolygonalShape2Dpublic int getVerticesNumber()
getVerticesNumber in interface PolygonalShape2Dpublic java.util.Collection<LineSegment2D> getEdges()
getEdges in interface PolygonalShape2Dpublic void clearPoints()
public Boundary2D getBoundary()
getBoundary in interface Domain2Dpublic double getDistance(java.awt.geom.Point2D p)
getDistance in interface Shape2D
public double getDistance(double x,
double y)
getDistance in interface Shape2Dpublic double getSignedDistance(java.awt.geom.Point2D p)
public double getSignedDistance(double x,
double y)
public Shape2D getClippedShape(Box2D box)
public Shape2D clip(Box2D box)
clip in interface Shape2Dbox - the clipping box
public Box2D getBoundingBox()
getBoundingBox in interface Shape2Dpublic boolean isBounded()
isBounded in interface Shape2Dpublic Polygon2D transform(AffineTransform2D trans)
transform in interface PolygonalShape2Dtransform in interface Shape2Dtrans - an affine transform
public boolean contains(double x,
double y,
double w,
double h)
contains in interface java.awt.Shapepublic boolean contains(java.awt.geom.Rectangle2D r)
contains in interface java.awt.Shapepublic boolean contains(java.awt.geom.Point2D p)
contains in interface java.awt.Shape
public boolean contains(double x,
double y)
contains in interface java.awt.Shapepublic java.awt.Rectangle getBounds()
getBounds in interface java.awt.Shapepublic java.awt.geom.Rectangle2D getBounds2D()
getBounds2D in interface java.awt.Shape
public boolean intersects(double x,
double y,
double w,
double h)
intersects in interface java.awt.Shapepublic boolean intersects(java.awt.geom.Rectangle2D r)
intersects in interface java.awt.Shapepublic java.awt.geom.GeneralPath getGeneralPath()
public java.awt.geom.PathIterator getPathIterator(java.awt.geom.AffineTransform trans)
getPathIterator in interface java.awt.Shape
public java.awt.geom.PathIterator getPathIterator(java.awt.geom.AffineTransform trans,
double flatness)
getPathIterator in interface java.awt.Shapepublic boolean equals(java.lang.Object obj)
equals in class java.lang.Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||