public final class Polygon extends AbstractPolygon
Given a list of points, the polygon is the area inside the figure created by joining each pair of adjacent points by a line segment. The first and last points are also joined; you do not need to repeat the first point in order to close the polygon.
A polygon whose edges cross each other may have unpredictable behavior. A point exactly on the edge of a polygon may fall inside or outside the polygon unpredictably. A point very close to an edge may seem to fall in the wrong area because of implications of floating-point arithmetic.
WARNING: this API is experimental and will likely change in the near future.
Constructor and Description |
---|
Polygon()
Constructs a polygon with default vertex capacity.
|
Polygon(int capacity)
Constructs a polygon with specified capacity.
|
Polygon(List<Point> points) |
Polygon(Point... points) |
Modifier and Type | Method and Description |
---|---|
void |
addArguments(StringBuilder buffer) |
void |
addPoint(double x,
double y)
Add a point to this polygon.
|
void |
addPoint(Point point)
Add a point to this polygon.
|
void |
clear()
Remove all points from this polygon.
|
Polygon |
clone() |
boolean |
contains(double x,
double y)
Return true if a point is contained inside this filter's polygon.
|
boolean |
equals(Object other) |
double |
fastGetX(int index)
Get the X coordinate of the Point at
index . |
double |
fastGetY(int index)
Get the Y coordinate of the Point at
index . |
boolean |
fastIntersects(Rectangle box)
Check if this shape's bounding box intersects with
box . |
Rectangle |
getBoundingBox()
Get the rectangle that represents the bounding box that fully contains this shape.
|
double |
getHeight()
Get the height of this shape's bounding box.
|
List<Point> |
getPoints() |
String |
getTypeName() |
double |
getWidth()
Get the width of this shape's bounding box.
|
int |
hashCode() |
boolean |
lineIntersects(double x1,
double y1,
double x2,
double y2)
Check if the line (x1, y1), (x2, y2) intersects with this polygon.
|
Polygon |
readExternal(DataInput in) |
void |
setPoints(List<Point> points) |
int |
size()
Return the number of vertices in this polygon.
|
void |
toString(StringBuilder buffer,
int i) |
void |
writeExternal(DataOutput out) |
getPoint, getPointX, getPointY, intersects, intersects
compareTo, contains, intersects, readExternal, toString, toString, toString, valueOf, writeExternal
public Polygon()
public Polygon(Point... points)
public Polygon(int capacity)
capacity
- the vertex capacitypublic String getTypeName()
getTypeName
in class Shape
public int size()
size
in class AbstractPolygon
public void clear()
public double fastGetX(int index)
index
.
WARNING: this method assumes that index
is positive and
less than AbstractPolygon.size()
.
fastGetX
in class AbstractPolygon
public double fastGetY(int index)
index
.
WARNING: this method assumes that index
is positive and
less than AbstractPolygon.size()
.
fastGetY
in class AbstractPolygon
public void addPoint(Point point)
public void addPoint(double x, double y)
public double getWidth()
public double getHeight()
public Rectangle getBoundingBox()
getBoundingBox
in class Shape
public boolean fastIntersects(Rectangle box)
box
.fastIntersects
in class Shape
public final boolean contains(double x, double y)
public boolean lineIntersects(double x1, double y1, double x2, double y2)
lineIntersects
in class AbstractPolygon
public void addArguments(StringBuilder buffer)
addArguments
in class Shape
public void toString(StringBuilder buffer, int i)
public void writeExternal(DataOutput out) throws IOException
writeExternal
in class Shape
IOException
public Polygon readExternal(DataInput in) throws IOException
readExternal
in class Shape
IOException
Copyright © 2018 Attivio, Inc. All Rights Reserved.
PATENT NOTICE: Attivio, Inc. Software Related Patents. With respect to the Attivio software product(s) being used, the following patents apply: Querying Joined Data Within A Search Engine Index: United States Patent No.(s): 8,073,840. Ordered Processing of Groups of Messages: U.S. Patent No.(s) 8,495,656. Signal processing approach to sentiment analysis for entities in documents: U.S. Patent No.(s) 8,725,494. Other U.S. and International Patents Pending.