Class ShapeAdapter

java.lang.Object
org.apache.sis.internal.referencing.j2d.AbstractShape
org.apache.sis.internal.feature.jts.ShapeAdapter
All Implemented Interfaces:
Shape, Serializable

final class ShapeAdapter extends AbstractShape implements 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

    Fields
    Modifier and Type
    Field
    Description
    protected 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 default CoordinateArraySequenceFactory.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    ShapeAdapter(org.locationtech.jts.geom.Geometry geometry)
    Creates a new wrapper for the given JTS geometry.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    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
    Returns true if this shape backed by primitive float values.

    Methods inherited from class org.apache.sis.internal.referencing.j2d.AbstractShape

    isFloat

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • serialVersionUID

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

      private static final org.locationtech.jts.geom.GeometryFactory SMALL_FACTORY
      A lightweight JTS geometry factory using the default CoordinateArraySequenceFactory. 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 the Coordinate[]. Used for contains(…) and intersects(…) implementations only.
    • geometry

      protected final org.locationtech.jts.geom.Geometry geometry
      The 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()
      Returns true if this shape backed by primitive float values.
      Overrides:
      isFloat in class AbstractShape
      Returns:
      true if this shape is backed by float coordinate values.
    • getBounds

      public Rectangle 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.
      Specified by:
      getBounds in interface Shape
    • getBounds2D

      public Rectangle2D 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 interface Shape
    • contains

      public boolean contains(Point2D p)
      Tests if the specified point is inside the boundary of the shape. This method delegates to contains(double, double).
      Specified by:
      contains in interface Shape
    • contains

      public boolean contains(double x, double y)
      Tests if the specified point is inside the boundary of the shape.
      Specified by:
      contains in interface Shape
    • contains

      public boolean contains(Rectangle2D r)
      Tests if the specified rectangle is inside the boundary of the shape.
      Specified by:
      contains in interface 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.
      Specified by:
      contains in interface Shape
    • intersects

      public boolean intersects(Rectangle2D r)
      Tests if the specified rectangle intersects this shape.
      Specified by:
      intersects in interface Shape
    • intersects

      public boolean intersects(double x, double y, double width, double height)
      Tests if the specified rectangle intersects this shape.
      Specified by:
      intersects in interface Shape
    • 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

      public PathIterator getPathIterator(AffineTransform at, double flatness)
      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 interface Shape
      Parameters:
      at - optional transform to apply on coordinate values.
      flatness - ignored.
      Returns:
      an iterator for the shape outline geometry.
    • getPathIterator

      public PathIterator getPathIterator(AffineTransform at)
      Returns an iterator for the shape outline geometry.
      Specified by:
      getPathIterator in interface Shape
      Parameters:
      at - optional transform to apply on coordinate values.
      Returns:
      an iterator for the shape outline geometry.