public class PinchToZoomGesture extends Object implements GestureHandler
MouseEvent
s
while producing PinchToZoomGesture.ZoomEvent
s 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, ..)
Modifier and Type | Class and Description |
---|---|
static class |
PinchToZoomGesture.ZoomEvent
A
GestureHandler.GestureEvent denominating zoom. |
GestureHandler.GestureEvent, GestureHandler.GestureListener
Modifier and Type | Field and Description |
---|---|
static boolean |
DEBUG |
Constructor and Description |
---|
PinchToZoomGesture(NativeSurface surface,
boolean allowMorePointer) |
Modifier and Type | Method and Description |
---|---|
void |
clear(boolean clearStarted)
Clears state of handler, i.e.
|
InputEvent |
getGestureEvent()
Returns the corresponding
InputEvent for the gesture as detected by
a previous GestureHandler.process(InputEvent) , which has not been cleared . |
float |
getZoom()
Zoom value lies within [0..2], with 1 as 1:1.
|
boolean |
hasGesture()
Returns true if a previous
GestureHandler.process(InputEvent) command produced a gesture,
which has not been cleared . |
boolean |
isWithinGesture()
Returns true if within a gesture as detected by a previous
GestureHandler.process(InputEvent) command,
which has not been cleared . |
boolean |
process(InputEvent in)
Process the given
InputEvent and returns true if it produced the gesture. |
void |
setZoom(float zoom)
Set zoom value within [0..2], with 1 as 1:1.
|
String |
toString() |
public PinchToZoomGesture(NativeSurface surface, boolean allowMorePointer)
surface
- the NativeSurface
, 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.public void clear(boolean clearStarted)
GestureHandler
clear
in interface GestureHandler
clearStarted
- 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.public boolean isWithinGesture()
GestureHandler
GestureHandler.process(InputEvent)
command,
which has not been cleared
.
Otherwise returns false.isWithinGesture
in interface GestureHandler
public boolean hasGesture()
GestureHandler
GestureHandler.process(InputEvent)
command produced a gesture,
which has not been cleared
.
Otherwise returns false.hasGesture
in interface GestureHandler
public InputEvent getGestureEvent()
GestureHandler
InputEvent
for the gesture as detected by
a previous GestureHandler.process(InputEvent)
, which has not been cleared
.
Otherwise returns null.
Only implemented for gestures mapping to InputEvent
s.
getGestureEvent
in interface GestureHandler
public final float getZoom()
public final void setZoom(float zoom)
public boolean process(InputEvent in)
GestureHandler
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
.
process
in interface GestureHandler
Copyright 2010 JogAmp Community.