|
||||||||||
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
ZVisualComponent is the base class for objects that actually get rendered. A visual component primarily implements three methods: paint(), pick(), and computeBounds(). New sub-classes must override at least paint() and computeBounds(), and will often choose to override pick() as well.
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.
Fields inherited from class edu.umd.cs.jazz.ZSceneGraphObject |
bounds, listenerList, volatileBounds, volatileBounds_DEFAULT |
Constructor Summary | |
ZVisualComponent()
Default constructor for visual component. |
Method Summary | |
void |
addParent(ZNode parent)
Method to add a node to be a new parent of this component. |
protected java.lang.Object |
duplicateObject()
Returns a clone of this object. |
int |
getNumParents()
Return the number of parents of this visual component. |
ZNode[] |
getParents()
Return a copy of the array of parents of this node. |
ZNode[] |
getParentsReference()
Returns a reference to the parents of this component. |
ZRoot |
getRoot()
Returns the root of the scene graph that this component is in. |
void |
paint(java.awt.Graphics2D g2)
Paints this component. |
boolean |
pick(java.awt.geom.Rectangle2D rect,
ZSceneGraphPath path)
Determines whether the specified rectangle (in local coordinates) should "pick" this visual component. |
boolean |
pickBounds(java.awt.geom.Rectangle2D rect)
This is a utility function to determine if the specified rectangle intersects the bounds of this visual component. |
void |
removeParent(ZNode parent)
Method to remove the specified parent node from this visual component. |
void |
render(ZRenderContext renderContext)
Renders this visual component. |
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 causes just the specified bounds of this visual component to be repainted. |
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 |
trimToSize()
Trims the capacity of the array that stores the parents list points to the actual number of points. |
protected void |
updateBounds()
Internal method that causes this node and all of its ancestors to recompute their bounds. |
protected void |
updateObjectReferences(ZObjectReferenceTable objRefTable)
Called to update internal object references after a clone operation by ZSceneGraphObject.clone() . |
protected void |
updateParentBounds()
Internal method that causes all the ancestors of this component to recompute their bounds. |
protected void |
updateVolatility()
Internal method to compute and cache the volatility of a component, 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 edu.umd.cs.jazz.ZSceneGraphObject |
addMouseListener, addMouseMotionListener, clone, computeBounds, dump, fireEvent, fireMouseEvent, getBounds, getBoundsReference, getListenerList, getVolatileBounds, hasLisenerOfType, hasMouseListener, processMouseEvent, removeEventListener, removeMouseListener, removeMouseMotionListener, reshape, setBounds, setVolatileBounds |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public ZVisualComponent()
Method Detail |
protected java.lang.Object duplicateObject()
duplicateObject
in class ZSceneGraphObject
ZSceneGraphObject.duplicateObject()
protected void updateObjectReferences(ZObjectReferenceTable objRefTable)
ZSceneGraphObject.clone()
.updateObjectReferences
in class ZSceneGraphObject
ZSceneGraphObject.updateObjectReferences(edu.umd.cs.jazz.util.ZObjectReferenceTable)
public void trimToSize()
protected void updateVolatility()
updateVolatility
in class ZSceneGraphObject
ZSceneGraphObject.setVolatileBounds(boolean)
,
ZSceneGraphObject.getVolatileBounds()
public ZRoot getRoot()
public ZNode[] getParents()
public int getNumParents()
public ZNode[] getParentsReference()
getNumParents()
.
Warning: This method returns a reference to an internal array. Any modification of this array will result in undefined behavior.
public void addParent(ZNode parent)
ZVisualLeaf.addVisualComponent(edu.umd.cs.jazz.ZVisualComponent)
instead.parent
- The new parent node.public void removeParent(ZNode parent)
ZVisualLeaf.addVisualComponent(edu.umd.cs.jazz.ZVisualComponent)
instead.parent
- The parent to be removed.public boolean pickBounds(java.awt.geom.Rectangle2D rect)
rect
- the rectangle that this method tests for intersection withpublic boolean pick(java.awt.geom.Rectangle2D rect, ZSceneGraphPath path)
The implementation of this pick method for the base visual component returns true if the rectangle intersects the bounds of the component. If a sub-class wants more detailed picking, then it must extend this class. For example, a circle may only consider itself to be picked if the pointer is within the circle - rather than within the rectangular bounds.
rect
- The rectangle that is picking this visual component in local coordinates.path
- The path through the scenegraph to the picked node. Modified by this call.ZDrawingSurface.pick(int, int)
public void paint(java.awt.Graphics2D g2)
The clip rectangle, composite mode and transform of the Graphics2D parameter are set by Jazz to reflect the context in which the component is being painted. However, the color, font and stroke of the Graphics2D parameter are left undefined by Jazz, and each visual component must set these attributes explicitly to ensure that they are painted correctly.
The paint method is called by ZVisualComponent.render. Some visual components may need to override render() instead of paint().
Graphics2D
- The graphics context to use for painting.render(ZRenderContext)
public void render(ZRenderContext renderContext)
This method is called by Jazz when the component needs to be redrawn on the screen. The default implementation of render simply calls paint(), passing it the graphics object stored in the renderContext:
paint(renderContext.getGraphics2D());
Sophisticated visual components may need access to the state information stored in the ZRenderContext to draw themselves. Such components should override render() rather than paint().
renderContext
- The graphics context to use for rendering.paint(Graphics2D)
public void repaint()
ZSceneGraphObject
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.)
repaint
in class ZSceneGraphObject
edu.umd.cs.jazz.ZSceneGraphObject
ZSceneGraphObject.reshape()
public void repaint(ZBounds repaintBounds)
repaintBounds
- The bounds to repaintrepaint()
protected void updateBounds()
updateBounds
in class ZSceneGraphObject
protected void updateParentBounds()
public void writeObject(ZObjectOutputStream out) throws java.io.IOException
writeObject
in interface ZSerializable
writeObject
in class ZSceneGraphObject
out
- The stream that this object writes intopublic void writeObjectRecurse(ZObjectOutputStream out) throws java.io.IOException
writeObjectRecurse
in interface ZSerializable
writeObjectRecurse
in class ZSceneGraphObject
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
setState
in class ZSceneGraphObject
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 |