edu.umd.cs.jazz.scenegraph
Class ZCamera

java.lang.Object
  |
  +--edu.umd.cs.jazz.scenegraph.ZNode
        |
        +--edu.umd.cs.jazz.scenegraph.ZCamera

public class ZCamera
extends ZNode

ZCamera represents a viewport onto a Scenegraph Node. A camera can look anywhere onto a scenegraph scape as specified by an arbitrary affine transformation. A ZNode can have any number of cameras onto it. Each camera can be associated with a top-level window, a portal, or may not be mapped to any visible device at all.

See Also:
ZNode

Field Summary
protected  java.util.HashSet dirty
           
protected  java.awt.Color fillColor
           
static java.awt.Color fillColor_DEFAULT
           
protected  ZTransform inverseViewTransform
           
protected  boolean inverseViewTransformDirty
           
protected  ZArea paintArea
           
protected  java.util.Vector paintStartPoints
           
protected  ZArea paintVisibleArea
           
protected  Dimension2DFloat size
           
protected  ZSurface surface
          The optional surface this camera is associated with.
protected  ZTransform viewTransform
           
 
Fields inherited from class edu.umd.cs.jazz.scenegraph.ZNode
alpha, alpha_DEFAULT, ancestorNotifier, cacheVolatile, cameras, children, clientProperties, compBoundsDirty, compBoundsDirty_DEFAULT, globalBounds, globalBoundsDirty, globalBoundsDirty_DEFAULT, globalCompBounds, isVolatile, layoutManager, listenerList, maxMag, maxMag_DEFAULT, minMag, minMag_DEFAULT, parent, recursiveLayout, save, save_DEFAULT, transform, visible, visible_DEFAULT, visualComponent
 
Constructor Summary
ZCamera()
          Constructs a new ZCamera.
ZCamera(ZNode node, ZSurface aSurface)
          Constructs a new ZCamera.
 
Method Summary
 void addPaintStartPoint(ZNode node)
          Add a portion of the scenegraph that what this camera sees
 void cameraToScene(java.awt.geom.Point2D pt)
          Transform the point through the camera.
 void cameraToScene(java.awt.geom.Rectangle2D rect)
          Transform the rectangle through the camera.
 void center(java.awt.geom.Rectangle2D bounds, int millis, ZSurface aSurface)
          Animates the camera view so that the specified bounds is centered with the view of the camera.
protected  void computeGlobalBounds()
          Computes the bounds of the camera as an object.
