public class Polygon extends java.util.ArrayList<Point> implements Shape
Constructor and Description |
---|
Polygon() |
Polygon(java.util.List<Point> corners) |
Polygon(Point[] points) |
Polygon(Point p0,
Point p1,
Point p2) |
Polygon(PointSet points) |
Modifier and Type | Method and Description |
---|---|
boolean |
contains(Point p) |
void |
deleteLast()
deletes last corner of the polygon
|
void |
draw(J2DScene scene) |
void |
draw(J2DScene scene,
java.awt.Color clr)
draws the polygon
|
Point |
getCenter()
Get the geometric center of the shape.
|
ConvexPolygon |
getConvexPolygon()
returns convex hull of a simple polygon in O(n) time
|
Point |
getCorner(int i) |
void |
insertAfter(Point p,
int index)
inserts point p into the polygon after the corner with specified index
|
boolean |
isConvex() |
int |
leftExtremePointIndx()
returns the index of the leftmost point (in case of ties, index of the bottommost one is returned)
|
int |
rightExtremePointIndx()
returns the index of the rightmost point (in case of ties, index of the topmost one is returned)
|
void |
setCorner(Point p,
int i) |
void |
shift(int shiftStep)
first corner of the polygon is moved by shiftStep positions
|
java.lang.String |
toString() |
add, add, addAll, addAll, clear, clone, contains, ensureCapacity, forEach, get, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeIf, removeRange, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray, trimToSize
public Polygon()
public Polygon(java.util.List<Point> corners)
public Polygon(PointSet points)
public Polygon(Point[] points)
public Point getCorner(int i)
public void setCorner(Point p, int i)
public void insertAfter(Point p, int index)
public void deleteLast()
public int leftExtremePointIndx()
public int rightExtremePointIndx()
public void shift(int shiftStep)
public boolean isConvex()
public Point getCenter()
Shape
public void draw(J2DScene scene, java.awt.Color clr)
public void draw(J2DScene scene)
public ConvexPolygon getConvexPolygon()
public java.lang.String toString()
toString
in class java.util.AbstractCollection<Point>