|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--edu.umd.cs.jazz.ZSceneGraphObject
ZSceneGraphObject is the base class for all objects in the Jazz scenegraph. It provides support for the basic shared methods between all nodes and visual components.
Coordinate Systems
Application developers must understand the basic coordinate systems used in Jazz.
The basic coordinate system has its origin at the upper-left. The X-axis increases positively
to the right, and the Y-axis increase positively down.
Because certain node types define transforms which define a new relative coordinate system, it is important to realize that typically, objects are not placed in "global" coordinates. Rather, every object is defined in their own "local" coordinate system. The relationship of the local coordinate system to the global coordinate system is determined by the series of transforms between that object, and the root of the scenegraph.
All Jazz operations occur in local coordinates. For instance, coordinates of rectangles are specified in local coordinates. In addition, objects maintain a bounding box which is stored in local coordinates.
See the Jazz Tutorial for a more complete description of the scene graph.
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.
ZNode
,
ZVisualComponent
, Serialized FormField Summary | |
protected ZBounds |
bounds
The bounding rectangle occupied by this object in its own local coordinate system. |
protected javax.swing.event.EventListenerList |
listenerList
A list of event listeners for this node. |
protected boolean |
volatileBounds
True if this node is specifically set to have volatile bounds |
static boolean |
volatileBounds_DEFAULT
|
Constructor Summary | |
protected |
ZSceneGraphObject()
Constructs an empty scenegraph object. |
Method Summary | |
void |
addMouseListener(ZMouseListener l)
Adds the specified mouse listener to receive mouse events from this object |
void |
addMouseMotionListener(ZMouseMotionListener l)
Adds the specified mouse motion listener to receive mouse motion events from this object |
java.lang.Object |
clone()
Clones this scene graph object and all its children and returns the newly cloned sub-tree. |
protected void |
computeBounds()
Recomputes and caches the bounds for this node. |
java.lang.String |
dump()
Generate a string that represents this object for debugging. |
protected java.lang.Object |
duplicateObject()
Creates a copy of this scene graph object and all its children. |
protected void |
fireEvent(ZEvent anEvent)
Notifies all listeners that have registered interest for notification on this event type. |
void |
fireMouseEvent(ZMouseEvent e)
Deprecated. as of Jazz 1.1 |
ZBounds |
getBounds()
Return a copy of the bounds of the subtree rooted at this node in local coordinates. |
ZBounds |
getBoundsReference()
Return a reference to the bounds of the subtree rooted at this node in local coordinates. |
protected javax.swing.event.EventListenerList |
getListenerList()
Return this objects current event listener list. |
boolean |
getVolatileBounds()
Determines if this node is volatile. |
boolean |
hasLisenerOfType(java.lang.Class aType)
Determines if this Object has a registered listener of the type specified in its listener list. |
boolean |
hasMouseListener()
Determines if this object has any kind of mouse listener (i.e., mouse or mouse motion listener.) |
void |
processMouseEvent(ZMouseEvent e)
Forwards event to fireEvent(ZMouseEvent e); |
protected void |
removeEventListener(java.lang.Class listenerType,
java.util.EventListener listener)
Removes the specified mouse listener so that it no longer receives mouse events from this object. |
void |
removeMouseListener(ZMouseListener l)
Removes the specified mouse listener so that it no longer receives mouse events from this object. |
void |
removeMouseMotionListener(ZMouseMotionListener l)
Removes the specified mouse motion listener so that it no longer receives mouse motion events from this object. |
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 |
reshape()
Reshape causes the portion of the surface that this object appears in before the bounds are changed to be marked as needing painting, and queues events to cause those areas to be painted. |
protected void |
setBounds(ZBounds newBounds)
Internal method to specify the bounds of this object. |
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 |
setVolatileBounds(boolean v)
Specifies whether or not this node is volatile. |
protected void |
updateBounds()
Internal method that causes this node and all of its ancestors to recompute their bounds. |
protected void |
updateObjectReferences(ZObjectReferenceTable objRefTable)
Updates references to scene graph nodes after a clone operation. |
protected void |
updateVolatility()
Internal method to compute and cache the volatility of a node, to recursively call the parents to compute volatility. |
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 java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final boolean volatileBounds_DEFAULT
protected ZBounds bounds
protected boolean volatileBounds
protected transient javax.swing.event.EventListenerList listenerList
Constructor Detail |
protected ZSceneGraphObject()
Most objects will want to store their bounds, and so we allocate bounds here. However, if a particular object is implemented by computing its bounds every time it is asked instead of allocating it, then it can free up the bounds allocated here.
Method Detail |
public ZBounds getBounds()
If the object is a context-sensitive object, then it may compute the bounds based on the current render context.
ZRoot.getCurrentRenderContext()
public ZBounds getBoundsReference()
Warning: This method returns a reference to an internal ZBounds object. Any modification of this ZBounds object will result in undefined behavior.
If the object is a context-sensitive object, then it may compute the bounds based on the current render context.
ZRoot.getCurrentRenderContext()
protected void setBounds(ZBounds newBounds)
protected void computeBounds()
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.)
reshape()
public void reshape()
Scenegraph objects should call reshape when their internal state has changed in such a way that their bounds have changed.
Important note : Scenegraph objects should call repaint() instead of reshape() if the bounds of the shape have not changed.
repaint()
protected void updateBounds()
public boolean getVolatileBounds()
setVolatileBounds(boolean)
.
All parents of this node are also volatile when this is volatile.
Volatile objects are those objects that change regularly, such as an object that is animated, or one whose rendering depends on its context.
setVolatileBounds(boolean)
public void setVolatileBounds(boolean v)
Volatile objects are those objects that change regularly, such as an object that is animated, or one whose rendering depends on its context.
v
- the new specification of whether this node is volatile.getVolatileBounds()
protected void updateVolatility()
setVolatileBounds(boolean)
,
getVolatileBounds()
protected java.lang.Object duplicateObject()
ZSceneGraphObject.duplicateObject() calls Object.clone() on this object, and returns the newly cloned object. This results in a shallow copy of the object.
Subclasses override this method to modify the cloning behavior for nodes in the scene graph. Typically, subclasses first invoke super.duplicateObject() to get the default cloning behavior, and then take additional actions after this. In particular, ZGroup.duplicateObject() first invokes super.duplicateObject(), and then calls duplicateObject() on all of the children in the group, so that the whole tree beneath the group is cloned. Applications do not call duplicateObject directly. Instead, ZSceneGraphObject.clone() is used clone a scene graph object.
protected void updateObjectReferences(ZObjectReferenceTable objRefTable)
This method is invoked on cloned objects after the clone operation has been completed. The objRefTable parameter is a table mapping from the original uncloned objects to their newly cloned versions. Subclasses override this method to update any internal references they have to scene graph nodes. For example, ZNode's updateObjectReferences does:
super.updateObjectReferences(objRefTable); // Set parent to point to the newly cloned parent, or to // null if the parent object was not cloned. parent = (ZNode)objRefTable.getNewObjectReference(parent);
objRefTable
- Table mapping from uncloned objects to their cloned versions.public java.lang.Object clone()
clone
in class java.lang.Object
public java.lang.String dump()
ZDebug.dump(edu.umd.cs.jazz.ZNode)
public void addMouseListener(ZMouseListener l)
l
- the mouse listenerpublic void addMouseMotionListener(ZMouseMotionListener l)
l
- the mouse motion listenerprotected void fireEvent(ZEvent anEvent)
If the event is consumed, then the event will not be passed to any more listeners in the list.
anEvent
- The ZEventZEvent
protected javax.swing.event.EventListenerList getListenerList()
public boolean hasLisenerOfType(java.lang.Class aType)
aType
- The type of listener to search for.public boolean hasMouseListener()
protected void removeEventListener(java.lang.Class listenerType, java.util.EventListener listener)
l
- the mouse listenerpublic void removeMouseListener(ZMouseListener l)
l
- the mouse listenerpublic void removeMouseMotionListener(ZMouseMotionListener l)
l
- the mouse motion listenerpublic void fireMouseEvent(ZMouseEvent e)
If the event is consumed, then the event will not be passed event listeners on the Component that the event came through.
e
- The mouse eventEventListenerList
public void processMouseEvent(ZMouseEvent e)
public void writeObject(ZObjectOutputStream out) throws java.io.IOException
writeObject
in interface ZSerializable
out
- The stream that this object writes intopublic void writeObjectRecurse(ZObjectOutputStream out) throws java.io.IOException
writeObjectRecurse
in interface ZSerializable
out
- The stream that this object writes intopublic void setState(java.lang.String fieldType, java.lang.String fieldName, java.lang.Object fieldValue)
setState
in interface ZSerializable
fieldType
- The fully qualified type of the fieldfieldName
- The name of the fieldfieldValue
- The value of the field
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |