edu.umd.cs.jazz
Class ZConstraintGroup

java.lang.Object
  |
  +--edu.umd.cs.jazz.ZSceneGraphObject
        |
        +--edu.umd.cs.jazz.ZNode
              |
              +--edu.umd.cs.jazz.ZGroup
                    |
                    +--edu.umd.cs.jazz.ZTransformGroup
                          |
                          +--edu.umd.cs.jazz.ZConstraintGroup
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable, ZSerializable, ZTransformable
Direct Known Subclasses:
ZStickyGroup

public class ZConstraintGroup
extends ZTransformGroup
implements java.io.Serializable

ZConstraintGroup is a transform group that changes its transform based on a computation defined in a specified method. Every time the camera view is changed, the method is called, recomputing the transform. Thus, depending on the algorithm chosen, various dynamic behaviors can be created.

Sub-classes must override the ZTransformGroup.getTransform() method of ZTransformGroup.getTransform() to define a new transform. This class stores a reference to a camera so, for example, a sub-class could define a constraint dependent on the camera so that the children move whenever the camera view changes.

Warning: Serialized and ZSerialized objects of this class will not be compatible with future Jazz releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Jazz. A future release of Jazz will provide support for long term persistence.

Author:
Benjamin B. Bederson
See Also:
ZStickyGroup, Serialized Form

Field Summary
protected  ZCamera camera
          The camera the constraint is related to
 
Fields inherited from class edu.umd.cs.jazz.ZGroup
children, childrenFindable_DEFAULT, childrenPickable_DEFAULT, hasOneChild_DEFAULT
 
Fields inherited from class edu.umd.cs.jazz.ZNode
findable_DEFAULT, pickable_DEFAULT, savable_DEFAULT, selectable_DEFAULT
 
Fields inherited from class edu.umd.cs.jazz.ZSceneGraphObject
bounds, listenerList, volatileBounds, volatileBounds_DEFAULT
 
Constructor Summary
ZConstraintGroup()
          Constructs a new constraint group.
ZConstraintGroup(ZCamera camera)
          Constructs a new constraint group with a specified camera.
ZConstraintGroup(ZCamera camera, ZNode child)
          Constructs a new constraint group with a specified camera that decorates the specified child.
ZConstraintGroup(ZNode child)
          Constructs a new constraint group that decorates the specified child.
 
Method Summary
 java.awt.geom.AffineTransform computeTransform()
          Computes the constraint that defines the child to not move even as the camera view changes.
 void finalize()
          Disposes of this constraint group when it is no longer used.
 ZCamera getCamera()
          Get the camera that this node is related to.
protected  void init(ZCamera camera)
          Internal method to help node construction.
 void setCamera(ZCamera camera)
          Set the camera that this node is related to
 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.
protected  void updateObjectReferences(ZObjectReferenceTable objRefTable)
          Called to update internal object references after a clone operation by ZSceneGraphObject.clone().
protected  void updateTransform()
          Internal method to recompute the constraint transform.
 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.ZTransformGroup
addTransformListener, animate, animate, animate, animate, computeBounds, computeInverseTransform, computeScale, concatenate, dump, duplicateObject, getInverseTransform, getLocalToGlobalTransform, getMatrix, getRotation, getScale, getTransform, getTransformReference, getTranslateX, getTranslateY, getTranslation, lerp, pick, position, position, preConcatenate, removeTransformListener, render, repaint, repaint, rotate, rotate, rotate, rotate, scale, scale, scale, scale, setRotation, setRotation, setRotation, setRotation, setScale, setScale, setScale, setScale, setTransform, setTransform, setTranslateX, setTranslateY, setTranslation, setTranslation, transform, transform, translate, translate
 
