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.
Constructor and Description |
---|
TLspTouchAndHoldActionController()
Constructs a new touch and hold action controller.
|
Modifier and Type | Method and Description |
---|---|
ILcdAction |
getPostTouchAndHoldAction()
Returns the action that is triggered when the touch is withdrawn after a touch and hold is detected.
|
ILcdAction |
getTouchAndHoldAction()
Returns the action that is triggered as soon as a touch and hold is detected.
|
ILcdIcon |
getTouchAndHoldIcon()
Returns the icon to be displayed while a touch and hold is active and not released.
|
int |
getTouchAndHoldTime()
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 of
paint 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.
|
getMaximumNumberOfPoints, getMinimumNumberOfPoints
getCurrentLocations, getMoveThreshold, getOriginalLocations, getPreviousLocations, getTouchPointIDs, handleAWTEventImpl, handleEventImpl, handleFXEvent, isDrawTouchPoints, setDrawTouchPoints, setMoveThreshold
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
public TLspTouchAndHoldActionController()
public int getTouchAndHoldTime()
public void setTouchAndHoldTime(int aTouchAndHoldTime)
move threshold
) in that time, a touch and hold
is registered. The default value is 1000.aTouchAndHoldTime
- the time it takes to recognize a touch and hold.public ILcdAction getTouchAndHoldAction()
public void setTouchAndHoldAction(ILcdAction aTouchAndHoldAction)
null
,
indicating no action has to be triggered.aTouchAndHoldAction
- the touch and hold actionpublic ILcdAction getPostTouchAndHoldAction()
public void setPostTouchAndHoldAction(ILcdAction aPostTouchAndHoldAction)
null
, indicating no action has to be triggered.aPostTouchAndHoldAction
- the post touch and hold actionpublic ILcdIcon getTouchAndHoldIcon()
public void setTouchAndHoldIcon(ILcdIcon aTouchAndHoldIcon)
ILcdAnchoredIcon
the anchor point will be placed on the location of the touch and hold.aTouchAndHoldIcon
- the touch and hold indication icon.paintTouchAndHoldIndication(com.luciad.view.opengl.binding.ILcdGLDrawable)
public void startInteraction(ILspView aView)
ALspController
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.startInteraction
in interface ILspController
startInteraction
in class ALspController
aView
- the view the controller operates onpublic void terminateInteraction(ILspView aView)
ALspController
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.terminateInteraction
in interface ILspController
terminateInteraction
in class ALspController
aView
- the view the controller was operating onpublic void handleAWTEvent(AWTEvent aEvent)
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
TLcdTouchEvent
s, the consumed state of the different TLcdTouchPoint
s
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.
handleAWTEvent
in interface ILcdAWTEventListener
handleAWTEvent
in class ALspTouchController
aEvent
- The event to be handled.ALspTouchController.touchPointMoved(java.util.List, com.luciad.input.touch.TLcdTouchPoint)
,
ALspTouchController.touchPointAvailable(java.util.List, com.luciad.input.touch.TLcdTouchPoint)
,
ALspTouchController.touchPointWithdrawn(java.util.List, com.luciad.input.touch.TLcdTouchPoint)
,
ALspTouchController.handleEventImpl(com.luciad.input.touch.TLcdTouchEvent)
protected List<TLcdTouchPoint> touchPointAvailable(List<TLcdTouchPoint> aTouchPoints, TLcdTouchPoint aTouchDown)
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 TLcdTouchPoint
s (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.
touchPointAvailable
in class ALspConfinedTouchController
aTouchPoints
- A List
containing all available TLcdTouchPoint
instances. This list will include aTouchDown
. Note that some
of these TLcdTouchPoint
s 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
.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
.protected List<TLcdTouchPoint> touchPointMoved(List<TLcdTouchPoint> aTrackedTouchPoints, TLcdTouchPoint aTouchMoved)
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 TLcdTouchPoint
s 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.
touchPointMoved
in class ALspTouchController
aTrackedTouchPoints
- List
containing all TLcdTouchPoint
s
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 movedList
containing all TLcdTouchPoint
s 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
.ALspTouchController.handleAWTEvent(java.awt.AWTEvent)
protected List<TLcdTouchPoint> touchPointWithdrawn(List<TLcdTouchPoint> aTouchPoints, TLcdTouchPoint aTouchUp)
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 TLcdTouchPoint
s (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.
touchPointWithdrawn
in class ALspConfinedTouchController
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
.List
containing all TLcdTouchPoint
s 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
.ALspTouchController.handleAWTEvent(java.awt.AWTEvent)
protected TLspPaintProgress paintImpl(ILcdGLDrawable aGLDrawable, ILspView aView, TLspPaintPhase aPaintPhase)
ALspController
paint
for this controller.paintImpl
in class ALspTouchController
aGLDrawable
- the drawable that should be painted onaView
- the view that is painted onaPaintPhase
- the current paint phaseprotected TLspPaintProgress paintTouchAndHoldIndication(ILcdGLDrawable aGLDrawable)
touch and hold icon
.aGLDrawable
- the drawable to paint on.