edu.umd.cs.jazz.component
Class ZStickyDecorator
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.ZStickyDecorator
- public class ZStickyDecorator
- extends ZConstraintDecorator
ZStickyDecorator is a decorator that forces the child to always be rendered
at the same place and size, independent of the camera view. Thus, as a particular
camera that looks at the component changes its magnification, the component changes
its transform by the inverse of the camera's transform so it's position 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 not move as the camera changes its view.
ZRectangle rect;
ZNode node;
ZStickyDecorator sticky;
rect = new ZRectangle(0, 0, 50, 50);
sticky = new ZStickyDecorator(camera, rect);
node = new ZNode(sticky);
layer.addChild(node);
surface.restore();
|
Method Summary |
java.lang.Object |
clone()
Duplicates the current ZStickyDecorator by using the copy constructor. |
protected java.awt.geom.AffineTransform |
computeTransform()
Computes the constraint that defines the child to not move
even as the camera view changes. |
void |
paint(ZRenderContext renderContext)
Paints the child, but applies the sticky so that it appears in a fixed place
independent of the camera. |
| Methods inherited from class edu.umd.cs.jazz.component.ZConstraintDecorator |
applyInverseTransform,
applyTransform,
computeLocalBounds,
getCamera,
insertAbove,
isVolatile,
pick,
remove,
setCamera,
setParent,
setState,
writeObject,
writeObjectRecurse |
| 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,
unselect,
updateBounds,
updateChildBounds,
updateLocalBounds,
updateVolatility |
| Methods inherited from class java.lang.Object |
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
ZStickyDecorator
public ZStickyDecorator()
- Constructs a new sticky decorator.
ZStickyDecorator
public ZStickyDecorator(ZCamera camera)
- Constructs a new sticky decorator with a specified camera.
- Parameters:
camera - The camera the component is related to.
ZStickyDecorator
public ZStickyDecorator(ZCamera camera,
ZVisualComponent child)
- Constructs a new sticky 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.
ZStickyDecorator
public ZStickyDecorator(ZStickyDecorator sticky)
- Constructs a new ZStickyDecorator that is a duplicate of the reference one, i.e., a "copy constructor"
- Parameters:
sticky - Reference sticky decorator
clone
public java.lang.Object clone()
- Duplicates the current ZStickyDecorator by using the copy constructor.
See the copy constructor comments for complete information about what is duplicated.
- Overrides:
- clone in class ZConstraintDecorator
- See Also:
ZStickyDecorator(ZStickyDecorator)
paint
public void paint(ZRenderContext renderContext)
- Paints the child, but applies the sticky so that it appears in a fixed place
independent of the camera. This method overrides the ZConstraintDecorator
paint method in order to implement sticky objects in a special way to
avoid the "jitter" that results from rounding errors otherwise.
- Parameters:
renderContext - The render context to paint into.- Overrides:
- paint in class ZConstraintDecorator
computeTransform
protected java.awt.geom.AffineTransform computeTransform()
- Computes the constraint that defines the child to not move
even as the camera view changes.
- Returns:
- the affine transform the defines the constraint.
- Overrides:
- computeTransform in class ZConstraintDecorator