Methods inherited from class edu.umd.cs.jazz.ZGroup
addChild, addChildImpl, addChildren, addGroupListener, childAddedNotification, childRemovedNotification, extract, findNodes, getChild, getChildren, getChildrenFindable, getChildrenIterator, getChildrenPickable, getChildrenReference, getNumChildren, getShallowBounds, getVolatileBounds, hasOneChild, indexOf, insertAbove, iterator, lower, lowerTo, raise, raiseTo, removeAllChildren, removeChild, removeChild, removeChild, removeChildImpl, removeGroupListener, removeNodeListener, setChildrenFindable, setChildrenPickable, setHasOneChild, trimToSize, updateHasNodeListener, updateVolatility
 
Methods inherited from class edu.umd.cs.jazz.ZNode
addClientProperty, addNodeListener, editor, getClientProperty, getGlobalBounds, getGlobalToLocalTransform, getParent, getRoot, globalToLocal, globalToLocal, hasNodeListener, isAncestorOf, isDescendentOf, isFindable, isPickable, isSavable, isSelectable, localToGlobal, localToGlobal, lower, lowerTo, percolateEventUpSceneGraph, putClientProperty, raise, raiseTo, remove, repaint, reparent, replaceWith, setEditorFactory, setFindable, setParent, setPickable, setSavable, setSelectable, updateBounds, writeReplace
 
Methods inherited from class edu.umd.cs.jazz.ZSceneGraphObject
addMouseListener, addMouseMotionListener, clone, fireEvent, fireMouseEvent, getBounds, getBoundsReference, getListenerList, hasLisenerOfType, hasMouseListener, processMouseEvent, removeEventListener, removeMouseListener, removeMouseMotionListener, reshape, setBounds, setVolatileBounds
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

camera

protected ZCamera camera
The camera the constraint is related to
Constructor Detail

ZConstraintGroup

public ZConstraintGroup()
Constructs a new constraint group. This constructor does not specify a camera to be used in calculating the constraint. Set the camera separately to make the node behave properly.
See Also:
setCamera(edu.umd.cs.jazz.ZCamera)

ZConstraintGroup

public ZConstraintGroup(ZCamera camera)
Constructs a new constraint group with a specified camera.
Parameters:
camera - The camera the node is related to.

ZConstraintGroup

public ZConstraintGroup(ZNode child)
Constructs a new constraint group that decorates the specified child.
Parameters:
child - The child that should go directly below this node.

ZConstraintGroup

public ZConstraintGroup(ZCamera camera,
                        ZNode child)
Constructs a new constraint group with a specified camera that decorates the specified child.
Parameters:
camera - The camera the node is related to.
child - The child that should go directly below this node.
Method Detail

finalize

public void finalize()
Disposes of this constraint group when it is no longer used.
Overrides:
finalize in class java.lang.Object

init

protected void init(ZCamera camera)
Internal method to help node construction.

updateObjectReferences

protected void updateObjectReferences(ZObjectReferenceTable objRefTable)
Called to update internal object references after a clone operation by ZSceneGraphObject.clone().
Overrides:
updateObjectReferences in class ZNode
See Also:
ZSceneGraphObject.updateObjectReferences(edu.umd.cs.jazz.util.ZObjectReferenceTable)

computeTransform

public java.awt.geom.AffineTransform computeTransform()
Computes the constraint that defines the child to not move even as the camera view changes. This is called whenever the camera view changes. This should be overrided by sub-classes defining constraints.
Returns:
The new transform

updateTransform

protected void updateTransform()
Internal method to recompute the constraint transform. This should be called whenever some internal state that can affect the constraint changes.

getCamera

public ZCamera getCamera()
Get the camera that this node is related to.
Returns:
the camera

setCamera

public void setCamera(ZCamera camera)
Set the camera that this node is related to
Parameters:
camera - The new camera

writeObject

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

writeObjectRecurse

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

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.
Overrides:
setState in class ZTransformGroup
Parameters:
fieldType - The fully qualified type of the field
fieldName - The name of the field
fieldValue - The value of the field


Copyright © 2001 by University of Maryland, College Park, MD 20742, USA All rights reserved.