|
||||||||||
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.ZNode | +--edu.umd.cs.jazz.ZGroup | +--edu.umd.cs.jazz.ZVisualGroup | +--edu.umd.cs.jazz.ZSelectionGroup
ZSelectionGroup is a visual group node that provides functionality for specifying
selection. Inserting a selection group in the scenegraph will visually
select its subtree. It has utility methods for selecting and unselecting nodes,
and for determining the selected nodes in a sub-tree.
It manages a visual component that actually represents the selection, and shows
a selected node by surrounding its children with a 1 pixel wide line.
To give selection a new visual look, an application can set the
SelectionComponentFactory setSelectionComponentFactory(edu.umd.cs.jazz.ZSelectionGroup.SelectionComponentFactory)
The primary visual component generation has changed to use a factory. This allows a developer to more easily change the look of all selected components. The following code demonstrates changing the default selection to be an ellipse, rather than a rectangle:
ZSelectionGroup.setSelectionComponentFactory(new ZSelectionGroup.SelectionComponentFactory() { public ZVisualComponent createSelectionComponent() { return new SelectionEllipse(); } });with the following example implementation of SelectionEllipse:
public class SelectionEllipse extends ZVisualComponent { public SelectionEllipse() { } public boolean pick(Rectangle2D pickRect, ZSceneGraphPath path) { return false; // pick handled by SelectionGroup } public void render(ZRenderContext ctx) { Graphics2D g2 = ctx.getGraphics2D(); double mag = ctx.getCompositeMagnification(); double sz = 1.0 / mag; ZNode p = getParents()[0]; if (p instanceof ZSelectionGroup) { ZSelectionGroup g = (ZSelectionGroup)p; Ellipse2D e = new Ellipse2D.Double(); e.setFrame(g.getBounds()); double x = e.getX(); double y = e.getY(); double w = e.getWidth(); double h = e.getHeight(); // don't draw very small selection objects if (w * mag < 2 || h * mag < 2) return; // shrink bounds by 1 pixel to ensure I am // inside them e.setFrame(x + sz, y + sz, w - sz*2, h - sz*2); g2.setStroke(new BasicStroke((float)sz)); g2.setColor(g.getPenColor()); g2.draw(e); } } // SelectionEllipse's have no logical bounds. protected void computeBounds() { }
ZSceneGraphEditor
provides a convenience mechanism to locate, create
and manage nodes of this type.
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.
Inner Class Summary | |
static interface |
ZSelectionGroup.SelectionComponentFactory
|
Field Summary | |
static java.awt.Color |
penColor_DEFAULT
|
Fields inherited from class edu.umd.cs.jazz.ZVisualGroup |
visualComponentPickable_DEFAULT |
Fields inherited from class edu.umd.cs.jazz.ZGroup |
children, childrenFindable_DEFAULT, childrenPickable_DEFAULT, hasOneChild_DEFAULT |
Fields inherited from class edu.umd.cs.jazz.ZNode |
findable_DEFAULT, pickable_DEFAULT, savable_DEFAULT, selectable_DEFAULT |
Fields inherited from class edu.umd.cs.jazz.ZSceneGraphObject |
bounds, listenerList, volatileBounds, volatileBounds_DEFAULT |
Constructor Summary | |
ZSelectionGroup()
Constructs a new ZSelectionGroup. |
|
ZSelectionGroup(ZNode child)
Constructs a new select group node with the specified node as a child of the new group. |
Method Summary | |
void |
addAuxiliaryVisualComponent(ZVisualComponent visualComponent)
Adds an auxiliary visual component to this selection group |
void |
clearAuxiliaryVisualComponents()
Remove all auxiliary visual components from this selection group. |
ZVisualComponent[] |
getAuxiliaryVisualComponents()
Return the auxiliary visual components associated with this selection group. |
java.awt.Color |
getPenColor()
Get the pen color that is used to render the selection. |
static java.util.ArrayList |
getSelectedNodes(ZCamera camera)
Deprecated. as of Jazz 1.1, replaced by ZSelectionManager.getSelectedNodes(ZCamera) |
static java.util.ArrayList |
getSelectedNodes(ZNode node)
Deprecated. as of Jazz 1.1, replaced by ZSelectionManager.getSelectedNodes(ZNode) |
static boolean |
isSelected(ZNode node)
Deprecated. as of Jazz 1.1, replaced by ZSelectionManager.isSelected(ZNode) |
boolean |
pick(java.awt.geom.Rectangle2D rect,
ZSceneGraphPath path)
ZSelectionGroup overrides this method to check whether any of the auxiliary visual components have been picked. |
void |
removeAuxiliaryVisualComponent(ZVisualComponent visualComponent)
Remove an auxiliary visual component from this selection group. |
void |
render(ZRenderContext renderContext)
Renders this node which results in the node's visual component getting rendered, followed by its children getting rendered. |
static ZSelectionGroup |
select(ZNode node)
Deprecated. as of Jazz 1.1, replaced by ZSelectionManager.select(ZNode) |
void |
setAuxiliaryVisualComponent(ZVisualComponent visualComponent)
Set the auxiliary visual component associated with this selection group. |
void |
setPenColor(java.awt.Color color)
Set the pen color that is used to render the selection. |
static void |
setSelectionComponentFactory(ZSelectionGroup.SelectionComponentFactory newFactory)
Set the SelectionComponentFactory used to generate visual components for selected objects |
void |
trimToSize()
Trims the capacity of the array that stores the parents list points to the actual number of points. |
static void |
unselect(ZNode node)
Deprecated. as of Jazz 1.1, replaced by ZSelectionManager.unselect(ZNode) |
static void |
unselectAll(ZCamera camera)
Deprecated. as of Jazz 1.1, replaced by ZSelectionManager.unselectAll(ZCamera) |
static void |
unselectAll(ZNode node)
Deprecated. as of Jazz 1.1, replaced by ZSelectionManager.unselectAll(ZNode) |
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 edu.umd.cs.jazz.ZNode |
addClientProperty, addNodeListener, editor, getClientProperty, getGlobalBounds, getGlobalToLocalTransform, getLocalToGlobalTransform, getParent, getRoot, globalToLocal, globalToLocal, hasNodeListener, isAncestorOf, isDescendentOf, isFindable, isPickable, isSavable, isSelectable, localToGlobal, localToGlobal, lower, lowerTo, percolateEventUpSceneGraph, putClientProperty, raise, raiseTo, remove, repaint, repaint, repaint, reparent, replaceWith, setEditorFactory, setFindable, setParent, setPickable, setSavable, setSelectable, updateBounds, updateObjectReferences, writeReplace |
Methods inherited from class edu.umd.cs.jazz.ZSceneGraphObject |
addMouseListener, addMouseMotionListener, clone, fireEvent, fireMouseEvent, getBounds, getBoundsReference, getListenerList, 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 |
Methods inherited from interface edu.umd.cs.jazz.io.ZSerializable |
setState |
Field Detail |
public static final java.awt.Color penColor_DEFAULT
Constructor Detail |
public ZSelectionGroup()
public ZSelectionGroup(ZNode child)
child
- Child of the new group node.Method Detail |
public void addAuxiliaryVisualComponent(ZVisualComponent visualComponent)
visualComponent
- The auxiliary visual component to be addedpublic void removeAuxiliaryVisualComponent(ZVisualComponent visualComponent)
visualComponent
- The visual component to be removed.public void setAuxiliaryVisualComponent(ZVisualComponent visualComponent)
visualComponent
- The new visual component for this group.public final ZVisualComponent[] getAuxiliaryVisualComponents()
public void clearAuxiliaryVisualComponents()
protected void updateVolatility()
updateVolatility
in class ZVisualGroup
ZSceneGraphObject.setVolatileBounds(boolean)
,
ZGroup.getVolatileBounds()
public static java.util.ArrayList getSelectedNodes(ZNode node)
ZSelectionManager.getSelectedNodes(ZNode)
public static java.util.ArrayList getSelectedNodes(ZCamera camera)
ZSelectionManager.getSelectedNodes(ZCamera)
public static ZSelectionGroup select(ZNode node)
ZSelectionManager.select(ZNode)
public static void unselect(ZNode node)
ZSelectionManager.unselect(ZNode)
public static void unselectAll(ZNode node)
ZSelectionManager.unselectAll(ZNode)
public static void unselectAll(ZCamera camera)
ZSelectionManager.unselectAll(ZCamera)
public static boolean isSelected(ZNode node)
ZSelectionManager.isSelected(ZNode)
public java.awt.Color getPenColor()
public void setPenColor(java.awt.Color color)
color
- the pen color, or null if none.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.
render
in class ZVisualGroup
renderContext
- The graphics context to use for rendering.public boolean pick(java.awt.geom.Rectangle2D rect, ZSceneGraphPath path)
pick
in class ZVisualGroup
rect
- The picking rectanglepath
- The picking path up to this nodepublic static void setSelectionComponentFactory(ZSelectionGroup.SelectionComponentFactory newFactory)
componentFactory
- The new SelectionComponentFactorypublic void writeObject(ZObjectOutputStream out) throws java.io.IOException
writeObject
in interface ZSerializable
writeObject
in class ZVisualGroup
out
- The stream that this object writes intopublic void writeObjectRecurse(ZObjectOutputStream out) throws java.io.IOException
writeObjectRecurse
in interface ZSerializable
writeObjectRecurse
in class ZVisualGroup
out
- The stream that this object writes intopublic void trimToSize()
trimToSize
in class ZGroup
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |