

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 

Fields inherited from interface math.geom2d.Shape2D 

ACCURACY 
Constructor Summary  

SimplePolygon2D()
Empty constructor: no vertex. 

SimplePolygon2D(java.util.Collection<? extends Point2D> points)


SimplePolygon2D(double[] xcoords,
double[] ycoords)
Constructor from two arrays, one for each coordinate. 

SimplePolygon2D(LinearRing2D ring)
Creates a simple polygon with the given linear ring representing its boundary. 

SimplePolygon2D(Point2D... vertices)
Constructor from an array of points 
Method Summary  

void 
addVertex(Point2D point)
Adds a point as the last vertex. 
boolean 
almostEquals(GeometricObject2D obj,
double eps)
Checks if the two objects are similar up to a given threshold value. 
double 
area()
Computes the signed area of the polygon. 
Polygon2D 
asPolygon(int n)
Returns an approximation of the domain as a polygon, or a MultiPolygon. 
CirculinearContourArray2D<LinearRing2D> 
boundary()
Returns a set of one LinearRing2D, which encloses the polygon. 
Box2D 
boundingBox()
Returns the bounding box of the polygon. 
CirculinearDomain2D 
buffer(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 
centroid()
Computes the centroid (center of mass) of the polygon. 
void 
clearVertices()
Removes all the vertices of the polygon. 
Polygon2D 
clip(Box2D box)
Returns the shape formed by the polygon clipped by the given box. 
SimplePolygon2D 
clone()

int 
closestVertexIndex(Point2D point)
Computes the index of the closest vertex to the input point. 
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)
Returns true if the point p lies inside the polygon, with precision given by Shape2D.ACCURACY. 
java.util.Collection<LinearRing2D> 
contours()
Returns the set of contours that enclose this domain. 
static SimplePolygon2D 
create(java.util.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. 
double 
distance(double x,
double y)
Returns the distance of the point to the polygon. 
double 
distance(Point2D p)
Returns the distance of the point to the polygon. 
void 
draw(java.awt.Graphics2D g2)
Draws the shape on the given graphics. 
int 
edgeNumber()
Returns the number of edges. 
java.util.Collection<LineSegment2D> 
edges()
Returns the set of edges, as a collection of LineSegment2D. 
boolean 
equals(java.lang.Object obj)
Tests if the two polygons are equal. 
void 
fill(java.awt.Graphics2D g)
Fills the interior of the domain, using the Graphics current Paint. 
java.awt.geom.GeneralPath 
getGeneralPath()
Returns a general path iterator. 
LinearRing2D 
getRing()
Returns the linear ring that composes the boundary of this polygon. 
int 
getWindingNumber(double x,
double y)
Computes the winding number of the polygon. 
void 
insertVertex(int index,
Point2D point)
Adds a point as the last vertex. 
boolean 
isBounded()
Returns true if polygon is oriented counterclockwise, false otherwise. 
boolean 
isEmpty()
Returns true if the shape does not contain any point. 
void 
removeVertex(int index)
Removes a vertex of the polygon specified by its index. 
boolean 
removeVertex(Point2D point)
Removes a vertex of the polygon. 
void 
setVertex(int index,
Point2D position)
Changes the position of the ith 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. 
Point2D 
vertex(int i)
Returns the ith vertex of the polygon. 
int 
vertexNumber()
Returns the number of vertices of the polygon. 
java.util.Collection<Point2D> 
vertices()
Returns the points of the polygon. 
Methods inherited from class java.lang.Object 

getClass, hashCode, notify, notifyAll, toString, wait, wait, wait 
Constructor Detail 

public SimplePolygon2D()
public SimplePolygon2D(Point2D... vertices)
vertices
 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(java.util.Collection<? extends Point2D> points)
public SimplePolygon2D(LinearRing2D ring)
ring
 the boundary of the polygonMethod Detail 

public static SimplePolygon2D create(java.util.Collection<? extends Point2D> points)
public static SimplePolygon2D create(Point2D... points)
public int getWindingNumber(double x, double y)
x
 the xcoordinate of the pointy
 the ycoordinate of the point
public LinearRing2D getRing()
public void addVertex(Point2D point)
addVertex
in interface Polygon2D
point
 the position of the new vertexpublic void insertVertex(int index, Point2D point)
insertVertex
in interface Polygon2D
index
 index at which the specified vertex is to be insertedpoint
 the position of the new vertexpublic void setVertex(int index, Point2D position)
setVertex
in interface Polygon2D
index
 the vertex indexposition
 the new position of the vertexpublic boolean removeVertex(Point2D point)
point
 the vertex to be removed.public void removeVertex(int index)
removeVertex
in interface Polygon2D
index
 index of the vertex to removepublic void clearVertices()
public int closestVertexIndex(Point2D point)
closestVertexIndex
in interface Polygon2D
public double area()
area
in interface Polygon2D
public Point2D centroid()
centroid
in interface Polygon2D
public java.util.Collection<Point2D> vertices()
vertices
in interface Polygon2D
public Point2D vertex(int i)
vertex
in interface Polygon2D
i
 index of the vertex, between 0 and the number of verticespublic int vertexNumber()
vertexNumber
in interface Polygon2D
public java.util.Collection<LineSegment2D> edges()
edges
in interface Polygon2D
public int edgeNumber()
edgeNumber
in interface Polygon2D
public CirculinearDomain2D transform(CircleInversion2D inv)
CirculinearShape2D
transform
in interface CirculinearDomain2D
transform
in interface CirculinearShape2D
inv
 the circle inversion
public CirculinearDomain2D buffer(double dist)
CirculinearShape2D
buffer
in interface CirculinearShape2D
dist
 the maximal distance between a point of the buffer and the
shape
public Polygon2D asPolygon(int n)
Domain2D
asPolygon
in interface Domain2D
public CirculinearContourArray2D<LinearRing2D> boundary()
boundary
in interface CirculinearDomain2D
boundary
in interface Domain2D
boundary
in interface Polygon2D
public java.util.Collection<LinearRing2D> contours()
Domain2D
contours
in interface CirculinearDomain2D
contours
in interface Domain2D
contours
in interface Polygon2D
Contour2D
public SimplePolygon2D complement()
complement
in interface CirculinearDomain2D
complement
in interface Domain2D
complement
in interface Polygon2D
public double distance(Point2D p)
distance
in interface Shape2D
public double distance(double x, double y)
distance
in interface Shape2D
public Polygon2D clip(Box2D box)
clip
in interface Domain2D
clip
in interface Polygon2D
clip
in interface Shape2D
box
 the clipping box
public Box2D boundingBox()
boundingBox
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 java.awt.geom.GeneralPath getGeneralPath()
public void draw(java.awt.Graphics2D g2)
Shape2D
draw
in interface Domain2D
draw
in interface Shape2D
g2
 the Graphics to draw onpublic void fill(java.awt.Graphics2D g)
Domain2D
fill
in interface Domain2D
g
 the Graphics to fill onpublic boolean almostEquals(GeometricObject2D obj, double eps)
GeometricObject2D
almostEquals
in interface GeometricObject2D
obj
 the object to compareeps
 a threshold value, for example the minimal coordinate difference
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public SimplePolygon2D clone()
clone
in class java.lang.Object


PREV CLASS NEXT CLASS  FRAMES NO FRAMES  
SUMMARY: NESTED  FIELD  CONSTR  METHOD  DETAIL: FIELD  CONSTR  METHOD 