edu.neu.ccs.gui
Class PathList

java.lang.Object
  extended byedu.neu.ccs.gui.PathList
All Implemented Interfaces:
Stringable

public class PathList
extends Object
implements Stringable

The PathList class combines an explicit sequence of PathNode objects together with a winding rule to provide a flexible alternative to the Java class GeneralPath.

A PathList may be constructed or modifed using a list of PathNode objects or a Shape or a PathIterator.

Conversely, from a PathList, one can construct a Shape or a PathIterator.

Unlike GeneralPath, PathList does not implement Shape directly since we separate the aspects of collecting the path node data from the shape issues. This class provides methods that create not only the Shape directly associated with the PathList data but also various Shape objects that capture its vertex polygon and bezier frame polygon as well as the dots that make up these polygons. This flexibility is used in the methods makeStructurePaintable that construct a Paintable that visually reveals the internal structure of the Shape directly associated with the PathList data.

Note: GeneralPath is used as an implementation class for the various PathList methods that construct Shape objects.

Changes in 2.6.0a:

In 2.6.0a, the policy concerning how to handle a pathlist that does not start with a MOVE operation was changed. Here is the context.

In construction of a Shape via GeneralPath, Java requires that the start node have type MOVE. If this condition does not hold, Java throws IllegalPathStateException. The option of throwing an exception was not one we wished to choose.

Since the introduction of PathList, we have had a method isValid() that returns true if the start node has type MOVE. Our original policy on Shape construction was that if a path list was not valid, then we would return a non-null but empty shape. We now realize that this policy is too restrictive.

As of 2.6.0a, we will now use the following policy on Shape construction. We will search for the first PathNode in the PathList which is not a CLOSE. We will then extract the endpoint of that node and use that to define the first MOVE that is required in building a Java Shape. After that, each node in the path list will be added to the GeneralPath as usual. This will enable as much of a Shape to be created as possible which is a benefit to developers during debugging and to end users.

As of 2,6.0a, the fromStringData method will ignore text lines after the first line that contain only whitespace. This will avoid adding spurious path nodes that “move to 0,0”.

As of 2.6.0a, append methods were added to take the nodes of a given path list, clone them, and then append them to a path list. This allows one path list to maintain sub-path information that may be easily appended to another path list.

Prior to 2.6.0a, this class included methods and data to read and save the PathList information to a file. This was a design error since it made it impossible to use this class in an applet. The methods and data associated with file read and save have been removed.

Additional changes in 2.6.0d:

Since:
2.4.0
Version:
2.6.0d

Field Summary
static String Alternate_WIND_EVEN_ODD
          The alternate String constant for WindingRule.WIND_EVEN_ODD without underscore characters.
static String Alternate_WIND_NON_ZERO
          The alternate String constant for WindingRule.WIND_NON_ZERO without underscore characters.
private static int CAP_ROUND
          Constant used to contruct stroke.
static int CLOSE
          Shorthand constant for PathIterator.SEG_CLOSE.
static int CUBIC
          Shorthand constant for PathIterator.SEG_CUBICTO.
private static int JOIN_ROUND
          Constant used to contruct stroke.
static int LINE
          Shorthand constant for PathIterator.SEG_LINETO.
static int MOVE
          Shorthand constant for PathIterator.SEG_MOVETO.
protected  Vector pathlist
          The path list.
static int QUAD
          Shorthand constant for PathIterator.SEG_QUADTO.
static String standardMessage
          The standard error message for fromStringData.
static String String_WIND_EVEN_ODD
          The String constant for WindingRule.WIND_EVEN_ODD.
static String String_WIND_NON_ZERO
          The String constant for WindingRule.WIND_NON_ZERO.
protected  WindingRule windingrule
          The winding rule as an object.
 
Constructor Summary
PathList()
          The default constructor that sets the path list to empty and the winding rule to WindingRule.WIND_NON_ZERO.
PathList(PathIterator iterator)
          The constructor that initializes the path list using the path nodes and winding rule obtained from the given PathIterator.
PathList(PathList list)
          The constructor that makes a deep clone of an existing path list.
PathList(PathNode[] nodes)
          The constructor that initializes the path list using the given array of path nodes and sets the winding rule to WindingRule.WIND_NON_ZERO.
PathList(PathNode[] nodes, int rule)
          The constructor that initializes the path list using the given array of path nodes and the given winding rule.
