edu.umd.cs.piccolox.swing
Class SwingLayoutNode

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

public class SwingLayoutNode
extends PNode

Uses Swing layout managers to position PNodes.

Author:
Sam Reid, Chris Malley (cmalley@pixelzoom.com)
See Also:
Serialized Form

Nested Class Summary
static interface SwingLayoutNode.Anchor
          Determines where nodes are anchored in the area allocated by the Swing layout manager.
 
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
SwingLayoutNode()
          Construct a SwingLayoutNode that uses FlowLayout.
SwingLayoutNode(Container container)
          Constructs a SwingLayoutNode that lays out its children as though they were children of the provided Container.
SwingLayoutNode(LayoutManager layoutManager)
          Constructs a SwingLayoutNode that uses the provided LayoutManager to layout its children.
 
Method Summary
 void addChild(int index, PNode child)
          
 void addChild(int index, PNode child, Object constraints)
          Adds a child at the specified index.
 void addChild(int index, PNode child, Object constraints, SwingLayoutNode.Anchor childAnchor)
          Adds a child at the specified index.
 void addChild(int index, PNode child, SwingLayoutNode.Anchor anchor)
          Adds a child at the specified index.
 void addChild(PNode child)
          Adds a child to the end of the node list.
 void addChild(PNode child, Object constraints)
          Adds a child to the end of the node list and specifies the given constraints.
 void addChild(PNode child, Object constraints, SwingLayoutNode.Anchor anchor)
          Adds a child to the end of the node list.
 void addChild(PNode child, SwingLayoutNode.Anchor anchor)
          Adds a child to the end of the node list.
 void addChildren(Collection nodes)
          
 void addChildren(Collection nodes, Object constraints)
          Adds a collection of nodes to the end of the list.
 void addChildren(Collection nodes, Object constraints, SwingLayoutNode.Anchor anchor)
          Adds a collection of nodes to the end of the list.
 void addChildren(Collection nodes, SwingLayoutNode.Anchor anchor)
          Adds a collection of nodes to the end of the list.
 SwingLayoutNode.Anchor getAnchor()
          Returns the anchor being used by this LayoutManager.
 Container getContainer()
          Some Swing layout managers (like BoxLayout) require a reference to the proxy Container.
 void removeAllChildren()
          PNode.removeAllChildren does not call removeChild, it manipulates an internal data structure.
 PNode removeChild(int index)
          Removes a node at a specified index.
 void setAnchor(SwingLayoutNode.Anchor anchor)
          Sets the default anchor.
 
Methods inherited from class edu.umd.cs.piccolo.PNode
addActivity, addAttribute, 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, intersects, invalidateFullBounds, invalidateLayout, invalidatePaint, isAncestorOf, isDescendentOf, isDescendentOfRoot, isOpaque, layoutChildren, lerp, localToGlobal, localToGlobal, localToGlobal, localToParent, localToParent, localToParent, moveInBackOf, moveInFrontOf, moveToBack, moveToFront, offset, paint, paintAfterChildren, paramString, parentBoundsChanged, parentToLocal, parentToLocal, parentToLocal, pick, pickAfterChildren, position, print, print, 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, 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

SwingLayoutNode

public SwingLayoutNode()
Construct a SwingLayoutNode that uses FlowLayout.


SwingLayoutNode

public SwingLayoutNode(LayoutManager layoutManager)
Constructs a SwingLayoutNode that uses the provided LayoutManager to layout its children.

Parameters:
layoutManager - LayoutManager to use for laying out children. Must not be null.

SwingLayoutNode

public SwingLayoutNode(Container container)
Constructs a SwingLayoutNode that lays out its children as though they were children of the provided Container. Whatever LayoutManager is being used by the container will be used when laying out nodes.

Parameters:
container - Container in which child nodes will effectively be laid out
Method Detail

setAnchor

public void setAnchor(SwingLayoutNode.Anchor anchor)
Sets the default anchor. If no anchor is specified when a node is added, then the default anchor determines where the node is positioned in the space allocated by the Swing layout manager.

