Package com.jogamp.newt.event
Class PinchToZoomGesture
- java.lang.Object
-
- com.jogamp.newt.event.PinchToZoomGesture
-
- All Implemented Interfaces:
GestureHandler
public class PinchToZoomGesture extends Object implements GestureHandler
2 pointer zoom, a.k.a. pinch to zoom, gesture handler processingMouseEvents while producingPinchToZoomGesture.ZoomEvents if gesture is completed.Zoom value lies within [0..2], with 1 as 1:1.
- choosing the smallest surface edge (width/height -> x/y) - tolerating other fingers to be pressed and hence user to add functionality (scale, ..)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classPinchToZoomGesture.ZoomEventAGestureHandler.GestureEventdenominating zoom.-
Nested classes/interfaces inherited from interface com.jogamp.newt.event.GestureHandler
GestureHandler.GestureEvent, GestureHandler.GestureListener
-
-
Field Summary
Fields Modifier and Type Field Description static booleanDEBUG
-
Constructor Summary
Constructors Constructor Description PinchToZoomGesture(NativeSurface surface, boolean allowMorePointer)
-
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.floatgetZoom()Zoom value lies within [0..2], with 1 as 1:1.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.voidsetZoom(float zoom)Set zoom value within [0..2], with 1 as 1:1.StringtoString()
-
-
-
Constructor Detail
-
PinchToZoomGesture
public PinchToZoomGesture(NativeSurface surface, boolean allowMorePointer)
- Parameters:
surface- theNativeSurface, which size is used to compute the relative zoom factorallowMorePointer- if false, allow only 2 pressed pointers (safe and recommended), otherwise accept other pointer to be pressed.
-
-
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
-
getZoom
public final float getZoom()
Zoom value lies within [0..2], with 1 as 1:1.
-
setZoom
public final void setZoom(float zoom)
Set zoom value within [0..2], with 1 as 1:1.
-
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
-
-