PathList(PathNode[] nodes, WindingRule rule)
          The constructor that initializes the path list using the given array of path nodes and the given winding rule.
PathList(Point2D[] points, boolean close)
          The constructor that makes a polygon path list using the given array points of point data; the boolean close determines whether or the polygon is open or closed.
PathList(Point2D[] points, boolean close, int rule)
          The constructor that makes a polygon path list using the given array points of point data; the boolean close determines whether or the polygon is open or closed; the given winding rule determines the winding rule.
PathList(Point2D[] points, boolean close, WindingRule rule)
          The constructor that makes a polygon path list using the given array points of point data; the boolean close determines whether or the polygon is open or closed; the given winding rule determines the winding rule.
PathList(Shape shape)
          The constructor that initializes the path list using the path nodes and winding rule obtained from the given Shape.
PathList(Shape shape, AffineTransform transform)
          The constructor that initializes the path list using the path nodes and winding rule obtained from the given Shape after applying the given transform to the shape data.
PathList(Shape shape, AffineTransform transform, double flatness)
          The constructor that initializes the path list using the path nodes and winding rule obtained from the given Shape after applying the given transform and flatness to the shape data.
PathList(WindingRule rule)
          The constructor that sets the path list to empty and the winding rule to the given winding rule.
 
Method Summary
 void add(int index, PathNode node)
          Inserts the specified node at the specified position in this PathList and shifts any elements right as needed.
 void add(int index, PathNode[] nodes)
          Inserts the specified array of nodes into this PathList starting at the specified position in the list and shifts any elements right as needed.
 void add(int index, PathNode[] nodes, boolean connect)
          Inserts the specified array of nodes into this PathList starting at the specified position in the list and shifts any elements right as needed.
 PathList append(PathIterator iterator)
          Extracts the path node data from the given iterator and appends the nodes to this path list.
 PathList append(PathIterator iterator, boolean connect)
          Extracts the path node data from the given iterator and appends the nodes to this path list.
 PathList append(PathList pathList)
          Extract the path nodes from the given path list, clone each of these nodes, and append the cloned nodes to this path list.
 PathList append(PathList pathList, boolean connect)
          Extract the path nodes from the given path list, clone each of these nodes, and append the cloned nodes to this path list.
 PathList append(PathNode node)
          Appends the specified node to this PathList.
 PathList append(PathNode[] nodes)
          Appends the specified array of nodes to this PathList.
 PathList append(PathNode[] nodes, boolean connect)
          Appends the specified array of nodes to this PathList.
 PathList append(Shape shape)
          Extracts the path node data from the given shape and appends the nodes to this path list.
 PathList append(Shape shape, AffineTransform transform)
          Extracts the path node data from the given shape and appends the nodes to this path list after applying the given transform.
 PathList append(Shape shape, AffineTransform transform, boolean connect)
          Extracts the path node data from the given shape and appends the nodes to this path list after applying the given transform.
 PathList append(Shape shape, AffineTransform transform, double flatness)
          Extracts the path node data from the given shape and appends the nodes to this path list after applying the given transform and flatness.
 PathList append(Shape shape, AffineTransform transform, double flatness, boolean connect)
          Extracts the path node data from the given shape and appends the nodes to this path list after applying the given transform and flatness.
 PathList append(Shape shape, boolean connect)
          Extracts the path node data from the given shape and appends the nodes to this path list.
 void cloneAndAdd(int index, PathNode node)
          Inserts a clone of the specified node at the specified position in this PathList and shifts any elements right as needed.
 void cloneAndAdd(int index, PathNode[] nodes)
          Inserts clones of the specified array of nodes to this PathList starting at the specified position in the list and shifts any elements right as needed.
 void cloneAndAdd(int index, PathNode[] nodes, boolean connect)
          Inserts clones of the specified array of nodes to this PathList starting at the specified position in the list and shifts any elements right as needed.
 PathList cloneAndAppend(PathNode node)
          Appends a clone of the specified node to this PathList.
 PathList cloneAndAppend(PathNode[] nodes)
          Appends clones of the specified array of nodes to this PathList.
 PathList cloneAndAppend(PathNode[] nodes, boolean connect)
          Appends clones of the specified array of nodes to this PathList.
 PathList close()
          Append a new PathNode of type CLOSE.
 PathList cubic(double x1, double y1, double x2, double y2, double x3, double y3)
          Append a new PathNode of type CUBIC.
 void fromStringData(String data)
          Sets the data of this path list using String data in the format produced by toString().
 PathNode get(int index)
          Returns the PathNode at the given index if the given index is in range; otherwise returns null.
 PathNode[] getPathNodes()
          Returns a PathNode array with the current path nodes in this path list.
 String[] getPathNodeStateArray()
          Returns a String array with the value of the method toStringData applied to each item in the array returned by getPathNodes.
 float[] getShapePoint(float t)
          Returns the point on the path corresponding to the parameter t as float[2].
 XPoint2D getShapePoint2D(double t)
          Returns the point on the path corresponding to the parameter t as XPoint2D.
 float[] getSlot(int[] indices)
          Returns the contents of the slot indices[1] of the PathNode at the index indices[0] if indices is non-null and of length 2 and if the index is in range and the slot is valid; otherwise returns null.
 float[] getSlot(int index, int slot)
          Returns the contents of the given slot of the PathNode at the given index if the index is in range and the slot is valid; otherwise returns null.
 WindingRule getWindingRule()
          Get the winding rule as an object.
 WindingRule getWindingRuleFromStringData(String data)
          Returns the WindingRule that corresponds to the given String data.
 String getWindingRuleString()
          Returns a String with the winding rule information.
 double getX(double t)
          Returns the x-coordinate of a point on the path corresponding to the parameter t.
 double getY(double t)
          Returns the y-coordinate of a point on the path corresponding to the parameter t.
 boolean isPolygon()
          Returns true if the list has at least 2 nodes, all nodes in the list have one of the following 3 types MOVE, LINE, CLOSE, and the first node is MOVE.
 boolean isStrictPolygon()
          Returns true if the list has at least 2 nodes, the initial node has type MOVE, the final node has type LINE or CLOSE, all inner nodes have type LINE, and at least one node has type LINE.
 boolean isValid()
          Returns true if this PathList is a valid path list for the construction of a Shape.
 String JavaCode()
          Returns in a String the Java code that might be used to make a clone of this path list.
 PathList line(double x1, double y1)
          Append a new PathNode of type LINE.
 PathList makeBezierDotsPathList()
          Returns a new PathList with the same winding rule as this path list and whose nodes are constructed from the nodes of this path list by the following operations.
 PathListIterator makeBezierDotsPathListIterator()
          Returns a PathListIterator constructed from an instance of makeBezierDotsPathList().
 Shape makeBezierDotsShape()
          Returns a Shape that consists of the bezier dots.
static Shape makeBezierDotsShape(Shape shape)
          Static method that returns the bezier dots shape corresponding to the given shape.
 PathList makeBezierPathList()
          Returns a new PathList with the same winding rule as this path list and whose nodes are constructed from the nodes of this path list by the following operations.
 PathListIterator makeBezierPathListIterator()
          Returns a PathListIterator constructed from an instance of makeBezierPathList().
 Point2D[] makeBezierPoints()
          Returns a new Point2D[] whose points are built to include the bezier points of the path list by the following operations.
static Point2D[] makeBezierPoints(Shape shape)
          Static method that returns the bezier point array for the given shape.
 Shape makeBezierShape()
          Returns a polygonal Shape that passes through the bezier points of this pathlist, that is, both the vertex points and the control points.
static Shape makeBezierShape(Shape shape)
          Static method that returns the bezier shape corresponding to the given shape.
 PathList makeControlDotsPathList()
          Returns a new PathList with the same winding rule as this path list and whose nodes are constructed from the nodes of this path list by the following operations.
 PathListIterator makeControlDotsPathListIterator()
          Returns a PathListIterator constructed from an instance of makeControlDotsPathList().
 Shape makeControlDotsShape()
          Returns a Shape that consists of the control dots.
static Shape makeControlDotsShape(Shape shape)
          Static method that returns the control dots shape corresponding to the given shape.
 Point2D[] makeControlPoints()
          Returns a new Point2D[] whose points are built to include the control points of the path list by the following operations.
static Point2D[] makeControlPoints(Shape shape)
          Static method that returns the control point array for the given shape.
 PathListIterator makePathListIterator()
          Factory method that returns a new PathListIterator based on the current data in this path list.
 Shape makeShape()
          Factory method that returns a new Shape based on the current data in this path list.
 PaintableSequence makeStructurePaintable()
          Returns a PaintableSequence whose components show the structure of the Shape associated with this PathList.
 PaintableSequence makeStructurePaintable(Color fillColor, Color drawColor, Color vertexDotsColor, Color controlDotsColor, Color vertexFrameColor, Color bezierFrameColor, Color pathPointsColor, int thickness, int divisions)
          Returns a PaintableSequence whose components show the structure of the Shape associated with this PathList.
 PaintableSequence makeStructurePaintable(Color fillColor, Color drawColor, Color vertexDotsColor, Color controlDotsColor, Color vertexFrameColor, Color bezierFrameColor, int thickness)
          Returns a PaintableSequence whose components show the structure of the Shape associated with this PathList.
 PaintableSequence makeStructurePaintable(Color fillColor, Color drawColor, int thickness)
          Returns a PaintableSequence whose components show the structure of the Shape associated with this PathList.
 PaintableSequence makeStructurePaintable(int thickness)
          Returns a PaintableSequence whose components show the structure of the Shape associated with this PathList.
 PathList makeVertexDotsPathList()
          Returns a new PathList with the same winding rule as this path list and whose nodes are constructed from the nodes of this path list by the following operations.
 PathListIterator makeVertexDotsPathListIterator()
          Returns a PathListIterator constructed from an instance of makeVertexDotsPathList().
 Shape makeVertexDotsShape()
          Returns a Shape that consists of the vertex dots.
static Shape makeVertexDotsShape(Shape shape)
          Static method that returns the vertex dots shape corresponding to the given shape.
 PathList makeVertexPathList()
          Returns a new PathList with the same winding rule as this path list and whose nodes are constructed from the nodes of this path list by the following operations.
 PathListIterator makeVertexPathListIterator()
          Returns a PathListIterator constructed from an instance of makeVertexPathList().
 Point2D[] makeVertexPoints()
          Returns a new Point2D[] whose points are built to include the vertex points of the path list by the following operations.
static Point2D[] makeVertexPoints(Shape shape)
          Static method that returns the vertex point array for the given shape.
 Shape makeVertexShape()
          Returns a polygonal Shape that passes through the vertex points of this pathlist.
static Shape makeVertexShape(Shape shape)
          Static method that returns the vertex shape corresponding to the given shape.
 PathList move(double x1, double y1)
          Append a new PathNode of type MOVE.
 int[] nearSlot(double x, double y, double epsilon)
          Searches the nodes in this path list and for each such node searches the slots in the node to determine if the given (x,y) is within epsilon of the values in the slot; if successful, returns an array int[2] with value 0 equal to the node index and value 1 equal to the slot index; if unsuccessful, returns null.
 int[] nearSlot(double x, double y, double epsilon, Metric metric)
          Searches the nodes in this path list and for each such node searches the slots in the node to determine if the given (x,y) is within epsilon of the values in the slot relative to the given metric; if successful, returns an array int[2] with value 0 equal to the node index and value 1 equal to the slot index; if unsuccessful, returns null.
 PathList quad(double x1, double y1, double x2, double y2)
          Append a new PathNode of type QUAD.
 PathNode remove(int index)
          Removes the PathNode at the given index and returns the removed node.
 PathNode[] remove(int m, int n)
          Removes the PathNodes starting at the given index m inclusive and ending at the given index n exclusive; returns an array with the removed nodes.
 PathNode[] removeAll()
          Removes all PathNodes from the path list and returns an array with the removed nodes.
 void set(int index, PathNode node)
          Sets the PathNode at the given index to a copy of the given node if the given node is non-null and if the given index is in range; otherwise does nothing.
 void setPathList(PathIterator iterator)
          Sets the path list using the path nodes and winding rule obtained from the given PathIterator.
 void setPathList(PathList list)
          Sets this path list to be a deep clone of an existing path list.
 void setPathList(Shape shape)
          Sets the path list using the path nodes and winding rule obtained from the given Shape.
 void setPathList(Shape shape, AffineTransform transform)
          Sets the path list using the path nodes and winding rule obtained from the given Shape after applying the given transform to the shape data.
 void setPathList(Shape shape, AffineTransform transform, double flatness)
          Sets the path list using the path nodes and winding rule obtained from the given Shape after applying the given transform and flatness to the shape data.
 void setPathNodes(PathNode[] nodes)
          Removes the current nodes in the path list and sets the nodes to those in the given array of nodes.
 void setSlot(int[] indices, double[] pair)
          Sets the contents of the slot indices[1] of the PathNode at the index indices[0] to the coordinates of the given pair if indices is non-null and of length 2, if the index is in range and the slot is valid, and if pair is non-null and of length 2; otherwise does nothing.
 void setSlot(int[] indices, double x, double y)
          Sets the contents of the slot indices[1] of the PathNode at the index indices[0] to the given x, y if indices is non-null and of length 2 and if the index is in range and the slot is valid; otherwise does nothing.
 void setSlot(int[] indices, float[] pair)
          Sets the contents of the slot indices[1] of the PathNode at the index indices[0] to the coordinates of the given pair if indices is non-null and of length 2, if the index is in range and the slot is valid, and if pair is non-null and of length 2; otherwise does nothing.
 void setSlot(int index, int slot, double[] pair)
          Sets the contents of the given slot of the PathNode at the given index to the coordinates of the given pair if the index is in range and the slot is valid and if pair is non-null and of length 2; otherwise does nothing.
 void setSlot(int index, int slot, double x, double y)
          Sets the contents of the given slot of the PathNode at the given index to the given x, y if the index is in range and the slot is valid; otherwise does nothing.
 void setSlot(int index, int slot, float[] pair)
          Sets the contents of the given slot of the PathNode at the given index to the coordinates of the given pair if the index is in range and the slot is valid and if pair is non-null and of length 2; otherwise does nothing.
 void setWindingRule(int rule)
          Sets the winding rule via an int.
 void setWindingRule(WindingRule rule)
          Sets the winding rule as an object.
 int size()
          Returns the size of the list.
 String toString()
          Returns the data in this path list as a multi-line String.
 String toStringData()
          Returns the same String as toString().
 void transform(AffineTransform T)
          Transforms the internal data points in each path node using the given affine transform.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, 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

