Class TLspTouchNavigateController

All Implemented Interfaces:
ILcdAWTEventListener, ILspController

public class TLspTouchNavigateController extends ALspConfinedTouchController

Touch controller to navigate on a 2D or 3D map. It supports:

  • Panning by dragging with a single finger
  • Zooming by pinching with two fingers
  • Rotating by twisting with two fingers
  • In 3D, rotating the camera up/down (pitching) by dragging two fingers close to each other up and down
  • In 2D, panning the camera by dragging two fingers close to each other in any direction

By default, the controller uses heuristics to automatically determine the principal navigation action (pan, zoom, or rotate) for a gesture, restricting the effect of the gesture to that action only. You can disable this and combine gestures.

This controller only tries to handle TLcdTouchPoints which are not-consumed, and marks the TLcdTouchPoints it uses as consumed, similar to the ALspTouchController.

Since:
2012.0
  • Constructor Details

    • TLspTouchNavigateController

      public TLspTouchNavigateController()
      Creates a new navigation controller that performs all supported navigation actions.
    • TLspTouchNavigateController

      public TLspTouchNavigateController(boolean aShouldRotate, boolean aShouldZoom, boolean aShouldPan)
      Creates a new navigation controller that offers rotating, zooming and panning based on the passed arguments.
      Parameters:
      aShouldRotate - boolean indicating whether this controller should rotate the view
      aShouldZoom - boolean indicating whether this controller should zoom the view
      aShouldPan - boolean indicating whether this controller should pan the view
  • Method Details

    • isShouldRotate

      public boolean isShouldRotate()
      Returns whether or not this controller should rotate the view.
      Returns:
      true if this controller should rotate the view, false otherwise.
    • setShouldRotate

      public void setShouldRotate(boolean aShouldRotate)
      Sets whether or not this controller should rotate the view.
      Parameters:
      aShouldRotate - true if this controller should rotate the view, false otherwise.
    • isShouldPan

      public boolean isShouldPan()
      Returns whether or not this controller should pan the view.
      Returns:
      true if this controller should pan the view, false otherwise.
    • setShouldPan

      public void setShouldPan(boolean aShouldPan)
      Sets whether or not this controller should pan the view.
      Parameters:
      aShouldPan - true if this controller should pan the view, false otherwise.
    • isShouldZoom

      public boolean isShouldZoom()
      Returns whether or not this controller should zoom the view.
      Returns:
      true if this controller should zoom the view, false otherwise.
    • setShouldZoom

      public void setShouldZoom(boolean aShouldZoom)
      Sets whether or not this controller should zoom the view.
      Parameters:
      aShouldZoom - true if this controller should zoom the view, false otherwise.
    • isZoomOnDoubleTap

      public boolean isZoomOnDoubleTap()
      Returns whether or not this controller should zoom the view after double tapping.
      Returns:
      true if this controller should zoom the view after double tapping, false otherwise.
    • setZoomOnDoubleTap

      public void setZoomOnDoubleTap(boolean aShouldDoubleTap)
      Sets whether or not this controller should zoom the view after double tapping.
      Parameters:
      aShouldDoubleTap - true if this controller should zoom the view after double tapping, false otherwise.
    • isEnableInertia

      public boolean isEnableInertia()
      Returns whether or not this controller should animate the gestures.
      Returns:
      true if this controller should animate the gestures, false otherwise.
    • setEnableInertia

      public void setEnableInertia(boolean aEnableInertia)
      Sets whether or not this controller should animate the gestures.
      Parameters:
      aEnableInertia - true if this controller should animate the gestures, false otherwise.
    • isCombineGestures

      public boolean isCombineGestures()
      Returns whether a single two-finger gesture can trigger different navigation actions (pan, zoom, rotate). If disabled, the controller will assign a single navigation action to each gesture and stick with it for as long as the gesture is ongoing. This filters out unintentional navigation actions and jitter.
      Returns:
      true if this controller performs gestures together, false if the controller handles them separately.
    • setCombineGestures

      public void setCombineGestures(boolean aCombineGestures)
      Sets whether a single two-finger gesture can trigger different navigation actions (pan, zoom, rotate). If disabled, the controller will assign a single navigation action to each gesture and stick with it for as long as the gesture is ongoing. This filters out unintentional navigation actions and jitter.

      For example, if the user starts a pinch gesture, the controller will zoom (and only zoom) until the user lifts his fingers. It won't try to rotate or pan the view.

      Parameters:
      aCombineGestures - true if this controller should perform gestures together, false if the controller needs to handle them separately.
    • setPitchDistanceThreshold

      public void setPitchDistanceThreshold(int aPitchDistanceThreshold)
      Returns how close fingers should be to interpret two-finger movements in a 3D view as a pitch gesture. If the distance between two fingers is lower than this threshold, the controller will pitch the view. Otherwise this controller will pan, zoom and/or rotate the view.

      The default value is 100.

      Parameters:
      aPitchDistanceThreshold - the threshold value between two fingers, in pixels
      Since:
      2019.1
    • getPitchDistanceThreshold

      public int getPitchDistanceThreshold()
      Returns how close fingers should be to interpret two-finger movements in a 3D view as a pitch gesture. If the distance between two fingers is lower than this threshold, the controller will pitch the view. Otherwise this controller will pan, zoom and/or rotate the view.
      Returns:
      the threshold value between two fingers, in pixels
      Since:
      2019.1
    • setPanDistanceThreshold

      public void setPanDistanceThreshold(int aPanDistanceThreshold)
      Sets how close fingers should be to interpret two-finger movements in a 2D view as a pan gesture. If the distance between two fingers is lower than this threshold, the controller will pan the view. Otherwise this controller will zoom and/or rotate the view.

      The default value is 100.

      Parameters:
      aPanDistanceThreshold - the threshold value between two fingers, in pixels
      Since:
      2019.1
    • getPanDistanceThreshold

      public int getPanDistanceThreshold()
      Returns how close fingers should be to interpret two-finger movements in a 2D view as a pan gesture. If the distance between two fingers is lower than this threshold, the controller will pan the view. Otherwise this controller will zoom and/or rotate the view.
      Returns:
      the threshold value between two fingers, in pixels
      Since:
      2019.1
    • touchPointAvailable

      protected final List<TLcdTouchPoint> touchPointAvailable(List<TLcdTouchPoint> aTouchPoints, TLcdTouchPoint aTouchDown)
      Description copied from class: ALspTouchController

      This method is called every time a new touch point is created or becomes available and allows to react accordingly.

      aTouchDown is the TLcdTouchPoint which has been created, while aTouchPoints contains all available TLcdTouchPoints (including aTouchDown). All of these points are non-consumed.

      This method allows to indicate which points should be tracked by this controller by returning them in a List. If a TLcdTouchPoint which is currently tracked is omitted from the List, that touch point will be made available to the rest of the chain as explained in the class javadoc.

      Overrides:
      touchPointAvailable in class ALspConfinedTouchController
      Parameters:
      aTouchPoints - A List containing all available TLcdTouchPoint instances. This list will include aTouchDown. Note that some of these TLcdTouchPoints can already be tracked by this controller (see getTouchPointIDs). It is possible to modify this List and return it instead of creating a new List.
      aTouchDown - The descriptor of the touch point which has been created or removed. The state of the descriptor will always be DOWN. Note that this descriptor is included in aTouchPoints.
      Returns:
      a List containing all TLcdTouchPoint instances which should be tracked by this controller. All TLcdTouchPoint instances contained in this List must be contained in aTouchPoints. May be an empty List, but not null.
    • touchPointWithdrawn

      protected final List<TLcdTouchPoint> touchPointWithdrawn(List<TLcdTouchPoint> aTouchPoints, TLcdTouchPoint aTouchUp)
      Description copied from class: ALspTouchController

      This methods is called every time a tracked touch point is removed or consumed and allows to react accordingly.

      aTouchUp is the TLcdTouchPoint which has been removed, while aTouchPoints contains all available TLcdTouchPoints (including aTouchUp). All of these points are non-consumed.

      This method allows to indicate that certain touch points should no longer be tracked by this controller. It does so by returning a List containing all TLcdTouchPoint instances which should be tracked by this controller. If a TLcdTouchPoint which is currently tracked is omitted from the List, that touch point will be made available to the rest of the chain as explained in the class javadoc.

      Overrides:
      touchPointWithdrawn in class ALspConfinedTouchController
      Parameters:
      aTouchPoints - A List containing all available TLcdTouchPoint instances, including aTouchUp. It is possible to modify this List and return it instead of creating a new List.
      aTouchUp - The touch point which has been removed. The state of the descriptor will always be UP. Note that this descriptor is included in aTouchPoints.
      Returns:
      a List containing all TLcdTouchPoints this controller should keep tracking. All TLcdTouchPoint instances contained in this List must be contained in aTrackedTouchPoints. May be an empty List, but not null.
      See Also:
    • touchPointMoved

      protected final List<TLcdTouchPoint> touchPointMoved(List<TLcdTouchPoint> aTrackedTouchPoints, TLcdTouchPoint aTouchMoved)
      Description copied from class: ALspTouchController

      This method is called when one of the touch points, used by this controller, is moved beyond the threshold and allows to react accordingly.

      aTouchMoved is the TLcdTouchPoint which has moved, while aTrackedTouchPoints contains all TLcdTouchPoints this controller is currently tracking (including aTouchMoved). All of these points will be non-consumed.

      This method allows to indicate that certain touch points should no longer be tracked by this controller. It does so by returning a List containing all TLcdTouchPoint instances which should be tracked by this controller. If a TLcdTouchPoint which is currently tracked is omitted from the List, that touch point will be made available to the rest of the chain as explained in the class javadoc.

      A possible use case is a select controller, which does not expect move events. The select controller can claim the touch point when it is created, but when the point starts moving it can decide it cannot handle it.

      Specified by:
      touchPointMoved in class ALspTouchController
      Parameters:
      aTrackedTouchPoints - List containing all TLcdTouchPoints currently tracked by this controller. It is possible to modify this List and return it instead of creating a new List.
      aTouchMoved - the TLcdTouchPoint that has moved
      Returns:
      a List containing all TLcdTouchPoints this controller should keep tracking. All TLcdTouchPoint instances contained in this List must be contained in aTrackedTouchPoints. May be an empty List, but not null.
      See Also:
    • getMaximumNumberOfPoints

      public final int getMaximumNumberOfPoints()
      Description copied from class: ALspConfinedTouchController

      Returns the maximum number of touch points this controller should handle, as specified in the constructor.

      Overrides:
      getMaximumNumberOfPoints in class ALspConfinedTouchController
      Returns:
      the maximum number of touch points this controller should handle.
      See Also:
    • getMinimumNumberOfPoints

      public final int getMinimumNumberOfPoints()
      Description copied from class: ALspConfinedTouchController

      Returns the minimum number of touch points this controller should handle, as specified in the constructor.

      Overrides:
      getMinimumNumberOfPoints in class ALspConfinedTouchController
      Returns:
      the minimum number of touch points this controller should handle.
      See Also:
    • getOriginalLocations

      public final List<ILcdPoint> getOriginalLocations()
      Description copied from class: ALspTouchController

      Returns the original locations of the touch points this controller is tracking (= the location of the point when it was passed to the touchPointAvailable method). The locations are expressed in view AWT coordinates. In case the view is moved after the touch down of the touch point (for example, due to a pan operation), these coordinates will not be altered. Hence the corresponding world coordinates will no longer match the world coordinates of the point during the touchPointAvailable method call.

      The order of the points in the returned list matches the order of the lists returned in getPreviousLocations and getCurrentLocations. The same order is applied on getTouchPointIDs.

      Overrides:
      getOriginalLocations in class ALspTouchController
      Returns:
      the original locations of the touch points this controller is tracking. The List is empty when no points are currently tracked.
    • getPreviousLocations

      public final List<ILcdPoint> getPreviousLocations()
      Description copied from class: ALspTouchController

      Returns the locations of the touch points this controller is tracking during the previous event. The locations are expressed in view AWT coordinates. In case the view is moved after the touch down or last move of the touch point (for example, due to a pan operation), these coordinates will not be altered. Hence the corresponding world coordinates will no longer match the world coordinates of the point during the touch down or the move.

      The order of the points in the returned list matches the order of the lists returned in getOriginalLocations and getCurrentLocations. The same order is applied on getTouchPointIDs.

      Overrides:
      getPreviousLocations in class ALspTouchController
      Returns:
      the previous locations of the touch points this controller is tracking. The List is empty when no points are currently tracked.
    • getCurrentLocations

      public final List<ILcdPoint> getCurrentLocations()
      Description copied from class: ALspTouchController

      Returns the current locations of the touch points this controller is tracking. Locations are expressed in view AWT coordinates.

      The order of the points in the returned list matches the order of the lists returned in getOriginalLocations and getPreviousLocations. The same order is applied on getTouchPointIDs.

      Overrides:
      getCurrentLocations in class ALspTouchController
      Returns:
      the current locations of the touch points this controller is tracking. The List is empty when no points are currently tracked.
    • getTouchPointIDs

      public final List<Long> getTouchPointIDs()
      Description copied from class: ALspTouchController

      Returns a list containing the touch point IDs of the touch points used by this controller.

      The order of the IDs is the order in which the points were passed to the touchPointAvailable method.

      Overrides:
      getTouchPointIDs in class ALspTouchController
      Returns:
      a list containing the touch point IDs of the touch points this controller is using. The List is empty when no points are currently tracked.