edu.umd.cs.piccolox.swt
Class PSWTBoundsHandle

java.lang.Object
  extended by edu.umd.cs.piccolo.PNode
      extended by edu.umd.cs.piccolox.swt.PSWTPath
          extended by edu.umd.cs.piccolox.swt.PSWTHandle
              extended by edu.umd.cs.piccolox.swt.PSWTBoundsHandle
All Implemented Interfaces:
java.awt.print.Printable, java.io.Serializable, java.lang.Cloneable

public class PSWTBoundsHandle
extends PSWTHandle

PSWTBoundsHandle a handle for resizing the bounds of another node. If a bounds handle is dragged such that the other node's width or height becomes negative then the each drag handle's locator assciated with that other node is "flipped" so that they are attached to and dragging a different corner of the nodes bounds.

Version:
1.0
Author:
Jesse Grosjean
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.piccolox.swt.PSWTHandle
DEFAULT_COLOR, DEFAULT_HANDLE_SHAPE, DEFAULT_HANDLE_SIZE
 
Fields inherited from class edu.umd.cs.piccolox.swt.PSWTPath
PROPERTY_SHAPE
 
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
PSWTBoundsHandle(PBoundsLocator locator)
          Creates a bounds handle that will use the provided bounds locator to position itself.
 
Method Summary
static void addBoundsHandlesTo(PNode node)
          Adds bounds handles to all corners and edges of the provided node.
static void addStickyBoundsHandlesTo(PNode node, PCamera camera)
          Adds sticky bounds handles to all corners and edges of the provided node and for display on the provided camera.
 void dragHandle(PDimension aLocalDimension, PInputEvent aEvent)
          Callback invoked when the user is dragging the handle.
 void endHandleDrag(java.awt.geom.Point2D aLocalPoint, PInputEvent aEvent)
          Callback invoked when the handle stops being dragged.
 void flipHandleIfNeeded(boolean flipX, boolean flipY)
          Flips this particular handle around if needed.
 void flipSiblingBoundsHandles(boolean flipX, boolean flipY)
          Iterates over all of this node's handles flipping them if necessary.
 java.awt.Cursor getCursorFor(int side)
          Returns an appropriate cursor to display when the mouse is over a handle on the side provided.
 PBasicInputEventHandler getHandleCursorEventHandler()
          Return the event handler that is responsible for setting the mouse cursor when it enters/exits this handle.
protected  void installHandleEventHandlers()
          Installs handlers responsible for updating the attached node's bounds and for updating the cursor when the mous enters a handle.
static void removeBoundsHandlesFrom(PNode node)
          Removes all bounds handles from the specified node.
 void startHandleDrag(java.awt.geom.Point2D aLocalPoint, PInputEvent aEvent)
          Callback invoked when the user has started to drag a handle.
 
Methods inherited from class edu.umd.cs.piccolox.swt.PSWTHandle
getHandleDraggerHandler, getLocator, parentBoundsChanged, relocateHandle, setLocator, setParent
 
Methods inherited from class edu.umd.cs.piccolox.swt.PSWTPath
cloneShape, createEllipse, createPolyline, createPolyline, createRectangle, createRoundRectangle, getCenter, getStrokePaint, internalUpdateBounds, intersects, paint, setPathToEllipse, setPathToPolyline, setPathToPolyline, setPathToRectangle, setPathToRoundRectangle, setShape, setStrokeColor, updateBoundsFromPath, updateShapePoints
 
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, invalidateFullBounds, invalidateLayout, invalidatePaint, isAncestorOf, isDescendentOf, isDescendentOfRoot, isOpaque, layoutChildren, lerp, localToGlobal, localToGlobal, localToGlobal, localToParent, localToParent, localToParent, moveInBackOf, moveInFrontOf, moveToBack, moveToFront, offset, paintAfterChildren, paramString, 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, setBounds, setBoundsChanged, setChildBoundsInvalid, setChildBoundsVolatile, setChildPaintInvalid, setChildrenPickable, setFullBoundsInvalid, setGlobalRotation, setGlobalScale, setGlobalTranslation, setHeight, setName, setOccluded, setOffset, setOffset, setPaint, setPaintInvalid, 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

PSWTBoundsHandle

public PSWTBoundsHandle(PBoundsLocator locator)
Creates a bounds handle that will use the provided bounds locator to position itself.

Parameters:
locator - locator to use when positioning this handle
Method Detail

addBoundsHandlesTo

public static void addBoundsHandlesTo(PNode node)
Adds bounds handles to all corners and edges of the provided node.

Parameters:
node - to decorate with bounds handles.

addStickyBoundsHandlesTo

public static void addStickyBoundsHandlesTo(PNode node,
                                            PCamera camera)
Adds sticky bounds handles to all corners and edges of the provided node and for display on the provided camera.

Parameters:
node - to decorate with bounds handles.
camera - camera onto which the handles should be stuck

removeBoundsHandlesFrom

public static void removeBoundsHandlesFrom(PNode node)
Removes all bounds handles from the specified node.

Parameters:
node - node from which to remove bounds handles

installHandleEventHandlers

protected void installHandleEventHandlers()
Installs handlers responsible for updating the attached node's bounds and for updating the cursor when the mous enters a handle.

Overrides:
installHandleEventHandlers in class PSWTHandle

getHandleCursorEventHandler

public PBasicInputEventHandler getHandleCursorEventHandler()
Return the event handler that is responsible for setting the mouse cursor when it enters/exits this handle.

Returns:
handler responsible for keeping the mouse cursor up to date

startHandleDrag

public void startHandleDrag(java.awt.geom.Point2D aLocalPoint,
                            PInputEvent aEvent)
Callback invoked when the user has started to drag a handle.

Overrides:
startHandleDrag in class PSWTHandle
Parameters:
aLocalPoint - point in the handle's coordinate system at which the drag was started
aEvent - Piccolo2d Event representing the start of the drag

dragHandle

public void dragHandle(PDimension aLocalDimension,
                       PInputEvent aEvent)
Callback invoked when the user is dragging the handle. Updates the associated node appropriately.

Overrides:
dragHandle in class PSWTHandle
Parameters:
aLocalDimension - magnitude of drag in the handle's coordinate system
aEvent - Piccolo2d Event representing the start of the drag

endHandleDrag

public void endHandleDrag(java.awt.geom.Point2D aLocalPoint,
                          PInputEvent aEvent)
Callback invoked when the handle stops being dragged.

Overrides:
endHandleDrag in class PSWTHandle
Parameters:
aLocalPoint - point in the handle's coordinate system at which the drag was stopped
aEvent - Piccolo2d Event representing the stop of the drag

flipSiblingBoundsHandles

public void flipSiblingBoundsHandles(boolean flipX,
                                     boolean flipY)
Iterates over all of this node's handles flipping them if necessary. This is needed since a node can become inverted when it's width or height becomes negative.

Parameters:
flipX - whether to allow flipping in the horizontal direction
flipY - whether to allow flipping in the vertical direction

flipHandleIfNeeded

public void flipHandleIfNeeded(boolean flipX,
                               boolean flipY)
Flips this particular handle around if needed. This is necessary since a node can become inverted when it's width or height becomes negative.

Parameters:
flipX - whether to allow flipping in the horizontal direction
flipY - whether to allow flipping in the vertical direction

getCursorFor

public java.awt.Cursor getCursorFor(int side)
Returns an appropriate cursor to display when the mouse is over a handle on the side provided.

Parameters:
side - value from SwingConstants
Returns:
Appropriate cursor, or null if no appropriate cursor can be found


Copyright © 1995-2011 Piccolo2D. All Rights Reserved.