edu.umd.cs.piccolox.nodes
Class PLine
java.lang.Object
edu.umd.cs.piccolo.PNode
edu.umd.cs.piccolox.nodes.PLine
- All Implemented Interfaces:
- java.awt.print.Printable, java.io.Serializable, java.lang.Cloneable
public class PLine
- extends PNode
PLine a class for drawing multisegment lines.
- Author:
- Hallvard Traetteberg.
- See Also:
- Serialized Form
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,
java.awt.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. |
java.awt.geom.Rectangle2D |
getLineBoundsWithStroke()
Calculates the bounds of the line taking stroke width into account. |
LineShape |
getLineReference()
Returns a reference to the underlying line shape. |
java.awt.geom.Point2D |
getPoint(int pointIndex,
java.awt.geom.Point2D dst)
Returns the point at the provided index. |
int |
getPointCount()
Returns the number of points in the line. |
java.awt.Stroke |
getStroke()
Returns the stroke that will be used when drawing the line. |
java.awt.Paint |
getStrokePaint()
Returns the paint to be used while drawing the line. |
boolean |
intersects(java.awt.geom.Rectangle2D aBounds)
Return true if this node intersects the given rectangle specified in
local bounds. |
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)
Set the bounds of this node to the given position and size. |
void |
setPoint(int pointIndex,
double x,
double y)
Changes the point at the provided index. |
void |
setStroke(java.awt.Stroke newStroke)
Sets stroke to use when drawing the line. |
void |
setStrokePaint(java.awt.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 |
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,
java.awt.Stroke aStroke)
- Constructs a PLine for the given lineShape and the given stroke.
- Parameters:
line
- line to be wrapped by this PLineaStroke
- stroke to use when drawling the line
getStrokePaint
public java.awt.Paint getStrokePaint()
- Returns the paint to be used while drawing the line.
- Returns:
- paint used when drawing the line
setStrokePaint
public void setStrokePaint(java.awt.Paint newStrokePaint)
- Changes the paint to be used while drawing the line.
- Parameters:
newStrokePaint
- paint to use when drawing the line
getStroke
public java.awt.Stroke getStroke()
- Returns the stroke that will be used when drawing the line.
- Returns:
- stroke used to draw the line
setStroke
public void setStroke(java.awt.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)
- Set the bounds of this node to the given position and size. These bounds
are stored in the local coordinate system of this node.
If the width or height is less then or equal to zero then the bound's
empty bit will be set to true.
Subclasses must call the super.setBounds() method.
- Overrides:
setBounds
in class PNode
- Parameters:
x
- x position of boundsy
- y position of boundswidth
- width to apply to the boundsheight
- height to apply to the bounds
- Returns:
- true if the bounds changed.
intersects
public boolean intersects(java.awt.geom.Rectangle2D aBounds)
- Return true if this node intersects the given rectangle specified in
local bounds. If the geometry of this node is complex this method can
become expensive, it is therefore recommended that
fullIntersects
is used for quick rejects before calling this
method.
- Overrides:
intersects
in class PNode
- Parameters:
aBounds
- the bounds to test for intersection against
- Returns:
- true if the given rectangle intersects this nodes geometry.
getLineBoundsWithStroke
public java.awt.geom.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 java.awt.geom.Point2D getPoint(int pointIndex,
java.awt.geom.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 linedst
- 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 changex
- x component to assign to the pointy
- 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 pointx
- x component of new pointy
- 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 pointsnumberOfPoints
- number of points to remove
removeAllPoints
public void removeAllPoints()
- Removes all points from the underlying line.
Copyright © 1995-2011 Piccolo2D. All Rights Reserved.