edu.umd.cs.jazz.scenegraph
Class ZVisualComponentDecorator

java.lang.Object
  |
  +--edu.umd.cs.jazz.scenegraph.ZVisualComponent
        |
        +--edu.umd.cs.jazz.scenegraph.ZVisualComponentDecorator
Direct Known Subclasses:
ZConstraintDecorator, ZLinkDecorator, ZSelectionDecorator

public class ZVisualComponentDecorator
extends ZVisualComponent
implements ZHasChild, ZSerializable

ZVisualComponentDecorator is the base class used to create a visual component decorator. Normally, a node has a single visual component. However, with the use of this class, it is possible to form a linear chain of visual components. Typically the last element of the chain represents the primary visual component that gets drawn, and all the other elements of the chain are decorators that somehow modify the primary visual component. Two standard decorators that are part of Jazz are ZSelectionDecorator and ZLinkDecorator. This class defines the minimum components of a visual component decorator, and will typically be extended by an application for any specific decorator. This class defines a child pointer to reference the next element of the chain, implements child manipulation methods, and wraps the paint, computeLocalBounds, pick and io methods.


Field Summary
protected  ZVisualComponent child
           
 
Fields inherited from class edu.umd.cs.jazz.scenegraph.ZVisualComponent
cacheVolatile, findable, findable_DEFAULT, isVolatile, localBounds, localBoundsDirty, parent, pickable, pickable_DEFAULT, selected
 
Constructor Summary
ZVisualComponentDecorator()
          Constructs a new ZVisualComponentDecorator
ZVisualComponentDecorator(ZVisualComponent c)
          Constructs a new ZVisualComponentDecorator that decorates the specified child.
ZVisualComponentDecorator(ZVisualComponentDecorator dec)
          Constructs a new ZVisualComponentDecorator that is a copy of the specified decorator component (i.e., a "copy constructor").
 
Method Summary
 java.lang.Object clone()
          Duplicates the current visual component decorator by using the copy constructor.
protected  void computeLocalBounds()
          Calls the child's computeLocalBounds method.
 ZVisualComponent getChild()
           
 void insertAbove(ZVisualComponent c)
          Insert this decorator in the chain above the specified child visual component.
 void paint(ZRenderContext renderContext)
          Calls the child's paint method
 boolean pick(java.awt.geom.Rectangle2D rect)
          Returns true if the specified rectangle is on the child.
 void remove()
          Remove this decorator from the visual component chain.
 void setChild(ZVisualComponent v)
           
 void setState(java.lang.String fieldType, java.lang.String fieldName, java.lang.Object fieldValue)
          Set some state of this object as it gets read back in.
 void setVisualComponent(ZVisualComponent c)
           
 java.lang.String toString()
          Generate a string that represents this object for debugging.
 void writeObject(ZObjectOutputStream out)
          Write out all of this object's state.
 void writeObjectRecurse(ZObjectOutputStream out)
          Specify which objects this object references in order to write out the scenegraph properly
 
Methods inherited from class edu.umd.cs.jazz.scenegraph.ZVisualComponent
damage, damage, findNode, findVisualComponent, getLocalBounds, getParent, isFindable, isPickable, isSelected, isVolatile, pickBounds, select, select, setFindable, setParent, setPickable, setSelected, setVolatile, unselect, updateBounds, updateChildBounds, updateLocalBounds, updateVolatility
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

child

protected ZVisualComponent child
Constructor Detail

ZVisualComponentDecorator

public ZVisualComponentDecorator()
Constructs a new ZVisualComponentDecorator

ZVisualComponentDecorator

public ZVisualComponentDecorator(ZVisualComponentDecorator dec)
Constructs a new ZVisualComponentDecorator that is a copy of the specified decorator component (i.e., a "copy constructor"). The portion of the reference decorator that is duplicated is that necessary to reuse the component within a new node, but the new decorator is not inserted into a node.

ZVisualComponentDecorator

public ZVisualComponentDecorator(ZVisualComponent c)
Constructs a new ZVisualComponentDecorator that decorates the specified child.
Parameters:
child - The child that should go directly below this decorator.
Method Detail

clone

public java.lang.Object clone()
Duplicates the current visual component decorator by using the copy constructor. See the copy constructor comments for complete information about what is duplicated.
Overrides:
clone in class ZVisualComponent
See Also:
ZVisualComponentDecorator(ZVisualComponentDecorator)

insertAbove

public void insertAbove(ZVisualComponent c)
Insert this decorator in the chain above the specified child visual component. If the child visual component already had a parent, then this decorator will be properly inserted inbetween the original parent and the child. If this decorator was already part of a chain, then it will be removed before being inserted.
Parameters:
c - the child visual component that this decorator should go above.

remove

public void remove()
Remove this decorator from the visual component chain. If this decorator had a parent, then after this decorator is removed, the child will be properly inserted underneath this decorator's original parent.

getChild

public ZVisualComponent getChild()
Specified by:
getChild in interface ZHasChild

setChild

public void setChild(ZVisualComponent v)

setVisualComponent

public void setVisualComponent(ZVisualComponent c)
Overrides:
setVisualComponent in class ZVisualComponent

paint

public void paint(ZRenderContext renderContext)
Calls the child's paint method
Parameters:
g2 - The graphics context to paint into.
Overrides:
paint in class ZVisualComponent

computeLocalBounds

protected void computeLocalBounds()
Calls the child's computeLocalBounds method.
Overrides:
computeLocalBounds in class ZVisualComponent

pick

public boolean pick(java.awt.geom.Rectangle2D rect)
Returns true if the specified rectangle is on the child.
Parameters:
rect - Pick rectangle in object coordinates.
Returns:
True if point is on object.
Overrides:
pick in class ZVisualComponent

toString

public java.lang.String toString()
Generate a string that represents this object for debugging.
Returns:
the string that represents this object for debugging
Overrides:
toString in class ZVisualComponent

setState

public void setState(java.lang.String fieldType,
                     java.lang.String fieldName,
                     java.lang.Object fieldValue)
Set some state of this object as it gets read back in. After the object is created with its default no-arg constructor, this method will be called on the object once for each bit of state that was written out through calls to ZObjectOutputStream.writeState() within the writeObject method.
Specified by:
setState in interface ZSerializable
Parameters:
fieldType - The fully qualified type of the field
fieldName - The name of the field
fieldValue - The value of the field
Overrides:
setState in class ZVisualComponent

writeObject

public void writeObject(ZObjectOutputStream out)
                 throws java.io.IOException
Write out all of this object's state.
Specified by:
writeObject in interface ZSerializable
Parameters:
out - The stream that this object writes into
Overrides:
writeObject in class ZVisualComponent

writeObjectRecurse

public void writeObjectRecurse(ZObjectOutputStream out)
                        throws java.io.IOException
Specify which objects this object references in order to write out the scenegraph properly
Specified by:
writeObjectRecurse in interface ZSerializable
Parameters:
out - The stream that this object writes into
Overrides:
writeObjectRecurse in class ZVisualComponent