|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object math.geom2d.polygon.SimplePolygon2D
public class SimplePolygon2D
Represent a polygonal domain whose boundary is a single closed polyline.
Field Summary | |
---|---|
protected ArrayList<Point2D> |
points
The inner ordered list of vertices. |
Fields inherited from interface math.geom2d.Shape2D |
---|
ACCURACY |
Constructor Summary | |
---|---|
SimplePolygon2D()
Empty constructor: no vertex. |
|
SimplePolygon2D(Collection<? extends Point2D> points)
|
|
SimplePolygon2D(double[] xcoords,
double[] ycoords)
Constructor from two arrays, one for each coordinate. |
|
SimplePolygon2D(Point2D[] tab)
Constructor from an array of points |
Method Summary | |
---|---|
void |
addPoint(Point2D point)
Deprecated. replaced by addVertex() (0.7.1) |
void |
addVertex(Point2D point)
Adds a point as the last vertex. |
void |
clearPoints()
Deprecated. use clearVertices instead |
void |
clearVertices()
Removes all the vertices of the polygon. |
Domain2D |
clip(Box2D box)
Returns the shape formed by the polygon clipped by the given box. |
SimplePolygon2D |
clone()
|
SimplePolygon2D |
complement()
Returns the polygon created by reversing the order of the vertices. |
boolean |
contains(double x,
double y)
Returns true if the point (x, y) lies inside the polygon, with precision given by Shape2D.ACCURACY. |
boolean |
contains(Point2D p)
Return true if the point p lies inside the polygon, with precision given by Shape2D.ACCURACY. |
static SimplePolygon2D |
create(Collection<? extends Point2D> points)
Static factory for creating a new SimplePolygon2D from a collection of points. |
static SimplePolygon2D |
create(Point2D[] points)
Static factory for creating a new SimplePolygon2D from an array of points. |
void |
draw(Graphics2D g2)
Draw the shape on the given graphics. |
boolean |
equals(Object obj)
Tests if the two polygons are equal. |
void |
fill(Graphics2D g)
Fills the interior of the domain, using the Graphics current Paint. |
double |
getArea()
Computes area of the polygon, by returning the absolute value of the signed area. |
CirculinearBoundarySet2D<LinearRing2D> |
getBoundary()
Returns a set of one LinearRing2D, which encloses the polygon. |
Box2D |
getBoundingBox()
Returns the bounding box of the polygon. |
CirculinearDomain2D |
getBuffer(double dist)
Computes the buffer of the shape, formed by the set of points located at a distance from the shape that is lower or equal to d. |
Point2D |
getCentroid()
Computes the centroid (center of mass) of the polygon. |
double |
getDistance(double x,
double y)
Returns the distance of the point to the polygon. |
double |
getDistance(Point2D p)
Returns the distance of the point to the polygon. |
int |
getEdgeNumber()
Returns the number of edges. |
Collection<LineSegment2D> |
getEdges()
Returns the set of edges, as a collection of LineSegment2D. |
GeneralPath |
getGeneralPath()
Returns a general path iterator. |
Collection<LinearRing2D> |
getRings()
Returns the set of rings comprising the boundary of this polygon. |
double |
getSignedArea()
Computes the signed area of the polygon. |
double |
getSignedDistance(double x,
double y)
Returns 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(Point2D p)
Returns 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. |
Point2D |
getVertex(int i)
Returns the i-th vertex of the polygon. |
int |
getVertexNumber()
Returns the number of vertices of the polygon. |
Collection<Point2D> |
getVertices()
Returns the points of the polygon. |
int |
getWindingNumber(double x,
double y)
Computes the winding number of the polygon. |
boolean |
isBounded()
Returns true if polygon is oriented counter-clockwise, false otherwise. |
boolean |
isEmpty()
Returns true if the shape does not contain any point. |
void |
removePoint(Point2D point)
Deprecated. replaced by removeVertex() (0.7.1) |
void |
removeVertex(Point2D point)
Removes a vertex of the polygon. |
void |
setVertex(int index,
Point2D position)
Changes the position of the i-th vertex. |
SimplePolygon2D |
transform(AffineTransform2D trans)
Returns the new Polygon created by an affine transform of this polygon. |
CirculinearDomain2D |
transform(CircleInversion2D inv)
Transforms the shape by a circle inversion. |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected ArrayList<Point2D> points
Constructor Detail |
---|
public SimplePolygon2D()
public SimplePolygon2D(Point2D[] tab)
tab
- the vertices stored in an array of Point2Dpublic SimplePolygon2D(double[] xcoords, double[] ycoords)
xcoords
- the x coordinate of each vertexycoords
- the y coordinate of each vertexpublic SimplePolygon2D(Collection<? extends Point2D> points)
Method Detail |
---|
public static SimplePolygon2D create(Collection<? extends Point2D> points)
public static SimplePolygon2D create(Point2D[] points)
public void addVertex(Point2D point)
public void removeVertex(Point2D point)
point
- the vertex to be removed.@Deprecated public void addPoint(Point2D point)
@Deprecated 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
@Deprecated public void clearPoints()
public void clearVertices()
public void setVertex(int index, Point2D position)
public Collection<Point2D> getVertices()
getVertices
in interface Polygon2D
public Point2D getVertex(int i)
getVertex
in interface Polygon2D
i
- index of the vertex, between 0 and the number of verticespublic int getVertexNumber()
getVertexNumber
in interface Polygon2D
public Collection<LineSegment2D> getEdges()
getEdges
in interface Polygon2D
public int getEdgeNumber()
getEdgeNumber
in interface Polygon2D
public Collection<LinearRing2D> getRings()
Polygon2D
getRings
in interface Polygon2D
public CirculinearDomain2D transform(CircleInversion2D inv)
CirculinearShape2D
transform
in interface CirculinearDomain2D
transform
in interface CirculinearShape2D
inv
- the circle inversion
public CirculinearDomain2D getBuffer(double dist)
CirculinearShape2D
getBuffer
in interface CirculinearShape2D
dist
- the maximal distance between a point of the buffer and the
shape
public CirculinearBoundarySet2D<LinearRing2D> getBoundary()
getBoundary
in interface CirculinearDomain2D
getBoundary
in interface Domain2D
getBoundary
in interface Polygon2D
public SimplePolygon2D complement()
complement
in interface Domain2D
complement
in interface Polygon2D
public double getDistance(Point2D p)
getDistance
in interface Shape2D
public double getDistance(double x, double y)
getDistance
in interface Shape2D
public double getSignedDistance(Point2D p)
public double getSignedDistance(double x, double y)
public Domain2D clip(Box2D box)
clip
in interface Domain2D
clip
in interface Shape2D
box
- the clipping box
public Box2D getBoundingBox()
getBoundingBox
in interface Shape2D
public boolean isBounded()
isBounded
in interface Shape2D
public boolean isEmpty()
Shape2D
isEmpty
in interface Shape2D
public SimplePolygon2D transform(AffineTransform2D trans)
transform
in interface Domain2D
transform
in interface Polygon2D
transform
in interface Shape2D
trans
- an affine transform
public boolean contains(Point2D p)
contains
in interface Shape2D
public boolean contains(double x, double y)
contains
in interface Shape2D
public GeneralPath getGeneralPath()
public void draw(Graphics2D g2)
Shape2D
draw
in interface Domain2D
draw
in interface Shape2D
g2
- the Graphics to draw onpublic void fill(Graphics2D g)
Domain2D
fill
in interface Domain2D
g
- the Graphics to fill onpublic boolean equals(Object obj)
equals
in class Object
public SimplePolygon2D clone()
clone
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |