Class DecimatedShape

All Implemented Interfaces:
Shape, Serializable

public final class DecimatedShape extends ShapeWrapper
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
See Also:
  • Field Details

    • serialVersionUID

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

      private final double xRes
      The desired resolution on each axis.
    • yRes

      private final double yRes
      The desired resolution on each axis.
  • 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
      Overrides:
      getPathIterator in class ShapeWrapper
      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
      Overrides:
      getPathIterator in class ShapeWrapper
      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.