Class ShapeAdapter
java.lang.Object
org.apache.sis.internal.referencing.j2d.AbstractShape
org.apache.sis.internal.feature.jts.ShapeAdapter
- All Implemented Interfaces:
Shape,Serializable
A thin wrapper that adapts a JTS geometry to the
Shape interface so
that the geometry can be used by Java 2D without copying coordinate values.
This class does not cache any value; if the JTS geometry is changed,
the modifications will be immediately visible in this Shape.- Since:
- 1.2
- Version:
- 1.2
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final org.locationtech.jts.geom.GeometryThe wrapped JTS geometry.private static final longFor cross-version compatibility.private static final org.locationtech.jts.geom.GeometryFactoryA lightweight JTS geometry factory using the defaultCoordinateArraySequenceFactory. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedShapeAdapter(org.locationtech.jts.geom.Geometry geometry) Creates a new wrapper for the given JTS geometry. -
Method Summary
Modifier and TypeMethodDescriptionbooleancontains(double x, double y) Tests if the specified point is inside the boundary of the shape.booleancontains(double x, double y, double width, double height) Tests if the specified rectangle is inside the boundary of the shape.booleanTests if the specified point is inside the boundary of the shape.booleanTests if the specified rectangle is inside the boundary of the shape.private static org.locationtech.jts.geom.GeometrycreateRect(double xmin, double ymin, double xmax, double ymax) Creates a JTS polygon which is a rectangle with the given coordinates.Returns an integer rectangle that completely encloses the shape.Returns a rectangle that completely encloses the shape.Returns an iterator for the shape outline geometry.getPathIterator(AffineTransform at, double flatness) Returns an iterator for the shape outline geometry.booleanintersects(double x, double y, double width, double height) Tests if the specified rectangle intersects this shape.booleanTests if the specified rectangle intersects this shape.protected booleanisFloat()Returnstrueif this shape backed by primitivefloatvalues.Methods inherited from class org.apache.sis.internal.referencing.j2d.AbstractShape
isFloat
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDFor cross-version compatibility.- See Also:
-
SMALL_FACTORY
private static final org.locationtech.jts.geom.GeometryFactory SMALL_FACTORYA lightweight JTS geometry factory using the defaultCoordinateArraySequenceFactory. This factory is inefficient for large geometries (it consumes more memory) but is a little bit more straightforward for geometry with few coordinates such as a point or a rectangle, because it stores theCoordinate[]. Used forcontains(…)andintersects(…)implementations only. -
geometry
protected final org.locationtech.jts.geom.Geometry geometryThe wrapped JTS geometry.
-
-
Constructor Details
-
ShapeAdapter
protected ShapeAdapter(org.locationtech.jts.geom.Geometry geometry) Creates a new wrapper for the given JTS geometry.- Parameters:
geometry- the JTS geometry to wrap.
-
-
Method Details
-
isFloat
protected boolean isFloat()Returnstrueif this shape backed by primitivefloatvalues.- Overrides:
isFloatin classAbstractShape- Returns:
trueif this shape is backed byfloatcoordinate values.
-
getBounds
Returns an integer rectangle that completely encloses the shape. There is no guarantee that the rectangle is the smallest bounding box that encloses the shape. -
getBounds2D
Returns a rectangle that completely encloses the shape. There is no guarantee that the rectangle is the smallest bounding box that encloses the shape.- Specified by:
getBounds2Din interfaceShape
-
contains
Tests if the specified point is inside the boundary of the shape. This method delegates tocontains(double, double). -
contains
public boolean contains(double x, double y) Tests if the specified point is inside the boundary of the shape. -
contains
Tests if the specified rectangle is inside the boundary of the shape. -
contains
public boolean contains(double x, double y, double width, double height) Tests if the specified rectangle is inside the boundary of the shape. -
intersects
Tests if the specified rectangle intersects this shape.- Specified by:
intersectsin interfaceShape
-
intersects
public boolean intersects(double x, double y, double width, double height) Tests if the specified rectangle intersects this shape.- Specified by:
intersectsin interfaceShape
-
createRect
private static org.locationtech.jts.geom.Geometry createRect(double xmin, double ymin, double xmax, double ymax) Creates a JTS polygon which is a rectangle with the given coordinates. This is a temporary shape used for union and intersection tests. -
getPathIterator
Returns an iterator for the shape outline geometry. The flatness factor is ignored on the assumption that this shape does not contain any Bézier curve.- Specified by:
getPathIteratorin interfaceShape- Parameters:
at- optional transform to apply on coordinate values.flatness- ignored.- Returns:
- an iterator for the shape outline geometry.
-
getPathIterator
Returns an iterator for the shape outline geometry.- Specified by:
getPathIteratorin interfaceShape- Parameters:
at- optional transform to apply on coordinate values.- Returns:
- an iterator for the shape outline geometry.
-