Package globus.glmap
Class GLMapGesturesDetector
- java.lang.Object
-
- globus.glmap.GLMapGesturesDetector
-
- All Implemented Interfaces:
android.view.View.OnTouchListener
@ParametersAreNonnullByDefault public class GLMapGesturesDetector extends java.lang.Object implements android.view.View.OnTouchListenerDetector of gestures for map view
-
-
Constructor Summary
Constructors Constructor Description GLMapGesturesDetector(GLMapView mapView)Default constructor
-
Method Summary
Modifier and Type Method Description longgetFlingSpeedGate()Minimal speed to trigger fling event Default implementation returns 400longgetFlingTimeGate()If last move event was older that returned value no fling events will be triggered Default implementation returns 100000000longgetLongPressDuration()Time to trigger long press Default implementation returns 1000000000longgetMaxTapsToDetect(int numberOfTouches)Maximum taps to detect for given number of touches Default implementation return 2 for 1 touch and 1 for otherslonggetMultiTapTimeGate()Time between taps Default implementation returns 250000000intgetNumberOfTouches()Returns number of active touchesfloatgetRotationGate()Rotation starts when user rotates two fingers for more than returned value Default implementation returns 10floatgetRotationResetGate()floatgetTapDistanceGate()Tap events disabled if movement of more then returned value is detected Default implementation returns 10floatgetTapZoomGate()Tap events disabled if zoom of more than returned value is detected Default implementation returns 1.01ffloatgetTouchX(int index)Returns x coordinate of the touchfloatgetTouchY(int index)Returns y coordinate of the touchvoidonBegin()Called when new touch started Default implementation does notingvoidonEnd()Called when all touches ended Default implementation rotate map to 0 if current angle is in range 340 ..voidonFling(float speedX, float speedY)Called when fling is detected Default implementation starts deceleration animationvoidonLongPress(int numberOfTouches, float cx, float cy)Called when long press detected.voidonMove(float dx, float dy)Called when movement detected Default implementation move map to new center without animationvoidonRotate(float delta, float cx, float cy)Called when rotation is detected Default implementation rotate map with animation if delta is greater than rotation gate.voidonRotationReset()voidonTap(int numberOfTouches, int numberOfTaps, float cx, float cy)Called when tap detected.booleanonTouch(android.view.View v, android.view.MotionEvent motionEvent)voidonZoom(float k, float cx, float cy)Called when zoom detectedvoidstopDetectingTouches()Stop detecting touches util all current touches are up
-
-
-
Constructor Detail
-
GLMapGesturesDetector
public GLMapGesturesDetector(GLMapView mapView)
Default constructor- Parameters:
mapView- position, angle and zoom of this map will be modified by this detector
-
-
Method Detail
-
stopDetectingTouches
public void stopDetectingTouches()
Stop detecting touches util all current touches are up
-
getTouchX
public float getTouchX(int index)
Returns x coordinate of the touch- Parameters:
index- index of touch- Returns:
- x coordinate of touch (in pixels)
-
getTouchY
public float getTouchY(int index)
Returns y coordinate of the touch- Parameters:
index- index of touch- Returns:
- y coordinate of touch (in pixels)
-
onTap
public void onTap(int numberOfTouches, int numberOfTaps, float cx, float cy)Called when tap detected. Default implementation performs zoom in on numberOfTouches == 1 and numberOfTaps ==2 Default implementation performs zoom out on numberOfTouches == 2 and numberOfTaps ==1- Parameters:
numberOfTouches- number of touchesnumberOfTaps- number of tapscx- x coordinate of the touches centercy- y coordinate of the touches center
-
onLongPress
public void onLongPress(int numberOfTouches, float cx, float cy)Called when long press detected. Default implementation does nothing- Parameters:
numberOfTouches- number of touchescx- x coordinate of the touches centercy- y coordinate of the touches center
-
onMove
public void onMove(float dx, float dy)Called when movement detected Default implementation move map to new center without animation- Parameters:
dx- movement distance over x axis (px)dy- movement distance over y axis (px)
-
onZoom
public void onZoom(float k, float cx, float cy)Called when zoom detected- Parameters:
k- zoom coefficientcx- x coordinate of the touches centercy- y coordinate of the touches center
-
onFling
public void onFling(float speedX, float speedY)Called when fling is detected Default implementation starts deceleration animation- Parameters:
speedX- speed over x axis (px/s)speedY- speed over y axis (px/s)
-
onRotate
public void onRotate(float delta, float cx, float cy)Called when rotation is detected Default implementation rotate map with animation if delta is greater than rotation gate.- Parameters:
delta- angle delta (in degrees)cx- x coordinate of rotation center (in pixels)cy- y coordinate of rotation center (in pixels)
-
onBegin
public void onBegin()
Called when new touch started Default implementation does noting
-
onEnd
public void onEnd()
Called when all touches ended Default implementation rotate map to 0 if current angle is in range 340 .. 20
-
onRotationReset
public void onRotationReset()
-
getTapDistanceGate
public float getTapDistanceGate()
Tap events disabled if movement of more then returned value is detected Default implementation returns 10- Returns:
- max move distance allowed for taps (in pixels)
-
getTapZoomGate
public float getTapZoomGate()
Tap events disabled if zoom of more than returned value is detected Default implementation returns 1.01f- Returns:
- max zoom allowed for taps
-
getRotationGate
public float getRotationGate()
Rotation starts when user rotates two fingers for more than returned value Default implementation returns 10- Returns:
- angle when map rotation starts (in degrees)
-
getRotationResetGate
public float getRotationResetGate()
-
getFlingTimeGate
public long getFlingTimeGate()
If last move event was older that returned value no fling events will be triggered Default implementation returns 100000000- Returns:
- max time to trigger fling event (in nanoseconds)
-
getFlingSpeedGate
public long getFlingSpeedGate()
Minimal speed to trigger fling event Default implementation returns 400- Returns:
- minimal speed to trigger fling event in px/s
-
getLongPressDuration
public long getLongPressDuration()
Time to trigger long press Default implementation returns 1000000000- Returns:
- time between taps (in nanoseconds)
-
getMultiTapTimeGate
public long getMultiTapTimeGate()
Time between taps Default implementation returns 250000000- Returns:
- time between taps (in nanoseconds)
-
getMaxTapsToDetect
public long getMaxTapsToDetect(int numberOfTouches)
Maximum taps to detect for given number of touches Default implementation return 2 for 1 touch and 1 for others- Parameters:
numberOfTouches- number of touches- Returns:
- number of taps to detect
-
getNumberOfTouches
public int getNumberOfTouches()
Returns number of active touches- Returns:
- number of active touches
-
onTouch
public boolean onTouch(android.view.View v, android.view.MotionEvent motionEvent)- Specified by:
onTouchin interfaceandroid.view.View.OnTouchListener
-
-