public class ShapeReader
extends java.lang.Object
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.
Modifier and Type | Field and Description |
---|---|
private GeometryFactory |
geometryFactory |
private static java.awt.geom.AffineTransform |
INVERT_Y |
Constructor and Description |
---|
ShapeReader(GeometryFactory geometryFactory) |
Modifier and Type | Method and Description |
---|---|
private boolean |
isHole(Coordinate[] pts) |
private static Coordinate[] |
nextCoordinateArray(java.awt.geom.PathIterator pathIt) |
Geometry |
read(java.awt.geom.PathIterator pathIt)
Converts a flat path to a
Geometry . |
static Geometry |
read(java.awt.geom.PathIterator pathIt,
GeometryFactory geomFact)
Converts a flat path to a
Geometry . |
static Geometry |
read(java.awt.Shape shp,
double flatness,
GeometryFactory geomFact)
Converts a Shape to a Geometry, flattening it first.
|
static java.util.List |
toCoordinates(java.awt.geom.PathIterator pathIt)
Extracts the points of the paths in a flat
PathIterator into
a list of Coordinate arrays. |
private static final java.awt.geom.AffineTransform INVERT_Y
private GeometryFactory geometryFactory
public ShapeReader(GeometryFactory geometryFactory)
public static Geometry read(java.awt.geom.PathIterator pathIt, GeometryFactory geomFact)
Geometry
.pathIt
- the path to convertgeomFact
- the GeometryFactory to usepublic static Geometry read(java.awt.Shape shp, double flatness, GeometryFactory geomFact)
shp
- the Java2D shapeflatness
- the flatness parameter to usegeomFact
- the GeometryFactory to usepublic Geometry read(java.awt.geom.PathIterator pathIt)
Geometry
.pathIt
- the path to convertprivate boolean isHole(Coordinate[] pts)
public static java.util.List toCoordinates(java.awt.geom.PathIterator pathIt)
PathIterator
into
a list of Coordinate arrays.pathIt
- a path iteratorjava.lang.IllegalArgumentException
- if a non-linear segment type is encounteredprivate static Coordinate[] nextCoordinateArray(java.awt.geom.PathIterator pathIt)