edu.umd.cs.jazz.event
Class ZoomEventHandler

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

public class ZoomEventHandler
extends java.lang.Object
implements ZEventHandler, ZMouseListener, ZMouseMotionListener, java.io.Serializable

ZoomEventhandler provides event handlers for basic zooming of a Jazz camera with the right button. The interaction is that the initial mouse press defines the zoom anchor point, and then moving the mouse to the right zooms with a speed proportional to the amount the mouse is moved to the right of the anchor point. Similarly, if the mouse is moved to the left, the the camera is zoomed out.

This event handler will properly pan within internal cameras if the clicked within an internal camera.

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:
Benjamin B. Bederson
See Also:
Serialized Form

Inner Class Summary
protected  class ZoomEventHandler.ZoomEventState
          Provides indirect access this event handlers private state.
 
Constructor Summary
ZoomEventHandler(ZNode node)
          Constructs a new ZoomEventHandler.
ZoomEventHandler(ZNode node, ZCamera camera)
          Constructs a new ZoomEventHandler.
 
Method Summary
protected  java.awt.geom.AffineTransform generateNextViewTransform(ZoomEventHandler.ZoomEventState state)
          Return the next view transform for the interaction cameras zooming sequence.
 boolean isActive()
          Determines if this event handler is active.
 void mouseClicked(ZMouseEvent e)
          Invoked when the mouse has been clicked on a component.
 void mouseDragged(ZMouseEvent e)
          Mouse drag event handler
 void mouseEntered(ZMouseEvent e)
          Invoked when the mouse enters a component.
 void mouseExited(ZMouseEvent e)
          Invoked when the mouse exits a component.
 void mouseMoved(ZMouseEvent e)
          Invoked when the mouse button has been moved on a node (with no buttons no down).
 void mousePressed(ZMouseEvent e)
          Mouse press event handler
 void mouseReleased(ZMouseEvent e)
          Mouse release event handler
 void setActive(boolean active)
          Specifies whether this event handler is active or not.
 void setMaxMagnification(double newMaxMag)
          Set the maximum magnification that the camera can be set to with this event handler.
 void setMinMagnification(double newMinMag)
          Set the minimum magnification that the camera can be set to with this event handler.
 void startZooming()
          Start animated zooming.
 void stopZooming()
          Stop animated zooming.
 void zoomOneStep()
          Do one zooming step, sleep a short amount, and schedule the next zooming step.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ZoomEventHandler

public ZoomEventHandler(ZNode node)
Constructs a new ZoomEventHandler.
Parameters:
node - The node this event handler attaches to.

ZoomEventHandler

public ZoomEventHandler(ZNode node,
                        ZCamera camera)
Constructs a new ZoomEventHandler.
Parameters:
node - The node this event handler attaches to.
camera - The camera to which this event handler attaches
Method Detail

setActive

public void setActive(boolean active)
Specifies whether this event handler is active or not.
Specified by:
setActive in interface ZEventHandler
Parameters:
active - True to make this event handler active

isActive

public boolean isActive()
Determines if this event handler is active.
Specified by:
isActive in interface ZEventHandler
Returns:
True if active

mousePressed

public void mousePressed(ZMouseEvent e)
Mouse press event handler
Specified by:
mousePressed in interface ZMouseListener
Parameters:
e - The event.

mouseDragged

public void mouseDragged(ZMouseEvent e)
Mouse drag event handler
Specified by:
mouseDragged in interface ZMouseMotionListener
Parameters:
e - The event.

mouseReleased

public void mouseReleased(ZMouseEvent e)
Mouse release event handler
Specified by:
mouseReleased in interface ZMouseListener
Parameters:
e - The event.

mouseEntered

public void mouseEntered(ZMouseEvent e)
Invoked when the mouse enters a component.
Specified by:
mouseEntered in interface ZMouseListener

mouseExited

public void mouseExited(ZMouseEvent e)
Invoked when the mouse exits a component.
Specified by:
mouseExited in interface ZMouseListener

mouseClicked

public void mouseClicked(ZMouseEvent e)
Invoked when the mouse has been clicked on a component.
Specified by:
mouseClicked in interface ZMouseListener

mouseMoved

public void mouseMoved(ZMouseEvent e)
Invoked when the mouse button has been moved on a node (with no buttons no down).
Specified by:
mouseMoved in interface ZMouseMotionListener

startZooming

public void startZooming()
Start animated zooming.

setMinMagnification

public void setMinMagnification(double newMinMag)
Set the minimum magnification that the camera can be set to with this event handler. Setting the min mag to <= 0 disables this feature. If the min mag if set to a value which is greater than the current camera magnification, then the camera is left at its current magnification.
Parameters:
newMinMag - the new minimum magnification

setMaxMagnification

public void setMaxMagnification(double newMaxMag)
Set the maximum magnification that the camera can be set to with this event handler. Setting the max mag to <= 0 disables this feature. If the max mag if set to a value which is less than the current camera magnification, then the camera is left at its current magnification.
Parameters:
newMaxMag - the new maximum magnification

stopZooming

public void stopZooming()
Stop animated zooming.

zoomOneStep

public void zoomOneStep()
Do one zooming step, sleep a short amount, and schedule the next zooming step. This effectively continuously zooms while still accepting input events so that the zoom center point can be changed, and zooming can be stopped.

generateNextViewTransform

protected java.awt.geom.AffineTransform generateNextViewTransform(ZoomEventHandler.ZoomEventState state)
Return the next view transform for the interaction cameras zooming sequence.
Parameters:
state - provides access to the current state of the event handler. ZoomEventState is declared as a protected inner class in ZoomEventHandler.


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