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

public Class PinchToZoomGesture

extends Object
implements GestureHandler
Class Inheritance
All Implemented Interfaces
com.jogamp.newt.event.GestureHandler
Imports
com.jogamp.nativewindow.NativeSurface, com.jogamp.newt.event.MouseEvent.PointerClass, jogamp.newt.Debug

2 pointer zoom, a.k.a. pinch to zoom, gesture handler processing MouseEvents while producing 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 and Inner Type Summary

Modifier and TypeClass and Description
public static class

Field Summary

Modifier and TypeField and Description
private final boolean
public static final boolean
private final short[]
private final NativeSurface
private float
private PinchToZoomGesture.ZoomEvent
private boolean
private int
private boolean

Constructor Summary

AccessConstructor and Description
public
PinchToZoomGesture(final NativeSurface
the NativeSurface, which size is used to compute the relative zoom factor
surface
,
final boolean
if false, allow only 2 pressed pointers (safe and recommended), otherwise accept other pointer to be pressed.
allowMorePointer
)

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
getZoom()

Zoom value lies within [0..2], with 1 as 1:1.

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 final void
setZoom(final float zoom)

Set zoom value within [0..2], with 1 as 1:1.

public String
toString()

Overrides java.lang.Object.toString.

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

Field Detail

allowMorePointerback to summary
private final boolean allowMorePointer
DEBUGback to summary
public static final boolean DEBUG

Hides com.jogamp.newt.event.GestureHandler.DEBUG.

pIdsback to summary
private final short[] pIds
surfaceback to summary
private final NativeSurface surface
zoomback to summary
private float zoom
zoomEventback to summary
private PinchToZoomGesture.ZoomEvent zoomEvent
zoomFirstTouchback to summary
private boolean zoomFirstTouch
zoomLastEdgeDistback to summary
private int zoomLastEdgeDist
zoomModeback to summary
private boolean zoomMode

Constructor Detail

PinchToZoomGestureback to summary
public PinchToZoomGesture(final NativeSurface surface, final boolean allowMorePointer)
Parameters
surface:NativeSurface

the NativeSurface, which size is used to compute the relative zoom factor

allowMorePointer:boolean

if false, allow only 2 pressed pointers (safe and recommended), otherwise accept other pointer to be pressed.

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
getZoomback to summary
public final float getZoom()

Zoom value lies within [0..2], with 1 as 1:1.

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
setZoomback to summary
public final void setZoom(final float zoom)

Set zoom value within [0..2], with 1 as 1:1.

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
com.jogamp.newt.event back to summary

public Class PinchToZoomGesture.ZoomEvent

extends GestureEvent
Class Inheritance
Annotations
@SuppressWarnings:serial

A GestureHandler.GestureEvent denominating zoom.

Field Summary

Modifier and TypeField and Description
private final float
private final float
private final float
Inherited from com.jogamp.newt.event.GestureHandler.GestureEvent:
EVENT_GESTURE_DETECTED

Constructor Summary

AccessConstructor and Description
public
ZoomEvent(final Object source, final long when, final int modifiers, final GestureHandler handler, final MouseEvent pe, final float zoom, final float delta, final float scale)

Method Summary

Modifier and TypeMethod and Description
public final float
getDelta()

Delta to last zoom value lies within [-1..1].

public final float
getScale()

Returns the scale used to determine the zoom and hence it's delta value, which semantics depends on the pointer type's PointerClass.

public final float
getZoom()

Zoom value lies within [0..2], with 1 as 1:1.

public final String
toString()

Overrides com.jogamp.newt.event.GestureHandler.GestureEvent.toString.

Returns a String representation of this EventObject.
Inherited from com.jogamp.newt.event.GestureHandler.GestureEvent:
getHandlergetTrigger

Field Detail

deltaback to summary
private final float delta
scaleback to summary
private final float scale
zoomback to summary
private final float zoom

Constructor Detail

ZoomEventback to summary
public ZoomEvent(final Object source, final long when, final int modifiers, final GestureHandler handler, final MouseEvent pe, final float zoom, final float delta, final float scale)

Method Detail

getDeltaback to summary
public final float getDelta()

Delta to last zoom value lies within [-1..1].

getScaleback to summary
public final float getScale()

Returns the scale used to determine the zoom and hence it's delta value, which semantics depends on the pointer type's PointerClass.

For PointerClass#Offscreen, the scale is usually 1.0f and denominates an abstract value without association to a physical value.

For PointerClass#Onscreen, the scale varies and denominates the divisor of the distance the finger[s] have moved on the screen. Hence scale * delta reproduces the screen distance in pixels the finger[s] have moved.

getZoomback to summary
public final float getZoom()

Zoom value lies within [0..2], with 1 as 1:1.

toStringback to summary
public final String toString()

Overrides com.jogamp.newt.event.GestureHandler.GestureEvent.toString.

Doc from java.util.EventObject.toString.

Returns a String representation of this EventObject.

Returns:String

a String representation of this EventObject