Package com.mindee.geometry
Class Polygon
- java.lang.Object
-
- com.mindee.geometry.Polygon
-
public class Polygon extends Object
Contains any number of vertex coordinates (Points).
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Polygoncombine(Polygon target)Merge the coordinates of the two polygons.intcompareOnX(Polygon polygon2)Compare two polygons based on their X coordinates.intcompareOnY(Polygon polygon2)Compare two polygons based on their Y coordinates.booleanequals(Object object)BboxgetAsBbox()Get the polygon as a Bbox.PolygongetBoundingBox()Get a bounding box that encloses the Polygon.PointgetCentroid()Get the central coordinates (centroid) of the Polygon.List<Point>getCoordinates()Position information as a list of points in clockwise order.MinMaxgetMinMaxX()Get the maximum and minimum Y coordinates.MinMaxgetMinMaxY()Get the maximum and minimum Y coordinates.inthashCode()booleanisEmpty()Returns true if there are no coordinates.StringtoString()Default string representation.StringtoStringPrecise()String representation with precise coordinates.
-
-
-
Constructor Detail
-
Polygon
public Polygon(Collection<List<Double>> coordinates)
Create a Polygon from a list of a list of floats.
-
-
Method Detail
-
getAsBbox
public Bbox getAsBbox()
Get the polygon as a Bbox.
-
getBoundingBox
public Polygon getBoundingBox()
Get a bounding box that encloses the Polygon.
-
getCentroid
public Point getCentroid()
Get the central coordinates (centroid) of the Polygon.
-
getMinMaxY
public MinMax getMinMaxY()
Get the maximum and minimum Y coordinates.
-
getMinMaxX
public MinMax getMinMaxX()
Get the maximum and minimum Y coordinates.
-
isEmpty
public boolean isEmpty()
Returns true if there are no coordinates.
-
toString
public String toString()
Default string representation.
-
toStringPrecise
public String toStringPrecise()
String representation with precise coordinates.
-
compareOnY
public int compareOnY(Polygon polygon2)
Compare two polygons based on their Y coordinates. Useful for sorting lists.
-
compareOnX
public int compareOnX(Polygon polygon2)
Compare two polygons based on their X coordinates. Useful for sorting lists.
-
-