Class 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 Details

    • PPanEventHandler

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

    • 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.