Package util.polygon2d
Class Polygon2D.Double
- java.lang.Object
-
- util.polygon2d.Polygon2D
-
- util.polygon2d.Polygon2D.Double
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class util.polygon2d.Polygon2D
Polygon2D.Double, Polygon2D.Float
-
-
Field Summary
-
Fields inherited from class util.polygon2d.Polygon2D
_closed, _coordCount
-
-
Constructor Summary
Constructors Constructor Description Double()Create a new polygon with no coordinatesDouble(double[] coords)Create a new polygon with the given vertices, in the format [x0, y0, x1, y1, ... ].Double(double x, double y)Create a new polygon with a single start pointDouble(int size)Create a new polygon with space for the given number of vertices.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Rectangle2DgetBounds2D()Get the floating-point bounds of the polygon.intgetVertexCount()Get the number of verticesdoublegetX(int index)Get the given X-coordinatedoublegetY(int index)Get the given Y-coordinatevoidlineTo(double x, double y)Add a new vertex to the end of the line.voidmoveTo(double x, double y)Move the start point of the vertex to the given position.voidsetX(int index, double x)Set the given X-coordinate.voidsetY(int index, double y)Set the given Y-coordinatevoidtransform(AffineTransform at)Transform the polygon with the given transform.voidtranslate(double x, double y)Translate the polygon the given distance.-
Methods inherited from class util.polygon2d.Polygon2D
closePath, contains, contains, contains, contains, getBounds, getPathIterator, getPathIterator, intersects, intersects, reset, toString
-
-
-
-
Constructor Detail
-
Double
public Double(int size)
Create a new polygon with space for the given number of vertices.
-
Double
public Double(double[] coords)
Create a new polygon with the given vertices, in the format [x0, y0, x1, y1, ... ].
-
Double
public Double()
Create a new polygon with no coordinates
-
Double
public Double(double x, double y)Create a new polygon with a single start point
-
-
Method Detail
-
getBounds2D
public Rectangle2D getBounds2D()
Get the floating-point bounds of the polygon.- Specified by:
getBounds2Din interfaceShape- Specified by:
getBounds2Din classPolygon2D
-
getVertexCount
public int getVertexCount()
Get the number of vertices- Overrides:
getVertexCountin classPolygon2D
-
getX
public double getX(int index)
Get the given X-coordinate- Specified by:
getXin classPolygon2D- Throws:
IndexOutOfBoundsException- The index is out of bounds.
-
getY
public double getY(int index)
Get the given Y-coordinate- Specified by:
getYin classPolygon2D- Throws:
IndexOutOfBoundsException- The index is out of bounds.
-
lineTo
public void lineTo(double x, double y)Add a new vertex to the end of the line.
-
moveTo
public void moveTo(double x, double y)Move the start point of the vertex to the given position.- Specified by:
moveToin classPolygon2D- Throws:
UnsupportedOperationException- The polygon already has vertices
-
setX
public void setX(int index, double x)Set the given X-coordinate.- Specified by:
setXin classPolygon2D- Throws:
IndexOutOfBoundsException- The index is out of bounds.
-
setY
public void setY(int index, double y)Set the given Y-coordinate- Specified by:
setYin classPolygon2D- Throws:
IndexOutOfBoundsException- The index is out of bounds.
-
transform
public void transform(AffineTransform at)
Transform the polygon with the given transform.
-
-