java.lang.Object
org.bzdev.geom.TransformedPathIterator
- All Implemented Interfaces:
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.
-
Field Summary
Fields inherited from interface java.awt.geom.PathIterator
SEG_CLOSE, SEG_CUBICTO, SEG_LINETO, SEG_MOVETO, SEG_QUADTO, WIND_EVEN_ODD, WIND_NON_ZERO -
Constructor Summary
ConstructorsConstructorDescriptionConstructor given an AffineTransform.Constructor given a Transform2D. -
Method Summary
Modifier and TypeMethodDescriptionintcurrentSegment(double[] coords) intcurrentSegment(float[] coords) intbooleanisDone()voidnext()
-
Constructor Details
-
TransformedPathIterator
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
to avoid having multiple references that modify the same object.PathIterator pi = ... AffineTransform at = ... pi = new TransformedPathIterator(pi, at);- Parameters:
pi- the path iteratorat- the affine transform; null if there is none.- Throws:
NullPointerException- the path iterator was null
-
TransformedPathIterator
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
to avoid having multiple references that modify the same object.PathIterator pi = ... Transform2D at = ... pi = new TransformedPathIterator(pi, at);- Parameters:
pi- the path iteratortf- the transform; null if there is none.- Throws:
NullPointerException- the path iterator was null
-
-
Method Details
-
currentSegment
public int currentSegment(double[] coords) - Specified by:
currentSegmentin interfacePathIterator
-
currentSegment
public int currentSegment(float[] coords) - Specified by:
currentSegmentin interfacePathIterator
-
getWindingRule
public int getWindingRule()- Specified by:
getWindingRulein interfacePathIterator
-
isDone
public boolean isDone()- Specified by:
isDonein interfacePathIterator
-
next
public void next()- Specified by:
nextin interfacePathIterator
-