edu.umd.cs.jazz.event
Class ZNavEventHandlerKeyBoard

java.lang.Object
  |
  +--edu.umd.cs.jazz.event.ZEventHandler
        |
        +--edu.umd.cs.jazz.event.ZNavEventHandlerKeyBoard

public class ZNavEventHandlerKeyBoard
extends ZEventHandler

ZNavEventHandlerKeyBoard provides event handlers for basic zooming and panning of a Jazz camera with the keyboard. Applications can define which keys are used for navigation, and how much each key moves the camera.

The camera is changed a little bit with each keypress. If a key is held down so it auto-repeats, that is detected, and the camera will then be continuously moved in until the key is released, or another key is pressed at which point it will return to the original behavior of one increment per key press.

The default parameters are: PageUp zooms in PageDown zooms out Arrow keys pan Each keypress zooms in 25%, or pans 25% Each camera change is animated over 250 milliseconds The camera is zoomed around the cursor


Field Summary
protected  int animTime
           
protected  boolean autoNav
           
protected  float autoPanXDelta
           
protected  float autoPanYDelta
           
protected  float autoZoomDelta
           
protected  int delay
           
protected  int homeKey
           
protected  float panDelta
           
protected  int panDownKey
           
protected  int panLeftKey
           
protected  int panRightKey
           
protected  int panUpKey
           
protected  java.awt.geom.Point2D pointerPosition
           
protected  int prevKeyPress
           
protected  float scaleDelta
           
protected  int zoomInKey
           
protected  int zoomOutKey
           
 
Fields inherited from class edu.umd.cs.jazz.event.ZEventHandler
activated, component, keyAdapter, mouseAdapter, mouseMotionAdapter, surface
 
Constructor Summary
ZNavEventHandlerKeyBoard(java.awt.Component c, ZSurface v)
          Constructs a new ZNavEventHandlerKeyBoard.
 
Method Summary
 boolean isAutoNav()
          Return true if currently auto-zooming
 void keyPressed(java.awt.event.KeyEvent e)
          Key press event handler
 void keyReleased(java.awt.event.KeyEvent e)
          Key release event handler
 void mouseDragged(java.awt.event.MouseEvent e)
           
 void mouseMoved(java.awt.event.MouseEvent e)
          Watch mouse motion so we always know where the mouse is.
 void navOneStep()
          Implements auto-navigation
 void setHomeKey(int homeKey)
          Define the key that is used to home.
 void setPanKeys(int leftKey, int rightKey, int upKey, int downKey)
          Define the keys that are used to pan.
 void setZoomKeys(int inKey, int outKey)
          Define the keys that are used to zoom.
 void startAutoNav()
          Start the auto navigation
 void stopAutoNav()
          Stops the auto navigation
 
Methods inherited from class edu.umd.cs.jazz.event.ZEventHandler
activate, deactivate, getCamera, getComponent, getSurface, keyTyped, mousePressed, mouseReleased
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

autoNav

protected boolean autoNav

scaleDelta

protected float scaleDelta

panDelta

protected float panDelta

autoPanXDelta

protected float autoPanXDelta

autoPanYDelta

protected float autoPanYDelta

autoZoomDelta

protected float autoZoomDelta

pointerPosition

protected java.awt.geom.Point2D pointerPosition

animTime

protected int animTime

zoomInKey

protected int zoomInKey

zoomOutKey

protected int zoomOutKey

panLeftKey

protected int panLeftKey

panRightKey

protected int panRightKey

panUpKey

protected int panUpKey

panDownKey

protected int panDownKey

homeKey

protected int homeKey

prevKeyPress

protected int prevKeyPress

delay

protected int delay
Constructor Detail

ZNavEventHandlerKeyBoard

public ZNavEventHandlerKeyBoard(java.awt.Component c,
                                ZSurface v)
Constructs a new ZNavEventHandlerKeyBoard.
Parameters:
c - The component that this event handler listens to events on
v - The surface that is panned
Method Detail

setZoomKeys

public void setZoomKeys(int inKey,
                        int outKey)
Define the keys that are used to zoom. A key can be set to 0 to disable that function.
Parameters:
inKey - The keycode of the key that should trigger zoom in events.
outKey - The keycode of the key that should trigger zoom out events.

setPanKeys

public void setPanKeys(int leftKey,
                       int rightKey,
                       int upKey,
                       int downKey)
Define the keys that are used to pan. A key can be set to 0 to disable that function.
Parameters:
leftKey - The keycode of the key that should trigger pan left events.
rightKey - The keycode of the key that should trigger pan right events.
upKey - The keycode of the key that should trigger pan up events.
downKey - The keycode of the key that should trigger pan down events.

setHomeKey

public void setHomeKey(int homeKey)
Define the key that is used to home. A key can be set to 0 to disable that function.
Parameters:
homeKey - The keycode of the key that should trigger the home event.

keyPressed

public void keyPressed(java.awt.event.KeyEvent e)
Key press event handler
Parameters:
e - The event.
Overrides:
keyPressed in class ZEventHandler

keyReleased

public void keyReleased(java.awt.event.KeyEvent e)
Key release event handler
Parameters:
e - The event.
Overrides:
keyReleased in class ZEventHandler

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent e)
Watch mouse motion so we always know where the mouse is. We can use this info to zoom around the mouse position.
Overrides:
mouseMoved in class ZEventHandler

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent e)
Overrides:
mouseDragged in class ZEventHandler

isAutoNav

public boolean isAutoNav()
Return true if currently auto-zooming

startAutoNav

public void startAutoNav()
Start the auto navigation

stopAutoNav

public void stopAutoNav()
Stops the auto navigation

navOneStep

public void navOneStep()
Implements auto-navigation