public class SimplePolygon2D extends Object implements Polygon2D
Modifier and Type | Field and Description |
---|---|
protected ArrayList<Point2D> |
points
The inner ordered list of vertices.
|
Constructor and Description |
---|
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
|
Modifier and Type | Method and Description |
---|---|
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.
|
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)
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)
public int getVertexNumber()
getVertexNumber
in interface Polygon2D
public Collection<LineSegment2D> getEdges()
public int getEdgeNumber()
getEdgeNumber
in interface Polygon2D
public Collection<LinearRing2D> getRings()
Polygon2D
public CirculinearDomain2D transform(CircleInversion2D inv)
CirculinearShape2D
transform
in interface CirculinearDomain2D
transform
in interface CirculinearShape2D
inv
- the circle inversionpublic CirculinearDomain2D getBuffer(double dist)
CirculinearShape2D
getBuffer
in interface CirculinearShape2D
dist
- the maximal distance between a point of the buffer and the
shapepublic 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)
public Box2D getBoundingBox()
getBoundingBox
in interface Shape2D
public boolean isBounded()
public boolean isEmpty()
Shape2D
public SimplePolygon2D transform(AffineTransform2D trans)
public boolean contains(Point2D p)
public boolean contains(double x, double y)
public GeneralPath getGeneralPath()
public void draw(Graphics2D g2)
Shape2D
public void fill(Graphics2D g)
Domain2D
public boolean equals(Object obj)
public SimplePolygon2D clone()
Copyright © 2012 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All Rights Reserved.