Class SimplePathMetrics

java.lang.Object
org.jhotdraw8.geom.AbstractShape
org.jhotdraw8.geom.shape.SimplePathMetrics
All Implemented Interfaces:
Shape, PathMetrics

public class SimplePathMetrics extends AbstractShape implements PathMetrics
The PathMetrics class allows access to the metrics needed to compute points along a path and to create sub-paths of a path.

Requirements for the path:

  • Constructor Details

    • SimplePathMetrics

      public SimplePathMetrics(Shape shape)
    • SimplePathMetrics

      public SimplePathMetrics(PathIterator pathIterator)
    • SimplePathMetrics

      public SimplePathMetrics(PathIterator pathIterator, double epsilon)
  • Method Details

    • evalAtArcLength

      public PointAndDerivative evalAtArcLength(double s)
      Evaluates the path at the specified arc length
      Specified by:
      evalAtArcLength in interface PathMetrics
      Parameters:
      s - the arc length, the value will be clamped to [0,arcLength()]
      Returns:
      point and tangent at s
    • arcLength

      public double arcLength()
      Gets the length of the path.
      Specified by:
      arcLength in interface PathMetrics
      Returns:
      the length of the path in [0,Double.MAX_VALUE].
    • reverse

      public PathMetrics reverse()
      Description copied from interface: PathMetrics
      Gets path metrics for the reversed path.
      Specified by:
      reverse in interface PathMetrics
      Returns:
      reverse path metrics
    • isEmpty

      public boolean isEmpty()
      Description copied from interface: PathMetrics
      Returns true if this path metrics is empty.
      Specified by:
      isEmpty in interface PathMetrics
      Returns:
      true if empty
    • getBounds2D

      public Rectangle2D getBounds2D()
      Specified by:
      getBounds2D in interface Shape
      Overrides:
      getBounds2D in class AbstractShape
    • contains

      public boolean contains(double x, double y)
      Specified by:
      contains in interface Shape
      Overrides:
      contains in class AbstractShape
    • contains

      public boolean contains(double x, double y, double w, double h)
      This implementation checks if the bounding box of this shape contains the specified rectangle.
      Specified by:
      contains in interface Shape
      Overrides:
      contains in class AbstractShape
      Parameters:
      x - the X coordinate of the upper-left corner of the specified rectangular area
      y - the Y coordinate of the upper-left corner of the specified rectangular area
      w - the width of the specified rectangular area
      h - the height of the specified rectangular area
      Returns:
      true if the interior of the bounding box of this shape contains the interior of the specified rectangle.
    • contains

      public boolean contains(Rectangle2D r)
      Specified by:
      contains in interface Shape
      Overrides:
      contains in class AbstractShape
      Parameters:
      r - the specified Rectangle2D
      Returns:
      true if this shape contains r
    • getSubPathIteratorAtArcLength

      public PathIterator getSubPathIteratorAtArcLength(double s0, double s1, @Nullable AffineTransform tx)
      Gets an iterator over a segment of the path from arc length s0 to arc length s1.
      Specified by:
      getSubPathIteratorAtArcLength in interface PathMetrics
      Parameters:
      s0 - the arc length at which the sub-path starts, the value will be clamped to [0,arcLength()].
      s1 - the arc length at which the sub-path ends, the value will be clamped to [s0,arcLength()].
      tx - an optional transformation for the path iterator
      Returns:
      the path iterator
    • getPathIterator

      public PathIterator getPathIterator(@Nullable AffineTransform tx)
      Returns a path iterator of the entire path.
      Specified by:
      getPathIterator in interface PathMetrics
      Specified by:
      getPathIterator in interface Shape
      Parameters:
      tx - an optional transformation for the path iterator
      Returns:
      the path iterator
    • toString

      public String toString()
      Overrides:
      toString in class Object