|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectGlobalNavigation.PolygonObstacle
public class PolygonObstacle
Represents a polygonal obstacle.
Obstacles are initially empty (i.e. no vertices). Vertices are then
added with any of the addVertex()
methods, in CCW order.
close()
is then called to finish the polygon. From then on, the
polygon is immutable.
Field Summary | |
---|---|
protected boolean |
closed
Whether this polygon has been closed. |
java.awt.Color |
color
|
protected java.awt.geom.GeneralPath |
path
Underlying implementation of the geometry. |
protected boolean |
started
Whether this polygon has been started. |
Constructor Summary | |
---|---|
PolygonObstacle()
|
Method Summary | |
---|---|
void |
addVertex(double x,
double y)
Covers addVertex(float, float) . |
void |
addVertex(float x,
float y)
Add a vertex to this polygon. |
void |
addVertex(java.awt.geom.Point2D vertex)
Covers addVertex(double, double) . |
void |
close()
Close this polygon. |
boolean |
contains(double x,
double y)
Check whether this obstacle polygon contains a point. |
boolean |
contains(java.awt.geom.Point2D p)
Check whether this obstacle polygon contains a point. |
java.util.List<java.awt.geom.Point2D.Double> |
getVertices()
Covers getVertices(List) , always makes a new list. |
java.util.List<java.awt.geom.Point2D.Double> |
getVertices(java.util.List<java.awt.geom.Point2D.Double> vertices)
Get the vertices of this polygon in the order in which they were added. |
boolean |
intersects(double x,
double y,
double w,
double h)
Check whether a rectangle intersects this obstacle polygon. |
boolean |
intersects(java.awt.geom.Rectangle2D r)
Check whether a rectangle intersects this obstacle polygon. |
java.lang.String |
toString()
Covers toStringBuffer(java.lang.StringBuffer) , internally conses a StringBuffer. |
void |
toStringBuffer(java.lang.StringBuffer sb)
Append a human-readable string representation of this obstacle to a StringBuffer. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected java.awt.geom.GeneralPath path
Underlying implementation of the geometry.
protected boolean started
Whether this polygon has been started.
protected boolean closed
Whether this polygon has been closed.
public java.awt.Color color
Constructor Detail |
---|
public PolygonObstacle()
Method Detail |
---|
public void addVertex(java.awt.geom.Point2D vertex)
Covers addVertex(double, double)
.
public void addVertex(double x, double y)
Covers addVertex(float, float)
.
public void addVertex(float x, float y)
Add a vertex to this polygon.
Vertices must be added in CCW order.
java.lang.IllegalStateException
- iff closed
public void close()
Close this polygon.
java.lang.IllegalStateException
- iff not started
or already
closed
public boolean contains(double x, double y)
Check whether this obstacle polygon contains a point.
x
- the point x coordy
- the point y coordpublic boolean contains(java.awt.geom.Point2D p)
Check whether this obstacle polygon contains a point.
p
- the pointpublic boolean intersects(double x, double y, double w, double h)
Check whether a rectangle intersects this obstacle polygon.
x
- the rectangle llc x coordy
- the rectangle llc y coordw
- the rectangle widthh
- the rectangle heightpublic boolean intersects(java.awt.geom.Rectangle2D r)
Check whether a rectangle intersects this obstacle polygon.
r
- the rectanglepublic java.util.List<java.awt.geom.Point2D.Double> getVertices()
Covers getVertices(List)
, always makes a new list.
public java.util.List<java.awt.geom.Point2D.Double> getVertices(java.util.List<java.awt.geom.Point2D.Double> vertices)
Get the vertices of this polygon in the order in which they were added.
vertices
- if non-null the vertices are added to this list (else a
fresh one is consed)
public java.lang.String toString()
Covers toStringBuffer(java.lang.StringBuffer)
, internally conses a StringBuffer.
toString
in class java.lang.Object
public void toStringBuffer(java.lang.StringBuffer sb)
Append a human-readable string representation of this obstacle to a StringBuffer.
sb
- the StringBuffer
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |