MouseEvents
while producing MouseEvent#EVENT_MOUSE_WHEEL_MOVED events if gesture is completed.
Criteria related to parameters:
- doubleTapSlop (scaled in pixels):
- Max 2 finger distance to start 'scroll' mode
- Max. distance diff of current 2-pointer middle and initiated 2-pointer middle.
- touchSlop (scaled in pixels):
- Min. movement w/ 2 pointer within ScaledDoubleTapSlop starting 'scroll' mode
- Avoid computation if not within gesture, especially for MOVE/DRAG
- Only allow gesture to start with PRESS
- Leave gesture completely with RELEASE of both/all fingers, or dist-diff exceeds doubleTapSlop
- Tolerate temporary lift 1 of 2 pointer
- Always validate pointer-id
Implementation uses a n-state to get detect gesture:
| from | to | action |
|---|---|---|
| NONE | 1PRESS | 1-pointer-pressed |
| 1PRESS | 2PRESS_T | 2-pointer-pressed within doubleTapSlope |
| 2PRESS_T | SCROLL | 2-pointer dragged, dist-diff within doubleTapSlop and scrollLen >= scrollSlop |
| 2PRESS_C | SCROLL | 2-pointer dragged, dist-diff within doubleTapSlop |
| SCROLL | SCROLL | 2-pointer dragged, dist-diff within doubleTapSlop |
isWithinGesture() returns gestureState >= 2PRESS_C
| Modifier and Type | Field and Description |
|---|---|
| public static final float | DOUBLE_TAP_SLOP_MM
Two pointer 'double tap' slop in millimeter, defaults to 20 mm. |
| public static final int | DOUBLE_TAP_SLOP_PIXEL
Two pointer 'double tap' slop in pixels (fallback), defaults to 104 pixels. |
| private final int | |
| private final int | |
| private int | gestureState
See class docu |
| private MouseEvent | |
| private int | |
| private int | |
| private final int[] | |
| private int | |
| public static final float | SCROLL_SLOP_MM
Scroll threshold in millimeter, defaults to 3 mm. |
| public static final int | SCROLL_SLOP_PIXEL
Scroll threshold in pixels (fallback), defaults to 16 pixels. |
| private final float[] | |
| private final int | |
| private final int | |
| private int | |
| private static final int | |
| private static final int | |
| private static final int | |
| private static final int | |
| private static final int |
| Access | Constructor and Description |
|---|---|
| public | DoubleTapScrollGesture(final int
Distance a pointer can wander before we think the user is scrolling in pixels. scaledScrollSlop, final int Distance in pixels between the first touch and second touch to still be considered a double tap. scaledDoubleTapSlop)scaledScrollSlop < scaledDoubleTapSlop |
| Modifier and Type | Method and Description |
|---|---|
| public void | clear(final boolean
if true, also clears clearStarted)started state,
otherwise stay within gesture - if appropriate.
Staying within a gesture allows fluent continuous gesture sequence,
e.g. for scrolling.Implements com. |
| private int | |
| public InputEvent | getGestureEvent()
Implements com. InputEvent for the gesture as detected by
a previous process(InputEvent), which has not been cleared.
|
| public final float[] | |
| private static final int | |
| public boolean | hasGesture()
Implements com. process(InputEvent) command produced a gesture,
which has not been cleared.
|
| public boolean | isWithinGesture()
Implements com. process(InputEvent) command,
which has not been cleared.
|
| public boolean | process(final InputEvent in)
Implements com. InputEvent and returns true if it produced the gesture.
|
| public String |
| DOUBLE_TAP_SLOP_MM | back to summary |
|---|---|
| public static final float DOUBLE_TAP_SLOP_MM Two pointer 'double tap' slop in millimeter, defaults to 20 mm. Can be overriden by integer property | |
| DOUBLE_TAP_SLOP_PIXEL | back to summary |
|---|---|
| public static final int DOUBLE_TAP_SLOP_PIXEL Two pointer 'double tap' slop in pixels (fallback), defaults to 104 pixels. Can be overriden by integer property | |
| doubleTapSlop | back to summary |
|---|---|
| private final int doubleTapSlop | |
| doubleTapSlopSquare | back to summary |
|---|---|
| private final int doubleTapSlopSquare | |
| gestureState | back to summary |
|---|---|
| private int gestureState See class docu | |
| hitGestureEvent | back to summary |
|---|---|
| private MouseEvent hitGestureEvent | |
| lastX | back to summary |
|---|---|
| private int lastX | |
| lastY | back to summary |
|---|---|
| private int lastY | |
| pIds | back to summary |
|---|---|
| private final int[] pIds | |
| pointerDownCount | back to summary |
|---|---|
| private int pointerDownCount | |
| SCROLL_SLOP_MM | back to summary |
|---|---|
| public static final float SCROLL_SLOP_MM Scroll threshold in millimeter, defaults to 3 mm. Can be overriden by integer property | |
| SCROLL_SLOP_PIXEL | back to summary |
|---|---|
| public static final int SCROLL_SLOP_PIXEL Scroll threshold in pixels (fallback), defaults to 16 pixels. Can be overriden by integer property | |
| scrollDistance | back to summary |
|---|---|
| private final float[] scrollDistance | |
| scrollSlop | back to summary |
|---|---|
| private final int scrollSlop | |
| scrollSlopSquare | back to summary |
|---|---|
| private final int scrollSlopSquare | |
| sqStartDist | back to summary |
|---|---|
| private int sqStartDist | |
| ST_1PRESS | back to summary |
|---|---|
| private static final int ST_1PRESS | |
| ST_2PRESS_C | back to summary |
|---|---|
| private static final int ST_2PRESS_C | |
| ST_2PRESS_T | back to summary |
|---|---|
| private static final int ST_2PRESS_T | |
| ST_NONE | back to summary |
|---|---|
| private static final int ST_NONE | |
| ST_SCROLL | back to summary |
|---|---|
| private static final int ST_SCROLL | |
| DoubleTapScrollGesture | back to summary |
|---|---|
| public DoubleTapScrollGesture(final int scaledScrollSlop, final int scaledDoubleTapSlop) scaledScrollSlop < scaledDoubleTapSlop
| |
| clear | back to summary |
|---|---|
| public void clear(final boolean clearStarted) Implements com. Doc from com. Clears state of handler, i.e. resets all states incl. previous detected gesture. | |
| gesturePointers | back to summary |
|---|---|
| private int gesturePointers(final MouseEvent e, final int excludeIndex) | |
| getGestureEvent | back to summary |
|---|---|
| public InputEvent getGestureEvent() Implements com. Doc from com. Returns the corresponding
Only implemented for gestures mapping to
| |
| getScrollDistanceXY | back to summary |
|---|---|
| public final float[] getScrollDistanceXY() | |
| getSquareDistance | back to summary |
|---|---|
| private static final int getSquareDistance(final float x1, final float y1, final float x2, final float y2) | |
| hasGesture | back to summary |
|---|---|
| public boolean hasGesture() Implements com. Doc from com. Returns true if a previous
| |
| isWithinGesture | back to summary |
|---|---|
| public boolean isWithinGesture() Implements com. Doc from com. Returns true if within a gesture as detected by a previous
| |
| process | back to summary |
|---|---|
| public boolean process(final InputEvent in) Implements com. Doc from com. Process the given If a gesture was already detected previously and has not been cleared, method does not process the event and returns true.
Besides validation of the event's details,
the handler may also validate the
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object. | |