Package org.locationtech.jts.awt
Class ShapeReader
java.lang.Object
org.locationtech.jts.awt.ShapeReader
Converts a Java2D
Shape
or the more general PathIterator
into a Geometry
.
The coordinate system for Java2D is typically screen coordinates, which has the Y axis inverted relative to the usual JTS coordinate system. This is rectified during conversion.
PathIterators to be converted are expected to be linear or flat. That is, they should contain only SEG_MOVETO, SEG_LINETO, and SEG_CLOSE segment types. Any other segment types will cause an exception.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate boolean
isHole
(Coordinate[] pts) private static Coordinate[]
nextCoordinateArray
(PathIterator pathIt) read
(PathIterator pathIt) Converts a flat path to aGeometry
.static Geometry
read
(PathIterator pathIt, GeometryFactory geomFact) Converts a flat path to aGeometry
.static Geometry
read
(Shape shp, double flatness, GeometryFactory geomFact) Converts a Shape to a Geometry, flattening it first.static List
toCoordinates
(PathIterator pathIt) Extracts the points of the paths in a flatPathIterator
into a list of Coordinate arrays.
-
Field Details
-
INVERT_Y
-
geometryFactory
-
-
Constructor Details
-
ShapeReader
-
-
Method Details
-
read
Converts a flat path to aGeometry
.- Parameters:
pathIt
- the path to convertgeomFact
- the GeometryFactory to use- Returns:
- a Geometry representing the path
-
read
Converts a Shape to a Geometry, flattening it first.- Parameters:
shp
- the Java2D shapeflatness
- the flatness parameter to usegeomFact
- the GeometryFactory to use- Returns:
- a Geometry representing the shape
-
read
Converts a flat path to aGeometry
.- Parameters:
pathIt
- the path to convert- Returns:
- a Geometry representing the path
-
isHole
-
toCoordinates
Extracts the points of the paths in a flatPathIterator
into a list of Coordinate arrays.- Parameters:
pathIt
- a path iterator- Returns:
- a List of Coordinate arrays
- Throws:
IllegalArgumentException
- if a non-linear segment type is encountered
-
nextCoordinateArray
-