Package edu.umd.cs.piccolo.event
Class PPanEventHandler
java.lang.Object
edu.umd.cs.piccolo.event.PBasicInputEventHandler
edu.umd.cs.piccolo.event.PDragSequenceEventHandler
edu.umd.cs.piccolo.event.PPanEventHandler
- All Implemented Interfaces:
PInputEventListener,EventListener
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
ConstructorsConstructorDescriptionConstructs a Pan Event Handler that will by default perform auto-panning. -
Method Summary
Modifier and TypeMethodDescriptionprotected voiddrag(PInputEvent event) Updates the view in response to a user initiated drag event.protected voiddragActivityStep(PInputEvent event) Performs auto-panning if enabled, even when the mouse is not moving.booleanReturns whether the auto-panning functoinality is enabled.doubleReturns the maxAutoPan speed in pixels per second.doubleReturns the minAutoPan speed in pixels per second.protected voidpan(PInputEvent event) Pans the camera in response to the pan event provided.voidsetAutopan(boolean autopan) Determines if auto-panning will occur or not.voidsetMaxAutopanSpeed(double maxAutopanSpeed) Set the maxAutoPan speed in pixels per second.voidsetMinAutopanSpeed(double minAutopanSpeed) Set the minAutoPan speed in pixels per second.protected doublevalidatePanningSpeed(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, stopDragActivityMethods 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
-
Constructor Details
-
PPanEventHandler
public PPanEventHandler()Constructs a Pan Event Handler that will by default perform auto-panning.
-
-
Method Details
-
drag
Updates the view in response to a user initiated drag event.- Overrides:
dragin classPDragSequenceEventHandler- Parameters:
event- event responsible for the drag
-
pan
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
Performs auto-panning if enabled, even when the mouse is not moving.- Overrides:
dragActivityStepin classPDragSequenceEventHandler- 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.
-