public abstract class ALspTouchController extends ALspController
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:
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.Modifier | Constructor and Description |
---|---|
protected |
ALspTouchController()
Default constructor, nothing is initialized.
|
Modifier and Type | Method and Description |
---|---|
List<ILcdPoint> |
getCurrentLocations()
Returns the current locations of the touch points this controller is tracking.
|
int |
getMoveThreshold()
Returns the current threshold for move events.
|
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). |
List<ILcdPoint> |
getPreviousLocations()
Returns the locations of the touch points this controller is tracking during the previous
event.
|
List<Long> |
getTouchPointIDs()
Returns a list containing the touch point IDs of the touch points used by this controller.
|
void |
handleAWTEvent(AWTEvent aEvent)
|
AWTEvent |
handleAWTEventImpl(AWTEvent aAWTEvent)
Called by
handleAWTEvent . |
protected void |
handleEventImpl(TLcdTouchEvent aTouchEvent)
This method is called right before a
TLcdTouchEvent is forwarded to the next
controller in the chain. |
void |
handleFXEvent(javafx.event.Event aEvent)
Delegates to
handleFXEventImpl . |
boolean |
isDrawTouchPoints()
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 of
paint 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.
|
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
protected ALspTouchController()
public boolean isDrawTouchPoints()
setDrawTouchPoints(boolean)
public void setDrawTouchPoints(boolean aDrawTouchPoints)
paint()
method will draw a circle at the location of each current touch point. By default, this
property is set to false.aDrawTouchPoints
- whether or not to visualize touch points in the viewpublic 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
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 ALspController
aEvent
- The event to be handled.touchPointMoved(java.util.List, com.luciad.input.touch.TLcdTouchPoint)
,
touchPointAvailable(java.util.List, com.luciad.input.touch.TLcdTouchPoint)
,
touchPointWithdrawn(java.util.List, com.luciad.input.touch.TLcdTouchPoint)
,
handleEventImpl(com.luciad.input.touch.TLcdTouchEvent)
public void handleFXEvent(javafx.event.Event aEvent)
ALspController
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.handleFXEvent
in interface ILspController
handleFXEvent
in class ALspController
aEvent
- the event to be handledprotected 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 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.
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
.handleAWTEvent(java.awt.AWTEvent)
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
.
List
is empty when no points are currently tracked.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
.
List
is empty when no points are currently tracked.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
.
List
is empty when no points are currently tracked.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.
List
is
empty
when no points are currently tracked.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 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.
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 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 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.
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
.handleAWTEvent(java.awt.AWTEvent)
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.
setMoveThreshold(int)
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.
aMoveThreshold
- the threshold for move events. Must be positive.getMoveThreshold()
protected TLspPaintProgress paintImpl(ILcdGLDrawable aGLDrawable, ILspView aView, TLspPaintPhase aPaintPhase)
ALspController
paint
for this controller.paintImpl
in class ALspController
aGLDrawable
- the drawable that should be painted onaView
- the view that is painted onaPaintPhase
- the current paint phaseprotected 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.
aTouchEvent
- the TLcdTouchEvent
which will be forwarded to the next
controller. The consumed state of the TLcdTouchPoint
s is already updated.public AWTEvent handleAWTEventImpl(AWTEvent aAWTEvent)
ALspController
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
TLcdTouchEvent
s). When the controller did not use the given event, it is returned
unaltered.handleAWTEventImpl
in class ALspController
aAWTEvent
- the event to be handled.null
when the input event was consumed, the (possibly modified) input
event when it was (partially) consumed.