edu.umd.cs.jazz.event
Class ZoomEventHandler

java.lang.Object
  |
  +--edu.umd.cs.jazz.event.ZFilteredEventHandler
        |
        +--edu.umd.cs.jazz.event.ZDragSequenceEventHandler
              |
              +--edu.umd.cs.jazz.event.ZoomEventHandler
All Implemented Interfaces:
ZEventHandler

public class ZoomEventHandler
extends ZDragSequenceEventHandler

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.

On a Mac with its single mouse button one may wish to change the standard right mouse button zooming behavior. This can be easily done with the ZMouseFilter. For example to zoom with button one and shift you would do this:


 zoomEventHandler.getMouseFilter().setAndMask(InputEvent.BUTTON1_MASK |
                                              InputEvent.SHIFT_MASK);
 

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

Author:
Benjamin B. Bederson
, Jesse Grosjean

Nested Class Summary
 
Nested classes inherited from class edu.umd.cs.jazz.event.ZFilteredEventHandler
ZFilteredEventHandler.ZFilteredEventDispatcher
 
Field Summary
 
Fields inherited from class edu.umd.cs.jazz.event.ZFilteredEventHandler
fFilteredEventDispatcher, fMouseFilter
 
Constructor Summary
ZoomEventHandler(ZSceneGraphObject aFilteredMouseEventSource)
          Constructs a new ZoomEventHandler.
 
Method Summary
protected  void endDrag(ZMouseEvent e)
          When the dragging action ends invoke stopZooming.
protected  java.awt.geom.AffineTransform generateNextViewTransform()
          Return the next view transform for the current cameras zooming sequence.
 double getMaxMagnification()
          Return the max magnification that the zooming action is bound by.
 double getMinMagnification()
          Return the min magnification that the zooming action is bound by.
 ZMouseFilter getMouseFilter()
          Return the current event filter.
protected  boolean isZooming()
          Return if is zooming.
protected  void isZooming(boolean aBoolean)
          Set if is zooming.
 void setMaxMagnification(double aMagnification)
          Set the maximum magnification that the camera can be set to with this event handler.
 void setMinMagnification(double aMagnification)
          Set the minimum magnification that the camera can be set to with this event handler.
protected  void startDrag(ZMouseEvent e)
          When the dragging action starts invoke startZooming.
protected  void startZooming(ZMouseEvent e)
          Start zooming around the given mouse point with the interaction camera.
protected  void stopZooming(ZMouseEvent e)
          Stop animated zooming.
protected  void zoomOneStep()
          Do one zooming step, sleep a short amount, and schedule the next zooming step.
 
Methods inherited from class edu.umd.cs.jazz.event.ZDragSequenceEventHandler
drag, dragInScreenCoords, filteredMouseDragged, filteredMousePressed, filteredMouseReleased, getCurrentScreenDelta, getCurrentScreenPoint, getDragStartScreenPoint, getMinDragStartDistance, getMousePressedScreenPoint, getPreviousScreenPoint, isDragging, setIsDragging, setMinDragStartDistance, shouldStartDragInteraction
 
Methods inherited from class edu.umd.cs.jazz.event.ZFilteredEventHandler
filteredKeyPressed, filteredKeyReleased, filteredKeyTyped, filteredMouseClicked, filteredMouseEntered, filteredMouseExited, filteredMouseMoved, getCurrentFilteredMouseEvent, getCurrentSelection, getFilteredEventDispatcher, getFilteredKeyEventSource, getFilteredMouseEventSource, getInteractionCamera, getTopCamera, isActive, setActive, setFilteredKeyEventSource, setFilteredMouseEventSource, setMouseFilter, wantsKeyEvents, wantsMouseEvents, wantsMouseMotionEvents
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ZoomEventHandler

public ZoomEventHandler(ZSceneGraphObject aFilteredMouseEventSource)
Constructs a new ZoomEventHandler.

Parameters:
aFilteredMouseEventSource - the source for filtered ZMouseEvents and ZMouseMotionEvents. See the ZFilteredEventHandler class comment to customize this behavior.
Method Detail

endDrag

protected void endDrag(ZMouseEvent e)
When the dragging action ends invoke stopZooming.

Overrides:
endDrag in class ZDragSequenceEventHandler
Parameters:
e - the event causing the end of the drag sequence.

generateNextViewTransform

protected java.awt.geom.AffineTransform generateNextViewTransform()
Return the next view transform for the current cameras zooming sequence.

Returns:
the next view transform for the zooming camera.

getMaxMagnification

public double getMaxMagnification()
Return the max magnification that the zooming action is bound by. If the value is <= 0 then this feature is disabled. The default value is -1.

Returns:
the max camera magnification.

getMinMagnification

public double getMinMagnification()
Return the min magnification that the zooming action is bound by. The default value is 0.

Returns:
the min camera magnification.

getMouseFilter

public ZMouseFilter getMouseFilter()
Return the current event filter. If no filter is specified then return a filter that only accepts BUTTON3 by default.

Overrides:
getMouseFilter in class ZFilteredEventHandler
Returns:
the filter that is currently in effect.

isZooming

protected boolean isZooming()
Return if is zooming.

Returns:
true if new zoom steps are currently being scheduled.

isZooming

protected void isZooming(boolean aBoolean)
Set if is zooming.


setMaxMagnification

public void setMaxMagnification(double aMagnification)
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.


setMinMagnification

public void setMinMagnification(double aMagnification)
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 is set to a value which is greater than the current camera magnification, then the camera is left at its current magnification.


startDrag

protected void startDrag(ZMouseEvent e)
When the dragging action starts invoke startZooming.

Overrides:
startDrag in class ZDragSequenceEventHandler
Parameters:
e - the event starting the drag sequence.

startZooming

protected void startZooming(ZMouseEvent e)
Start zooming around the given mouse point with the interaction camera.


stopZooming

protected void stopZooming(ZMouseEvent e)
Stop animated zooming.


zoomOneStep

protected 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.



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