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 to create various Shape objects as desired.

PathList utilizes the Java class GeneralPath for the implementation of the construction of a Shape given the data in this class.

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. In this class, the requirement that the start node have type MOVE is tested by the method isValid(). If this method returns false and the user calls makeShape, an empty Shape will be returned by this call rather than throwing an exception.


Field Summary
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.
protected  JFileChooser filechooser
          The file chooser used for file I/O.
protected  File home
          Initialization for home directory as directory ".".
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  FileExtensionFilter textFileFilter
          The file filter for file I/O that restricts to .txt files.
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.
 
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.
 void append(PathIterator iterator)
          Extracts the path node data from the given iterator and appends the nodes to this path list.
 void append(PathIterator iterator, boolean connect)
          Extracts the path node data from the given iterator and appends the nodes to this path list.
 void append(PathNode node)
          Appends the specified node to this PathList.
 void append(PathNode[] nodes)
          Appends the specified array of nodes to this PathList.
 void append(PathNode[] nodes, boolean connect)
          Appends the specified array of nodes to this PathList.
 void append(Shape shape)
          Extracts the path node data from the given shape and appends the nodes to this path list.
 void 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.
 void 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.
 void 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.
 void 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.
 void 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.
 void cloneAndAppend(PathNode node)
          Appends a clone of the specified node to this PathList.
 void cloneAndAppend(PathNode[] nodes)
          Appends clones of the specified array of nodes to this PathList.
 void cloneAndAppend(PathNode[] nodes, boolean connect)
          Appends clones of the specified array of nodes to this PathList.
 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 with the value of the method toStringData applied to each item in the array returned by getPathNodes.
 float[] getShapePoint(float t)
          Without actually constructing the shape, this function returns the mathematical point at float parameter t on the shape that would correspond to this path list.
 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.
 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.
 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, 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.
 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.
 boolean readDataFromFile()
          Opens a file dialog to get the file name of a text file with path list data and then reads the data.
 boolean readDataFromFile(File source, boolean displayErrorDialogs)
          Reads the path list data from the given text file.
 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.
 boolean saveDataToFile()
          Opens a file dialog to get the file name of a text file and then saves the data to the file.
 boolean saveDataToFile(File target, boolean displayErrorDialogs)
          Saves the path list data to the given text file.
 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, 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[] indices, float x, float 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 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 setSlot(int index, int slot, float x, float 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 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

pathlist

protected Vector pathlist
The path list.


windingrule

protected WindingRule windingrule
The winding rule as an object.


textFileFilter

protected final FileExtensionFilter textFileFilter
The file filter for file I/O that restricts to .txt files.


home

protected final File home
Initialization for home directory as directory ".".


filechooser

protected final JFileChooser filechooser
The file chooser used for file I/O.

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(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(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(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(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.

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. In this class, the requirement that the start node have type MOVE is tested by the method isValid(). If this method returns false and the user calls makeShape, an empty Shape will be returned by this call rather than throwing an exception.


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,
                                                      int thickness)

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 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
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 more general method with the following defaults.

  vertexDotsColor:  Colors.red
  controlDotsColor: Colors.darkorange
  vertexFrameColor: Colors.transparent
  bezierFrameColor: Colors.darkorchid

In particular, with these defaults, the vertex frame is 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 more general method with the following defaults.

  fillColor:        Colors.lime
  drawColor:        Colors.black
  vertexDotsColor:  Colors.red
  controlDotsColor: Colors.darkorange
  vertexFrameColor: Colors.transparent
  bezierFrameColor: Colors.darkorchid

In particular, with these defaults, the vertex frame is 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 more general method with the following defaults.

  fillColor:        Colors.lime
  drawColor:        Colors.black
  vertexDotsColor:  Colors.red
  controlDotsColor: Colors.darkorange
  vertexFrameColor: Colors.transparent
  bezierFrameColor: Colors.darkorchid
  thickness:        2

In particular, with these defaults, the vertex frame is not included in the PaintableSequence.


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.


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

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(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

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

size

public final int size()
Returns the size of the 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

setSlot

public final void setSlot(int index,
                          int slot,
                          float x,
                          float 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.

Parameters:
index - the index of a path node in the path list
slot - the slot within the path node (1, 2, 3)
x - the x-coordinate
y - the y-coordinate

setSlot

public final 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.

Parameters:
index - the index of a path node in the path list
slot - the slot within the path node (1, 2, 3)
pair - the float[2] array with x, y

setSlot

public final void setSlot(int[] indices,
                          float x,
                          float 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.

Parameters:
indices - the index-slot pair
x - the x-coordinate
y - the y-coordinate

setSlot

public final 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.

Parameters:
indices - the index-slot pair
pair - the float[2] array with x, y

getSlot

public final 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.

Parameters:
index - the index of a path node in the path list
slot - the slot within the path node (1, 2, 3)

getSlot

public final 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.

Parameters:
indices - the index-slot pair

nearSlot

public final 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.

The metric Metric.MAX is used.

Parameters:
x - the x-coordinate of the search point
y - the y-coordinate of the search point
epsilon - the measure of closeness

nearSlot

public final 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.

If the given metric is null then Metric.MAX is used.

Parameters:
x - the x-coordinate of the search point
y - the y-coordinate of the search point
epsilon - the measure of closeness
metric - the metric to do the distance computation

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 clone and 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 clone and 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

append

public final void append(PathNode node)

Appends the specified node to this PathList.

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

Does nothing if the given node is null.

Parameters:
node - the node to clone and append to the list

append

public final void append(PathNode[] nodes)

Appends the specified array of nodes to this PathList.

Does not clone any nodes but appends them as is.

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

Parameters:
nodes - the nodes to clone and append to the list

append

public final void append(PathNode[] nodes,
                         boolean connect)

Appends the specified array of nodes to this PathList.

Does not clone any nodes but appends them as is.

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

If the connect parameter is true and if the current list is not empty then if the first appended 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 appended node.

Parameters:
nodes - the nodes to clone and append to the list
connect - whether or not to modify the first appended node in order to connect the appended nodes to the existing nodes

append

public final void append(PathIterator iterator)

Extracts the path node data from the given iterator and appends the nodes to this path list.

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

Parameters:
iterator - the iterator whose data is to be extracted

append

public final void append(PathIterator iterator,
                         boolean connect)

Extracts the path node data from the given iterator and appends the nodes to this path list.

If the connect parameter is true and if the current list is not empty then if the first appended 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 appended node.

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

Parameters:
iterator - the iterator whose data is to be extracted
connect - whether or not to modify the first appended node in order to connect the appended nodes to the existing nodes

append

public final void append(Shape shape)

Extracts the path node data from the given shape and appends the nodes to this path list.

Parameters:
shape - the shape whose data is to be extracted

append

public final void append(Shape shape,
                         boolean connect)

Extracts the path node data from the given shape and appends the nodes to this path list.

If the connect parameter is true and if the current list is not empty then the first appended node will be changed from a MOVE to a LINE.

Parameters:
shape - the shape whose data is to be extracted
connect - whether or not to modify the first appended node in order to connect the appended nodes to the existing nodes

append

public final void 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.

Parameters:
shape - the shape whose data is to be extracted
transform - the transform to apply to the shape data

append

public final void 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.

If the connect parameter is true and if the current list is not empty then the first appended node will be changed from a MOVE to a LINE.

Parameters:
shape - the shape whose data is to be extracted
transform - the transform to apply to the shape data
connect - whether or not to modify the first appended node in order to connect the appended nodes to the existing nodes

append

public final void 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.

Parameters:
shape - the shape whose data is to be extracted
transform - the transform to apply to the shape data
flatness - the flatness to require

append

public final void 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.

If the connect parameter is true and if the current list is not empty then the first appended node will be changed from a MOVE to a LINE.

Parameters:
shape - the shape whose data is to be extracted
transform - the transform to apply to the shape data
flatness - the flatness to require
connect - whether or not to modify the first appended node in order to connect the appended 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 clone and 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 in the array.

Forces the given start index into the range:

    0 <= index <= size()

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

cloneAndAdd

public final 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.

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 clone and 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

cloneAndAppend

public final void cloneAndAppend(PathNode node)

Appends a clone of the specified node to this PathList.

Does nothing if the given node is null.

Parameters:
node - the node to clone and append to the list

cloneAndAppend

public final void cloneAndAppend(PathNode[] nodes)

Appends clones of the specified array of nodes to this PathList.

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

Parameters:
nodes - the nodes to clone and append to the list

cloneAndAppend

public final void cloneAndAppend(PathNode[] nodes,
                                 boolean connect)

Appends clones of the specified array of nodes to this PathList.

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

If the connect parameter is true and if the current list is not empty then if the first appended 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 appended node.

Parameters:
nodes - the nodes to clone and append to the list
connect - whether or not to modify the first appended node in order to connect the appended nodes to the existing nodes

remove

public final PathNode remove(int index)

Removes the PathNode at the given index and returns the removed node.

Returns null if the index is not valid.

Parameters:
index - the index of the PathNode to remove

remove

public final 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.

Forces m and n into range if needed.

Returns an array of length 0 if no nodes are removed.

Parameters:
m - the starting index inclusive
n - the ending index exclusive

removeAll

public final PathNode[] removeAll()
Removes all PathNodes from the path list and returns an array with the removed nodes.


transform

public final void transform(AffineTransform T)

Transforms the internal data points in each path node using the given affine transform.

Does nothing if the given affine transform is null.

Parameters:
T - the affine transform

isValid

public final boolean isValid()

Returns true if this PathList is a valid path list for the construction of a Shape.

More precisely, returns true if the list is empty (size is zero) or if the initial PathNode has type MOVE.


isPolygon

public final 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.

This is a "loose" definition of "polygon" since the method does not make assertions about whether the path consists of one open or closed chain of line segments.


isStrictPolygon

public final 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.

Historical note: Java defines java.awt.Polygon. Since this class is awt-based, the coordinates of a point must be integers not floating point numbers. In addition, this class requires that a polygon be closed and have WIND_EVEN_ODD at its winding rule. This method intentionally does not test for these constraints since we do believe them to be essential.


makeVertexPathList

public final 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.

If the type of a node is MOVE, LINE, or CLOSE, then a copy of the node is inserted in the new list.

A node of the form QUAD[x1;y1;x2;y2] is replaced by a node LINE[x2;y2].

A node of the form CUBIC[x1;y1;x2;y2;x3;y3] is replaced by a node LINE[x3;y3].

If isPolygon() is true then this method just returns a copy of this path list.


makeBezierPathList

public final 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.

If the type of a node is MOVE, LINE, or CLOSE, then a copy of the node is inserted in the new list.

A node of the form QUAD[x1;y1;x2;y2] is replaced by 2 nodes LINE[x1;y1], LINE[x2;y2].

A node of the form CUBIC[x1;y1;x2;y2;x3;y3] is replaced by 3 nodes LINE[x1;y1], LINE[x2;y2], LINE[x3;y3].

If isPolygon() is true then this method just returns a copy of this path list.


makeVertexDotsPathList

public final 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.

If the type of a node is CLOSE, then the node is ignored.

A node of the form MOVE[x1;y1] or the form LINE[x1;y1] is replaced by 2 nodes MOVE[x1;y1], LINE[x1;y1].

A node of the form QUAD[x1;y1;x2;y2] is replaced by 2 nodes MOVE[x2;y2], LINE[x2;y2].

A node of the form CUBIC[x1;y1;x2;y2;x3;y3] is replaced by 2 nodes MOVE[x3;y3], LINE[x3;y3].


makeBezierDotsPathList

public final 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.

If the type of a node is CLOSE, then the node is ignored.

A node of the form MOVE[x1;y1] or the form LINE[x1;y1] is replaced by 2 nodes MOVE[x1;y1], LINE[x1;y1].

A node of the form QUAD[x1;y1;x2;y2] is replaced by 4 nodes MOVE[x1;y1], LINE[x1;y1], MOVE[x2;y2], LINE[x2;y2].

A node of the form CUBIC[x1;y1;x2;y2;x3;y3] is replaced by 6 nodes MOVE[x1;y1], LINE[x1;y1], MOVE[x2;y2], LINE[x2;y2], MOVE[x3;y3], LINE[x3;y3].


makeControlDotsPathList

public final 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.

If the type of a node is MOVE, LINE, or CLOSE, then the node is ignored.

A node of the form QUAD[x1;y1;x2;y2] is replaced by 2 nodes MOVE[x1;y1], LINE[x1;y1].

A node of the form CUBIC[x1;y1;x2;y2;x3;y3] is replaced by 4 nodes MOVE[x1;y1], LINE[x1;y1], MOVE[x2;y2], LINE[x2;y2].


makeVertexPathListIterator

public final PathListIterator makeVertexPathListIterator()
Returns a PathListIterator constructed from an instance of makeVertexPathList().


makeBezierPathListIterator

public final PathListIterator makeBezierPathListIterator()
Returns a PathListIterator constructed from an instance of makeBezierPathList().


makeVertexDotsPathListIterator

public final PathListIterator makeVertexDotsPathListIterator()
Returns a PathListIterator constructed from an instance of makeVertexDotsPathList().


makeBezierDotsPathListIterator

public final PathListIterator makeBezierDotsPathListIterator()
Returns a PathListIterator constructed from an instance of makeBezierDotsPathList().


makeControlDotsPathListIterator

public final PathListIterator makeControlDotsPathListIterator()
Returns a PathListIterator constructed from an instance of makeControlDotsPathList().


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.


makeVertexPoints

public final Point2D[] makeVertexPoints()

Returns a new Point2D[] whose points are built to include the vertex points of the path list by the following operations.

For a node of the form MOVE[x1;y1] or LINE[x1;y1], 1 point [x1;y1] is added to the array.

For a node of the form QUAD[x1;y1;x2;y2], 1 point [x2;y2] is added to the array.

For a node of the form CUBIC[x1;y1;x2;y2;x3;y3], 1 point [x3;y3] is added to the array.


makeBezierPoints

public final Point2D[] makeBezierPoints()

Returns a new Point2D[] whose points are built to include the bezier points of the path list by the following operations.

For a node of the form MOVE[x1;y1] or LINE[x1;y1], 1 point [x1;y1] is added to the array.

For a node of the form QUAD[x1;y1;x2;y2], 2 points [x1;y1], [x2;y2] are added to the array.

For a node of the form CUBIC[x1;y1;x2;y2;x3;y3], 3 points [x1;y1], [x2;y2], [x3;y3] are added to the array.


makeControlPoints

public final Point2D[] makeControlPoints()

Returns a new Point2D[] whose points are built to include the control points of the path list by the following operations.

For a node of the form QUAD[x1;y1;x2;y2], 1 point [x1;y1] is added to the array.

For a node of the form CUBIC[x1;y1;x2;y2;x3;y3], 2 points [x1;y1], [x2;y2] are added to the array.


makeVertexShape

public static Shape makeVertexShape(Shape shape)

Static method that returns the vertex shape corresponding to the given shape.

Current implementation: Use the shape to make a path list and then use the path list to make the associated vertex shape.

Parameters:
shape - the shape whose vertex shape is desired

makeBezierShape

public static Shape makeBezierShape(Shape shape)

Static method that returns the bezier shape corresponding to the given shape.

Current implementation: Use the shape to make a path list and then use the path list to make the associated bezier shape.

Parameters:
shape - the shape whose bezier shape is desired

makeVertexDotsShape

public static Shape makeVertexDotsShape(Shape shape)

Static method that returns the vertex dots shape corresponding to the given shape.

Current implementation: Use the shape to make a path list and then use the path list to make the associated vertex dots shape.

Parameters:
shape - the shape whose vertex dots shape is desired

makeBezierDotsShape

public static Shape makeBezierDotsShape(Shape shape)

Static method that returns the bezier dots shape corresponding to the given shape.

Current implementation: Use the shape to make a path list and then use the path list to make the associated bezier dots shape.

Parameters:
shape - the shape whose bezier dots shape is desired

makeControlDotsShape

public static Shape makeControlDotsShape(Shape shape)

Static method that returns the control dots shape corresponding to the given shape.

Current implementation: Use the shape to make a path list and then use the path list to make the associated control dots shape.

Parameters:
shape - the shape whose control dots shape is desired

makeVertexPoints

public static Point2D[] makeVertexPoints(Shape shape)

Static method that returns the vertex point array for the given shape.

Current implementation: Use the shape to make a path list and then use the path list to make the associated vertex point array.

Parameters:
shape - the shape whose vertex point array is desired

makeBezierPoints

public static Point2D[] makeBezierPoints(Shape shape)

Static method that returns the bezier point array for the given shape.

Current implementation: Use the shape to make a path list and then use the path list to make the associated bezier point array.

Parameters:
shape - the shape whose bezier point array is desired

makeControlPoints

public static Point2D[] makeControlPoints(Shape shape)

Static method that returns the control point array for the given shape.

Current implementation: Use the shape to make a path list and then use the path list to make the associated control point array.

Parameters:
shape - the shape whose control point array is desired

getShapePoint

public final float[] getShapePoint(float t)

Without actually constructing the shape, this function returns the mathematical point at float parameter t on the shape that would correspond to this path list.

Let us explain how the computation is done and what happens in boundary cases. For brevity, we use the notation [x;y] to stand for an internal data pair or for a return value of the form new float[] { x, y }.

Returns [0;0] if the size of this list is 0 or if isValid() is false.

Otherwise, for this discussion, let N = size() and M = N - 1.

First assume that t is an integer with 0 <= t <= M. What is returned at t depends on the t-th node in the path list.

If the t-th node is MOVE[x1;y1] or LINE[x1;y1], return [x1;y1].

If the t-th node is QUAD[x1;y1;x2;y2], return [x2;y2].

If the t-th node is CUBIC[x1;y1;x2;y2;x3;y3], return [x3;y3].

If the t-th node is CLOSE[], return [xc;yc] where [xc;yc] is the coordinate pair of the last previous MOVE operation in the path list.

We next give the out-of-bounds return values.

If t < 0, return the value for t = 0.

If t > M, return the value for t = M.

Finally assume that t = k + z where k is an integer and 0 < z < 1. Assume also that [x0,y0] is the coordinate pair of the point returned by this function at the integer k.

If the node at (k+1) is MOVE[x1;y1], return [x0;y0] since a move represents a discontinuous jump.

If the node at (k+1) is LINE[x1;y1], return the linear interpolation by z between [x0;y0] and [x1;y1]. The linear interpolation is defined by:

  (1-z)*[x0;y0] + z*[x1;y1]

If the node at (k+1) is QUAD[x1;y1;x2;y2], return the quadratic interpolation by z in the quadratic bezier arch [x0;y0;x1;y1;x2;y2].

If the node at (k+1) is CUBIC[x1;y1;x2;y2;x3;y3], return the cubic interpolation by z in the cubic bezier arch [x0;y0;x1;y1;x2;y2;x3;y3].

If the node at (k+1) is CLOSE[] return the linear interpolation by z between [x0;y0] and [xc;yc] where [xc;yc] is the coordinate pair of the last previous MOVE operation in the path list.

The Bezier polynomials defined in class Bezier are used to compute the x,y coordinates of the linear, quadratic, and cubic interpolations. See the comments in that class for more mathematical details.

Examination of the above algorithm reveals that we assume that the parameter interval for each node in the pathlist is of length 1. It is possible to assign a different parameter interval to each node but we have decided to stick with the simplest case in this method.

Parameters:
t - the parameter at which to a point on a shape

toString

public String toString()

Returns the data in this path list as a multi-line String.

The first line returned is one of the following two lines:

WIND_NON_ZERO
WIND_EVEN_ODD

The remaining lines give the PathNode information for each path node in the path list using the toString() method of that class.


toStringData

public String toStringData()
Returns the same String as toString().

Specified by:
toStringData in interface Stringable
See Also:
Stringable.fromStringData(String)

fromStringData

public void fromStringData(String data)
                    throws ParseException

Sets the data of this path list using String data in the format produced by toString().

Throws ParseException if the data is not in the correct format.

Specified by:
fromStringData in interface Stringable
Parameters:
data - the String with the list information
Throws:
ParseException
See Also:
Stringable.toStringData()

getPathNodeStateArray

public final String[] getPathNodeStateArray()

Returns a String with the value of the method toStringData applied to each item in the array returned by getPathNodes.


getWindingRuleString

public final String getWindingRuleString()

Returns a String with the winding rule information.

Returns one of:

WIND_NON_ZERO
WIND_EVEN_ODD


getWindingRuleFromStringData

public WindingRule getWindingRuleFromStringData(String data)
                                         throws ParseException

Returns the WindingRule that corresponds to the given String data.

The valid input data is:

WIND_NON_ZERO
WIND_EVEN_ODD

Throws ParseException if the winding rule data does not match either of the above strings.

Parameters:
data - the String with the winding rule
Throws:
ParseException

readDataFromFile

public final boolean readDataFromFile()

Opens a file dialog to get the file name of a text file with path list data and then reads the data.

Does nothing to the current list if errors occur.

Returns:
true if the operation succeeds

readDataFromFile

public final boolean readDataFromFile(File source,
                                      boolean displayErrorDialogs)

Reads the path list data from the given text file.

Does nothing to the current list if errors occur.

Parameters:
source - the data source
displayErrorDialogs - if true display error dialogs
Returns:
true if the operation succeeds

saveDataToFile

public final boolean saveDataToFile()

Opens a file dialog to get the file name of a text file and then saves the data to the file.

The current path list is unchanged.

Does nothing if errors occur.

Returns:
true if the operation succeeds

saveDataToFile

public final boolean saveDataToFile(File target,
                                    boolean displayErrorDialogs)

Saves the path list data to the given text file.

The current path list is unchanged.

Does nothing if errors occur.

Parameters:
target - the data target
displayErrorDialogs - if true display error dialogs
Returns:
true if the operation succeeds