Class Factory
- All Implemented Interfaces:
Serializable
The factory of geometry objects backed by Java2D.
- Since:
- 0.7
- Version:
- 1.1
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Factory
The singleton instance of this factory.private static final long
For cross-version compatibility.Fields inherited from class org.apache.sis.internal.feature.Geometries
BIDIMENSIONAL, library, pointClass, polygonClass, polylineClass, rootClass, TRIDIMENSIONAL
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncastOrWrap
(Object geometry) Returns a wrapper for the given<G>
orGeometryWrapper<G>
geometry.createFromComponents
(GeometryType type, Object components) Creates a geometry from components.createMultiPolygon
(Object[] geometries) Creates a multi-polygon from an array of geometries.private static Path2D
createPath
(boolean isFloat, int length) Creates an initially empty Java2D path.createPoint
(double x, double y) Creates a two-dimensional point from the given coordinate.createPoint
(double x, double y, double z) Unsupported operation with Java2D.createPoint
(float x, float y) Creates a two-dimensional point from the given coordinate.createPolyline
(boolean polygon, int dimension, Vector... coordinates) Creates a path from the given coordinate values.protected GeometryWrapper
<Shape> createWrapper
(Shape geometry) Creates a wrapper for the given geometry instance.parseWKB
(ByteBuffer data) Well Known Binary (WKB) reading not supported with Java2D.Well Known Text (WKT) parsing not supported with Java2D.protected Object
Invoked at deserialization time for obtaining the unique instance of thisGeometries
class.boolean
Notifies that this library can create geometry objects backed by single-precision type.Methods inherited from class org.apache.sis.internal.feature.Geometries
createPoint, getGeometryClass, implementation, implementation, isKnownType, mergePolylines, toGeometry2D, unsupported, unsupported, unwrap, wrap
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDFor cross-version compatibility.- See Also:
-
INSTANCE
The singleton instance of this factory.
-
-
Constructor Details
-
Factory
private Factory()Creates the singleton instance.
-
-
Method Details
-
readResolve
Invoked at deserialization time for obtaining the unique instance of thisGeometries
class.- Returns:
INSTANCE
.- Throws:
ObjectStreamException
- if the object state is invalid.
-
castOrWrap
Returns a wrapper for the given<G>
orGeometryWrapper<G>
geometry.- Specified by:
castOrWrap
in classGeometries<Shape>
- Parameters:
geometry
- the geometry instance to wrap (can benull
).- Returns:
- a wrapper for the given geometry implementation, or
null
. - Throws:
ClassCastException
- if the given geometry is not an instance of valid type.- See Also:
-
createWrapper
Creates a wrapper for the given geometry instance.- Specified by:
createWrapper
in classGeometries<Shape>
- Parameters:
geometry
- the geometry to wrap.- Returns:
- wrapper for the given geometry.
- See Also:
-
supportSinglePrecision
public boolean supportSinglePrecision()Notifies that this library can create geometry objects backed by single-precision type.- Overrides:
supportSinglePrecision
in classGeometries<Shape>
- Returns:
- whether the library support single-precision values.
- See Also:
-
createPoint
Creates a two-dimensional point from the given coordinate.- Overrides:
createPoint
in classGeometries<Shape>
- Parameters:
x
- the first coordinate value.y
- the second coordinate value.- Returns:
- the point for the given coordinate values.
- See Also:
-
createPoint
Creates a two-dimensional point from the given coordinate.- Specified by:
createPoint
in classGeometries<Shape>
- Parameters:
x
- the first coordinate value.y
- the second coordinate value.- Returns:
- the point for the given coordinate values.
- See Also:
-
createPoint
Unsupported operation with Java2D.- Specified by:
createPoint
in classGeometries<Shape>
- Parameters:
x
- the first coordinate value.y
- the second coordinate value.z
- the third coordinate value.- Returns:
- the point for the given coordinate values.
- See Also:
-
createPath
Creates an initially empty Java2D path.- Parameters:
isFloat
-true
forfloat
type,false
fordouble
type.length
- initial capacity.- Returns:
- an initially empty path of the given type.
-
createPolyline
Creates a path from the given coordinate values. EachDouble.NaN
coordinate value starts a new path. The geometry may be backed byfloat
ordouble
primitive type, depending on the type used by the given vectors.- Specified by:
createPolyline
in classGeometries<Shape>
- Parameters:
polygon
- whether to return the path as a polygon instead of polyline.dimension
- the number of dimensions (2<G> or 3<G>).coordinates
- sequence of (x,y) or (x,y,z) tuples.- Returns:
- the geometric object for the given points.
- Throws:
UnsupportedOperationException
- if this operation is not implemented for the given number of dimensions.
-
createMultiPolygon
Creates a multi-polygon from an array of geometries. Callers must ensure that the given objects are Java2D geometries.- Specified by:
createMultiPolygon
in classGeometries<Shape>
- Parameters:
geometries
- the polygons or linear rings to put in a multi-polygons.- Returns:
- the multi-polygon.
- Throws:
ClassCastException
- if an element in the array is not a Java2D geometry.
-
createFromComponents
Creates a geometry from components. The expectedcomponents
type depend on the target geometry type:- Specified by:
createFromComponents
in classGeometries<Shape>
- Parameters:
type
- type of geometry to create.components
- the components. Valid classes depend on the type of geometry to create.- Returns:
- geometry built from the given components.
- Throws:
ClassCastException
- if the given object is not an array or a collection of supported geometry components.
-
parseWKT
Well Known Text (WKT) parsing not supported with Java2D.- Specified by:
parseWKT
in classGeometries<Shape>
- Parameters:
wkt
- the WKT to parse. Cannot be null.- Returns:
- the geometry object for the given WKT (never
null
). - See Also:
-
parseWKB
Well Known Binary (WKB) reading not supported with Java2D.- Specified by:
parseWKB
in classGeometries<Shape>
- Parameters:
data
- the binary data in WKB format. Cannot be null.- Returns:
- decoded geometry (never
null
).
-