Class ALspTouchController

java.lang.Object
com.luciad.view.lightspeed.controller.ALspController
com.luciad.view.lightspeed.controller.touch.ALspTouchController
All Implemented Interfaces:
ILcdAWTEventListener, ILspController
Direct Known Subclasses:
ALspConfinedTouchController

public abstract class ALspTouchController extends ALspController

Extension of ALspController for TLcdTouchEvent instances. It provides support for tracking multiple TLcdTouchPoints and allows to react when a point is created, moves (beyond a certain threshold) or is removed.

All incoming events are passed down the chain to the next controller. In case of TLcdTouchEvents, the consumed state of the different TLcdTouchPoints contained in the event will be updated according to the points this controller is handling.

The handleFXEvent(Event aEvent) converts the native JavaFX TouchEvent to a TLcdTouchEvent and passes it to the handleAWTEvent(AWTEvent aEvent).

Implementations of this class can track touch points by implementing touchPointAvailable, touchPointMoved, and touchPointWithdrawn as follows:

  • Every time a new touch point becomes available, the touchPointAvailable method is called. This method determines which points will be tracked by this controller. A touch point becomes available when:

    • a TLcdTouchPoint is created and not consumed by a previous controller in the chain.
    • the consumed state of a TLcdTouchPoint switches from true to false.

  • If one of the tracked points moves or is withdrawn, the touchPointMoved and touchPointWithdrawn methods are respectively called. At both occasions, it is possible to indicate certain points should no longer be tracked by this controller. A TLcdTouchPoint is withdrawn when:

    • the TLcdTouchPoint is removed.
    • the consumed state of a TLcdTouchPoint switches from false to true.
See ALcdGXYTouchChainableController for an example of this controller's behavior.
Since:
2012.0
  • Constructor Details

    • ALspTouchController

      protected ALspTouchController()
      Default constructor, nothing is initialized.
  • Method Details

    • isDrawTouchPoints

      public boolean isDrawTouchPoints()
      Returns true if this controller is configured to visualize touch points in the view. By default, this feature is off.
      Returns:
      true if this controller is configured to visualize touch points in the view
      See Also:
    • setDrawTouchPoints

      public void setDrawTouchPoints(boolean aDrawTouchPoints)
      Determines whether this controller should visualize touch points in the view. If true, the controller's paint() method will draw a circle at the location of each current touch point. By default, this property is set to false.
      Parameters:
      aDrawTouchPoints - whether or not to visualize touch points in the view
    • handleAWTEvent

      public void handleAWTEvent(AWTEvent aEvent)

      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 ALspController
      Parameters:
      aEvent - The event to be handled.
      See Also:
    • handleFXEvent

      public void handleFXEvent(Event aEvent)
      Description copied from class: ALspController
      Delegates to handleFXEventImpl. If that method does not return null, the result is passed on to the next controller in the chain (if one exists). If the controller has a filter that does not accept the event, the event is not delegated and is immediately passed on to the next controller.
      Specified by:
      handleFXEvent in interface ILspController
      Overrides:
      handleFXEvent in class ALspController
      Parameters:
      aEvent - the event to be handled
    • touchPointMoved

      protected abstract List<TLcdTouchPoint> touchPointMoved(List<TLcdTouchPoint> aTrackedTouchPoints, TLcdTouchPoint aTouchMoved)

      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.

      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:
    • getOriginalLocations

      public List<ILcdPoint> getOriginalLocations()

      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.

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

      public List<ILcdPoint> getPreviousLocations()

      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.

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

      public List<ILcdPoint> getCurrentLocations()

      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.

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

      public List<Long> getTouchPointIDs()

      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.

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

      protected abstract List<TLcdTouchPoint> touchPointAvailable(List<TLcdTouchPoint> aTouchPoints, TLcdTouchPoint aTouchDown)

      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.

      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 abstract List<TLcdTouchPoint> touchPointWithdrawn(List<TLcdTouchPoint> aTouchPoints, TLcdTouchPoint aTouchUp)

      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.

      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:
    • getMoveThreshold

      public int getMoveThreshold()

      Returns the current threshold for move events.

      The touchPointMoved method will only be called if the point moves further then the threshold in either the X or Y direction, and the same applies for the update of the previous and current locations.

      The default value for this property is 0, which means every move of a tracked touch point will be handled.

      Returns:
      the current threshold for move events
      See Also:
    • setMoveThreshold

      public void setMoveThreshold(int aMoveThreshold)

      Sets the threshold for move events.

      The touchPointMoved method will only be called if the point moves further then the threshold in either the X or Y direction, and the same applies for the update of the previous and current locations.

      The new value of the threshold will not affect any events which arrived at the controller prior to the change in threshold.

      The default value for this property is 0, which means every move of a tracked touch point will be handled.

      Parameters:
      aMoveThreshold - the threshold for move events. Must be positive.
      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 ALspController
      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
    • handleEventImpl

      protected void handleEventImpl(TLcdTouchEvent aTouchEvent)

      This method is called right before a TLcdTouchEvent is forwarded to the next controller in the chain. The default implementation of this method is empty.

      Parameters:
      aTouchEvent - the TLcdTouchEvent which will be forwarded to the next controller. The consumed state of the TLcdTouchPoints is already updated.
    • handleAWTEventImpl

      public AWTEvent handleAWTEventImpl(AWTEvent aAWTEvent)
      Description copied from class: ALspController
      Called by handleAWTEvent. Returns null when the controller consumed the event or a partially consumed event when the controller partially consumed the event (which could happen with TLcdTouchEvents). When the controller did not use the given event, it is returned unaltered.
      Specified by:
      handleAWTEventImpl in class ALspController
      Parameters:
      aAWTEvent - the event to be handled.
      Returns:
      null when the input event was consumed, the (possibly modified) input event when it was (partially) consumed.