CAP_ROUND

private static final int CAP_ROUND
Constant used to contruct stroke.

See Also:
Constant Field Values

JOIN_ROUND

private static final int JOIN_ROUND
Constant used to contruct stroke.

See Also:
Constant Field Values

standardMessage

public static final String standardMessage
The standard error message for fromStringData.

See Also:
Constant Field Values

String_WIND_NON_ZERO

public static final String String_WIND_NON_ZERO
The String constant for WindingRule.WIND_NON_ZERO.

See Also:
Constant Field Values

String_WIND_EVEN_ODD

public static final String String_WIND_EVEN_ODD
The String constant for WindingRule.WIND_EVEN_ODD.

See Also:
Constant Field Values

Alternate_WIND_NON_ZERO

public static final String Alternate_WIND_NON_ZERO
The alternate String constant for WindingRule.WIND_NON_ZERO without underscore characters.

See Also:
Constant Field Values

Alternate_WIND_EVEN_ODD

public static final String Alternate_WIND_EVEN_ODD
The alternate String constant for WindingRule.WIND_EVEN_ODD without underscore characters.

See Also:
Constant Field Values

pathlist

protected Vector pathlist
The path list.


windingrule

protected WindingRule windingrule
The winding rule as an object.

Constructor Detail

PathList

public PathList()
The default constructor that sets the path list to empty and the winding rule to WindingRule.WIND_NON_ZERO.


PathList

public PathList(WindingRule rule)
The constructor that sets the path list to empty and the winding rule to the given winding rule.

Parameters:
rule - the desired winding rule

PathList

public PathList(PathNode[] nodes)

The constructor that initializes the path list using the given array of path nodes and sets the winding rule to WindingRule.WIND_NON_ZERO.

Parameters:
nodes - the nodes to add to the path list

PathList

public PathList(PathNode[] nodes,
                WindingRule rule)

The constructor that initializes the path list using the given array of path nodes and the given winding rule.

Parameters:
nodes - the nodes to add to the path list
rule - the winding rule as an object

PathList

public PathList(PathNode[] nodes,
                int rule)

The constructor that initializes the path list using the given array of path nodes and the given winding rule.

Parameters:
nodes - the nodes to add to the path list
rule - the winding rule as an int

PathList

public PathList(PathList list)

The constructor that makes a deep clone of an existing path list.

Parameters:
list - the path list to clone

PathList

public PathList(Shape shape)

The constructor that initializes the path list using the path nodes and winding rule obtained from the given Shape.

Parameters:
shape - the shape whose data is cloned to this list

PathList

public PathList(Shape shape,
                AffineTransform transform)

