Class GestureEvent

java.lang.Object
com.codename1.sensors.GestureEvent

public final class GestureEvent extends Object

A high level gesture detected by the framework from the motion sensor stream and delivered to a GestureListener. The gesture detection runs in the core so the same gestures are available on every platform that exposes an accelerometer.

The available gestures are identified by the TYPE_* constants on this class; register interest in one of them through MotionSensorManager.addGestureListener(int, GestureListener).

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    The device was turned face down (screen towards the ground).
    static final int
    The device was turned face up (screen towards the sky).
    static final int
    The device is in free fall (near weightlessness was detected).
    static final int
    The device was picked up from a resting position.
    static final int
    The device was shaken back and forth.
    static final int
    The top of the device was tilted towards the user (pitched backward).
    static final int
    The top of the device was tilted away from the user (pitched forward).
    static final int
    The device was tilted to the left (top edge rotating towards the user's left hand).
    static final int
    The device was tilted to the right.
  • Constructor Summary

    Constructors
    Constructor
    Description
    GestureEvent(int type, double value, long timestamp)
    Creates a new gesture event.
  • Method Summary

    Modifier and Type
    Method
    Description
    A human readable name for the gesture type, useful for logging.
    long
    The time at which the gesture was detected, in milliseconds, compatible with System.currentTimeMillis().
    int
    The gesture that occurred, one of the TYPE_* constants.
    double
    A magnitude describing the strength of the gesture.
    Returns a string representation of the object.

    Methods inherited from class Object

    clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • TYPE_SHAKE

      public static final int TYPE_SHAKE
      The device was shaken back and forth.
      See Also:
    • TYPE_FLIP_FACE_DOWN

      public static final int TYPE_FLIP_FACE_DOWN
      The device was turned face down (screen towards the ground).
      See Also:
    • TYPE_FLIP_FACE_UP

      public static final int TYPE_FLIP_FACE_UP
      The device was turned face up (screen towards the sky).
      See Also:
    • TYPE_TILT_LEFT

      public static final int TYPE_TILT_LEFT
      The device was tilted to the left (top edge rotating towards the user's left hand).
      See Also:
    • TYPE_TILT_RIGHT

      public static final int TYPE_TILT_RIGHT
      The device was tilted to the right.
      See Also:
    • TYPE_TILT_FORWARD

      public static final int TYPE_TILT_FORWARD
      The top of the device was tilted away from the user (pitched forward).
      See Also:
    • TYPE_TILT_BACKWARD

      public static final int TYPE_TILT_BACKWARD
      The top of the device was tilted towards the user (pitched backward).
      See Also:
    • TYPE_PICK_UP

      public static final int TYPE_PICK_UP
      The device was picked up from a resting position.
      See Also:
    • TYPE_FREE_FALL

      public static final int TYPE_FREE_FALL
      The device is in free fall (near weightlessness was detected).
      See Also:
  • Constructor Details

    • GestureEvent

      public GestureEvent(int type, double value, long timestamp)

      Creates a new gesture event. Application code does not normally construct these; they are delivered by the framework.

      Parameters
      • type: one of the TYPE_* constants
      • value: a magnitude describing the gesture; the peak acceleration in meters per second squared for TYPE_SHAKE, TYPE_PICK_UP and TYPE_FREE_FALL, or the tilt angle in radians for the tilt and flip gestures
      • timestamp: the event time in milliseconds
  • Method Details

    • getType

      public int getType()
      The gesture that occurred, one of the TYPE_* constants.
    • getValue

      public double getValue()
      A magnitude describing the strength of the gesture. See the constructor documentation for the meaning per gesture type.
    • getTimestamp

      public long getTimestamp()
      The time at which the gesture was detected, in milliseconds, compatible with System.currentTimeMillis().
    • getName

      public String getName()
      A human readable name for the gesture type, useful for logging.
    • toString

      public String toString()
      Description copied from class: Object
      Returns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method. The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of: getClass().getName() + '@' + Integer.toHexString(hashCode())
      Overrides:
      toString in class Object