Class Factory

java.lang.Object
org.apache.sis.internal.feature.Geometries<Shape>
org.apache.sis.internal.feature.j2d.Factory
All Implemented Interfaces:
Serializable

public final class Factory extends Geometries<Shape>
The factory of geometry objects backed by Java2D.
Since:
0.7
Version:
1.1
See Also:
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      For cross-version compatibility.
      See Also:
    • INSTANCE

      public static final Factory INSTANCE
      The singleton instance of this factory.
  • Constructor Details

    • Factory

      private Factory()
      Creates the singleton instance.
  • Method Details

    • readResolve

      protected Object readResolve() throws ObjectStreamException
      Invoked at deserialization time for obtaining the unique instance of this Geometries class.
      Returns:
      INSTANCE.
      Throws:
      ObjectStreamException - if the object state is invalid.
    • castOrWrap

      public GeometryWrapper<Shape> castOrWrap(Object geometry)
      Returns a wrapper for the given <G> or GeometryWrapper<G> geometry.
      Specified by:
      castOrWrap in class Geometries<Shape>
      Parameters:
      geometry - the geometry instance to wrap (can be null).
      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

      protected GeometryWrapper<Shape> createWrapper(Shape geometry)
      Creates a wrapper for the given geometry instance.
      Specified by:
      createWrapper in class Geometries<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 class Geometries<Shape>
      Returns:
      whether the library support single-precision values.
      See Also:
    • createPoint

      public Object createPoint(float x, float y)
      Creates a two-dimensional point from the given coordinate.
      Overrides:
      createPoint in class Geometries<Shape>
      Parameters:
      x - the first coordinate value.
      y - the second coordinate value.
      Returns:
      the point for the given coordinate values.
      See Also:
    • createPoint

      public Object createPoint(double x, double y)
      Creates a two-dimensional point from the given coordinate.
      Specified by:
      createPoint in class Geometries<Shape>
      Parameters:
      x - the first coordinate value.
      y - the second coordinate value.
      Returns:
      the point for the given coordinate values.
      See Also:
    • createPoint

      public Object createPoint(double x, double y, double z)
      Unsupported operation with Java2D.
      Specified by:
      createPoint in class Geometries<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

      private static Path2D createPath(boolean isFloat, int length)
      Creates an initially empty Java2D path.
      Parameters:
      isFloat - true for float type, false for double type.
      length - initial capacity.
      Returns:
      an initially empty path of the given type.
    • createPolyline

      public Shape createPolyline(boolean polygon, int dimension, Vector... coordinates)
      Creates a path from the given coordinate values. Each Double.NaN coordinate value starts a new path. The geometry may be backed by float or double primitive type, depending on the type used by the given vectors.
      Specified by:
      createPolyline in class Geometries<Shape>
      Parameters:
      polygon - whether to return the path as a polygon instead of polyline.
      dimension - the number of dimensions (2 or 3).
      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

      public GeometryWrapper<Shape> createMultiPolygon(Object[] geometries)
      Creates a multi-polygon from an array of geometries. Callers must ensure that the given objects are Java2D geometries.
      Specified by:
      createMultiPolygon in class Geometries<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

      public GeometryWrapper<Shape> createFromComponents(GeometryType type, Object components)
      Creates a geometry from components. The expected components type depend on the target geometry type:
      • If type is a multi-geometry, then the components shall be an array of Shape elements.
      • Otherwise the components shall be an array or collection of Point2D instances.
      Specified by:
      createFromComponents in class Geometries<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

      public GeometryWrapper<Shape> parseWKT(String wkt)
      Well Known Text (WKT) parsing not supported with Java2D.
      Specified by:
      parseWKT in class Geometries<Shape>
      Parameters:
      wkt - the WKT to parse. Cannot be null.
      Returns:
      the geometry object for the given WKT (never null).
      See Also:
    • parseWKB

      public GeometryWrapper<Shape> parseWKB(ByteBuffer data)
      Well Known Binary (WKB) reading not supported with Java2D.
      Specified by:
      parseWKB in class Geometries<Shape>
      Parameters:
      data - the binary data in WKB format. Cannot be null.
      Returns:
      decoded geometry (never null).