The constructor that initializes the path list using the path nodes and winding rule obtained from the given Shape after applying the given transform to the shape data.

Parameters:
shape - the shape whose data is used to make this list
transform - the transform to apply to the shape data

PathList

public PathList(Shape shape,
                AffineTransform transform,
                double flatness)

The constructor that initializes the path list using the path nodes and winding rule obtained from the given Shape after applying the given transform and flatness to the shape data.

Parameters:
shape - the shape whose data is used to make this list
transform - the transform to apply to the shape data
flatness - the flatness to require

PathList

public PathList(PathIterator iterator)

The constructor that initializes the path list using the path nodes and winding rule obtained from the given PathIterator.

The constructor must execute the iteration so when it is complete then iterator.isDone() will be true.

Parameters:
iterator - the iterator whose data is cloned to this list

PathList

public PathList(Point2D[] points,
                boolean close)

The constructor that makes a polygon path list using the given array points of point data; the boolean close determines whether or the polygon is open or closed.

Does nothing if points is null.

Ignores null data items in points.

The path list is constructed by doing MOVE to the first point and LINE to all succeeding points. If the boolean close is true then CLOSE is appended at the end.

Parameters:
points - the polygon points
close - whether or not to close the polygon

PathList

public PathList(Point2D[] points,
                boolean close,
                WindingRule rule)

The constructor that makes a polygon path list using the given array points of point data; the boolean close determines whether or the polygon is open or closed; the given winding rule determines the winding rule.

Utilizes PathList(Point2D[], boolean).

Parameters:
points - the polygon points
close - whether or not to close the polygon
rule - the winding rule as an object

PathList

public PathList(Point2D[] points,
                boolean close,
                int rule)

The constructor that makes a polygon path list using the given array points of point data; the boolean close determines whether or the polygon is open or closed; the given winding rule determines the winding rule.

Utilizes PathList(Point2D[], boolean).

Parameters:
points - the polygon points
close - whether or not to close the polygon
rule - the winding rule as an int
Method Detail

makeShape

public final Shape makeShape()

Factory method that returns a new Shape based on the current data in this path list. The Shape is constructed using the Java class GeneralPath.

See the notes in the introduction to this class concerning how this Shape is constructed.


makeVertexShape

public final Shape makeVertexShape()

Returns a polygonal Shape that passes through the vertex points of this pathlist.


makeBezierShape

public final Shape makeBezierShape()

Returns a polygonal Shape that passes through the bezier points of this pathlist, that is, both the vertex points and the control points.


makeVertexDotsShape

public final Shape makeVertexDotsShape()
Returns a Shape that consists of the vertex dots.


makeBezierDotsShape

public final Shape makeBezierDotsShape()
Returns a Shape that consists of the bezier dots.


makeControlDotsShape

public final Shape makeControlDotsShape()
Returns a Shape that consists of the control dots.


makePathListIterator

public final PathListIterator makePathListIterator()

Factory method that returns a new PathListIterator based on the current data in this path list.


makeStructurePaintable

public final PaintableSequence makeStructurePaintable(Color fillColor,
                                                      Color drawColor,
                                                      Color vertexDotsColor,
                                                      Color controlDotsColor,
                                                      Color vertexFrameColor,
                                                      Color bezierFrameColor,
                                                      Color pathPointsColor,
                                                      int thickness,
                                                      int divisions)

Returns a PaintableSequence whose components show the structure of the Shape associated with this PathList.

Each component in the sequence corresponds to one of the Color parameters and if a particular parameter is null or has an alpha value of 0 then that particular component is omitted from the sequence.

The components are inserted into the sequence from top to bottom as follows.

At the top, the path points computed algorithmically with the given number of divisions of the unit interval. These points are computed using the methods of the class PathListFunction. The points are inserted as an internal paintable sequence. Each point uses a PointPaintable with the path points color.

Next, the dots corresponding to the Bezier control points are inserted as an internal paintable sequence. Each dot uses a PointPaintable with the control dots color.

Next, the dots corresponding to the vertex points are inserted as an internal paintable sequence. Each dot uses a PointPaintable with the vertex dots color.

Next, the shape constructed by makeShape is inserted into the sequence as a ShapePaintable to be drawn in the draw color.

Next, the frame constructed by makeBezierShape is inserted into the sequence as a ShapePaintable to be drawn in the bezier frame color.

