public abstract class Polygon2D extends Object implements Shape
Modifier and Type | Class and Description |
---|---|
static class |
Polygon2D.Double
The concrete Polygon class that stores coordinates internally
as doubles.
|
static class |
Polygon2D.Float
The concrete Polygon class that stores coordinates internally
as floats.
|
Modifier and Type | Field and Description |
---|---|
protected boolean |
_closed
The flag that says the the polygon has been closed
|
protected int |
_coordCount
The current number of coordinates
|
Constructor and Description |
---|
Polygon2D() |
Modifier and Type | Method and Description |
---|---|
void |
closePath()
Close the polygon.
|
boolean |
contains(double x,
double y)
Return true if the given point is inside the polygon.
|
boolean |
contains(double x1,
double y1,
double w,
double h)
Return true if the given rectangle is entirely inside
the polygon.
|
boolean |
contains(Point2D p)
Return true if the given point is inside the polygon.
|
boolean |
contains(Rectangle2D r)
Return true if the given rectangle is entirely inside
the polygon.
|
Rectangle |
getBounds()
Get the integer bounds of the polygon.
|
abstract Rectangle2D |
getBounds2D()
Get the floating-point bounds of the polygon.
|
PathIterator |
getPathIterator(AffineTransform at)
Get a path iterator over the object.
|
PathIterator |
getPathIterator(AffineTransform at,
double flatness)
Get a path iterator over the object.
|
int |
getVertexCount()
Get the number of vertices
|
abstract double |
getX(int index)
Get the given X-coordinate
|
abstract double |
getY(int index)
Get the given Y-coordinate
|
boolean |
intersects(double x1,
double y1,
double w,
double h)
Test if the polygon is intersected by the given
rectangle.
|
boolean |
intersects(Rectangle2D r)
Test if the polygon is intersected by the given
rectangle.
|
abstract void |
lineTo(double x,
double y)
Add a new vertex to the end of the polygon.
|
abstract void |
moveTo(double x,
double y)
Move the start point of the vertex to the given position.
|
void |
reset()
Reset the polygon back to empty.
|
abstract void |
setX(int index,
double x)
Set the given X-coordinate.
|
abstract void |
setY(int index,
double y)
Set the given Y-coordinate
|
String |
toString()
Return a string representation of the polygon.
|
abstract void |
transform(AffineTransform at)
Transform the polygon with the given transform.
|
abstract void |
translate(double x,
double y)
Translate the polygon the given distance.
|
protected int _coordCount
protected boolean _closed
public void closePath()
public boolean contains(double x, double y)
public boolean contains(Point2D p)
public boolean contains(Rectangle2D r)
public boolean contains(double x1, double y1, double w, double h)
public Rectangle getBounds()
public abstract Rectangle2D getBounds2D()
getBounds2D
in interface Shape
public PathIterator getPathIterator(AffineTransform at, double flatness)
getPathIterator
in interface Shape
public PathIterator getPathIterator(AffineTransform at)
getPathIterator
in interface Shape
public int getVertexCount()
public abstract double getX(int index)
IndexOutOfBoundsException
- The index is out of bounds.public abstract double getY(int index)
IndexOutOfBoundsException
- The index is out of bounds.public boolean intersects(Rectangle2D r)
intersects
in interface Shape
public boolean intersects(double x1, double y1, double w, double h)
intersects
in interface Shape
public abstract void lineTo(double x, double y)
public abstract void moveTo(double x, double y)
public void reset()
public abstract void setX(int index, double x)
IndexOutOfBoundsException
- The index is out of bounds.public abstract void setY(int index, double y)
IndexOutOfBoundsException
- The index is out of bounds.public abstract void transform(AffineTransform at)
public abstract void translate(double x, double y)
Copyright © 2024 Central Laboratory of the Research Councils. All Rights Reserved.