edu.umd.cs.jazz.event
Class ZoomToEventHandler

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

public class ZoomToEventHandler
extends ZFilteredEventHandler

ZoomToEventhandler provides the ability to zoom the interaction camera to a target node on the drawing surface.

On filtered mouse pressed with the right mouse button this event handler will zoom to the node that was picked by the mouse press. If no node was picked then it will zoom to its default zoom to node that is specified when the event handler is created or by setDefaultZoomToNode. The event handler uses two methods to zoom into a target node. The method to use is set by setZoomToScale and setZoomToScreen.

Author:
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
ZoomToEventHandler(ZSceneGraphObject aFilteredMouseEventSource)
          Constructs a new ZoomToEventHandler.
ZoomToEventHandler(ZSceneGraphObject aFilteredMouseEventSource, ZNode aDefaultZoomToNode)
          Constructs a new ZoomToEventHandler.
 
Method Summary
 void filteredMousePressed(ZMouseEvent e)
          Maps filtered mouse pressed onto the zoomTo action.
 ZMouseFilter getMouseFilter()
          Return the event filter.
protected  ZNode getNodeToZoomTo(ZMouseEvent aEvent)
          Return the node that should be zoomed to for the given event.
 int getZoomTime()
          Return the amount of time that the zoom action should take.
 void setDefaultZoomToNode(ZNode aDefaultZoomToNode)
          Set the default node that the camera should zoom to when no other node is picked for a zoom action.
 int setZoomTime(int aTime)
          Set the amount of time that the zoom action should take.
 void setZoomToScale(double aScale)
          Set the zoom mode to scale.
 void setZoomToScreen(double aSpacing)
          Set the zoom mode to screen.
protected  void zoomTo(ZMouseEvent e)
          Zoom the interaction camera to the node picked by the current mouse event.
protected  void zoomToScaleWith(ZCamera aCamera, ZNode aNode)
          Zoom the specified camera so that the specified node appears in the center of the camera view at the scale specified by setZoomToScale.
protected  void zoomToScreenWith(ZCamera aCamera, ZNode aNode)
          Zoom the specified camera so that the specified node fills the center of the camera view minus the specified spacing set in setZoomToScreen.
 
Methods inherited from class edu.umd.cs.jazz.event.ZFilteredEventHandler
filteredKeyPressed, filteredKeyReleased, filteredKeyTyped, filteredMouseClicked, filteredMouseDragged, filteredMouseEntered, filteredMouseExited, filteredMouseMoved, filteredMouseReleased, 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

ZoomToEventHandler

public ZoomToEventHandler(ZSceneGraphObject aFilteredMouseEventSource)
Constructs a new ZoomToEventHandler.

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

ZoomToEventHandler

public ZoomToEventHandler(ZSceneGraphObject aFilteredMouseEventSource,
                          ZNode aDefaultZoomToNode)
Constructs a new ZoomToEventHandler.

Parameters:
aFilteredMouseEventSource - the source for filtered ZMouseEvents and ZMouseMotionEvents. See the ZFilteredEventHandler class comment to customize this behavior.
aDefaultZoomToNode - The node that the event handler will zoom to if no other node is picked.
Method Detail

getMouseFilter

public ZMouseFilter getMouseFilter()
Return the event filter. If the filter is null then create the default event filter for ZPanEventHandler, it filters out events that do not have BUTTON1 pressed.

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

filteredMousePressed

public void filteredMousePressed(ZMouseEvent e)
Maps filtered mouse pressed onto the zoomTo action.

Overrides:
filteredMousePressed in class ZFilteredEventHandler
Parameters:
e - the filtered mouse pressed event.

zoomTo

protected void zoomTo(ZMouseEvent e)
Zoom the interaction camera to the node picked by the current mouse event. If no node is picked then zoom to the default zoom to node.

Parameters:
e - the event starting the zoomto action.

getNodeToZoomTo

protected ZNode getNodeToZoomTo(ZMouseEvent aEvent)
Return the node that should be zoomed to for the given event. The default behavior returns the node picked by the event. If no node is picked then the default zoom to node is returned.

Parameters:
aEvent - the event used to determine the node to zoom to.
Returns:
the node that the interaction camera should zoom to.

getZoomTime

public int getZoomTime()
Return the amount of time that the zoom action should take.

Returns:
the zoom animation duration.

setZoomTime

public int setZoomTime(int aTime)
Set the amount of time that the zoom action should take.

Parameters:
aTime - the duration for proceeding zoomto animations.

setDefaultZoomToNode

public void setDefaultZoomToNode(ZNode aDefaultZoomToNode)
Set the default node that the camera should zoom to when no other node is picked for a zoom action.

Parameters:
aDefaultZoomToNode - the default zoom to node.

setZoomToScale

public void setZoomToScale(double aScale)
Set the zoom mode to scale. This means the interaction camera will zoom so that the zoom to node appears at the specified scale on the screen.

Parameters:
aScale - the scale that the zoom to node should appear on the screen after a zoom action.

setZoomToScreen

public void setZoomToScreen(double aSpacing)
Set the zoom mode to screen. This means the interaction camera will zoom so that the zoom to node fills the screen minus the specified spacing.

Parameters:
aSpacing - the spacing that should be left around the zoom to node after a zoom action.

zoomToScaleWith

protected void zoomToScaleWith(ZCamera aCamera,
                               ZNode aNode)
Zoom the specified camera so that the specified node appears in the center of the camera view at the scale specified by setZoomToScale.

Parameters:
aCamera - the camera that will be zoomed.
aNode - the node that will be zoomed to.

zoomToScreenWith

protected void zoomToScreenWith(ZCamera aCamera,
                                ZNode aNode)
Zoom the specified camera so that the specified node fills the center of the camera view minus the specified spacing set in setZoomToScreen.

Parameters:
aCamera - the camera that will be zoomed.
aNode - the node that will be zoomed to.


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