|
Jazz API Documentation | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--edu.umd.cs.jazz.ZSceneGraphObject | +--edu.umd.cs.jazz.ZVisualComponent | +--edu.umd.cs.jazz.ZCamera
ZCamera represents a viewport onto a list of nodes. A camera can look at any number of ZLayerGroups, and can specify where in space it looks as specified by an arbitrary affine transformation.
When a ZCanvas is created, it automatically creates a top-level camera attached to that canvas that is the same size as the canvas. Thus, the whole scenegraph is rendered within that canvas.
It is also possible to create an "internal camera" that acts as a portal, or internal window. That is, it is an object within the scene that looks onto the scene. To do this, create a scenegraph where the top-level camera sees both the regular layer, and a new layer that contains the internal camera. Then, make the new internal camera look at the regular layer. The following code demonstrates this:
ZCamera portal = new ZCamera(); portal.setBounds(100, 100, 200, 200); portal.setFillColor(Color.red); ZVisualLeaf leaf = new ZVisualLeaf(portal); leaf.setFindable(false); ZVisualGroup border = new ZVisualGroup(leaf); ZRectangle rect = new ZRectangle(100, 100, 200, 200); rect.setPenColor(Color.blue); rect.setFillColor(null); rect.setPenWidth(5.0f); border.setFrontVisualComponent(rect); ZLayerGroup layer = new ZLayerGroup(border); canvas.getRoot().addChild(layer); canvas.getCamera().addLayer(layer); portal.addLayer(canvas.getLayer());
Field Summary | |
static java.awt.Color |
fillColor_DEFAULT
|
protected javax.swing.event.EventListenerList |
listenerList
List of event listeners for camera events. |
Fields inherited from class edu.umd.cs.jazz.ZSceneGraphObject |
bounds,
objRefTable,
volatileBounds_DEFAULT |
Constructor Summary | |
ZCamera()
Constructs a new ZCamera. |
|
ZCamera(ZLayerGroup layer,
ZDrawingSurface aSurface)
Constructs a new ZCamera. |
Method Summary | |
void |
addCameraListener(ZCameraListener l)
Adds the specified camera listener to receive camera events from this camera |
void |
addLayer(ZLayerGroup layer)
Add a portion of the scenegraph that what this camera sees. |
void |
animate(java.awt.geom.AffineTransform at,
int millis,
ZDrawingSurface surface)
Set the transform of this camera to the specified transform, and animate the change from its current transformation over the specified number of milliseconds using a slow-in slow-out animation. |
float |
cameraToLocal(java.awt.geom.Point2D pt,
ZNode node)
Transform a point in the camera's coordinate system through the camera down the tree to the specified node's local coordinate system. |
float |
cameraToLocal(java.awt.geom.Rectangle2D rect,
ZNode node)
Transform a rectangle in the camera's coordinate system through the camera down the tree to the specified node's local coordinate system. |
void |
center(java.awt.geom.Rectangle2D refBounds,
int millis,
ZDrawingSurface aSurface)
Animates the camera view so that the specified bounds (in global coordinates) is centered within the view of the camera. |
java.lang.Object |
clone()
Duplicates the current object by using the copy constructor. |
protected void |
computeInverseViewTransform()
Internal method to compute the inverse camera transform based on the camera transform. |
java.lang.String |
dump()
Generate a string that represents this object for debugging. |
void |
duplicateObject(ZCamera refCamera)
Copies all object information from the reference object into the current object. |
java.util.ArrayList |
findNodes(ZFindFilter filter)
Return the list of nodes that are accepted by the specified filter in the portion of the scenegraph visible through this camera. |
protected void |
fireCameraEvent(int id,
java.awt.geom.AffineTransform origViewTransform)
Notifies all listeners that have registered interest for notification on this event type. |
ZDrawingSurface |
getDrawingSurface()
Get the value of surface. |
java.awt.Color |
getFillColor()
Get the value of fillColor. |
java.awt.geom.AffineTransform |
getInverseViewTransform()
Returns a copy of the inverse view transform associated with this camera. |
ZLayerGroup[] |
getLayers()
Returns a copy of the list of layers that this camera looks onto. |
float |
getMagnification()
Returns the current magnification of this camera. |
int |
getNumLayers()
Returns the number of layers of this camera. |
ZRoot |
getRoot()
Returns the root of the scene graph that this camera is looking at |
float |
getScale()
Returns the current scale of this transform. |
float |
getTranslateX()
Returns the current X translation of this object |
float |
getTranslateY()
Returns the current Y translation of this object |
java.awt.geom.Point2D |
getTranslation()
Returns the current translation of this object |
ZBounds |
getViewBounds()
Returns the bounds that this Camera sees in global scene coordinates. |
java.awt.geom.AffineTransform |
getViewTransform()
Returns a copy of the view transform that specifes where in space this camera looks. |
float |
localToCamera(java.awt.geom.Point2D pt,
ZNode node)
Transform a point in a node's local coordinate system up the scenegraph backwards through the camera to the camera's coordinate system. |
float |
localToCamera(java.awt.geom.Rectangle2D rect,
ZNode node)
Transform a rectangle in a node's local coordinate system up the scenegraph backwards through the camera to the camera's coordinate system. |
boolean |
pick(java.awt.geom.Rectangle2D rect,
ZSceneGraphPath path)
Picks the first object under the specified rectangle (if there is one) as searched in reverse (front-to-back) order. |
void |
removeCameraListener(ZCameraListener l)
Removes the specified camera listener so that it no longer receives camera events from this camera. |
void |
removeLayer(ZLayerGroup layer)
Removes a portion of the scenegrpah from what this camera sees |
void |
render(ZRenderContext renderContext)
Renders the view this camera sees. |
void |
repaint()
Repaint causes the portions of the surfaces that this object appears in to be marked as needing painting, and queues events to cause those areas to be painted. |
void |
repaint(ZBounds repaintBounds)
This is an internal form of repaint that is only intended to be used by calls from within Jazz. |
void |
replaceLayer(ZLayerGroup original,
ZLayerGroup replacement)
Replaces the specified node out of the list of layers of this camera, and replaces it with the specified node. |
void |
scale(float dz)
Scale the object from its current scale to the scale specified by muliplying the current scale and dz. |
void |
scale(float dz,
float x,
float y)
Scale the object around the specified point (x, y) from its current scale to the scale specified by muliplying the current scale and dz. |
void |
scale(float dz,
float x,
float y,
int millis,
ZDrawingSurface surface)
Animate the object around the specified point (x, y) from its current scale to the scale specified by muliplying the current scale and dz |
void |
scale(float dz,
int millis,
ZDrawingSurface surface)
Animate the object from its current scale to the scale specified by muliplying the current scale and deltaZ |
void |
setBounds(int x,
int y,
int w,
int h)
Sets the bounds of this camera. |
void |
setBounds(java.awt.geom.Rectangle2D newBounds)
Sets the bounds of this camera. |
void |
setDrawingSurface(ZDrawingSurface aSurface)
Set the value of surface. |
void |
setFillColor(java.awt.Color aColor)
Set the value of fillColor. |
void |
setScale(float finalz)
Sets the scale of the view transform |
void |
setScale(float finalz,
float x,
float y)
Set the scale of the object to the specified target scale, scaling the object around the specified point (x, y). |
void |
setScale(float finalz,
float x,
float y,
int millis,
ZDrawingSurface surface)
Animate the object around the specified point (x, y) to the specified target scale. |
void |
setScale(float finalz,
int millis,
ZDrawingSurface surface)
Animate the object from its current scale to the specified target scale. |
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 |
setTranslate(float x,
float y)
Translate the object to the specified position |
void |
setTranslate(float x,
float y,
int millis,
ZDrawingSurface surface)
Animate the object from its current position to the position specified by x, y |
void |
setTranslateX(float x)
Sets the current X translation of this object |
void |
setTranslateY(float y)
Sets the current Y translation of this object |
void |
setViewTransform(java.awt.geom.AffineTransform transform)
Sets the view transform associated with this camera. |
void |
setViewTransform(double m00,
double m10,
double m01,
double m11,
double m02,
double m12)
Sets the view transform associated with this camera. |
void |
translate(float dx,
float dy)
Translate the object by the specified deltaX and deltaY |
void |
translate(float dx,
float dy,
int millis,
ZDrawingSurface surface)
Animate the object from its current position by the specified deltaX and deltaY |
void |
trimToSize()
Trims the capacity of the array that stores the layers list points to the actual number of points. |
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.ZVisualComponent |
boundsUpdated,
duplicateObject,
getParents,
paint,
pickBounds,
updateBounds,
updateVolatility |
Methods inherited from class edu.umd.cs.jazz.ZSceneGraphObject |
computeBounds,
duplicateObject,
getBounds,
getVolatileBounds,
reshape,
setVolatileBounds,
updateObjectReferences |
Methods inherited from class java.lang.Object |
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Field Detail |
public static final java.awt.Color fillColor_DEFAULT
protected transient javax.swing.event.EventListenerList listenerList
Constructor Detail |
public ZCamera()
public ZCamera(ZLayerGroup layer, ZDrawingSurface aSurface)
node
- The part of the scenegraph this camera sees.surf
- The surface this top-level camera projects ontoMethod Detail |
public void duplicateObject(ZCamera refCamera)
refCamera
- The reference camera to copypublic java.lang.Object clone()
In particular, the camera's layers are duplicated so that a copied camera will continue to see the same part of the scenegraph. However, if the reference camera was attached to a surface, the copied camera will not be attached to that surface, and must be made visible by attaching to a new surface (or by being visible through another camera.)
However, the event listeners for the duplicated camera are reused references to the original camera's event listeners.
ZSceneGraphObject.updateObjectReferences(edu.umd.cs.jazz.util.ZObjectReferenceTable)
public void trimToSize()
public void addLayer(ZLayerGroup layer)
layer
- The part of the scenegraph added to what this camera sees.public void removeLayer(ZLayerGroup layer)
layer
- The part of the scenegraph removed from what this camera sees.public void replaceLayer(ZLayerGroup original, ZLayerGroup replacement)
original
- is the old node that is being swapped out as a layerreplacement
- is the new node that is being swapped in as a layerpublic ZLayerGroup[] getLayers()
public int getNumLayers()
public ZDrawingSurface getDrawingSurface()
public void setDrawingSurface(ZDrawingSurface aSurface)
v
- Value to assign to surface.public java.awt.Color getFillColor()
public void setFillColor(java.awt.Color aColor)
v
- Value to assign to fillColor.public ZBounds getViewBounds()
public void setBounds(int x, int y, int w, int h)
x,y,w,h
- The new bounds of this camerapublic void setBounds(java.awt.geom.Rectangle2D newBounds)
newBounds
- The new bounds of this camerapublic float getMagnification()
public void repaint()
Scenegraph objects should call repaint when their internal state has changed and they need to be redrawn on the screen.
Important note : Scenegraph objects should call reshape() instead of repaint() if the internal state change effects the bounds of the shape in any way (e.g. changing penwidth, selection, transform, adding points to a line, etc.)
ZSceneGraphObject.reshape()
public void repaint(ZBounds repaintBounds)
repaintBounds
- The bounds that need to be repainted (in global coordinates)public void render(ZRenderContext renderContext)
The transform, clip, and composite will be set appropriately when this object is rendered. It is up to this object to restore the transform, clip, and composite of the Graphics2D if this node changes any of them. However, the color, font, and stroke are unspecified by Jazz. This object should set those things if they are used, but they do not need to be restored.
renderContext
- The graphics context to use for rendering.public ZRoot getRoot()
public boolean pick(java.awt.geom.Rectangle2D rect, ZSceneGraphPath path)
rect
- Coordinates of pick rectangle in camera coordinates.ZDrawingSurface.pick(int, int)
public java.util.ArrayList findNodes(ZFindFilter filter)
filter
- The filter that decides whether or not to include individual nodes in the find listZNode.isFindable()
,
ZFindFilter
public java.lang.String dump()
ZDebug.dump(edu.umd.cs.jazz.ZNode)
public void addCameraListener(ZCameraListener l)
l
- the camera listenerpublic void removeCameraListener(ZCameraListener l)
l
- the camera listenerprotected void fireCameraEvent(int id, java.awt.geom.AffineTransform origViewTransform)
id
- The event id (CAMERA_VIEW_CHANGED)origViewTransform
- The original view transform (for view change events)EventListenerList
public java.awt.geom.AffineTransform getViewTransform()
protected void computeInverseViewTransform()
public java.awt.geom.AffineTransform getInverseViewTransform()
public void setViewTransform(java.awt.geom.AffineTransform transform)
transform
- public void setViewTransform(double m00, double m10, double m01, double m11, double m02, double m12)
m00, m01, m02, m10, m11, m12
- the
6 floating point values that compose the 3x3 transformation matrixpublic float cameraToLocal(java.awt.geom.Point2D pt, ZNode node)
If the node is specified as null, then the point is transformed through the camera, but no further - thus transforming the point from window to global coordinates.
If the specified node is not on the portion of the scenegraph that is visible through the camera, then a ZNodeNotFoundException is thrown.
pt
- The point to be transformednode
- The node to transform tolocalToCamera(Point2D, ZNode)
public float cameraToLocal(java.awt.geom.Rectangle2D rect, ZNode node)
If the node is specified as null, then the rectangle is transformed through the camera, but no further - thus transforming the rectangle from window to global coordinates.
If the specified node is not on the portion of the scenegraph that is visible through the camera, then a ZNodeNotFoundException is thrown.
rect
- The rectangle to be transformednode
- The node to transform tolocalToCamera(Rectangle2D, ZNode)
public float localToCamera(java.awt.geom.Point2D pt, ZNode node)
If the node is specified as null, then the point is transformed from global coordinates through the camera, thus transforming the point from global to window coordinates.
If the specified node is not on the portion of the scenegraph that is visible through the camera, then a ZNodeNotFoundException is thrown.
pt
- The point to be transformednode
- The node that represents the local coordinates to transform fromcameraToLocal(Point2D, ZNode)
public float localToCamera(java.awt.geom.Rectangle2D rect, ZNode node)
If the node is specified as null, then the rectangle is transformed from global coordinates through the camera, thus transforming the rectangle from global to window coordinates.
If the specified node is not on the portion of the scenegraph that is visible through the camera, then a ZNodeNotFoundException is thrown.
rect
- The rectangle to be transformednode
- The node that represents the local coordinates to transform fromcameraToLocal(Rectangle2D, ZNode)
public void center(java.awt.geom.Rectangle2D refBounds, int millis, ZDrawingSurface aSurface)
refBounds
- The bounds (in global coordinates) to be centered.millis
- The time in milliseconds to perform the animationsurface
- The surface to be updated during the animationpublic java.awt.geom.Point2D getTranslation()
public float getTranslateX()
public void setTranslateX(float x)
public float getTranslateY()
public void setTranslateY(float y)
public void translate(float dx, float dy)
dx
- X-coord of translationdy
- Y-coord of translationpublic void translate(float dx, float dy, int millis, ZDrawingSurface surface)
dx
- X-coord of translationdy
- Y-coord of translationmillis
- Number of milliseconds over which to perform the animationsurface
- The surface to updated during animation.public void setTranslate(float x, float y)
x
- X-coord of translationy
- Y-coord of translationpublic void setTranslate(float x, float y, int millis, ZDrawingSurface surface)
x
- X-coord of translationy
- Y-coord of translationmillis
- Number of milliseconds over which to perform the animationsurface
- The surface to updated during animation.public float getScale()
public void scale(float dz)
dz
- scale factorpublic void scale(float dz, float x, float y)
dz
- scale factorx
- X coordinate of the point to scale aroundy
- Y coordinate of the point to scale aroundpublic void scale(float dz, int millis, ZDrawingSurface surface)
dz
- scale factormillis
- Number of milliseconds over which to perform the animationsurface
- The surface to updated during animation.public void scale(float dz, float x, float y, int millis, ZDrawingSurface surface)
dz
- scale factorx
- X coordinate of the point to scale aroundy
- Y coordinate of the point to scale aroundmillis
- Number of milliseconds over which to perform the animationsurface
- The surface to updated during animation.public void setScale(float finalz)
the
- new scalepublic void setScale(float finalz, float x, float y)
finalz
- scale factorx
- X coordinate of the point to scale aroundy
- Y coordinate of the point to scale aroundpublic void setScale(float finalz, int millis, ZDrawingSurface surface)
finalz
- scale factormillis
- Number of milliseconds over which to perform the animationsurface
- The surface to updated during animation.public void setScale(float finalz, float x, float y, int millis, ZDrawingSurface surface)
finalz
- scale factorx
- X coordinate of the point to scale aroundy
- Y coordinate of the point to scale aroundmillis
- Number of milliseconds over which to perform the animationsurface
- The surface to updated during animation.public void animate(java.awt.geom.AffineTransform at, int millis, ZDrawingSurface surface)
If millis is 0, then the transform is updated once, and the scene is not repainted immediately, but rather a repaint request is queued, and will be processed by an event handler.
at
- Final transformationmillis
- Number of milliseconds over which to perform the animationsurface
- The surface to updated during animation.public void writeObject(ZObjectOutputStream out) throws java.io.IOException
out
- The stream that this object writes intopublic void writeObjectRecurse(ZObjectOutputStream out) throws java.io.IOException
out
- The stream that this object writes intopublic void setState(java.lang.String fieldType, java.lang.String fieldName, java.lang.Object fieldValue)
fieldType
- The fully qualified type of the fieldfieldName
- The name of the fieldfieldValue
- The value of the field
|
Jazz API Documentation | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |