edu.neu.ccs.gui
Class PathListIterator

java.lang.Object
  extended byedu.neu.ccs.gui.PathListIterator
All Implemented Interfaces:
PathIterator

public class PathListIterator
extends Object
implements PathIterator

The PathListIterator class creates a Java PathIterator based on an internal PathList.

The caller may query or modify the internal PathList.

If a path list is used in a constructor or in the method setPathList, this iterator is linked to that path list.

The caller may reset the iterator to its initial state to allow for multiple uses of the iterator.

A factory method is provided to construct a new Java Shape from the current iterator data. This method calls the corresponding method for its path list.

As of 2.6.0a, this class was modified to reflect the changes to the class PathList.

Since:
2.4.0
Version:
2.6.0a

Field Summary
static int CLOSE
          Shorthand constant for PathIterator.SEG_CLOSE.
static int CUBIC
          Shorthand constant for PathIterator.SEG_CUBICTO.
static int LINE
          Shorthand constant for PathIterator.SEG_LINETO.
static int MOVE
          Shorthand constant for PathIterator.SEG_MOVETO.
protected  PathList pathList
          The path list used by this iterator.
private  int pointer
          The interator index.
static int QUAD
          Shorthand constant for PathIterator.SEG_QUADTO.
private  int start
          The first index in the path list that does not have a path node of type CLOSE or else pathList.size();
private  PathNode startNode
          The adjusted start path node which is forced to be a MOVE node or else null.
 
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
PathListIterator()
          The default constructor that initializes the iterator to a new PathList object with zero nodes and winding rule WindingRule.WIND_NON_ZERO.
PathListIterator(PathList pathList)
          The constructor that initializes the iterator using the given PathList object.
 
Method Summary
 int currentSegment(double[] coords)
          Returns the type of the current segment as the return value and stores the numeric data of the segment in the supplied array which must be non-null and of size at least 6.
 int currentSegment(float[] coords)
          Returns the type of the current segment as the return value and stores the numeric data of the segment in the supplied array which must be non-null and of size at least 6.
 PathList getPathList()
          Returns the internal PathList that is the basis for this iterator.
 int getWindingRule()
          Returns the winding rule of the iterator as an int.
 boolean isDone()
          Returns true if the iteration pointer is beyond the last available path segment in the internal path list.
 boolean isValid()
          Returns true if this PathListIterator is a valid path iterator for the construction of a Shape.
 Shape makeShape()
          Returns the Shape constructed from the internal path list.
 void next()
          Advances the iteration pointer one step or anchors it one step beyond the end of the internal path list.
 void reset()
          Resets the iteration pointer to its initial state.
 void setPathList(PathList pathList)
          Sets the internal PathList that is the basis for this iterator.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MOVE

public static final int MOVE
Shorthand constant for PathIterator.SEG_MOVETO.

See Also:
Constant Field Values

LINE

public static final int LINE
Shorthand constant for PathIterator.SEG_LINETO.

See Also:
Constant Field Values

QUAD

public static final int QUAD
Shorthand constant for PathIterator.SEG_QUADTO.

See Also:
Constant Field Values

CUBIC

public static final int CUBIC
Shorthand constant for PathIterator.SEG_CUBICTO.

See Also:
Constant Field Values

CLOSE

public static final int CLOSE
Shorthand constant for PathIterator.SEG_CLOSE.

See Also:
Constant Field Values

pathList

protected PathList pathList
The path list used by this iterator.


pointer

private int pointer
The interator index.


start

private int start
The first index in the path list that does not have a path node of type CLOSE or else pathList.size();


startNode

private PathNode startNode
The adjusted start path node which is forced to be a MOVE node or else null.

Constructor Detail

PathListIterator

public PathListIterator()

The default constructor that initializes the iterator to a new PathList object with zero nodes and winding rule WindingRule.WIND_NON_ZERO.


PathListIterator

public PathListIterator(PathList pathList)

The constructor that initializes the iterator using the given PathList object.

Parameters:
pathList - the path list to be used for the iterator
Method Detail

setPathList

public final void setPathList(PathList pathList)

Sets the internal PathList that is the basis for this iterator.

Resets the iterator.

Sets the internal PathList to a new empty path list if the given path list is null.

Parameters:
pathList - the path list to set

getPathList

public final PathList getPathList()

Returns the internal PathList that is the basis for this iterator.

This method enables the user to query any properties of the internal path list.

In addition, the caller can modify the internal path list. We believe that under certain circumstances this ability might be quite valuable. Nevertheless, we recommend caution in using this ability.

In particular, if any changes are made to the internal path list, then you MUST call reset() so the interator will be reset to its initial state and certain critical internal variables will be computed.

If the path list is empty or invalid then isDone() may return true even when the iterator is in its reset state.


isValid

public final boolean isValid()

Returns true if this PathListIterator is a valid path iterator for the construction of a Shape.

More precisely, returns true if the internal path list is valid, that is, its size is zero or its size is positive and its start node has type MOVE.

As of 2.6.0, this iterator will return the best possible partial shape even if it is not valid.


getWindingRule

public final int getWindingRule()
Returns the winding rule of the iterator as an int.

Specified by:
getWindingRule in interface PathIterator

isDone

public final boolean isDone()

Returns true if the iteration pointer is beyond the last available path segment in the internal path list.

If an attempt is made to retrieve path segment data when isDone() is true then an IndexOutOfBoundsException will be thrown.

Specified by:
isDone in interface PathIterator

next

public final void next()
Advances the iteration pointer one step or anchors it one step beyond the end of the internal path list.

Specified by:
next in interface PathIterator

reset

public final void reset()

Resets the iteration pointer to its initial state.

If the path list is empty or invalid then isDone() may return true even when the iterator is in its reset state.


currentSegment

public final int currentSegment(float[] coords)

Returns the type of the current segment as the return value and stores the numeric data of the segment in the supplied array which must be non-null and of size at least 6.

Throws IllegalArgumentException if the supplied array does not meet the preconditions.

Overwrites the existing contents of the first 6 cells of the supplied array.

Throws IndexOutOfBoundsException if this method is called when isDone() is true.

Specified by:
currentSegment in interface PathIterator
Parameters:
coords - an array of size 6 to hold the segment data
Throws:
IllegalArgumentException
IndexOutOfBoundsException

currentSegment

public final int currentSegment(double[] coords)

Returns the type of the current segment as the return value and stores the numeric data of the segment in the supplied array which must be non-null and of size at least 6.

Throws IllegalArgumentException if the supplied array does not meet the preconditions.

Overwrites the existing contents of the first 6 cells of the supplied array.

Throws IndexOutOfBoundsException if this method is called when isDone() is true.

Specified by:
currentSegment in interface PathIterator
Parameters:
coords - an array of size 6 to hold the segment data
Throws:
IllegalArgumentException
IndexOutOfBoundsException

makeShape

public final Shape makeShape()

Returns the Shape constructed from the internal path list.

The state of the iterator is not used and is not changed.