Package globus.glmap
Class GLMapGesturesDetector
java.lang.Object
globus.glmap.GLMapGesturesDetector
- All Implemented Interfaces:
android.view.View.OnTouchListener
Detector of gestures for map view
-
Field Summary
FieldsModifier and TypeFieldDescriptionbooleanInverse one-finger zoom (tap-zoom) gesture direction. -
Constructor Summary
ConstructorsConstructorDescriptionGLMapGesturesDetector(GLMapViewRenderer renderer, android.os.Handler handler) Default constructor -
Method Summary
Modifier and TypeMethodDescriptionlongMinimal speed to trigger fling event.longIf last move event is older than the returned value, no fling events will be triggered.longTime to trigger long press.longgetMaxTapsToDetect(int numberOfTouches) Maximum taps to detect for a given number of touches.longTime between taps.intReturns number of active touchesfloatReturns the minimum distance (in screen points / dp) that any touch point needs to travel to start detecting a pitch gesture.floatPitch events are disabled if Y distance between fingers is more than the returned value.floatRotation starts when user rotates two fingers by more than the returned value.floatRotation resets if user rotates by an angle less than the gate.floatTap events are disabled if movement greater than the returned value is detected.floatTap events are disabled if zoom greater than the returned value is detected.floatgetTouchX(int index) Returns x coordinate of the touchfloatgetTouchY(int index) Returns y coordinate of the touchvoidonBegin()Called when new touch started.voidonEnd()Called when all touches ended.voidonFling(float speedX, float speedY) Called when fling is detected.voidonLongPress(int numberOfTouches, float cx, float cy) Called when long press detected.voidonMove(float dx, float dy) Called when movement detected.voidonPitch(float distance) Called when pitch gesture is detected.voidonRotate(float delta, float cx, float cy) Called when rotation is detected.voidCalled when rotation reset happensvoidonTap(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 detectedvoidStop detecting pan until all current touches are upvoidStop detecting taps until all current touches are upvoidStop detecting touches until all current touches are up
-
Field Details
-
oneFingerZoomInverse
public boolean oneFingerZoomInverseInverse one-finger zoom (tap-zoom) gesture direction.trueby default. When inverted — move up to zoom out, move down to zoom in.
-
-
Constructor Details
-
GLMapGesturesDetector
public GLMapGesturesDetector(@NonNull GLMapViewRenderer renderer, @NonNull android.os.Handler handler) Default constructor- Parameters:
renderer- position, angle and zoom of this map will be modified by this detectorhandler- gesture handler
-
-
Method Details
-
stopDetectingTouches
public void stopDetectingTouches()Stop detecting touches until all current touches are up -
stopDetectingTaps
public void stopDetectingTaps()Stop detecting taps until all current touches are up -
stopDetectingPan
public void stopDetectingPan()Stop detecting pan until 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)
-
getNumberOfTouches
public int getNumberOfTouches()Returns number of active touches- Returns:
- number of active touches
-
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 moves 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 rotates the map with animation if delta is greater than the rotation gate.- Parameters:
delta- angle delta (in degrees)cx- x coordinate of rotation center (in pixels)cy- y coordinate of rotation center (in pixels)
-
onPitch
public void onPitch(float distance) Called when pitch gesture is detected.- Parameters:
distance- distance of pitch gesture
-
onBegin
public void onBegin()Called when new touch started. Default implementation does nothing. -
onEnd
public void onEnd()Called when all touches ended. Default implementation rotates map to 0 if current angle is in range 340 .. 20 -
onRotationReset
public void onRotationReset()Called when rotation reset happens -
getTapDistanceGate
public float getTapDistanceGate()Tap events are disabled if movement greater than the returned value is detected. Default implementation returns 10.- Returns:
- max move distance allowed for taps (in screen points / dp)
-
getPitchDistanceGate
public float getPitchDistanceGate()Returns the minimum distance (in screen points / dp) that any touch point needs to travel to start detecting a pitch gesture. The detector accumulates touch movement until this threshold is met, then evaluates if it's a valid pitch gesture. Default implementation returns 30 points.- Returns:
- minimum travel distance to initiate pitch gesture detection (in screen points / dp)
-
getPitchYDeltaGate
public float getPitchYDeltaGate()Pitch events are disabled if Y distance between fingers is more than the returned value. Default implementation returns 100.- Returns:
- max Y distance allowed for pitch gesture (in screen points / dp)
-
getTapZoomGate
public float getTapZoomGate()Tap events are disabled if zoom greater than the 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 by more than the returned value. Default implementation returns 10.- Returns:
- angle when map rotation starts (in degrees)
-
getRotationResetGate
public float getRotationResetGate()Rotation resets if user rotates by an angle less than the gate.- Returns:
- gate value for angle
-
getFlingTimeGate
public long getFlingTimeGate()If last move event is older than the 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 500000000.- Returns:
- time between taps (in nanoseconds)
-
getMultiTapTimeGate
public long getMultiTapTimeGate()Time between taps. Default implementation returns 350000000.- Returns:
- time between taps (in nanoseconds)
-
getMaxTapsToDetect
public long getMaxTapsToDetect(int numberOfTouches) Maximum taps to detect for a given number of touches. Default implementation returns 2 for 1 touch and 1 for others.- Parameters:
numberOfTouches- number of touches- Returns:
- number of taps to detect
-
onTouch
public boolean onTouch(android.view.View v, android.view.MotionEvent motionEvent) - Specified by:
onTouchin interfaceandroid.view.View.OnTouchListener
-