edu.neu.ccs.gui
Class BaseVertexShape

java.lang.Object
  extended byedu.neu.ccs.gui.BaseShape
      extended byedu.neu.ccs.gui.BaseVertexShape
All Implemented Interfaces:
Shape, SupportsPropertyChange
Direct Known Subclasses:
AutomaticShape, PolygonDotsShape, PolygonShape

public class BaseVertexShape
extends BaseShape

Class BaseVertexShape extends BaseShape to provide the common functionality for those classes that either do not use the tangent data of BaseShape or compute the tangent data automatically from the vertex data and other internal settings.

Class BaseVertexShape contains the common code for the derived classes:

Class BaseVertexShape may not be instantiated directly since it does not have a public constructor.

If a derived class computes tangents automatically then this must be done by overriding the method makePath() that is inherited from BaseShape. See the documentation in that class for instructions on how to do the override.

Since:
2.4.0
Version:
2.4.0

Field Summary
static String ADD_VERTEX
          Bound property name to add one or more vertices.
static String REMOVE_VERTEX
          Bound property name to remove one or more vertices.
static String SET_VERTEX
          Bound property name to set one or more vertices.
 
Fields inherited from class edu.neu.ccs.gui.BaseShape
REMOVE_SHAPE_DATA, SET_CLOSURE_MODE, SET_PATH_STRATEGY, SET_WINDING_RULE, tangent, vertex
 
Constructor Summary
protected BaseVertexShape()
          The protected default constructor.
 
Method Summary
 void addVertex(int index, float[] point)
          Adds a new vertex at the given index with a clone of the given point and makes a new path.
 void addVertex(int index, float x, float y)
          Adds a new vertex at the given index with the given point coordinates and makes a new path.
 void addVertices(int index, float[][] points)
          Adds a new sequence of vertices at the given index using clones of the given points and makes a new path.
 void appendVertex(float[] point)
          Appends a new vertex with a clone of the given point and makes a new path.
 void appendVertex(float x, float y)
          Appends a new vertex with the given point coordinates and makes a new path.
 void appendVertices(int index, float[][] points)
          Appends a new sequence of vertices using clones of the given points and makes a new path.
 float[][] removeAllVertices()
          Removes all vertices, makes a new path, and returns an array with the vertices removed.
 float[] removeVertex(int index)
          Removes the vertex at the given index, makes a new path, and returns the vertex removed.
 float[][] removeVertices(int m, int n)
          Removes the vertices starting at the given index m inclusive and ending at the given index n exclusive, makes a new path, and returns an array with the vertices removed.
 void setVertex(int index, float[] point)
          Sets the vertex at the given index to a clone of the given point and makes a new path.
 void setVertex(int index, float x, float y)
          Sets the vertex at the given index to the given point coordinates and makes a new path.
 void setVertexData(float[][] vertex)
          Sets the vertex data of the shape using a 2-dimensional array of single precision numbers and makes a new path.
 
Methods inherited from class edu.neu.ccs.gui.BaseShape
addForwardingListener, addPropertyChangeListener, addPropertyChangeListener, addPropertyChangeListeners, addPropertyChangeListeners, bezierTangentSegmentPoints, closedBezierControlPoints, closedBezierFramePoints, contains, contains, contains, contains, findControlA, findControlA, findControlB, findControlB, findVertex, findVertex, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAX, getAY, getBezierTangentSegmentData, getBounds, getBounds2D, getBX, getBY, getClosedBezierControlData, getClosedBezierFrameData, getClosureMode, getControlA, getControlB, getCubicCurvePoint, getForwardingListener, getOpenBezierControlData, getOpenBezierFrameData, getPath, getPathIterator, getPathIterator, getPathStrategy, getPolygonPoint, getPropertyChangeListeners, getPropertyChangeListeners, getTangent, getTangentData, getTransformedShape, getTransformedShape, getTX, getTY, getVertex, getVertexData, getVertexTangent, getVertexTangentData, getVX, getVY, getWindingRule, hasListeners, intersects, intersects, isTangentNull, length, makeBezierTangentSegments, makeClosedBezierFrame, makeClosedControlDots, makeClosedPolygon, makeOpenBezierFrame, makeOpenControlDots, makeOpenPolygon, makePath, makePolygonDots, openBezierControlPoints, openBezierFramePoints, removeAndAddForwardingListener, removeForwardingListener, removePropertyChangeListener, removePropertyChangeListener, removeShapeData, setClosureMode, setPathStrategy, setWindingRule, setWindingRule
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SET_VERTEX