Next, the frame constructed by makeVertexShape is inserted into the sequence as a ShapePaintable to be drawn in the vertex frame color.

Finally, the shape constructed by makeShape is inserted into the sequence as a ShapePaintable to be filled in the fill color.

This order of insertion ensures that the dots are on top, the drawn shape is next, the frames are next, and the filled shape is on the bottom. This order gives the maximum amount of information to the user of this method.

The thickness controls the thickness of the drawing stroke. Also, the PointPaintable for the dots uses a size equal to (thickness+2).

Parameters:
fillColor - the fill color for the shape
drawColor - the draw color for the shape
vertexDotsColor - the color for the vertex dots
controlDotsColor - the color for the control dots
vertexFrameColor - the color for the vertex frame
bezierFrameColor - the color for the bezier frame
pathPointsColor - the color for the path points
thickness - the stroke thickness
divisions - the number of subdivisions of a unit interval when constructing path points

makeStructurePaintable

public final PaintableSequence makeStructurePaintable(Color fillColor,
                                                      Color drawColor,
                                                      Color vertexDotsColor,
                                                      Color controlDotsColor,
                                                      Color vertexFrameColor,
                                                      Color bezierFrameColor,
                                                      int thickness)

Returns a PaintableSequence whose components show the structure of the Shape associated with this PathList.

Calls the most general method with the following defaults.

  pathPointsColor:  Colors.transparent
  divisions:        1

In particular, with these defaults, the path points are not included in the PaintableSequence.

Parameters:
fillColor - the fill color for the shape
drawColor - the draw color for the shape
vertexDotsColor - the color for the vertex dots
controlDotsColor - the color for the control dots
vertexFrameColor - the color for the vertex frame
bezierFrameColor - the color for the bezier frame
thickness - the stroke thickness

makeStructurePaintable

public final PaintableSequence makeStructurePaintable(Color fillColor,
                                                      Color drawColor,
                                                      int thickness)

Returns a PaintableSequence whose components show the structure of the Shape associated with this PathList.

Calls the most general method with the following defaults.

  vertexDotsColor:  Colors.red
  controlDotsColor: Colors.blue
  vertexFrameColor: Colors.transparent
  bezierFrameColor: Colors.darkorchid
  pathPointsColor:  Colors.transparent
  divisions:        1

In particular, with these defaults, the vertex frame and the path points are not included in the PaintableSequence.

Parameters:
fillColor - the fill color for the shape
drawColor - the draw color for the shape
thickness - the stroke thickness

makeStructurePaintable

public final PaintableSequence makeStructurePaintable(int thickness)

Returns a PaintableSequence whose components show the structure of the Shape associated with this PathList.

Calls the most general method with the following defaults.

  fillColor:        Colors.lime
  drawColor:        Colors.black
  vertexDotsColor:  Colors.red
  controlDotsColor: Colors.blue
  vertexFrameColor: Colors.transparent
  bezierFrameColor: Colors.darkorchid
  pathPointsColor:  Colors.transparent
  divisions:        1

In particular, with these defaults, the vertex frame and the path points are not included in the PaintableSequence.

Parameters:
thickness - the stroke thickness

makeStructurePaintable

public final PaintableSequence makeStructurePaintable()

Returns a PaintableSequence whose components show the structure of the Shape associated with this PathList.

Calls the most general method with the following defaults.

  fillColor:        Colors.lime
  drawColor:        Colors.black
  vertexDotsColor:  Colors.red
  controlDotsColor: Colors.blue
  vertexFrameColor: Colors.transparent
  bezierFrameColor: Colors.darkorchid
  pathPointsColor:  Colors.transparent
  thickness:        2
  divisions:        1

In particular, with these defaults, the vertex frame and the path points are not included in the PaintableSequence.


setPathList

public final void setPathList(PathList list)

Sets this path list to be a deep clone of an existing path list.

If the given path list is null then does nothing.

Parameters:
list - the path list to clone

setPathList

public final void setPathList(Shape shape)

Sets the path list using the path nodes and winding rule obtained from the given Shape.

If the given shape is null then does nothing.

Parameters:
shape - the shape whose data is cloned to this list

setPathList

public final void setPathList(Shape shape,
                              AffineTransform transform)

Sets the path list using the path nodes and winding rule obtained from the given Shape after applying the given transform to the shape data.

Parameters:
shape - the shape whose data is used to make this list
transform - the transform to apply to the shape data

setPathList

