Package com.jogamp.newt.event
Class DoubleTapScrollGesture
- java.lang.Object
-
- com.jogamp.newt.event.DoubleTapScrollGesture
-
- All Implemented Interfaces:
GestureHandler
public class DoubleTapScrollGesture extends Object implements GestureHandler
2 pointer scroll/rotate gesture handler processingMouseEvents while producingMouseEvent.EVENT_MOUSE_WHEEL_MOVEDevents 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-idImplementation uses a n-state to get detect gesture:
State ST_2PRESS_C merely exist to pick up gesture after one pointer has been lost temporarily.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
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.jogamp.newt.event.GestureHandler
GestureHandler.GestureEvent, GestureHandler.GestureListener
-
-
Field Summary
Fields Modifier and Type Field Description static floatDOUBLE_TAP_SLOP_MMTwo pointer 'double tap' slop in millimeter, defaults to 20 mm.static intDOUBLE_TAP_SLOP_PIXELTwo pointer 'double tap' slop in pixels (fallback), defaults to 104 pixels.static floatSCROLL_SLOP_MMScroll threshold in millimeter, defaults to 3 mm.static intSCROLL_SLOP_PIXELScroll threshold in pixels (fallback), defaults to 16 pixels.-
Fields inherited from interface com.jogamp.newt.event.GestureHandler
DEBUG
-
-
Constructor Summary
Constructors Constructor Description DoubleTapScrollGesture(int scaledScrollSlop, int scaledDoubleTapSlop)scaledScrollSlop < scaledDoubleTapSlop
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear(boolean clearStarted)Clears state of handler, i.e.InputEventgetGestureEvent()Returns the correspondingInputEventfor the gesture as detected by a previousGestureHandler.process(InputEvent), which has not beencleared.float[]getScrollDistanceXY()booleanhasGesture()Returns true if a previousGestureHandler.process(InputEvent)command produced a gesture, which has not beencleared.booleanisWithinGesture()Returns true if within a gesture as detected by a previousGestureHandler.process(InputEvent)command, which has not beencleared.booleanprocess(InputEvent in)Process the givenInputEventand returns true if it produced the gesture.StringtoString()
-
-
-
Field Detail
-
SCROLL_SLOP_PIXEL
public static final int SCROLL_SLOP_PIXEL
Scroll threshold in pixels (fallback), defaults to 16 pixels. Can be overriden by integer propertynewt.event.scroll_slop_pixel.
-
DOUBLE_TAP_SLOP_PIXEL
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 propertynewt.event.double_tap_slop_pixel.
-
SCROLL_SLOP_MM
public static final float SCROLL_SLOP_MM
Scroll threshold in millimeter, defaults to 3 mm. Can be overriden by integer propertynewt.event.scroll_slop_mm.
-
DOUBLE_TAP_SLOP_MM
public static final float DOUBLE_TAP_SLOP_MM
Two pointer 'double tap' slop in millimeter, defaults to 20 mm. Can be overriden by integer propertynewt.event.double_tap_slop_mm.
-
-
Constructor Detail
-
DoubleTapScrollGesture
public DoubleTapScrollGesture(int scaledScrollSlop, int scaledDoubleTapSlop)scaledScrollSlop < scaledDoubleTapSlop- Parameters:
scaledScrollSlop- Distance a pointer can wander before we think the user is scrolling in pixels.scaledDoubleTapSlop- Distance in pixels between the first touch and second touch to still be considered a double tap.
-
-
Method Detail
-
clear
public void clear(boolean clearStarted)
Description copied from interface:GestureHandlerClears state of handler, i.e. resets all states incl. previous detected gesture.- Specified by:
clearin interfaceGestureHandler- Parameters:
clearStarted- if true, also clearsstartedstate, otherwise stay within gesture - if appropriate. Staying within a gesture allows fluent continuous gesture sequence, e.g. for scrolling.
-
isWithinGesture
public boolean isWithinGesture()
Description copied from interface:GestureHandlerReturns true if within a gesture as detected by a previousGestureHandler.process(InputEvent)command, which has not beencleared. Otherwise returns false.- Specified by:
isWithinGesturein interfaceGestureHandler
-
hasGesture
public boolean hasGesture()
Description copied from interface:GestureHandlerReturns true if a previousGestureHandler.process(InputEvent)command produced a gesture, which has not beencleared. Otherwise returns false.- Specified by:
hasGesturein interfaceGestureHandler
-
getGestureEvent
public InputEvent getGestureEvent()
Description copied from interface:GestureHandlerReturns the correspondingInputEventfor the gesture as detected by a previousGestureHandler.process(InputEvent), which has not beencleared. Otherwise returns null.Only implemented for gestures mapping to
InputEvents.- Specified by:
getGestureEventin interfaceGestureHandler
-
getScrollDistanceXY
public final float[] getScrollDistanceXY()
-
process
public boolean process(InputEvent in)
Description copied from interface:GestureHandlerProcess the givenInputEventand 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.InputClassand/orInputEvent.InputType.- Specified by:
processin interfaceGestureHandler
-
-