edu.umd.cs.jazz.component
Class ZStickyZDecorator

java.lang.Object
  |
  +--edu.umd.cs.jazz.scenegraph.ZVisualComponent
        |
        +--edu.umd.cs.jazz.scenegraph.ZVisualComponentDecorator
              |
              +--edu.umd.cs.jazz.component.ZConstraintDecorator
                    |
                    +--edu.umd.cs.jazz.component.ZStickyZDecorator

public class ZStickyZDecorator
extends ZConstraintDecorator

ZStickyZDecorator is a decorator that forces the child to always be rendered at the same scale. Thus, as a particular camera that looks at the component changes its magnification, the component changes its size by the inverse of the camera's magnification so it's magnification is not changed.

A basic way to use this is to create a constraint decorator that wraps a simple visual component. The following code creates a rectangle, decorates it with a constraint, and then creates a node with the decorator chain. The result is that the rectangle will pan with the camera, but won't change size as the camera changes its magnification.

	ZRectangle rect;
	ZNode node;
	ZStickyZDecorator sticky;

	rect = new ZRectangle(0, 0, 50, 50);
	sticky = new ZStickyZDecorator(camera, rect);
	node = new ZNode(sticky);
	layer.addChild(node);
      surface.restore();
 


Field Summary
protected  java.awt.geom.Point2D pt
          Internal point used for temporary storage.
protected  float stickyPointX
          The point of the child that will be fixed.
static float stickyPointX_DEFAULT
          Defaults for the point of the child that will be fixed.
protected  float stickyPointY
           
static float stickyPointY_DEFAULT
           
 
Fields inherited from class edu.umd.cs.jazz.component.ZConstraintDecorator
camera
 
Fields inherited from class edu.umd.cs.jazz.scenegraph.ZVisualComponentDecorator
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
ZStickyZDecorator()
          Constructs a new sticky z decorator.
ZStickyZDecorator(ZCamera camera)
          Constructs a new sticky z decorator with a specified camera.
ZStickyZDecorator(ZCamera camera, ZVisualComponent child)
          Constructs a new sticky z decorator with a specified camera that decorates the specified child.
ZStickyZDecorator(ZStickyZDecorator stickyz)
          Constructs a new ZStickyZDecorator that is a duplicate of the reference one, i.e., a "copy constructor"
 
Method Summary
 java.lang.Object clone()
          Duplicates the current ZStickyZDecorator by using the copy constructor.
protected  java.awt.geom.AffineTransform computeTransform()
          Computes the constraint that defines the child to keep a constant magnification even as the camera magnification changes.
 java.awt.Dimension getStickyPoint()
          Returns a Dimension specifying a point on the sticky object that remains fixed as the scene is zoomed.
 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 setStickyPoint(float x, float y)
          Specifies a point on the unit square of the sticky object that will remain fixed when the scene is zoomed.
 void writeObject(ZObjectOutputStream out)
          Write out all of this object's state.
 
Methods inherited from class edu.umd.cs.jazz.component.ZConstraintDecorator
applyInverseTransform, applyTransform, computeLocalBounds, getCamera, insertAbove, isVolatile, paint, pick, remove, setCamera, setParent, writeObjectRecurse
 
Methods inherited from class edu.umd.cs.jazz.scenegraph.ZVisualComponentDecorator
getChild, setChild, setVisualComponent, toString
 
Methods inherited from class edu.umd.cs.jazz.scenegraph.ZVisualComponent
damage, damage, findNode, findVisualComponent, getLocalBounds, getParent, isFindable, isPickable, isSelected, pickBounds, select, select, setFindable, setPickable, setSelected, setVolatile, transformChanged, unselect, updateBounds, updateChildBounds, updateLocalBounds, updateVolatility
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

stickyPointX_DEFAULT

public static float stickyPointX_DEFAULT
Defaults for the point of the child that will be fixed.

stickyPointY_DEFAULT

public static float stickyPointY_DEFAULT

stickyPointX

protected float stickyPointX
The point of the child that will be fixed.

stickyPointY

protected float stickyPointY

pt

protected java.awt.geom.Point2D pt
Internal point used for temporary storage.
Constructor Detail

ZStickyZDecorator

public ZStickyZDecorator()
Constructs a new sticky z decorator.

ZStickyZDecorator

public ZStickyZDecorator(ZCamera camera)
Constructs a new sticky z decorator with a specified camera.
Parameters:
camera - The camera the component is related to.

ZStickyZDecorator

public ZStickyZDecorator(ZCamera camera,
                         ZVisualComponent child)
Constructs a new sticky z decorator with a specified camera that decorates the specified child.
Parameters:
camera - The camera the component is related to.
child - The child that should go directly below this decorator.

ZStickyZDecorator

public ZStickyZDecorator(ZStickyZDecorator stickyz)
Constructs a new ZStickyZDecorator that is a duplicate of the reference one, i.e., a "copy constructor"
Parameters:
stickyz - Reference stickyz decorator
Method Detail

clone

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

setStickyPoint

public void setStickyPoint(float x,
                           float y)
Specifies a point on the unit square of the sticky object that will remain fixed when the scene is zoomed. The coordinates range from upper left hand corner (0,0) of the sticky object, to bottom right hand corner (1,1).
Parameters:
x - X coordinate of the sticky point of the sticky object.
y - Y coordinate of the sticky point of the sticky object.

getStickyPoint

public java.awt.Dimension getStickyPoint()
Returns a Dimension specifying a point on the sticky object that remains fixed as the scene is zoomed.
Returns:
the coordinates of the fixed point of the sticky object.

computeTransform

protected java.awt.geom.AffineTransform computeTransform()
Computes the constraint that defines the child to keep a constant magnification even as the camera magnification changes.
Returns:
the affine transform the defines the constraint.
Overrides:
computeTransform in class ZConstraintDecorator

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.
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 ZConstraintDecorator

writeObject

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