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.Geometry
The wrapped JTS geometry.private static final long
For cross-version compatibility.private static final org.locationtech.jts.geom.GeometryFactory
A lightweight JTS geometry factory using the defaultCoordinateArraySequenceFactory
. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
ShapeAdapter
(org.locationtech.jts.geom.Geometry geometry) Creates a new wrapper for the given JTS geometry. -
Method Summary
Modifier and TypeMethodDescriptionboolean
contains
(double x, double y) Tests if the specified point is inside the boundary of the shape.boolean
contains
(double x, double y, double width, double height) Tests if the specified rectangle is inside the boundary of the shape.boolean
Tests if the specified point is inside the boundary of the shape.boolean
Tests if the specified rectangle is inside the boundary of the shape.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.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.boolean
intersects
(double x, double y, double width, double height) Tests if the specified rectangle intersects this shape.boolean
Tests if the specified rectangle intersects this shape.protected boolean
isFloat()
Returnstrue
if this shape backed by primitivefloat
values.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()Returnstrue
if this shape backed by primitivefloat
values.- Overrides:
isFloat
in classAbstractShape
- Returns:
true
if this shape is backed byfloat
coordinate 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:
getBounds2D
in 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:
intersects
in interfaceShape
-
intersects
public boolean intersects(double x, double y, double width, double height) Tests if the specified rectangle intersects this shape.- Specified by:
intersects
in 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:
getPathIterator
in 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:
getPathIterator
in interfaceShape
- Parameters:
at
- optional transform to apply on coordinate values.- Returns:
- an iterator for the shape outline geometry.
-