Package edu.umd.cs.piccolo.event
Class PZoomEventHandler
java.lang.Object
edu.umd.cs.piccolo.event.PBasicInputEventHandler
edu.umd.cs.piccolo.event.PDragSequenceEventHandler
edu.umd.cs.piccolo.event.PZoomEventHandler
- All Implemented Interfaces:
PInputEventListener,EventListener
ZoomEventhandler provides event handlers for basic zooming of the
canvas view with the right (third) button. The interaction is that the
initial mouse press defines the zoom anchor point, and then moving the mouse
to the right zooms with a speed proportional to the amount the mouse is moved
to the right of the anchor point. Similarly, if the mouse is moved to the
left, the the view is zoomed out.
On a Mac with its single mouse button one may wish to change the standard right mouse button zooming behavior. This can be easily done with the PInputEventFilter. For example to zoom with button one and shift you would do this:
zoomEventHandler.getEventFilter().setAndMask(InputEvent.BUTTON1_MASK |
InputEvent.SHIFT_MASK);
- Version:
- 1.0
- Author:
- Jesse Grosjean
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voiddragActivityFirstStep(PInputEvent event) Records the start point of the zoom.protected voiddragActivityStep(PInputEvent event) Updates the current zoom periodically, regardless of whether the mouse has moved recently.doubleReturns the maximum view magnification factor that this event handler is bound by.doubleReturns the minimum view magnification factor that this event handler is bound by.voidsetMaxScale(double maxScale) Sets the maximum view magnification factor that this event handler is bound by.voidsetMinScale(double minScale) Sets the minimum view magnification factor that this event handler is bound by.Methods inherited from class edu.umd.cs.piccolo.event.PDragSequenceEventHandler
drag, dragActivityFinalStep, 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
-
PZoomEventHandler
public PZoomEventHandler()Creates a new zoom handler.
-
-
Method Details
-
getMinScale
public double getMinScale()Returns the minimum view magnification factor that this event handler is bound by. The default is 0.- Returns:
- the minimum camera view scale
-
setMinScale
public void setMinScale(double minScale) Sets the minimum view magnification factor that this event handler is bound by. The camera is left at its current scale even ifminScaleis larger than the current scale.- Parameters:
minScale- the minimum scale, must not be negative.
-
getMaxScale
public double getMaxScale()Returns the maximum view magnification factor that this event handler is bound by. The default is Double.MAX_VALUE.- Returns:
- the maximum camera view scale
-
setMaxScale
public void setMaxScale(double maxScale) Sets the maximum view magnification factor that this event handler is bound by. The camera is left at its current scale even ifmaxScaleis smaller than the current scale. Use Double.MAX_VALUE to specify the largest possible scale.- Parameters:
maxScale- the maximum scale, must not be negative.
-
dragActivityFirstStep
Records the start point of the zoom. Used when calculating the delta for zoom speed.- Overrides:
dragActivityFirstStepin classPDragSequenceEventHandler- Parameters:
event- event responsible for starting the zoom interaction
-
dragActivityStep
Updates the current zoom periodically, regardless of whether the mouse has moved recently.- Overrides:
dragActivityStepin classPDragSequenceEventHandler- Parameters:
event- contains information about the current state of the mouse
-