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 processing `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, ..)

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `PinchToZoomGesture.ZoomEvent` A `GestureHandler.GestureEvent` denominating zoom.

    - ### Nested classes/interfaces inherited from interface com.jogamp.newt.event.GestureHandler

      `GestureHandler.GestureEvent, GestureHandler.GestureListener`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static boolean` | `DEBUG`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `PinchToZoomGesture(NativeSurface surface, boolean allowMorePointer)`

  - ### Method Summary

    Methods
    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()`

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### DEBUG

          public static final boolean DEBUG

  - ### Constructor Detail

    - #### PinchToZoomGesture

          public PinchToZoomGesture(NativeSurface surface,
                            boolean allowMorePointer)

      Parameters:
        `surface` - the `NativeSurface`, which size is used to compute the relative zoom factor
        `allowMorePointer` - if false, allow only 2 pressed pointers (safe and recommended), otherwise accept other pointer to be pressed.

  - ### Method Detail

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### clear

          public void clear(boolean clearStarted)

      Description copied from interface: `GestureHandler`
      Clears state of handler, i.e. resets all states incl. previous detected gesture.
      Specified by:
        `clear` in interface `GestureHandler`
      Parameters:
        `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.

    - #### isWithinGesture

          public boolean isWithinGesture()

      Description copied from interface: `GestureHandler`
      Returns true if within a gesture as detected by a previous `GestureHandler.process(InputEvent)` command, which has not been `cleared`. Otherwise returns false.
      Specified by:
        `isWithinGesture` in interface `GestureHandler`

    - #### hasGesture

          public boolean hasGesture()

      Description copied from interface: `GestureHandler`
      Returns true if a previous `GestureHandler.process(InputEvent)` command produced a gesture, which has not been `cleared`. Otherwise returns false.
      Specified by:
        `hasGesture` in interface `GestureHandler`

    - #### getGestureEvent

          public InputEvent getGestureEvent()

      Description copied from interface: `GestureHandler`
      Returns the corresponding `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.

      Specified by:
        `getGestureEvent` in interface `GestureHandler`

    - #### 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: `GestureHandler`
      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`.

      Specified by:
        `process` in interface `GestureHandler`

Copyright 2010 JogAmp Community.