public final void setPathList(Shape shape,
                              AffineTransform transform,
                              double flatness)

Sets the path list using the path nodes and winding rule obtained from the given Shape after applying the given transform and flatness to the shape data.

Parameters:
shape - the shape whose data is used to make this list
transform - the transform to apply to the shape data
flatness - the flatness to require

setPathList

public final void setPathList(PathIterator iterator)

Sets the path list using the path nodes and winding rule obtained from the given PathIterator.

This method must execute the iteration so when it is complete then iterator.isDone() will be true.

If the given iterator is null then does nothing.

Parameters:
iterator - the iterator whose data is cloned to this list

size

public final int size()
Returns the size of the list.


setWindingRule

public final void setWindingRule(WindingRule rule)

Sets the winding rule as an object.

Does nothing if the parameter is null.

Parameters:
rule - the winding rule as an object

setWindingRule

public final void setWindingRule(int rule)

Sets the winding rule via an int.

GeneralPath.WIND_NON_ZERO corresponds to WindingRule.WIND_NON_ZERO.

GeneralPath.WIND_EVEN_ODD corresponds to WindingRule.WIND_EVEN_ODD.

Ignores an invalid parameter.

Parameters:
rule - the winding rule as an int

getWindingRule

public final WindingRule getWindingRule()
Get the winding rule as an object.

Returns:
the winding rule

setPathNodes

public final void setPathNodes(PathNode[] nodes)

Removes the current nodes in the path list and sets the nodes to those in the given array of nodes.

If the given nodes array is null then does nothing.

Parameters:
nodes - the nodes to use for the path list

getPathNodes

public final PathNode[] getPathNodes()

Returns a PathNode array with the current path nodes in this path list.

The PathNode items in the array are live, that is, they are identical to the current items in the path list. This means that the user of this array may make changes to the path list directly. Obviously, this facility must be used with care.

The length of the array is size().

If the user changes the path list by adding or removing items then this array will be out of synchronization with the data in the path list.


set

public final void set(int index,
                      PathNode node)

Sets the PathNode at the given index to a copy of the given node if the given node is non-null and if the given index is in range; otherwise does nothing.

Parameters:
index - the index of a path node in the path list
node - the path node to copy

get

public final PathNode get(int index)

Returns the PathNode at the given index if the given index is in range; otherwise returns null.

Parameters:
index - the index of a path node in the path list

add

public final void add(int index,
                      PathNode node)

Inserts the specified node at the specified position in this PathList and shifts any elements right as needed.

Does not clone the node but adds the node as is.

Does nothing if the given node is null. It is therefore impossible to place a null node in the list.

Forces the given index into the range:

    0 <= index <= size()

Parameters:
index - the list position
node - the node to add to the list

add

public final void add(int index,
                      PathNode[] nodes)

Inserts the specified array of nodes into this PathList starting at the specified position in the list and shifts any elements right as needed.

Does not clone any nodes but adds them as is.

Does nothing if the given node array is null and ignores any null items in the array.

Forces the given start index into the range:

    0 <= index <= size()

Parameters:
index - the list start position
nodes - the nodes to add to the list

add

public final void add(int index,
                      PathNode[] nodes,
                      boolean connect)

Inserts the specified array of nodes into this PathList starting at the specified position in the list and shifts any elements right as needed.

Does not clone any nodes but adds them as is.

Does nothing if the given node array is null and ignores any null items in the array.

Forces the given start index into the range:

    0 <= index <= size()

If the connect parameter is true and if the insert start index is not zero then if the first inserted node is a MOVE it will be changed to a LINE. If the connect parameter is false then there will be no change to the first inserted node.

Parameters:
index - the list start position
nodes - the nodes to add to the list
connect - whether or not to modify the first inserted node in order to connect the inserted nodes to the existing nodes

cloneAndAdd

public final void cloneAndAdd(int index,
                              PathNode node)

Inserts a clone of the specified node at the specified position in this PathList and shifts any elements right as needed.

Does nothing if the given node is null. It is therefore impossible to place a null node in the list.

Forces the given index into the range:

    0 <= index <= size()

Parameters:
index - the list position
node - the node to add to the list

cloneAndAdd

public final void cloneAndAdd(int index,
                              PathNode[] nodes)

Inserts clones of the specified array of nodes to this PathList starting at the specified position in the list and shifts any elements right as needed.

Does nothing if the given node array is null and ignores any null items i