Class ALspTouchController
- All Implemented Interfaces:
ILcdAWTEventListener
,ILspController
- Direct Known Subclasses:
ALspConfinedTouchController
Extension of ALspController
for TLcdTouchEvent
instances.
It provides support for tracking multiple TLcdTouchPoint
s 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
TLcdTouchEvent
s, the consumed state of the different TLcdTouchPoint
s 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:
-
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:
ALcdGXYTouchChainableController
for an example of this controller's behavior.- Since:
- 2012.0
-
Constructor Summary
ModifierConstructorDescriptionprotected
Default constructor, nothing is initialized. -
Method Summary
Modifier and TypeMethodDescriptionReturns the current locations of the touch points this controller is tracking.int
Returns the current threshold for move events.Returns the original locations of the touch points this controller is tracking (= the location of the point when it was passed to thetouchPointAvailable
method).Returns the locations of the touch points this controller is tracking during the previous event.Returns a list containing the touch point IDs of the touch points used by this controller.void
handleAWTEvent
(AWTEvent aEvent) handleAWTEventImpl
(AWTEvent aAWTEvent) Called byhandleAWTEvent
.protected void
handleEventImpl
(TLcdTouchEvent aTouchEvent) This method is called right before aTLcdTouchEvent
is forwarded to the next controller in the chain.void
handleFXEvent
(Event aEvent) Delegates tohandleFXEventImpl
.boolean
Returns true if this controller is configured to visualize touch points in the view.protected TLspPaintProgress
paintImpl
(ILcdGLDrawable aGLDrawable, ILspView aView, TLspPaintPhase aPaintPhase) The specific implementation ofpaint
for this controller.void
setDrawTouchPoints
(boolean aDrawTouchPoints) Determines whether this controller should visualize touch points in the view.void
setMoveThreshold
(int aMoveThreshold) Sets the threshold for move events.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.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.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.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, startInteraction, startInteractionImpl, terminateInteraction, terminateInteractionImpl
-
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'spaint()
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
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 classALspController
- Parameters:
aEvent
- The event to be handled.- See Also:
-
handleFXEvent
Description copied from class:ALspController
Delegates tohandleFXEventImpl
. If that method does not returnnull
, 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 interfaceILspController
- Overrides:
handleFXEvent
in classALspController
- 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 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.
- 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:
-
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 thetouchPointAvailable
method call.The order of the points in the returned list matches the order of the lists returned in
getPreviousLocations
andgetCurrentLocations
. The same order is applied ongetTouchPointIDs
.- Returns:
- the original locations of the touch points this controller is tracking. The
List
is empty when no points are currently tracked.
-
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
andgetCurrentLocations
. The same order is applied ongetTouchPointIDs
.- Returns:
- the previous locations of the touch points this controller is tracking. The
List
is empty when no points are currently tracked.
-
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
andgetPreviousLocations
. The same order is applied ongetTouchPointIDs
.- Returns:
- the current locations of the touch points this controller is tracking. The
List
is empty when no points are currently tracked.
-
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 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.- 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
.
-
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 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.- 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:
-
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 ofpaint
for this controller.- Overrides:
paintImpl
in classALspController
- 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
-
handleEventImpl
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
- theTLcdTouchEvent
which will be forwarded to the next controller. The consumed state of theTLcdTouchPoint
s is already updated.
-
handleAWTEventImpl
Description copied from class:ALspController
Called byhandleAWTEvent
. Returnsnull
when the controller consumed the event or a partially consumed event when the controller partially consumed the event (which could happen withTLcdTouchEvent
s). When the controller did not use the given event, it is returned unaltered.- Specified by:
handleAWTEventImpl
in classALspController
- 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.
-