Class TLspTouchAndHoldActionController

All Implemented Interfaces:
ILcdAWTEventListener, ILspController

public class TLspTouchAndHoldActionController extends ALspConfinedTouchController

This controller allows you to trigger actions based on the occurrence of a touch and hold. A touch and hold is defined as a single touch that remains stationary (within the move threshold) for a certain time. When a touch and hold is registered, a visible clue will be rendered on the screen. Two actions can be triggered, one as soon as the touch and hold is detected, and one when the touch that caused a touch and hold is withdrawn.

Note that as soon as a touch and hold is no longer possible (finger moved or lifted before time out) all relevant events (including the TOUCH_DOWN) are passed to the next controller in the chain.

Since:
2012.0
  • Constructor Details

    • TLspTouchAndHoldActionController

      public TLspTouchAndHoldActionController()
      Constructs a new touch and hold action controller. No actions are configured. Note that the default move threshold is 5.
  • Method Details

    • getTouchAndHoldTime

      public int getTouchAndHoldTime()
      Returns the time (in milliseconds) it takes for a touch and hold to be registered.
      Returns:
      the time spent waiting on a touch and hold.
    • setTouchAndHoldTime

      public void setTouchAndHoldTime(int aTouchAndHoldTime)
      Sets the time (in milliseconds) it takes for a touch and hold to be registered. If the finger doesn't move (over the move threshold) in that time, a touch and hold is registered. The default value is 1000.
      Parameters:
      aTouchAndHoldTime - the time it takes to recognize a touch and hold.
    • getTouchAndHoldAction

      public ILcdAction getTouchAndHoldAction()
      Returns the action that is triggered as soon as a touch and hold is detected.
      Returns:
      the touch and hold action.
    • setTouchAndHoldAction

      public void setTouchAndHoldAction(ILcdAction aTouchAndHoldAction)
      Sets the action to be triggered as soon as a touch and hold is detected. The default is null, indicating no action has to be triggered.
      Parameters:
      aTouchAndHoldAction - the touch and hold action
    • getPostTouchAndHoldAction

      public ILcdAction getPostTouchAndHoldAction()
      Returns the action that is triggered when the touch is withdrawn after a touch and hold is detected.
      Returns:
      the post touch and hold action.
    • setPostTouchAndHoldAction

      public void setPostTouchAndHoldAction(ILcdAction aPostTouchAndHoldAction)
      Sets the action to be triggered when the touch is withdrawn after a touch and hold is detected. The default is null, indicating no action has to be triggered.
      Parameters:
      aPostTouchAndHoldAction - the post touch and hold action
    • getTouchAndHoldIcon

      public ILcdIcon getTouchAndHoldIcon()
      Returns the icon to be displayed while a touch and hold is active and not released.
      Returns:
      the touch and hold indication icon.
    • setTouchAndHoldIcon

      public void setTouchAndHoldIcon(ILcdIcon aTouchAndHoldIcon)
      Sets the icon to be displayed when a touch and hold action is active and not released. There is a default icon. Set to null if you don't want to display any icon. If the icon is an instance of ILcdAnchoredIcon the anchor point will be placed on the location of the touch and hold.
      Parameters:
      aTouchAndHoldIcon - the touch and hold indication icon.
      See Also:
    • startInteraction

      public void startInteraction(ILspView aView)
      Description copied from class: ALspController
      Called to start interacting with the controller. This automatically happens when setting the controller on the view using ILspView.setController(com.luciad.view.lightspeed.controller.ILspController).

      This implementation sends out a status event based on the short description. It also calls startInteraction on the next controller. Override startInteractionImpl if you want to add your own behavior to this controller.

      Specified by:
      startInteraction in interface ILspController
      Overrides:
      startInteraction in class ALspController
      Parameters:
      aView - the view the controller operates on
    • terminateInteraction

      public void terminateInteraction(ILspView aView)
      Description copied from class: ALspController
      Terminates interaction with this controller. This automatically happens when setting a different controller on the view using ILspView.setController(com.luciad.view.lightspeed.controller.ILspController).

      This implementation also calls terminateInteraction on the next controller. Override terminateInteractionImpl if you want to add your own behavior to this controller.

      Specified by:
      terminateInteraction in interface ILspController
      Overrides:
      terminateInteraction in class ALspController
      Parameters:
      aView - the view the controller was operating on
    • handleAWTEvent

      public void handleAWTEvent(AWTEvent aEvent)
      Description copied from class: ALspTouchController

      When the event describes the creation of a touch point, the touchPointAvailable method will be called, allowing to indicate which touch points to track. The touchPointAvailable method will also be called if a TLcdTouchPoint was previously marked as consumed and is no longer consumed in aEvent.

      When the event describes the move of a touch point tracked by this controller, the touchPointMoved will be called if the threshold is exceeded.

      When the event describes the removal of a touch point, the touchPointWithdrawn method will be called. The touchPointWithdrawn method will also be called when aEvent indicates one of the tracked points is consumed.

      All incoming events will be forwarded to the next controller. In case of TLcdTouchEvents, the consumed state of the different TLcdTouchPoints contained in the event will be adjusted according to the points this controller is handling. Right before any TLcdTouchEvent is forwarded to the next controller, the handleEventImpl method is called.

      Typically this method should not be overridden. Override touchPointAvailable, touchPointMoved or touchPointWithdrawn instead.

      If aEvent is not an instance of TLcdTouchEvent, it will simply be forwarded to the next controller without affecting this controller.

      Specified by:
      handleAWTEvent in interface ILcdAWTEventListener
      Overrides:
      handleAWTEvent in class ALspTouchController
      Parameters:
      aEvent - The event to be handled.
      See Also:
    • touchPointAvailable

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

      protected 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:
    • touchPointWithdrawn

      protected 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:
    • paintImpl

      protected TLspPaintProgress paintImpl(ILcdGLDrawable aGLDrawable, ILspView aView, TLspPaintPhase aPaintPhase)
      Description copied from class: ALspController
      The specific implementation of paint for this controller.
      Overrides:
      paintImpl in class ALspTouchController
      Parameters:
      aGLDrawable - the drawable that should be painted on
      aView - the view that is painted on
      aPaintPhase - the current paint phase
      Returns:
      whether or not the painting was finished
    • paintTouchAndHoldIndication

      protected TLspPaintProgress paintTouchAndHoldIndication(ILcdGLDrawable aGLDrawable)
      This method will be called in the paint method while the touch and hold is detected and not released. By default this method will display the touch and hold icon.
      Parameters:
      aGLDrawable - the drawable to paint on.
      Returns:
      the paint progress.