edu.umd.cs.jazz.event
Class ZSelectionResizeHandler

java.lang.Object
  |
  +--edu.umd.cs.jazz.event.ZSelectionResizeHandler
All Implemented Interfaces:
java.util.EventListener, java.io.Serializable, ZEventHandler, ZGroupListener

public class ZSelectionResizeHandler
extends java.lang.Object
implements ZEventHandler, ZGroupListener, java.io.Serializable

ZSelectionResizeHandler is a selection handler for use with ZSelectionManager. ZSelectionResizeHandler renders resize "handles" over the current selection, and allows the user to resize the selection by dragging these handles.

Resizing works as expected from drawing applications such as PowerPoint. Dragging a resize handle allows for unconstrained scaling while shift-drag allows constrained proportion scaling.

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.

Author:
Antony Courtney, Yale University
, Lance Good, University of Maryland , Benjamin Bederson, University of Maryland
See Also:
ZSelectionManager, ZSelectionModifyHandler, ZSelectionMoveHandler, ZSelectionDeleteHandler, ZSelectionScaleHandler, Serialized Form

Nested Class Summary
static class ZSelectionResizeHandler.ResizeEvent
          An event to signal that a node has been resized by this event handler.
protected  class ZSelectionResizeHandler.ResizeHandles
          Inner class used to render resize handles over a single component.
static interface ZSelectionResizeHandler.ResizeListener
          Interface that a class must implement to handle the resizing of the selected nodes for a given ZSelectionResizeHandler.
 
Field Summary
protected  java.util.HashMap activeHandles
          active resize handles.
protected  javax.swing.event.EventListenerList listenerList
          registered event listeners
protected static double RESIZE_HANDLE_SIZE
          The resize handle size
 
Constructor Summary
ZSelectionResizeHandler(ZNode node)
          Construct a new ZSelectionResizeHandler which will be active across all cameras
ZSelectionResizeHandler(ZNode node, ZCamera camera)
          Construct a new ZSelectionResizeHandler.
 
Method Summary
 void addResizeListener(ZSelectionResizeHandler.ResizeListener l)
          Add a ResizeListener, registered for nodeResized events.
protected  ZSelectionResizeHandler.ResizeHandles createResizeHandles()
          render the resize handles on a selected node
protected  ZSelectionResizeHandler.ResizeListener createResizeListener()
          Creates the default resizer which just allows unconstrained scale resizing.
protected  void fireResizeEvent(ZSelectionResizeHandler.ResizeEvent re)
          Fires the resize event on the appropriate listeners
 java.awt.Color getHighLightColor()
          Gets the current highlight color
protected  void init()
          Initializes this event handler
 boolean isActive()
          Determines if this event handler is active.
 void nodeAdded(ZGroupEvent e)
          required method of ZGroupListener:
 void nodeRemoved(ZGroupEvent e)
          required method of ZGroupListener:
 void removeResizeListener(ZSelectionResizeHandler.ResizeListener l)
          Remove a ResizeListener, registered for nodeResized events.
protected  void scale(ZTransformGroup zTransform, double dxz, double dyz, double x, double y)
          Scales the given ZTransformGroup by the given (unconstrained) scale factors around the specified point
 void setActive(boolean active)
          Specifies whether this event handler is active
 void setDefaultResizeListenerActive(boolean active)
          Remove the default resize listener
 void setHighLightColor(java.awt.Color color)
          Sets the highlight color for this resize handler.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RESIZE_HANDLE_SIZE

protected static double RESIZE_HANDLE_SIZE
The resize handle size


activeHandles

protected transient java.util.HashMap activeHandles
active resize handles. Maps from ZNode -> ResizeHandle


listenerList

protected transient javax.swing.event.EventListenerList listenerList
registered event listeners

Constructor Detail

ZSelectionResizeHandler

public ZSelectionResizeHandler(ZNode node)
Construct a new ZSelectionResizeHandler which will be active across all cameras

Parameters:
node - The node to which this handler attaches

ZSelectionResizeHandler

public ZSelectionResizeHandler(ZNode node,
                               ZCamera camera)
Construct a new ZSelectionResizeHandler.

Parameters:
node - The node to which this handler attaches
camera - The camera to which this handler attaches
Method Detail

addResizeListener

public void addResizeListener(ZSelectionResizeHandler.ResizeListener l)
Add a ResizeListener, registered for nodeResized events.

Parameters:
l - The resize listener to register

removeResizeListener

public void removeResizeListener(ZSelectionResizeHandler.ResizeListener l)
Remove a ResizeListener, registered for nodeResized events.

Parameters:
l - The resize listener to un-register

createResizeListener

protected ZSelectionResizeHandler.ResizeListener createResizeListener()
Creates the default resizer which just allows unconstrained scale resizing.


createResizeHandles

protected ZSelectionResizeHandler.ResizeHandles createResizeHandles()
render the resize handles on a selected node


fireResizeEvent

protected void fireResizeEvent(ZSelectionResizeHandler.ResizeEvent re)
Fires the resize event on the appropriate listeners

Parameters:
re - The resize event to be fired

getHighLightColor

public java.awt.Color getHighLightColor()
Gets the current highlight color

Returns:
The current highlight color

init

protected void init()
Initializes this event handler


isActive

public boolean isActive()
Determines if this event handler is active.

Specified by:
isActive in interface ZEventHandler
Returns:
True if active

nodeAdded

public void nodeAdded(ZGroupEvent e)
required method of ZGroupListener:

Specified by:
nodeAdded in interface ZGroupListener
Parameters:
e - The group event.

nodeRemoved

public void nodeRemoved(ZGroupEvent e)
required method of ZGroupListener:

Specified by:
nodeRemoved in interface ZGroupListener
Parameters:
e - The group event.

scale

protected void scale(ZTransformGroup zTransform,
                     double dxz,
                     double dyz,
                     double x,
                     double y)
Scales the given ZTransformGroup by the given (unconstrained) scale factors around the specified point

Parameters:
zTransform - The transform group to scale
dxz - The x scale
dyz - The y scale
x - The x coordinate around which to scale
y - The y coordinate around which to scale

setActive

public void setActive(boolean active)
Specifies whether this event handler is active

Specified by:
setActive in interface ZEventHandler
Parameters:
active - True to make this event handler active

setDefaultResizeListenerActive

public void setDefaultResizeListenerActive(boolean active)
Remove the default resize listener


setHighLightColor

public void setHighLightColor(java.awt.Color color)
Sets the highlight color for this resize handler.

Parameters:
color - The new highlight color


Copyright 2003 by University of Maryland, College Park, MD 20742, USA All rights reserved.