Parameters:
anchor - anchor to use when a node is added but its anchor is not specified

getAnchor

public SwingLayoutNode.Anchor getAnchor()
Returns the anchor being used by this LayoutManager.

Returns:
anchor currently being used when laying out children.

getContainer

public Container getContainer()
Some Swing layout managers (like BoxLayout) require a reference to the proxy Container. For example: SwingLayoutNode layoutNode = new SwingLayoutNode(); layoutNode.setLayout( new BoxLayout( layoutNode.getContainer(), BoxLayout.Y_AXIS ) );

Returns:
container in which children will logically be laid out in

addChild

public void addChild(int index,
                     PNode child,
                     Object constraints,
                     SwingLayoutNode.Anchor childAnchor)
Adds a child at the specified index. Like Swing, bad things can happen if the type of the constraints isn't compatible with the layout manager.

Parameters:
index - 0 based index at which to add the child
child - child to be added
constraints - constraints the layout manager uses when laying out the child
childAnchor - specifies the location from which layout takes place

addChild

public void addChild(int index,
                     PNode child)

Overrides:
addChild in class PNode

addChild

public void addChild(int index,
                     PNode child,
                     Object constraints)
Adds a child at the specified index. Like Swing, bad things can happen if the type of the constraints isn't compatible with the layout manager.

Parameters:
index - 0 based index at which to add the child
child - child to be added
constraints - constraints the layout manager uses when laying out the child

addChild

public void addChild(int index,
                     PNode child,
                     SwingLayoutNode.Anchor anchor)
Adds a child at the specified index.

Parameters:
index - 0 based index at which to add the child
child - child to be added
anchor - specifies the location from which layout takes place

addChild

public void addChild(PNode child,
                     Object constraints,
                     SwingLayoutNode.Anchor anchor)
Adds a child to the end of the node list.

Parameters:
child - child to be added
constraints - constraints the layout manager uses when laying out the child
anchor - specifies the location from which layout takes place

addChild

public void addChild(PNode child)
Adds a child to the end of the node list.

Overrides:
addChild in class PNode
Parameters:
child - child to be added

addChild

public void addChild(PNode child,
                     Object constraints)
Adds a child to the end of the node list and specifies the given constraints.

Parameters:
child - child to be added
constraints - constraints the layout manager uses when laying out the child

addChild

public void addChild(PNode child,
                     SwingLayoutNode.Anchor anchor)
Adds a child to the end of the node list.

Parameters:
child - child to be added
anchor - specifies the location from which layout takes place

addChildren

public void addChildren(Collection nodes,
                        Object constraints,
                        SwingLayoutNode.Anchor anchor)
Adds a collection of nodes to the end of the list.

Parameters:
nodes - nodes to add to the end of the list
constraints - constraints the layout manager uses when laying out the child
anchor - specifies the location from which layout takes place

addChildren

public void addChildren(Collection nodes)

Overrides:
addChildren in class PNode

addChildren

public void addChildren(Collection nodes,
                        Object constraints)
Adds a collection of nodes to the end of the list.

Parameters:
nodes - nodes to add to the end of the list
constraints - constraints the layout manager uses when laying out the child

addChildren

public void addChildren(Collection nodes,
                        SwingLayoutNode.Anchor anchor)
Adds a collection of nodes to the end of the list.

Parameters:
nodes - nodes to add to the end of the list
anchor - specifies the location from which layout takes place

removeChild

public PNode removeChild(int index)
Removes a node at a specified index.

Overrides:
removeChild in class PNode
Parameters:
index - 0 based index of the child to be removed

removeAllChildren

public void removeAllChildren()
PNode.removeAllChildren does not call removeChild, it manipulates an internal data structure. So we must override this in a more careful (and less efficient) manner.

Overrides:
removeAllChildren in class PNode


Copyright © 1995-2010 Piccolo2D. All Rights Reserved.