public class TLspTouchNavigateController extends ALspConfinedTouchController
Touch controller to navigate on a 2D or 3D map. It supports:
close to each other
up and downclose to each other
in any directionBy 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
.
Constructor and Description |
---|
TLspTouchNavigateController()
Creates 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.
|
Modifier and Type | Method and Description |
---|---|
List<ILcdPoint> |
getCurrentLocations()
Returns the current locations of the touch points this controller is tracking.
|
int |
getMaximumNumberOfPoints()
Returns the maximum number of touch points this controller should handle, as specified in
the constructor.
|
int |
getMinimumNumberOfPoints()
Returns the minimum number of touch points this controller should handle, as specified in
the constructor.
|
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). |
int |
getPanDistanceThreshold()
Returns how close fingers should be to interpret two-finger movements in a 2D view as a pan gesture.
|
int |
getPitchDistanceThreshold()
Returns how close fingers should be to interpret two-finger movements in a 3D view as a pitch gesture.
|
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.
|
boolean |
isCombineGestures()
Returns whether a single two-finger gesture can trigger different navigation actions (pan, zoom, rotate).
|
boolean |
isEnableInertia()
Returns whether or not this controller should animate the gestures.
|
boolean |
isShouldPan()
Returns whether or not this controller should pan the view.
|
boolean |
isShouldRotate()
Returns whether or not this controller should rotate the view.
|
boolean |
isShouldZoom()
Returns whether or not this controller should zoom the view.
|
boolean |
isZoomOnDoubleTap()
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 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.
|
getMoveThreshold, handleAWTEvent, handleAWTEventImpl, handleEventImpl, handleFXEvent, isDrawTouchPoints, paintImpl, 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, startInteraction, startInteractionImpl, terminateInteraction, terminateInteractionImpl
public TLspTouchNavigateController()
public TLspTouchNavigateController(boolean aShouldRotate, boolean aShouldZoom, boolean aShouldPan)
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 viewpublic boolean isShouldRotate()
true
if this controller should rotate the view, false
otherwise.public void setShouldRotate(boolean aShouldRotate)
aShouldRotate
- true
if this controller should rotate the view, false
otherwise.public boolean isShouldPan()
true
if this controller should pan the view, false
otherwise.public void setShouldPan(boolean aShouldPan)
aShouldPan
- true
if this controller should pan the view, false
otherwise.public boolean isShouldZoom()
true
if this controller should zoom the view, false
otherwise.public void setShouldZoom(boolean aShouldZoom)
aShouldZoom
- true
if this controller should zoom the view, false
otherwise.public boolean isZoomOnDoubleTap()
true
if this controller should zoom the view after double tapping, false
otherwise.public void setZoomOnDoubleTap(boolean aShouldDoubleTap)
aShouldDoubleTap
- true
if this controller should zoom the view after double tapping, false
otherwise.public boolean isEnableInertia()
true
if this controller should animate the gestures, false
otherwise.public void setEnableInertia(boolean aEnableInertia)
aEnableInertia
- true
if this controller should animate the gestures, false
otherwise.public boolean isCombineGestures()
true
if this controller performs gestures together, false
if the controller handles them separately.public void setCombineGestures(boolean aCombineGestures)
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.
aCombineGestures
- true
if this controller should perform gestures together,
false
if the controller needs to handle them separately.public void setPitchDistanceThreshold(int aPitchDistanceThreshold)
The default value is 100.
aPitchDistanceThreshold
- the threshold value between two fingers, in pixelspublic int getPitchDistanceThreshold()
public void setPanDistanceThreshold(int aPanDistanceThreshold)
The default value is 100.
aPanDistanceThreshold
- the threshold value between two fingers, in pixelspublic int getPanDistanceThreshold()
protected final 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 final 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 final 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)
public final int getMaximumNumberOfPoints()
ALspConfinedTouchController
Returns the maximum number of touch points this controller should handle, as specified in the constructor.
getMaximumNumberOfPoints
in class ALspConfinedTouchController
ALspConfinedTouchController.getMinimumNumberOfPoints()
public final int getMinimumNumberOfPoints()
ALspConfinedTouchController
Returns the minimum number of touch points this controller should handle, as specified in the constructor.
getMinimumNumberOfPoints
in class ALspConfinedTouchController
ALspConfinedTouchController.getMaximumNumberOfPoints()
public final List<ILcdPoint> getOriginalLocations()
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 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
.
getOriginalLocations
in class ALspTouchController
List
is empty when no points are currently tracked.public final List<ILcdPoint> getPreviousLocations()
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
and getCurrentLocations
. The same order is applied on getTouchPointIDs
.
getPreviousLocations
in class ALspTouchController
List
is empty when no points are currently tracked.public final List<ILcdPoint> getCurrentLocations()
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
and getPreviousLocations
. The same order is applied on getTouchPointIDs
.
getCurrentLocations
in class ALspTouchController
List
is empty when no points are currently tracked.public final List<Long> getTouchPointIDs()
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.
getTouchPointIDs
in class ALspTouchController
List
is
empty
when no points are currently tracked.