Class TLspTouchAndHoldActionController
- All Implemented Interfaces:
ILcdAWTEventListener
,ILspController
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 Summary
ConstructorDescriptionConstructs a new touch and hold action controller. -
Method Summary
Modifier and TypeMethodDescriptionReturns the action that is triggered when the touch is withdrawn after a touch and hold is detected.Returns the action that is triggered as soon as a touch and hold is detected.Returns the icon to be displayed while a touch and hold is active and not released.int
Returns the time (in milliseconds) it takes for a touch and hold to be registered.void
handleAWTEvent
(AWTEvent aEvent) protected TLspPaintProgress
paintImpl
(ILcdGLDrawable aGLDrawable, ILspView aView, TLspPaintPhase aPaintPhase) The specific implementation ofpaint
for this controller.protected TLspPaintProgress
paintTouchAndHoldIndication
(ILcdGLDrawable aGLDrawable) This method will be called in the paint method while the touch and hold is detected and not released.void
setPostTouchAndHoldAction
(ILcdAction aPostTouchAndHoldAction) Sets the action to be triggered when the touch is withdrawn after a touch and hold is detected.void
setTouchAndHoldAction
(ILcdAction aTouchAndHoldAction) Sets the action to be triggered as soon as a touch and hold is detected.void
setTouchAndHoldIcon
(ILcdIcon aTouchAndHoldIcon) Sets the icon to be displayed when a touch and hold action is active and not released.void
setTouchAndHoldTime
(int aTouchAndHoldTime) Sets the time (in milliseconds) it takes for a touch and hold to be registered.void
startInteraction
(ILspView aView) Called to start interacting with the controller.void
terminateInteraction
(ILspView aView) Terminates interaction with this controller.protected 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.protected 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.protected 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.Methods inherited from class com.luciad.view.lightspeed.controller.touch.ALspConfinedTouchController
getMaximumNumberOfPoints, getMinimumNumberOfPoints
Methods inherited from class com.luciad.view.lightspeed.controller.touch.ALspTouchController
getCurrentLocations, getMoveThreshold, getOriginalLocations, getPreviousLocations, getTouchPointIDs, handleAWTEventImpl, handleEventImpl, handleFXEvent, isDrawTouchPoints, setDrawTouchPoints, setMoveThreshold
Methods inherited from class com.luciad.view.lightspeed.controller.ALspController
addPropertyChangeListener, addStatusListener, appendController, firePropertyChange, fireStatusEvent, getAWTFilter, getCursor, getFXCursor, getFXFilter, getIcon, getLayered, getName, getNextController, getShortDescription, getView, handleFXEventImpl, paint, registerViewPropertyNameForReset, removePropertyChangeListener, removeStatusListener, setAWTFilter, setCursor, setFXCursor, setFXFilter, setIcon, setName, setShortDescription, startInteractionImpl, terminateInteractionImpl
-
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 themove 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
Returns the action that is triggered as soon as a touch and hold is detected.- Returns:
- the touch and hold action.
-
setTouchAndHoldAction
Sets the action to be triggered as soon as a touch and hold is detected. The default isnull
, indicating no action has to be triggered.- Parameters:
aTouchAndHoldAction
- the touch and hold action
-
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
Sets the action to be triggered when the touch is withdrawn after a touch and hold is detected. The default isnull
, indicating no action has to be triggered.- Parameters:
aPostTouchAndHoldAction
- the post touch and hold action
-
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
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 ofILcdAnchoredIcon
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
Description copied from class:ALspController
Called to start interacting with the controller. This automatically happens when setting the controller on the view usingILspView.setController(com.luciad.view.lightspeed.controller.ILspController)
. This implementation sends out a status event based on theshort description
. It also callsstartInteraction
on the next controller. OverridestartInteractionImpl
if you want to add your own behavior to this controller.- Specified by:
startInteraction
in interfaceILspController
- Overrides:
startInteraction
in classALspController
- Parameters:
aView
- the view the controller operates on
-
terminateInteraction
Description copied from class:ALspController
Terminates interaction with this controller. This automatically happens when setting a different controller on the view usingILspView.setController(com.luciad.view.lightspeed.controller.ILspController)
. This implementation also callsterminateInteraction
on the next controller. OverrideterminateInteractionImpl
if you want to add your own behavior to this controller.- Specified by:
terminateInteraction
in interfaceILspController
- Overrides:
terminateInteraction
in classALspController
- Parameters:
aView
- the view the controller was operating on
-
handleAWTEvent
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. ThetouchPointAvailable
method will also be called if aTLcdTouchPoint
was previously marked as consumed and is no longer consumed inaEvent
.When the event describes the move of a touch point tracked by this controller, the
touchPointMoved
will be called if thethreshold
is exceeded.When the event describes the removal of a touch point, the
touchPointWithdrawn
method will be called. ThetouchPointWithdrawn
method will also be called whenaEvent
indicates one of the tracked points is consumed.All incoming events will be forwarded to the next controller. In case of
TLcdTouchEvent
s, the consumed state of the differentTLcdTouchPoint
s contained in the event will be adjusted according to the points this controller is handling. Right before anyTLcdTouchEvent
is forwarded to the next controller, the handleEventImpl method is called.Typically this method should not be overridden. Override
touchPointAvailable
,touchPointMoved
ortouchPointWithdrawn
instead.If
aEvent
is not an instance ofTLcdTouchEvent
, it will simply be forwarded to the next controller without affecting this controller.- Specified by:
handleAWTEvent
in interfaceILcdAWTEventListener
- Overrides:
handleAWTEvent
in classALspTouchController
- 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 theTLcdTouchPoint
which has been created, whileaTouchPoints
contains all availableTLcdTouchPoint
s (includingaTouchDown
). 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 aTLcdTouchPoint
which is currently tracked is omitted from theList
, that touch point will be made available to the rest of the chain as explained in the class javadoc.- Overrides:
touchPointAvailable
in classALspConfinedTouchController
- Parameters:
aTouchPoints
- AList
containing all availableTLcdTouchPoint
instances. This list will includeaTouchDown
. Note that some of theseTLcdTouchPoint
s can already be tracked by this controller (seegetTouchPointIDs
). It is possible to modify thisList
and return it instead of creating a newList
.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 inaTouchPoints
.- Returns:
- a
List
containing allTLcdTouchPoint
instances which should be tracked by this controller. AllTLcdTouchPoint
instances contained in thisList
must be contained inaTouchPoints
. May be an emptyList
, but notnull
.
-
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 theTLcdTouchPoint
which has moved, whileaTrackedTouchPoints
contains allTLcdTouchPoint
s this controller is currently tracking (includingaTouchMoved
). 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 allTLcdTouchPoint
instances which should be tracked by this controller. If aTLcdTouchPoint
which is currently tracked is omitted from theList
, 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 classALspTouchController
- Parameters:
aTrackedTouchPoints
-List
containing allTLcdTouchPoint
s currently tracked by this controller. It is possible to modify thisList
and return it instead of creating a newList
.aTouchMoved
- theTLcdTouchPoint
that has moved- Returns:
- a
List
containing allTLcdTouchPoint
s this controller should keep tracking. AllTLcdTouchPoint
instances contained in thisList
must be contained inaTrackedTouchPoints
. May be an emptyList
, but notnull
. - 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 theTLcdTouchPoint
which has been removed, whileaTouchPoints
contains all availableTLcdTouchPoint
s (includingaTouchUp
). 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 allTLcdTouchPoint
instances which should be tracked by this controller. If aTLcdTouchPoint
which is currently tracked is omitted from theList
, that touch point will be made available to the rest of the chain as explained in the class javadoc.- Overrides:
touchPointWithdrawn
in classALspConfinedTouchController
- Parameters:
aTouchPoints
- AList
containing all availableTLcdTouchPoint
instances, includingaTouchUp
. It is possible to modify thisList
and return it instead of creating a newList
.aTouchUp
- The touch point which has been removed. The state of the descriptor will always be UP. Note that this descriptor is included inaTouchPoints
.- Returns:
- a
List
containing allTLcdTouchPoint
s this controller should keep tracking. AllTLcdTouchPoint
instances contained in thisList
must be contained inaTrackedTouchPoints
. May be an emptyList
, but notnull
. - See Also:
-
paintImpl
protected TLspPaintProgress paintImpl(ILcdGLDrawable aGLDrawable, ILspView aView, TLspPaintPhase aPaintPhase) Description copied from class:ALspController
The specific implementation ofpaint
for this controller.- Overrides:
paintImpl
in classALspTouchController
- Parameters:
aGLDrawable
- the drawable that should be painted onaView
- the view that is painted onaPaintPhase
- the current paint phase- Returns:
- whether or not the painting was finished
-
paintTouchAndHoldIndication
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 thetouch and hold icon
.- Parameters:
aGLDrawable
- the drawable to paint on.- Returns:
- the paint progress.
-