edu.umd.cs.jazz.event
Class ZoomToEventHandler

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

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

ZoomToEventhandler provides the ability to zoom the current camera to a target node on the drawing surface. On a double click with the right mouse button this event handler will zoom to the node that picked by the mouse click. If no object 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 makeZoomToScale(aScale) and makeZoomToScreen(aSpacing).

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:
Jesse Grosjean
See Also:
Serialized Form

Constructor Summary
ZoomToEventHandler(ZNode aNode)
          Constructs a new ZoomToEventHandler.
ZoomToEventHandler(ZNode aNode, ZNode aDefaultZoomToNode)
          Constructs a new ZoomToEventHandler.
 
Method Summary
protected  ZCamera getCameraToZoomWith(ZSceneGraphPath aPath)
          Get the camera from the scene graph path that we will use to perform the zoom.
protected  ZNode getNodeToZoomTo(ZSceneGraphPath aPath)
          Get the node the use for the target of the zoom.
 int getZoomTime()
          Get the amount of time that the zoom animation will take.
 boolean isActive()
          Determines if this event handler is active.
 void makeZoomToScale(double aScale)
          This method puts the event handler in zoom to scale mode.
 void makeZoomToScreen(double aSpacing)
          This method puts the event handler in zoom to screen mode.
 void mouseClicked(ZMouseEvent e)
          Invoked when the mouse has been clicked on a component.
 void mouseEntered(ZMouseEvent e)
          Invoked when the mouse enters a component.
 void mouseExited(ZMouseEvent e)
          Invoked when the mouse exits a component.
 void mousePressed(ZMouseEvent e)
          If the mouse is double clicked then zoom into the picked node.
 void mouseReleased(ZMouseEvent e)
          Mouse release event handler
 void setActive(boolean active)
          Specifies whether this event handler is active or not.
 void setDefaultZoomToNode(ZNode aNode)
          Set the default node to zoom to.
 int setZoomTime(int aTime)
          Set the amount of time that the zoom animation will take.
protected  void zoomToScaleWith(ZCamera aCamera, ZNode aNode)
          Zoom the specified camera so that the specified target node appears at a certain scale on the screen.
protected  void zoomToScreenWith(ZCamera aCamera, ZNode aNode)
          Zoom the specified camera so that the specified target node fills the screen minus the spacing set in makeZoomToScreen(aSpacing);
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ZoomToEventHandler

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

ZoomToEventHandler

public ZoomToEventHandler(ZNode aNode,
                          ZNode aDefaultZoomToNode)
Constructs a new ZoomToEventHandler.
Parameters:
aNode - The node this event handler attaches to.
aDefaultZoomToNode - The node that we should zoom to if no other node is picked.
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)
If the mouse is double clicked then zoom into the picked node.
Specified by:
mousePressed in interface ZMouseListener
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

getCameraToZoomWith

protected ZCamera getCameraToZoomWith(ZSceneGraphPath aPath)
Get the camera from the scene graph path that we will use to perform the zoom.

getNodeToZoomTo

protected ZNode getNodeToZoomTo(ZSceneGraphPath aPath)
Get the node the use for the target of the zoom.

getZoomTime

public int getZoomTime()
Get the amount of time that the zoom animation will take.

setZoomTime

public int setZoomTime(int aTime)
Set the amount of time that the zoom animation will take.

setDefaultZoomToNode

public void setDefaultZoomToNode(ZNode aNode)
Set the default node to zoom to. This node is zoomed to when there is a double click, but no object has been picked. Usually the default zoom to node is set to a layer group.

makeZoomToScale

public void makeZoomToScale(double aScale)
This method puts the event handler in zoom to scale mode. This means that when the handler zooms to a picked node it will zoom to so that the picked node appears in the specified scale on the screen.

makeZoomToScreen

public void makeZoomToScreen(double aSpacing)
This method puts the event handler in zoom to screen mode. This means that when the handler zooms to a picked node it will zoom to so that the picked node fills the screen (camera view bounds), minus the specified spacing.

zoomToScaleWith

protected void zoomToScaleWith(ZCamera aCamera,
                               ZNode aNode)
Zoom the specified camera so that the specified target node appears at a certain scale on the screen. This scale is set by makeZoomToScale(aScale);

zoomToScreenWith

protected void zoomToScreenWith(ZCamera aCamera,
                                ZNode aNode)
Zoom the specified camera so that the specified target node fills the screen minus the spacing set in makeZoomToScreen(aSpacing);


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