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
ConstructorsConstructorDescriptionConstructs 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.intReturns the time (in milliseconds) it takes for a touch and hold to be registered.voidhandleAWTEvent(AWTEvent aEvent) protected TLspPaintProgresspaintImpl(ILcdGLDrawable aGLDrawable, ILspView aView, TLspPaintPhase aPaintPhase) The specific implementation ofpaintfor this controller.protected TLspPaintProgresspaintTouchAndHoldIndication(ILcdGLDrawable aGLDrawable) This method will be called in the paint method while the touch and hold is detected and not released.voidsetPostTouchAndHoldAction(ILcdAction aPostTouchAndHoldAction) Sets the action to be triggered when the touch is withdrawn after a touch and hold is detected.voidsetTouchAndHoldAction(ILcdAction aTouchAndHoldAction) Sets the action to be triggered as soon as a touch and hold is detected.voidsetTouchAndHoldIcon(ILcdIcon aTouchAndHoldIcon) Sets the icon to be displayed when a touch and hold action is active and not released.voidsetTouchAndHoldTime(int aTouchAndHoldTime) Sets the time (in milliseconds) it takes for a touch and hold to be registered.voidstartInteraction(ILspView aView) Called to start interacting with the controller.voidterminateInteraction(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, getMinimumNumberOfPointsMethods inherited from class com.luciad.view.lightspeed.controller.touch.ALspTouchController
getCurrentLocations, getMoveThreshold, getOriginalLocations, getPreviousLocations, getTouchPointIDs, handleAWTEventImpl, handleEventImpl, handleFXEvent, isDrawTouchPoints, setDrawTouchPoints, setMoveThresholdMethods 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 ofILcdAnchoredIconthe 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:ALspControllerCalled 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 callsstartInteractionon the next controller. OverridestartInteractionImplif you want to add your own behavior to this controller.- Specified by:
startInteractionin interfaceILspController- Overrides:
startInteractionin classALspController- Parameters:
aView- the view the controller operates on
-
terminateInteraction
Description copied from class:ALspControllerTerminates 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 callsterminateInteractionon the next controller. OverrideterminateInteractionImplif you want to add your own behavior to this controller.- Specified by:
terminateInteractionin interfaceILspController- Overrides:
terminateInteractionin classALspController- Parameters:
aView- the view the controller was operating on
-
handleAWTEvent
Description copied from class:ALspTouchControllerWhen the event describes the creation of a touch point, the
touchPointAvailablemethod will be called, allowing to indicate which touch points to track. ThetouchPointAvailablemethod will also be called if aTLcdTouchPointwas 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
touchPointMovedwill be called if thethresholdis exceeded.When the event describes the removal of a touch point, the
touchPointWithdrawnmethod will be called. ThetouchPointWithdrawnmethod will also be called whenaEventindicates 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 differentTLcdTouchPoints contained in the event will be adjusted according to the points this controller is handling. Right before anyTLcdTouchEventis forwarded to the next controller, the handleEventImpl method is called.Typically this method should not be overridden. Override
touchPointAvailable,touchPointMovedortouchPointWithdrawninstead.If
aEventis not an instance ofTLcdTouchEvent, it will simply be forwarded to the next controller without affecting this controller.- Specified by:
handleAWTEventin interfaceILcdAWTEventListener- Overrides:
handleAWTEventin classALspTouchController- Parameters:
aEvent- The event to be handled.- See Also:
-
touchPointAvailable
protected List<TLcdTouchPoint> touchPointAvailable(List<TLcdTouchPoint> aTouchPoints, TLcdTouchPoint aTouchDown) Description copied from class:ALspTouchControllerThis method is called every time a new touch point is created or becomes available and allows to react accordingly.
aTouchDownis theTLcdTouchPointwhich has been created, whileaTouchPointscontains all availableTLcdTouchPoints (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 aTLcdTouchPointwhich 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:
touchPointAvailablein classALspConfinedTouchController- Parameters:
aTouchPoints- AListcontaining all availableTLcdTouchPointinstances. This list will includeaTouchDown. Note that some of theseTLcdTouchPoints can already be tracked by this controller (seegetTouchPointIDs). It is possible to modify thisListand 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
Listcontaining allTLcdTouchPointinstances which should be tracked by this controller. AllTLcdTouchPointinstances contained in thisListmust be contained inaTouchPoints. May be an emptyList, but notnull.
-
touchPointMoved
protected List<TLcdTouchPoint> touchPointMoved(List<TLcdTouchPoint> aTrackedTouchPoints, TLcdTouchPoint aTouchMoved) Description copied from class:ALspTouchControllerThis method is called when one of the touch points, used by this controller, is moved beyond the threshold and allows to react accordingly.
aTouchMovedis theTLcdTouchPointwhich has moved, whileaTrackedTouchPointscontains allTLcdTouchPoints 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
Listcontaining allTLcdTouchPointinstances which should be tracked by this controller. If aTLcdTouchPointwhich 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:
touchPointMovedin classALspTouchController- Parameters:
aTrackedTouchPoints-Listcontaining allTLcdTouchPoints currently tracked by this controller. It is possible to modify thisListand return it instead of creating a newList.aTouchMoved- theTLcdTouchPointthat has moved- Returns:
- a
Listcontaining allTLcdTouchPoints this controller should keep tracking. AllTLcdTouchPointinstances contained in thisListmust 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:ALspTouchControllerThis methods is called every time a tracked touch point is removed or consumed and allows to react accordingly.
aTouchUpis theTLcdTouchPointwhich has been removed, whileaTouchPointscontains all availableTLcdTouchPoints (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
Listcontaining allTLcdTouchPointinstances which should be tracked by this controller. If aTLcdTouchPointwhich 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:
touchPointWithdrawnin classALspConfinedTouchController- Parameters:
aTouchPoints- AListcontaining all availableTLcdTouchPointinstances, includingaTouchUp. It is possible to modify thisListand 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
Listcontaining allTLcdTouchPoints this controller should keep tracking. AllTLcdTouchPointinstances contained in thisListmust 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:ALspControllerThe specific implementation ofpaintfor this controller.- Overrides:
paintImplin 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.
-