Class GestureEvent
java.lang.Object
com.codename1.sensors.GestureEvent
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
FieldsModifier and TypeFieldDescriptionstatic final intThe device was turned face down (screen towards the ground).static final intThe device was turned face up (screen towards the sky).static final intThe device is in free fall (near weightlessness was detected).static final intThe device was picked up from a resting position.static final intThe device was shaken back and forth.static final intThe top of the device was tilted towards the user (pitched backward).static final intThe top of the device was tilted away from the user (pitched forward).static final intThe device was tilted to the left (top edge rotating towards the user's left hand).static final intThe device was tilted to the right. -
Constructor Summary
ConstructorsConstructorDescriptionGestureEvent(int type, double value, long timestamp) Creates a new gesture event. -
Method Summary
Modifier and TypeMethodDescriptiongetName()A human readable name for the gesture type, useful for logging.longThe time at which the gesture was detected, in milliseconds, compatible withSystem.currentTimeMillis().intgetType()The gesture that occurred, one of theTYPE_*constants.doublegetValue()A magnitude describing the strength of the gesture.toString()Returns a string representation of the object.
-
Field Details
-
TYPE_SHAKE
public static final int TYPE_SHAKEThe device was shaken back and forth.- See Also:
-
TYPE_FLIP_FACE_DOWN
public static final int TYPE_FLIP_FACE_DOWNThe device was turned face down (screen towards the ground).- See Also:
-
TYPE_FLIP_FACE_UP
public static final int TYPE_FLIP_FACE_UPThe device was turned face up (screen towards the sky).- See Also:
-
TYPE_TILT_LEFT
public static final int TYPE_TILT_LEFTThe 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_RIGHTThe device was tilted to the right.- See Also:
-
TYPE_TILT_FORWARD
public static final int TYPE_TILT_FORWARDThe top of the device was tilted away from the user (pitched forward).- See Also:
-
TYPE_TILT_BACKWARD
public static final int TYPE_TILT_BACKWARDThe top of the device was tilted towards the user (pitched backward).- See Also:
-
TYPE_PICK_UP
public static final int TYPE_PICK_UPThe device was picked up from a resting position.- See Also:
-
TYPE_FREE_FALL
public static final int TYPE_FREE_FALLThe 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 theTYPE_*constantsvalue: a magnitude describing the gesture; the peak acceleration in meters per second squared forTYPE_SHAKE,TYPE_PICK_UPandTYPE_FREE_FALL, or the tilt angle in radians for the tilt and flip gesturestimestamp: the event time in milliseconds
-
-
Method Details
-
getType
public int getType()The gesture that occurred, one of theTYPE_*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 withSystem.currentTimeMillis(). -
getName
A human readable name for the gesture type, useful for logging. -
toString
Description copied from class:ObjectReturns 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())
-