Class TransformedPathIterator

java.lang.Object
org.bzdev.geom.TransformedPathIterator
All Implemented Interfaces:
PathIterator

public class TransformedPathIterator extends Object implements PathIterator
PathIterator based on an affine transformation of another PathIterator. This class obtains the segment type and control points from a path iterator that it encapsulates, and applies an affine transform to those control points. The path iterator passed to the constructor will be modified as methods are called.

The rationale for this class is that the Shape interface allows an affine transformation to be applied when creating a path iterator, but there are no methods in subpackages of the java and javax packages that will apply an affine transformation to an existing path iterator—instead one must create a new path and obtain an iterator for that path.

The same effect can be achieved by calling FlattenedPathIterator2D with a limit of 0, albeit with slightly worse performance.

  • Constructor Details

    • TransformedPathIterator

      public TransformedPathIterator(PathIterator pi, AffineTransform at)
      Constructor given an AffineTransform. Because the path iterator passed to this constructor will be modified by this object's methods, it is a good practice to call the constructor as follows
      
            PathIterator pi = ...
            AffineTransform at = ...
            pi = new TransformedPathIterator(pi, at);
       
      to avoid having multiple references that modify the same object.
      Parameters:
      pi - the path iterator
      at - the affine transform; null if there is none.
      Throws:
      NullPointerException - the path iterator was null
    • TransformedPathIterator

      public TransformedPathIterator(PathIterator pi, Transform2D tf)
      Constructor given a Transform2D. Because the path iterator passed to this constructor will be modified by this object's methods, it is a good practice to call the constructor as follows
      
            PathIterator pi = ...
            Transform2D at = ...
            pi = new TransformedPathIterator(pi, at);
       
      to avoid having multiple references that modify the same object.
      Parameters:
      pi - the path iterator
      tf - the transform; null if there is none.
      Throws:
      NullPointerException - the path iterator was null
  • Method Details