Class TLspTouchNavigateController
- All Implemented Interfaces:
ILcdAWTEventListener
,ILspController
Touch controller to navigate on a 2D or 3D map. It supports:
- Panning by dragging with a single finger
- Zooming by pinching with two fingers
- Rotating by twisting with two fingers
- In 3D, rotating the camera up/down (pitching) by dragging two fingers
close to each other
up and down - In 2D, panning the camera by dragging two fingers
close to each other
in any direction
By default, the controller uses heuristics to automatically determine the principal navigation action (pan, zoom, or rotate)
for a gesture, restricting the effect of the gesture to that action only.
You can disable this and combine
gestures.
This controller only tries to handle TLcdTouchPoint
s which are not-consumed, and marks the
TLcdTouchPoint
s it uses as consumed, similar to the
ALspTouchController
.
- Since:
- 2012.0
-
Constructor Summary
ConstructorDescriptionCreates a new navigation controller that performs all supported navigation actions.TLspTouchNavigateController
(boolean aShouldRotate, boolean aShouldZoom, boolean aShouldPan) Creates a new navigation controller that offers rotating, zooming and panning based on the passed arguments. -
Method Summary
Modifier and TypeMethodDescriptionReturns the current locations of the touch points this controller is tracking.final int
Returns the maximum number of touch points this controller should handle, as specified in the constructor.final int
Returns the minimum number of touch points this controller should handle, as specified in the constructor.Returns the original locations of the touch points this controller is tracking (= the location of the point when it was passed to thetouchPointAvailable
method).int
Returns how close fingers should be to interpret two-finger movements in a 2D view as a pan gesture.int
Returns how close fingers should be to interpret two-finger movements in a 3D view as a pitch gesture.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.boolean
Returns whether a single two-finger gesture can trigger different navigation actions (pan, zoom, rotate).boolean
Returns whether or not this controller should animate the gestures.boolean
Returns whether or not this controller should pan the view.boolean
Returns whether or not this controller should rotate the view.boolean
Returns whether or not this controller should zoom the view.boolean
Returns whether or not this controller should zoom the view after double tapping.void
setCombineGestures
(boolean aCombineGestures) Sets whether a single two-finger gesture can trigger different navigation actions (pan, zoom, rotate).void
setEnableInertia
(boolean aEnableInertia) Sets whether or not this controller should animate the gestures.void
setPanDistanceThreshold
(int aPanDistanceThreshold) Sets how close fingers should be to interpret two-finger movements in a 2D view as a pan gesture.void
setPitchDistanceThreshold
(int aPitchDistanceThreshold) Returns how close fingers should be to interpret two-finger movements in a 3D view as a pitch gesture.void
setShouldPan
(boolean aShouldPan) Sets whether or not this controller should pan the view.void
setShouldRotate
(boolean aShouldRotate) Sets whether or not this controller should rotate the view.void
setShouldZoom
(boolean aShouldZoom) Sets whether or not this controller should zoom the view.void
setZoomOnDoubleTap
(boolean aShouldDoubleTap) Sets whether or not this controller should zoom the view after double tapping.protected final 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 final 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 final 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.ALspTouchController
getMoveThreshold, handleAWTEvent, handleAWTEventImpl, handleEventImpl, handleFXEvent, isDrawTouchPoints, paintImpl, 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, startInteraction, startInteractionImpl, terminateInteraction, terminateInteractionImpl
-
Constructor Details
-
TLspTouchNavigateController
public TLspTouchNavigateController()Creates a new navigation controller that performs all supported navigation actions. -
TLspTouchNavigateController
public TLspTouchNavigateController(boolean aShouldRotate, boolean aShouldZoom, boolean aShouldPan) Creates a new navigation controller that offers rotating, zooming and panning based on the passed arguments.- Parameters:
aShouldRotate
- boolean indicating whether this controller should rotate the viewaShouldZoom
- boolean indicating whether this controller should zoom the viewaShouldPan
- boolean indicating whether this controller should pan the view
-
-
Method Details
-
isShouldRotate
public boolean isShouldRotate()Returns whether or not this controller should rotate the view.- Returns:
true
if this controller should rotate the view,false
otherwise.
-
setShouldRotate
public void setShouldRotate(boolean aShouldRotate) Sets whether or not this controller should rotate the view.- Parameters:
aShouldRotate
-true
if this controller should rotate the view,false
otherwise.
-
isShouldPan
public boolean isShouldPan()Returns whether or not this controller should pan the view.- Returns:
true
if this controller should pan the view,false
otherwise.
-
setShouldPan
public void setShouldPan(boolean aShouldPan) Sets whether or not this controller should pan the view.- Parameters:
aShouldPan
-true
if this controller should pan the view,false
otherwise.
-
isShouldZoom
public boolean isShouldZoom()Returns whether or not this controller should zoom the view.- Returns:
true
if this controller should zoom the view,false
otherwise.
-
setShouldZoom
public void setShouldZoom(boolean aShouldZoom) Sets whether or not this controller should zoom the view.- Parameters:
aShouldZoom
-true
if this controller should zoom the view,false
otherwise.
-
isZoomOnDoubleTap
public boolean isZoomOnDoubleTap()Returns whether or not this controller should zoom the view after double tapping.- Returns:
true
if this controller should zoom the view after double tapping,false
otherwise.
-
setZoomOnDoubleTap
public void setZoomOnDoubleTap(boolean aShouldDoubleTap) Sets whether or not this controller should zoom the view after double tapping.- Parameters:
aShouldDoubleTap
-true
if this controller should zoom the view after double tapping,false
otherwise.
-
isEnableInertia
public boolean isEnableInertia()Returns whether or not this controller should animate the gestures.- Returns:
true
if this controller should animate the gestures,false
otherwise.
-
setEnableInertia
public void setEnableInertia(boolean aEnableInertia) Sets whether or not this controller should animate the gestures.- Parameters:
aEnableInertia
-true
if this controller should animate the gestures,false
otherwise.
-
isCombineGestures
public boolean isCombineGestures()Returns whether a single two-finger gesture can trigger different navigation actions (pan, zoom, rotate). If disabled, the controller will assign a single navigation action to each gesture and stick with it for as long as the gesture is ongoing. This filters out unintentional navigation actions and jitter.- Returns:
true
if this controller performs gestures together,false
if the controller handles them separately.
-
setCombineGestures
public void setCombineGestures(boolean aCombineGestures) Sets whether a single two-finger gesture can trigger different navigation actions (pan, zoom, rotate). If disabled, the controller will assign a single navigation action to each gesture and stick with it for as long as the gesture is ongoing. This filters out unintentional navigation actions and jitter.For example, if the user starts a pinch gesture, the controller will zoom (and only zoom) until the user lifts his fingers. It won't try to rotate or pan the view.
- Parameters:
aCombineGestures
-true
if this controller should perform gestures together,false
if the controller needs to handle them separately.
-
setPitchDistanceThreshold
public void setPitchDistanceThreshold(int aPitchDistanceThreshold) Returns how close fingers should be to interpret two-finger movements in a 3D view as a pitch gesture. If the distance between two fingers is lower than this threshold, the controller will pitch the view. Otherwise this controller will pan, zoom and/or rotate the view.The default value is 100.
- Parameters:
aPitchDistanceThreshold
- the threshold value between two fingers, in pixels- Since:
- 2019.1
-
getPitchDistanceThreshold
public int getPitchDistanceThreshold()Returns how close fingers should be to interpret two-finger movements in a 3D view as a pitch gesture. If the distance between two fingers is lower than this threshold, the controller will pitch the view. Otherwise this controller will pan, zoom and/or rotate the view.- Returns:
- the threshold value between two fingers, in pixels
- Since:
- 2019.1
-
setPanDistanceThreshold
public void setPanDistanceThreshold(int aPanDistanceThreshold) Sets how close fingers should be to interpret two-finger movements in a 2D view as a pan gesture. If the distance between two fingers is lower than this threshold, the controller will pan the view. Otherwise this controller will zoom and/or rotate the view.The default value is 100.
- Parameters:
aPanDistanceThreshold
- the threshold value between two fingers, in pixels- Since:
- 2019.1
-
getPanDistanceThreshold
public int getPanDistanceThreshold()Returns how close fingers should be to interpret two-finger movements in a 2D view as a pan gesture. If the distance between two fingers is lower than this threshold, the controller will pan the view. Otherwise this controller will zoom and/or rotate the view.- Returns:
- the threshold value between two fingers, in pixels
- Since:
- 2019.1
-
touchPointAvailable
protected final 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
.
-
touchPointWithdrawn
protected final 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:
-
touchPointMoved
protected final 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:
-
getMaximumNumberOfPoints
public final int getMaximumNumberOfPoints()Description copied from class:ALspConfinedTouchController
Returns the maximum number of touch points this controller should handle, as specified in the constructor.
- Overrides:
getMaximumNumberOfPoints
in classALspConfinedTouchController
- Returns:
- the maximum number of touch points this controller should handle.
- See Also:
-
getMinimumNumberOfPoints
public final int getMinimumNumberOfPoints()Description copied from class:ALspConfinedTouchController
Returns the minimum number of touch points this controller should handle, as specified in the constructor.
- Overrides:
getMinimumNumberOfPoints
in classALspConfinedTouchController
- Returns:
- the minimum number of touch points this controller should handle.
- See Also:
-
getOriginalLocations
Description copied from class:ALspTouchController
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
.- Overrides:
getOriginalLocations
in classALspTouchController
- Returns:
- the original locations of the touch points this controller is tracking. The
List
is empty when no points are currently tracked.
-
getPreviousLocations
Description copied from class:ALspTouchController
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
.- Overrides:
getPreviousLocations
in classALspTouchController
- Returns:
- the previous locations of the touch points this controller is tracking. The
List
is empty when no points are currently tracked.
-
getCurrentLocations
Description copied from class:ALspTouchController
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
.- Overrides:
getCurrentLocations
in classALspTouchController
- Returns:
- the current locations of the touch points this controller is tracking. The
List
is empty when no points are currently tracked.
-
getTouchPointIDs
Description copied from class:ALspTouchController
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.
- Overrides:
getTouchPointIDs
in classALspTouchController
- 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.
-