Class DecimatedShape

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

public final class DecimatedShape extends AbstractShape
A shape that apply a simple decimation on-the-fly for faster drawing.

Limitations

Current implementation assumes that the shape is flattened. There is some tolerance for quadratic and cubic curves, but the result may not be correct.
Since:
1.2
Version:
1.2
Author:
Johann Sorel (Puzzle-GIS, Geomatys), Martin Desruisseaux (Geomatys)
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final Shape
    The source of coordinate values.
  • Constructor Summary

    Constructors
    Constructor
    Description
    DecimatedShape(Shape source, double[] resolution)
    Creates a new wrapper which will decimate the coordinates of the given source.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    contains(double x, double y)
    Tests if the specified coordinates are inside the boundary of this shape.
    boolean
    contains(double x, double y, double w, double h)
    Tests if the interior of this Shape entirely contains the interior of a specified rectangular area.
    boolean
    Tests if the point is inside the boundary of this shape.
    boolean
    Tests if the interior of this Shape entirely contains the interior of a specified rectangular area.
    Returns a rectangle that completely encloses this Shape.
    Returns a rectangle that completely encloses this Shape.
    Returns an iterator over the coordinates of this shape after decimation.
    getPathIterator(AffineTransform at, double flatness)
    Returns an iterator over the coordinates of this shape, approximated by decimated line segments.
    boolean
    intersects(double x, double y, double w, double h)
    Tests if the interior of this Shape intersects the interior of a specified rectangular area.
    boolean
    Tests if the interior of this Shape intersects the interior of a specified rectangular area.
    protected boolean
    Returns true if this shape backed by primitive float values.
    boolean
    Returns true if resolutions are strictly positive and finite numbers.

    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

    • source

      protected final Shape source
      The source of coordinate values.
  • Constructor Details

    • DecimatedShape

      public DecimatedShape(Shape source, double[] resolution)
      Creates a new wrapper which will decimate the coordinates of the given source.
      Parameters:
      source - the shape to decimate.
      resolution - the desired resolution on each axis.
  • Method Details

    • isValid

      public boolean isValid()
      Returns true if resolutions are strictly positive and finite numbers.
      Returns:
      whether this object can effectively apply decimation.
    • getPathIterator

      public PathIterator getPathIterator(AffineTransform at)
      Returns an iterator over the coordinates of this shape after decimation.
      Specified by:
      getPathIterator in interface Shape
      Parameters:
      at - an optional transform to be applied on coordinate values, or null if none.
      Returns:
      iterator over the coordinate values of this shape.
    • getPathIterator

      public PathIterator getPathIterator(AffineTransform at, double flatness)
      Returns an iterator over the coordinates of this shape, approximated by decimated line segments.
      Specified by:
      getPathIterator in interface Shape
      Parameters:
      at - an optional transform to be applied on coordinate values, or null if none.
      flatness - maximum distance between line segments approximations and the curve segments.
      Returns:
      iterator over the coordinate values of line segments approximating this shape.
    • 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 a rectangle that completely encloses this Shape. This is not necessarily the smallest bounding box if an accurate computation would be too expansive.
      Specified by:
      getBounds in interface Shape
      Returns:
      a rectangle that completely encloses this Shape.
    • getBounds2D

      public Rectangle2D getBounds2D()
      Returns a rectangle that completely encloses this Shape. This is not necessarily the smallest bounding box if an accurate computation would be too expansive.
      Specified by:
      getBounds2D in interface Shape
      Returns:
      a rectangle that completely encloses this Shape.
    • contains

      public boolean contains(double x, double y)
      Tests if the specified coordinates are inside the boundary of this shape.
      Specified by:
      contains in interface Shape
      Parameters:
      x - the first coordinate value.
      y - the second coordinate value.
      Returns:
      whether the point specified by given coordinates is inside this shape.
    • contains

      public boolean contains(Point2D p)
      Tests if the point is inside the boundary of this shape.
      Specified by:
      contains in interface Shape
      Parameters:
      p - the point to test.
      Returns:
      whether the given point is inside this shape.
    • intersects

      public boolean intersects(double x, double y, double w, double h)
      Tests if the interior of this Shape intersects the interior of a specified rectangular area. This method may conservatively return true if an accurate computation would be too expansive.
      Specified by:
      intersects in interface Shape
      Parameters:
      x - minimal x coordinate of the rectangle.
      y - minimal y coordinate of the rectangle.
      w - width of the rectangle.
      h - height of the rectangle.
      Returns:
      whether the specified rectangle intersects the interior of this shape.
    • intersects

      public boolean intersects(Rectangle2D r)
      Tests if the interior of this Shape intersects the interior of a specified rectangular area. This method may conservatively return true if an accurate computation would be too expansive.
      Specified by:
      intersects in interface Shape
      Parameters:
      r - the rectangular area to test.
      Returns:
      whether the specified rectangle intersects the interior of this shape.
    • contains

      public boolean contains(double x, double y, double w, double h)
      Tests if the interior of this Shape entirely contains the interior of a specified rectangular area. This method may conservatively return false if an accurate computation would be too expansive.
      Specified by:
      contains in interface Shape
      Parameters:
      x - minimal x coordinate of the rectangle.
      y - minimal y coordinate of the rectangle.
      w - width of the rectangle.
      h - height of the rectangle.
      Returns:
      whether the specified rectangle entirely contains the interior of this shape.
    • contains

      public boolean contains(Rectangle2D r)
      Tests if the interior of this Shape entirely contains the interior of a specified rectangular area. This method may conservatively return false if an accurate computation would be too expansive.
      Specified by:
      contains in interface Shape
      Parameters:
      r - the rectangular area to test.
      Returns:
      whether the specified rectangle entirely contains the interior of this shape.