protected  void computeInverseViewTransform()
          Compute the inverse camera transform based on the camera transform.
 void damage()
          This implements damage in just the same way as is described by ZNode.damage
 void damage(boolean boundsChanged)
          This implements damage in just the same way as is described by ZNode.damage
 void damage(ZBounds bounds)
          This is an internal form of damage that is only intended to be used by calls from within ZNode.
 java.util.Vector findNodes(ZFindFilter filter)
          Return the list of nodes that are accepted by the specified filter in the subtree rooted with this.
 java.awt.Color getFillColor()
          Get the value of fillColor.
 ZTransform getInverseViewTransform()
          Returns the inverse ZTransform associated with this camera.
 float getMagnification()
          Returns the current magnification of this camera.
 java.util.Vector getPaintStartPoints()
          Returns the Scenegraph that this camera looks onto.
 java.util.Vector getSelectedNodes()
          Returns the Scenegraph that is selected in this camera's view
 java.awt.geom.Dimension2D getSize()
          Returns the size of this camera.
 ZSurface getSurface()
          Get the value of surface.
 ZBounds getViewBounds()
          Returns the bounds that this Camera sees in global scene coordinates.
 ZTransform getViewTransform()
          Returns the ZTransform associated with this camera.
 void paint(ZRenderContext renderContext)
          Paints the view this camera sees.
 ZNode pick(ZBounds rect)
          Returns the first object under the specified rectangle (if there is one) as searched in reverse (front-to-back) order.
 void removePaintStartPoint(ZNode node)
          Removes a portion of the scenegrpah from what this camera sees
 void sceneToCamera(java.awt.geom.Point2D pt)
          Transform the point backwards through the camera (from the camera's viewpoint).
 void sceneToCamera(java.awt.geom.Rectangle2D rect)
          Transform the rectangle backwards through the camera (from the camera's viewpoint).
 void setFillColor(java.awt.Color aColor)
          Set the value of fillColor.
 void setSize(java.awt.geom.Dimension2D size)
          Sets the size of this camera.
 void setSize(float width, float height)
          Sets the size of this camera.
 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 setSurface(ZSurface aSurface)
          Set the value of surface.
 void setViewTransform(ZTransform transform)
          Sets the ZTransform associated with this camera.
 void swapPaintStartPoint(ZNode original, ZNode replacement)
          Swaps the specified node out of the list of paint start points of this camera, and replaces it with the specified node.
 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.ZNode
addAncestorListener, addChild, addNodeContainerListener, addNodeListener, addProperty, addProperty, clearVisualComponent, clone, computeGlobalCompBounds, computeGlobalCoordinateFrame, createComposite, doLayout, findAllCameras, findCameras, findNode, findNodes, findRoot, findVisualComponent, fireNodeContainerEvent, fireNodeEvent, getAlpha, getCameras, getChildren, getCompBounds, getGlobalBounds, getGlobalCompBounds, getLayoutManager, getMaxMag, getMinMag, getObjs, getParent, getProperties, getProperty, getRecursiveLayout, getSave, getSelectedChildren, getTransform, getVisible, getVisualComponent, helpFindAllCameras, isAncestor, isDescendent, isVisible, isVolatile, lower, lowerTo, pick, raise, raiseTo, removeAncestorListener, removeChild, removeNodeContainerListener, removeNodeListener, reparent, selectAll, setAlpha, setLayoutManager, setMaxMag, setMinMag, setParent, setRecursiveLayout, setSave, setTransform, setVisible, setVisualComponent, setVolatile, swap, transformChanged, unselectAll, updateBounds, updateChildBounds, updateGlobalBounds, updateGlobalCompBounds, updateVolatility, writeReplace
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

fillColor_DEFAULT

public static final java.awt.Color fillColor_DEFAULT

viewTransform

protected ZTransform viewTransform

inverseViewTransform

protected ZTransform inverseViewTransform

inverseViewTransformDirty

protected boolean inverseViewTransformDirty

paintStartPoints

protected java.util.Vector paintStartPoints

dirty

protected java.util.HashSet dirty

fillColor

protected java.awt.Color fillColor

paintArea

protected ZArea paintArea

paintVisibleArea

protected ZArea paintVisibleArea

size

protected Dimension2DFloat size

surface

protected ZSurface surface
The optional surface this camera is associated with. If this surface is non-null, then the camera will render directly onto this surface. Else, the camera will only be visible within other cameras that looks at it.
Constructor Detail

ZCamera

public ZCamera()
Constructs a new ZCamera. Camera's are always associated with a scenegraph, but are not attached to any output device (such as a window or a portal) to start.

ZCamera

public ZCamera(ZNode node,
               ZSurface aSurface)
Constructs a new ZCamera. Camera's are always associated with a scenegraph, but are not attached to any output device (such as a window or a portal) to start.
Parameters:
node - The part of the scenegraph this camera sees.
surf - The surface this top-level camera projects onto
Method Detail

addPaintStartPoint

public void addPaintStartPoint(ZNode node)
Add a portion of the scenegraph that what this camera sees
Parameters:
node - The part of the scenegraph added to what this camera sees.

removePaintStartPoint

public void removePaintStartPoint(ZNode node)
Removes a portion of the scenegrpah from what this camera sees
Parameters:
node - The part of the scenegraph removed from what this camera sees.

swapPaintStartPoint

public void swapPaintStartPoint(ZNode original,
                                ZNode replacement)
Swaps the specified node out of the list of paint start points of this camera, and replaces it with the specified node. The replacement node will be added to paint start point list in the same position as the original was.
Parameters:
original - is the old node that is being swapped out as a paint start point
replacement - is the new node that is being swapped in as a paint start point

getPaintStartPoints

public java.util.Vector getPaintStartPoints()
Returns the Scenegraph that this camera looks onto.
Returns:
Portion of scenegraph that is visible from this camera.

getSelectedNodes

public java.util.Vector getSelectedNodes()
Returns the Scenegraph that is selected in this camera's view
Returns:
Portion of scenegraph visible to this camera that is selected.

getSurface

public ZSurface getSurface()
Get the value of surface.
Returns:
Value of surface.

setSurface

public void setSurface(ZSurface aSurface)
Set the value of surface.
Parameters:
v - Value to assign to surface.

getViewTransform

public ZTransform getViewTransform()
Returns the ZTransform associated with this camera.
Returns:
The current camera transform.

computeInverseViewTransform

protected void computeInverseViewTransform()
Compute the inverse camera transform based on the camera transform. This is a protected method and gets called from within ZCamera whenever the inverse camera transform cache has been invalidated, and it is needed.

getInverseViewTransform

public ZTransform getInverseViewTransform()
Returns the inverse ZTransform associated with this camera.
Returns:
The current inverse camera transform.

setViewTransform

public void setViewTransform(ZTransform transform)
Sets the ZTransform associated with this camera.
Parameters:
transform -  

cameraToScene

public void cameraToScene(java.awt.geom.Point2D pt)
Transform the point through the camera. In the typical case where this is a top-level camera, and the point represents a coordinate in screen coordinates, this will transform the point to Jazz global coordinates. The input point is modified by this method.
Parameters:
pt - The point to be transformed
See Also:
sceneToCamera(Point2D)

cameraToScene

public void cameraToScene(java.awt.geom.Rectangle2D rect)
Transform the rectangle through the camera. In the typical case where this is a top-level camera, and the rectangle represents coordinates in screen coordinates, this will transform the rectangle to Jazz global coordinates. The input rectangle is modified by this method.
Parameters:
rect - The rectangle to be transformed
See Also:
sceneToCamera(Rectangle2D)

sceneToCamera

public void sceneToCamera(java.awt.geom.Point2D pt)
Transform the point backwards through the camera (from the camera's viewpoint). In the typical case where this is a top-level camera, and the point represents a coordinate in Jazz global coordinates, this will transform to screen coordinates. The input point is modified by this method.
Parameters:
pt - The point to be transformed
See Also:
cameraToScene(Point2D)

sceneToCamera

public void sceneToCamera(java.awt.geom.Rectangle2D rect)
Transform the rectangle backwards through the camera (from the camera's viewpoint). In the typical case where this is a top-level camera, and the rectangle represents coordinates in Jazz global coordinates, this will transform to screen coordinates. The input rectangle is modified by this method.
Parameters:
rect - The rectangle to be transformed
See Also:
cameraToScene(Rectangle2D)

getFillColor

public java.awt.Color getFillColor()
Get the value of fillColor.
Returns:
Value of fillColor.

setFillColor

public void setFillColor(java.awt.Color aColor)
Set the value of fillColor.
Parameters:
v - Value to assign to fillColor.

center

public void center(java.awt.geom.Rectangle2D bounds,
                   int millis,
                   ZSurface aSurface)
Animates the camera view so that the specified bounds is centered with the view of the camera.
Parameters:
bounds - The bounds to be centered.
millis - The time in milliseconds to perform the animation
surface - The surface to be updated during the animation

computeGlobalBounds

protected void computeGlobalBounds()
Computes the bounds of the camera as an object. These bounds consist of its size and its visual component. The bounds are stored in globalBounds
Overrides:
computeGlobalBounds in class ZNode

getViewBounds

public ZBounds getViewBounds()
Returns the bounds that this Camera sees in global scene coordinates.
Returns:
The bounds.

setSize

public void setSize(java.awt.geom.Dimension2D size)
Sets the size of this camera.
Parameters:
size - The new dimension of this camera

setSize

public void setSize(float width,
                    float height)
Sets the size of this camera.
Parameters:
width - The new width of this camera.
height - The new height of this camera.

getSize

public java.awt.geom.Dimension2D getSize()
Returns the size of this camera.
Returns:
The size.

getMagnification

public float getMagnification()
Returns the current magnification of this camera.
Returns:
The magnification factor.

damage

public void damage()
This implements damage in just the same way as is described by ZNode.damage
Overrides:
damage in class ZNode
See Also:
ZNode.damage()

damage

public void damage(boolean boundsChanged)
This implements damage in just the same way as is described by ZNode.damage
Overrides:
damage in class ZNode
See Also:
ZNode.damage(boolean)

damage

public void damage(ZBounds bounds)
This is an internal form of damage that is only intended to be used by calls from within ZNode.
Parameters:
bounds - The bounds that need to be damaged

paint

public void paint(ZRenderContext renderContext)
Paints the view this camera sees.
Parameters:
renderContext - The graphics context to use for rendering.
Overrides:
paint in class ZNode

pick

public ZNode pick(ZBounds rect)
Returns the first object under the specified rectangle (if there is one) as searched in reverse (front-to-back) order. Only returns nodes with "pickable" visual components.
Parameters:
rect - Coordinates of pick rectangle in camera coordinates.
Returns:
The picked object.

findNodes

public java.util.Vector findNodes(ZFindFilter filter)
Return the list of nodes that are accepted by the specified filter in the subtree rooted with this. If this node is hidden or it is not "findable", then neither this node, nor any of its descendants will be included. The filter specifies whether or not a given node should be accepted by this search, and whether the children of a node should be searched.
Parameters:
filter - The filter that decides whether or not to include individual nodes in the find list
Returns:
The nodes found
See Also:
ZVisualComponent.isFindable(), ZFindFilter

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 java.lang.Object

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 ZNode

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 ZNode

writeObjectRecurse

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