public static final String SET_VERTEX
Bound property name to set one or more vertices.

See Also:
Constant Field Values

ADD_VERTEX

public static final String ADD_VERTEX
Bound property name to add one or more vertices.

See Also:
Constant Field Values

REMOVE_VERTEX

public static final String REMOVE_VERTEX
Bound property name to remove one or more vertices.

See Also:
Constant Field Values
Constructor Detail

BaseVertexShape

protected BaseVertexShape()
The protected default constructor.

Method Detail

setVertexData

public final void setVertexData(float[][] vertex)

Sets the vertex data of the shape using a 2-dimensional array of single precision numbers and makes a new path.

Preconditions:

If the given vertex array is null then the internal vertex array is set to float[0][2].

Does nothing if the precondition fails.

Fires property change: SET_VERTEX.

Parameters:
vertex - the vertex data to set

setVertex

public final void setVertex(int index,
                            float x,
                            float y)

Sets the vertex at the given index to the given point coordinates and makes a new path.

Does nothing if the index is not in [0, length()).

Fires property change: SET_VERTEX.

Parameters:
index - the vertex index
x - the new x-coordinate for the vertex
y - the new y-coordinate for the vertex

setVertex

public final void setVertex(int index,
                            float[] point)

Sets the vertex at the given index to a clone of the given point and makes a new path.

Does nothing if the index is not in [0, length()).

Does nothing if point is not float[2].

Fires property change: SET_VERTEX.

Parameters:
index - the vertex index
point - the new point for the vertex at the given index

addVertex

public final void addVertex(int index,
                            float x,
                            float y)

Adds a new vertex at the given index with the given point coordinates and makes a new path.

If index is 0, the insertion is at the front.

If index is length(), the insertion is at the end.

Forces the given index into the range:

  0 <= index <= length()

Fires property change: ADD_VERTEX.

Parameters:
index - the vertex index
x - the x-coordinate for the new vertex to add
y - the y-coordinate for the new vertex to add

addVertex

public final void addVertex(int index,
                            float[] point)

Adds a new vertex at the given index with a clone of the given point and makes a new path.

If index is 0, the insertion is at the front.

If index is length(), the insertion is at the end.

Forces the given index into the range:

    0 <= index <= length()

Fires property change: ADD_VERTEX.

Parameters:
index - the vertex index
point - the new vertex to add

addVertices

public final void addVertices(int index,
                              float[][] points)

Adds a new sequence of vertices at the given index using clones of the given points and makes a new path.

If index is 0, the insertion is at the front.

If index is length(), the insertion is at the end.

Forces the given index into the range:

  0 <= index <= length()

Does nothing if the given array is null or does not have the form float[K][2].

Fires property change: ADD_VERTEX.

Parameters:
index - the start index
points - the new vertices to add

appendVertex

public final void appendVertex(float x,
                               float y)

Appends a new vertex with the given point coordinates and makes a new path.

Fires property change: ADD_VERTEX.

Parameters:
x - the x-coordinate for the new vertex to append
y - the y-coordinate for the new vertex to append

appendVertex

public final void appendVertex(float[] point)

Appends a new vertex with a clone of the given point and makes a new path.

Fires property change: ADD_VERTEX.

Parameters:
point - the new vertex to append

appendVertices

public final void appendVertices(int index,
                                 float[][] points)

Appends a new sequence of vertices using clones of the given points and makes a new path.

Does nothing if the given array is null or does not have the form float[K][2].

Fires property change: ADD_VERTEX.

Parameters:
points - the new vertices to append

removeVertex

public final float[] removeVertex(int index)

Removes the vertex at the given index, makes a new path, and returns the vertex removed.

If the index is not in [0, length()), no vertex is removed and null is returned.

Fires property change: REMOVE_VERTEX.

Parameters:
index - the vertex index

removeVertices

public final float[][] removeVertices(int m,
                                      int n)

Removes the vertices starting at the given index m inclusive and ending at the given index n exclusive, makes a new path, and returns an array with the vertices removed.

Forces m and n into range if needed.

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

Fires property change: REMOVE_VERTEX.

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

removeAllVertices

public final float[][] removeAllVertices()

Removes all vertices, makes a new path, and returns an array with the vertices removed.

Fires property change: REMOVE_VERTEX.