Package ucar.nc2.dt.ugrid.geom
Class Polygon2D.Double
- java.lang.Object
-
- ucar.nc2.dt.ugrid.geom.Polygon2D
-
- ucar.nc2.dt.ugrid.geom.Polygon2D.Double
-
- All Implemented Interfaces:
Shape,Serializable
- Enclosing class:
- Polygon2D
public static class Polygon2D.Double extends Polygon2D
The concrete Polygon class that stores coordinates internally as doubles.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class ucar.nc2.dt.ugrid.geom.Polygon2D
Polygon2D.Double, Polygon2D.Float
-
-
Field Summary
-
Fields inherited from class ucar.nc2.dt.ugrid.geom.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[] xlocs, double[] ylocs)Create a new polygon with the provided x and y locations.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.Double(Point2D p)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Polygon2D.Doublecopy()Creates a copy of this polygon with the same coordinates.Rectangle2DgetBounds2D()Get the floating-point bounds of the polygon.GeoRectangle.DoublegetBoundsGeo()Get the bound box of this poly as aGeoRectangle2DPoint2DgetCentroid()Calculates the center point of thisPolygon2DList<Point2D>getVertices()Gets a list of Point2D vertices of this polygon.doublegetX(int index)Get the given X-coordinatedouble[]getXCoords()Gets a double array containing the X coordinates of the polygon.doublegetY(int index)Get the given Y-coordinatedouble[]getYCoords()Gets a double array containing the Y coordinates of the polygon.voidlineTo(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 ucar.nc2.dt.ugrid.geom.Polygon2D
area, closePath, contains, contains, contains, contains, contains, contains, distance, distanceSq, getArea, getBounds, getMaxX, getMaxY, getMinX, getMinY, getPathIterator, getPathIterator, getVertexCount, intersects, intersects, intersects, intersects, intersects, intersects, lineIntersectsPoint, linesIntersect, lineTo, moveTo, reset, toString
-
-
-
-
Constructor Detail
-
Double
public Double()
Create a new polygon with no coordinates
-
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(Point2D p)
-
Double
public Double(double x, double y)Create a new polygon with a single start point
-
Double
public Double(double[] xlocs, double[] ylocs)Create a new polygon with the provided x and y locations. If the two arrays are of unequal length, an empty polygon is created. NaN values are ignored- Parameters:
xlocs- the array of x locations.ylocs- the array of y locations.
-
-
Method Detail
-
copy
public Polygon2D.Double copy()
Creates a copy of this polygon with the same coordinates. The original polygon remains unchanged.
-
getBounds2D
public Rectangle2D getBounds2D()
Get the floating-point bounds of the polygon.- Specified by:
getBounds2Din interfaceShape- Specified by:
getBounds2Din classPolygon2D
-
getBoundsGeo
public GeoRectangle.Double getBoundsGeo()
Description copied from class:Polygon2DGet the bound box of this poly as aGeoRectangle2D- Specified by:
getBoundsGeoin classPolygon2D
-
getCentroid
public Point2D getCentroid()
Description copied from class:Polygon2DCalculates the center point of thisPolygon2D- Specified by:
getCentroidin classPolygon2D- Returns:
- the center point of this
Polygon2D
-
getVertices
public List<Point2D> getVertices()
Description copied from class:Polygon2DGets a list of Point2D vertices of this polygon.- Specified by:
getVerticesin classPolygon2D- Returns:
- a List{Point2D} of vertices
-
getXCoords
public double[] getXCoords()
Description copied from class:Polygon2DGets a double array containing the X coordinates of the polygon.- Specified by:
getXCoordsin classPolygon2D- Returns:
- the X coordinates
-
getYCoords
public double[] getYCoords()
Description copied from class:Polygon2DGets a double array containing the Y coordinates of the polygon.- Specified by:
getYCoordsin classPolygon2D- Returns:
- the Y coordinates
-
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.
-
-