Top Description Fields Constructors Methods
com.jogamp.newt.event

public Class DoubleTapScrollGesture

extends Object
implements GestureHandler
Class Inheritance
All Implemented Interfaces
com.jogamp.newt.event.GestureHandler
Imports
com.jogamp.common.util.PropertyAccess, jogamp.newt.Debug

2 pointer scroll/rotate gesture handler processing 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
State ST_2PRESS_C merely exist to pick up gesture after one pointer has been lost temporarily.

isWithinGesture() returns gestureState >= 2PRESS_C

Field Summary

Modifier and TypeField 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

Constructor Summary

AccessConstructor 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

Method Summary

Modifier and TypeMethod and Description
public void
clear(final boolean
if true, also clears started state, otherwise stay within gesture - if appropriate. Staying within a gesture allows fluent continuous gesture sequence, e.g. for scrolling.
clearStarted
)

Implements com.jogamp.newt.event.GestureHandler.clear.

Clears state of handler, i.e. resets all states incl.
private int
gesturePointers(final MouseEvent e, final int excludeIndex)

public InputEvent
getGestureEvent()

Implements com.jogamp.newt.event.GestureHandler.getGestureEvent.

Returns the corresponding InputEvent for the gesture as detected by a previous process(InputEvent), which has not been cleared.
public final float[]
private static final int
getSquareDistance(final float x1, final float y1, final float x2, final float y2)

public boolean
hasGesture()

Implements com.jogamp.newt.event.GestureHandler.hasGesture.

Returns true if a previous process(InputEvent) command produced a gesture, which has not been cleared.
public boolean
isWithinGesture()

Implements com.jogamp.newt.event.GestureHandler.isWithinGesture.

Returns true if within a gesture as detected by a previous process(InputEvent) command, which has not been cleared.
public boolean
process(final InputEvent in)

Implements com.jogamp.newt.event.GestureHandler.process.

Process the given InputEvent and returns true if it produced the gesture.
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

DOUBLE_TAP_SLOP_MMback 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 newt.event.double_tap_slop_mm.

DOUBLE_TAP_SLOP_PIXELback 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 newt.event.double_tap_slop_pixel.

doubleTapSlopback to summary
private final int doubleTapSlop
doubleTapSlopSquareback to summary
private final int doubleTapSlopSquare
gestureStateback to summary
private int gestureState

See class docu

hitGestureEventback to summary
private MouseEvent hitGestureEvent
lastXback to summary
private int lastX
lastYback to summary
private int lastY
pIdsback to summary
private final int[] pIds
pointerDownCountback to summary
private int pointerDownCount
SCROLL_SLOP_MMback to summary
public static final float SCROLL_SLOP_MM

Scroll threshold in millimeter, defaults to 3 mm. Can be overriden by integer property newt.event.scroll_slop_mm.

SCROLL_SLOP_PIXELback to summary
public static final int SCROLL_SLOP_PIXEL

Scroll threshold in pixels (fallback), defaults to 16 pixels. Can be overriden by integer property newt.event.scroll_slop_pixel.

scrollDistanceback to summary
private final float[] scrollDistance
scrollSlopback to summary
private final int scrollSlop
scrollSlopSquareback to summary
private final int scrollSlopSquare
sqStartDistback to summary
private int sqStartDist
ST_1PRESSback to summary
private static final int ST_1PRESS
ST_2PRESS_Cback to summary
private static final int ST_2PRESS_C
ST_2PRESS_Tback to summary
private static final int ST_2PRESS_T
ST_NONEback to summary
private static final int ST_NONE
ST_SCROLLback to summary
private static final int ST_SCROLL

Constructor Detail

DoubleTapScrollGestureback to summary
public DoubleTapScrollGesture(final int scaledScrollSlop, final int scaledDoubleTapSlop)

scaledScrollSlop < scaledDoubleTapSlop

Parameters
scaledScrollSlop:int

Distance a pointer can wander before we think the user is scrolling in pixels.

scaledDoubleTapSlop:int

Distance in pixels between the first touch and second touch to still be considered a double tap.

Method Detail

clearback to summary
public void clear(final boolean clearStarted)

Implements com.jogamp.newt.event.GestureHandler.clear.

Doc from com.jogamp.newt.event.GestureHandler.clear.

Clears state of handler, i.e. resets all states incl. previous detected gesture.

Parameters
clearStarted:boolean

if true, also clears started state, otherwise stay within gesture - if appropriate. Staying within a gesture allows fluent continuous gesture sequence, e.g. for scrolling.

Annotations
@Override
gesturePointersback to summary
private int gesturePointers(final MouseEvent e, final int excludeIndex)
getGestureEventback to summary
public InputEvent getGestureEvent()

Implements com.jogamp.newt.event.GestureHandler.getGestureEvent.

Doc from com.jogamp.newt.event.GestureHandler.getGestureEvent.

Returns the corresponding InputEvent for the gesture as detected by a previous process(InputEvent), which has not been cleared. Otherwise returns null.

Only implemented for gestures mapping to InputEvents.

Annotations
@Override
getScrollDistanceXYback to summary
public final float[] getScrollDistanceXY()
getSquareDistanceback to summary
private static final int getSquareDistance(final float x1, final float y1, final float x2, final float y2)
hasGestureback to summary
public boolean hasGesture()

Implements com.jogamp.newt.event.GestureHandler.hasGesture.

Doc from com.jogamp.newt.event.GestureHandler.hasGesture.

Returns true if a previous process(InputEvent) command produced a gesture, which has not been cleared. Otherwise returns false.

Annotations
@Override
isWithinGestureback to summary
public boolean isWithinGesture()

Implements com.jogamp.newt.event.GestureHandler.isWithinGesture.

Doc from com.jogamp.newt.event.GestureHandler.isWithinGesture.

Returns true if within a gesture as detected by a previous process(InputEvent) command, which has not been cleared. Otherwise returns false.

Annotations
@Override
processback to summary
public boolean process(final InputEvent in)

Implements com.jogamp.newt.event.GestureHandler.process.

Doc from com.jogamp.newt.event.GestureHandler.process.

Process the given InputEvent and returns true if it produced the gesture. Otherwise returns false.

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 InputEvent.InputClass and/or InputEvent.InputType.

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object

Annotations
@Override