edu.umd.cs.piccolox.nodes
Class PLine

java.lang.Object
  extended by edu.umd.cs.piccolo.PNode
      extended by edu.umd.cs.piccolox.nodes.PLine
All Implemented Interfaces:
Printable, Serializable, Cloneable

public class PLine
extends PNode

PLine a class for drawing multisegment lines.

Author:
Hallvard Traetteberg.
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class edu.umd.cs.piccolo.PNode
PNode.PSceneGraphDelegate
 
Field Summary
 
Fields inherited from class edu.umd.cs.piccolo.PNode
FILL_STRATEGY_ASPECT_COVER, FILL_STRATEGY_ASPECT_FIT, FILL_STRATEGY_EXACT_FIT, PROPERTY_BOUNDS, PROPERTY_CHILDREN, PROPERTY_CHILDREN_PICKABLE, PROPERTY_CLIENT_PROPERTIES, PROPERTY_CODE_BOUNDS, PROPERTY_CODE_CHILDREN, PROPERTY_CODE_CHILDREN_PICKABLE, PROPERTY_CODE_CLIENT_PROPERTIES, PROPERTY_CODE_FULL_BOUNDS, PROPERTY_CODE_PAINT, PROPERTY_CODE_PARENT, PROPERTY_CODE_PICKABLE, PROPERTY_CODE_TRANSFORM, PROPERTY_CODE_TRANSPARENCY, PROPERTY_CODE_VISIBLE, PROPERTY_FULL_BOUNDS, PROPERTY_PAINT, PROPERTY_PARENT, PROPERTY_PICKABLE, PROPERTY_TRANSFORM, PROPERTY_TRANSPARENCY, PROPERTY_VISIBLE, SCENE_GRAPH_DELEGATE
 
Fields inherited from interface java.awt.print.Printable
NO_SUCH_PAGE, PAGE_EXISTS
 
Constructor Summary
PLine()
          Constructs a new PLine with an empty LineShape.
PLine(LineShape lineShape)
          Constructs a PLine object for displaying the provided line.
PLine(LineShape line, Stroke aStroke)
          Constructs a PLine for the given lineShape and the given stroke.
 
Method Summary
 void addPoint(int pointIndex, double x, double y)
          Inserts a point at the provided index.
 Rectangle2D getLineBoundsWithStroke()
          Calculates the bounds of the line taking stroke width into account.
 LineShape getLineReference()
          Returns a reference to the underlying line shape.
 Point2D getPoint(int pointIndex, Point2D dst)
          Returns the point at the provided index.
 int getPointCount()
          Returns the number of points in the line.
 Stroke getStroke()
          Returns the stroke that will be used when drawing the line.
 Paint getStrokePaint()
          Returns the paint to be used while drawing the line.
 boolean intersects(Rectangle2D aBounds)
          
protected  void lineChanged()
          Fires appropriate change events, updates line bounds and flags the PLine as requiring a repaint.
protected  void paint(PPaintContext paintContext)
          Paints the PLine in the provided context if it has both a stroke and a stroke paint assigned.
 void removeAllPoints()
          Removes all points from the underlying line.
 void removePoints(int startIndex, int numberOfPoints)
          Removes points from the line.
 boolean setBounds(double x, double y, double width, double height)
          
 void setPoint(int pointIndex, double x, double y)
          Changes the point at the provided index.
 void setStroke(Stroke newStroke)
          Sets stroke to use when drawing the line.
 void setStrokePaint(Paint newStrokePaint)
          Changes the paint to be used while drawing the line.
 void updateBoundsFromLine()
          Recalculates the bounds when a change to the underlying line occurs.
 
Methods inherited from class edu.umd.cs.piccolo.PNode
addActivity, addAttribute, addChild, addChild, addChildren, addClientProperty, addInputEventListener, addPropertyChangeListener, addPropertyChangeListener, animateToBounds, animateToColor, animateToPositionScaleRotation, animateToRelativePosition, animateToTransform, animateToTransparency, animateTransformToBounds, centerBoundsOnPoint, centerFullBoundsOnPoint, clone, computeFullBounds, endResizeBounds, findIntersectingNodes, fireChildPropertyChange, firePropertyChange, fullIntersects, fullPaint, fullPick, getAllNodes, getAllNodes, getAttribute, getAttribute, getBooleanAttribute, getBounds, getBoundsChanged, getBoundsReference, getBoundsVolatile, getChild, getChildBoundsInvalid, getChildBoundsVolatile, getChildPaintInvalid, getChildrenCount, getChildrenIterator, getChildrenPickable, getChildrenReference, getClientProperties, getClientProperty, getClientPropertyKeysEnumeration, getClientPropertyKeysIterator, getDoubleAttribute, getFullBounds, getFullBoundsInvalid, getFullBoundsReference, getGlobalBounds, getGlobalFullBounds, getGlobalRotation, getGlobalScale, getGlobalToLocalTransform, getGlobalTranslation, getHeight, getInputEventListeners, getIntegerAttribute, getInverseTransform, getListenerList, getLocalToGlobalTransform, getName, getOccluded, getOffset, getPaint, getPaintInvalid, getParent, getPickable, getPropertyChangeParentMask, getRoot, getRotation, getScale, getTransform, getTransformReference, getTransparency, getUnionOfChildrenBounds, getVisible, getWidth, getX, getXOffset, getY, getYOffset, globalToLocal, globalToLocal, globalToLocal, indexOfChild, internalUpdateBounds, invalidateFullBounds, invalidateLayout, invalidatePaint, isAncestorOf, isDescendentOf, isDescendentOfRoot, isOpaque, layoutChildren, lerp, localToGlobal, localToGlobal, localToGlobal, localToParent, localToParent, localToParent, moveInBackOf, moveInFrontOf, moveToBack, moveToFront, offset, paintAfterChildren, paramString, parentBoundsChanged, parentToLocal, parentToLocal, parentToLocal, pick, pickAfterChildren, position, print, print, removeAllChildren, removeChild, removeChild, removeChildren, removeFromParent, removeInputEventListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaintFrom, reparent, replaceWith, resetBounds, rotate, rotateAboutPoint, rotateAboutPoint, rotateInPlace, scale, scaleAboutPoint, scaleAboutPoint, setBounds, setBoundsChanged, setChildBoundsInvalid, setChildBoundsVolatile, setChildPaintInvalid, setChildrenPickable, setFullBoundsInvalid, setGlobalRotation, setGlobalScale, setGlobalTranslation, setHeight, setName, setOccluded, setOffset, setOffset, setPaint, setPaintInvalid, setParent, setPickable, setPropertyChangeParentMask, setRotation, setScale, setTransform, setTransparency, setVisible, setWidth, setX, setY, signalBoundsChanged, startResizeBounds, toImage, toImage, toImage, toImage, transformBy, translate, validateFullBounds, validateFullPaint
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PLine

public PLine()
Constructs a new PLine with an empty LineShape.


PLine

public PLine(LineShape lineShape)
Constructs a PLine object for displaying the provided line.

Parameters:
lineShape - will be displayed by this PLine

PLine

public PLine(LineShape line,
             Stroke aStroke)
Constructs a PLine for the given lineShape and the given stroke.

Parameters:
line - line to be wrapped by this PLine
aStroke - stroke to use when drawling the line
Method Detail

getStrokePaint

public Paint getStrokePaint()
Returns the paint to be used while drawing the line.

Returns:
paint used when drawing the line

setStrokePaint

public void setStrokePaint(Paint newStrokePaint)
Changes the paint to be used while drawing the line.

Parameters:
newStrokePaint - paint to use when drawing the line

getStroke

public Stroke getStroke()
Returns the stroke that will be used when drawing the line.

Returns:
stroke used to draw the line

setStroke

public void setStroke(Stroke newStroke)
Sets stroke to use when drawing the line.

Parameters:
newStroke - stroke to use when drawing the line

setBounds

public boolean setBounds(double x,
                         double y,
                         double width,
                         double height)

Overrides:
setBounds in class PNode

intersects

public boolean intersects(Rectangle2D aBounds)

Overrides:
intersects in class PNode

getLineBoundsWithStroke

public Rectangle2D getLineBoundsWithStroke()
Calculates the bounds of the line taking stroke width into account.

Returns:
rectangle representing the bounds of the line taking stroke width into account

updateBoundsFromLine

public void updateBoundsFromLine()
Recalculates the bounds when a change to the underlying line occurs.


paint

protected void paint(PPaintContext paintContext)
Paints the PLine in the provided context if it has both a stroke and a stroke paint assigned.

Overrides:
paint in class PNode
Parameters:
paintContext - the context into which the line should be drawn

getLineReference

public LineShape getLineReference()
Returns a reference to the underlying line shape. Be careful!

Returns:
direct reference to the underlying line shape

getPointCount

public int getPointCount()
Returns the number of points in the line.

Returns:
number of points in the line

getPoint

public Point2D getPoint(int pointIndex,
                        Point2D dst)
Returns the point at the provided index. If dst is not null, it will populate it with the point's coordinates rather than create a new point.

Parameters:
pointIndex - index of desired point in line
dst - point to populate, may be null
Returns:
the desired point, or dst populate with its coordinates

lineChanged

protected void lineChanged()
Fires appropriate change events, updates line bounds and flags the PLine as requiring a repaint.


setPoint

public void setPoint(int pointIndex,
                     double x,
                     double y)
Changes the point at the provided index.

Parameters:
pointIndex - index of point to change
x - x component to assign to the point
y - y component to assign to the point

addPoint

public void addPoint(int pointIndex,
                     double x,
                     double y)
Inserts a point at the provided index.

Parameters:
pointIndex - index at which to add the point
x - x component of new point
y - y component of new point

removePoints

public void removePoints(int startIndex,
                         int numberOfPoints)
Removes points from the line.

Parameters:
startIndex - index from which to remove the points
numberOfPoints - number of points to remove

removeAllPoints

public void removeAllPoints()
Removes all points from the underlying line.



Copyright © 1995-2010 Piccolo2D. All Rights Reserved.