edu.umd.cs.piccolo.event
Class PPanEventHandler

java.lang.Object
  extended by edu.umd.cs.piccolo.event.PBasicInputEventHandler
      extended by edu.umd.cs.piccolo.event.PDragSequenceEventHandler
          extended by edu.umd.cs.piccolo.event.PPanEventHandler
All Implemented Interfaces:
PInputEventListener, EventListener

public class PPanEventHandler
extends PDragSequenceEventHandler

PPanEventHandler provides event handlers for basic panning of the canvas view with the left mouse. The interaction is that clicking and dragging the mouse translates the view so that the point on the surface stays under the mouse.

Version:
1.0
Author:
Jesse Grosjean

Constructor Summary
PPanEventHandler()
          Constructs a Pan Event Handler that will by default perform auto-panning.
 
Method Summary
protected  void drag(PInputEvent event)
          Updates the view in response to a user initiated drag event.
protected  void dragActivityStep(PInputEvent event)
          Performs auto-panning if enabled, even when the mouse is not moving.
 boolean getAutopan()
          Returns whether the auto-panning functoinality is enabled.
 double getMaxAutoPanSpeed()
          Returns the maxAutoPan speed in pixels per second.
 double getMinAutoPanSpeed()
          Returns the minAutoPan speed in pixels per second.
protected  void pan(PInputEvent event)
          Pans the camera in response to the pan event provided.
 void setAutopan(boolean autopan)
          Determines if auto-panning will occur or not.
 void setMaxAutopanSpeed(double maxAutopanSpeed)
          Set the maxAutoPan speed in pixels per second.
 void setMinAutopanSpeed(double minAutopanSpeed)
          Set the minAutoPan speed in pixels per second.
protected  double validatePanningSpeed(double delta)
          Clips the panning speed to the minimum and maximum auto-pan speeds assigned.
 
Methods inherited from class edu.umd.cs.piccolo.event.PDragSequenceEventHandler
dragActivityFinalStep, dragActivityFirstStep, endDrag, getDragActivity, getMinDragStartDistance, getMousePressedCanvasPoint, isDragging, mouseDragged, mousePressed, mouseReleased, setIsDragging, setMinDragStartDistance, shouldStartDragInteraction, startDrag, startDragActivity, stopDragActivity
 
Methods inherited from class edu.umd.cs.piccolo.event.PBasicInputEventHandler
acceptsEvent, getEventFilter, keyboardFocusGained, keyboardFocusLost, keyPressed, keyReleased, keyTyped, mouseClicked, mouseEntered, mouseExited, mouseMoved, mouseWheelRotated, mouseWheelRotatedByBlock, paramString, processEvent, setEventFilter
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PPanEventHandler

public PPanEventHandler()
Constructs a Pan Event Handler that will by default perform auto-panning.

Method Detail

drag

protected void drag(PInputEvent event)
Updates the view in response to a user initiated drag event.

Overrides:
drag in class PDragSequenceEventHandler
Parameters:
event - event responsible for the drag

pan

protected void pan(PInputEvent event)
Pans the camera in response to the pan event provided.

Parameters:
event - contains details about the drag used to translate the view

setAutopan

public void setAutopan(boolean autopan)
Determines if auto-panning will occur or not.

Parameters:
autopan - true if auto-panning functionality will be active

getAutopan

public boolean getAutopan()
Returns whether the auto-panning functoinality is enabled.

Returns:
true if auto-panning is enabled

setMinAutopanSpeed

public void setMinAutopanSpeed(double minAutopanSpeed)
Set the minAutoPan speed in pixels per second.

Parameters:
minAutopanSpeed - number of pixels to assign as the minimum the autopan feature can pan the view

setMaxAutopanSpeed

public void setMaxAutopanSpeed(double maxAutopanSpeed)
Set the maxAutoPan speed in pixels per second.

Parameters:
maxAutopanSpeed - number of pixels to assign as the maximum the autopan feature can pan the view

getMinAutoPanSpeed

public double getMinAutoPanSpeed()
Returns the minAutoPan speed in pixels per second.

Returns:
minimum distance the autopan feature can pan the view
Since:
1.3

getMaxAutoPanSpeed

public double getMaxAutoPanSpeed()
Returns the maxAutoPan speed in pixels per second.

Returns:
max distance the autopan feature can pan the view by
Since:
1.3

dragActivityStep

protected void dragActivityStep(PInputEvent event)
Performs auto-panning if enabled, even when the mouse is not moving.

Overrides:
dragActivityStep in class PDragSequenceEventHandler
Parameters:
event - current drag relevant details about the drag activity

validatePanningSpeed

protected double validatePanningSpeed(double delta)
Clips the panning speed to the minimum and maximum auto-pan speeds assigned. If delta is below the threshold, it will be increased. If above, it will be decreased.

Parameters:
delta - auto-pan delta to be clipped
Returns:
clipped delta value.


Copyright © 1995-2011 Piccolo2D. All Rights Reserved.