GestureΒΆ

The Gesture class represents a recognized movement by the user. More...

Inherits Interface.

Inherited by CircleGesture, KeyTapGesture, ScreenTapGesture, and SwipeGesture.

Classes

enum  State
 The possible gesture states. More...
 
enum  Type
 The supported types of gestures. More...
 

Public Member Functions

long duration ()
 The elapsed duration of the recognized movement up to the frame containing this Gesture object, in microseconds. More...
 
float durationSeconds ()
 The elapsed duration in seconds. More...
 
boolean equals (Gesture rhs)
 Compare Gesture object equality. More...
 
Frame frame ()
 The Frame containing this Gesture instance. More...
 
 Gesture ()
 Constructs a new Gesture object. More...
 
 Gesture (Gesture rhs)
 Constructs a new copy of an Gesture object. More...
 
HandList hands ()
 The list of hands associated with this Gesture, if any. More...
 
int id ()
 The gesture ID. More...
 
boolean isValid ()
 Reports whether this Gesture instance represents a valid Gesture. More...
 
PointableList pointables ()
 The list of fingers and tools associated with this Gesture, if any. More...
 
Gesture.State state ()
 The gesture state. More...
 
String toString ()
 A string containing a brief, human-readable description of this Gesture. More...
 
Gesture.Type type ()
 The gesture type. More...
 

Static Public Member Functions

static Gesture invalid ()
 Returns an invalid Gesture object. More...
 

Detailed Description

The Gesture class represents a recognized movement by the user.

Deprecated:
3.0

Constructor & Destructor Documentation

Gesture ( )

Constructs a new Gesture object.

An uninitialized Gesture object is considered invalid. Get valid instances of the Gesture class, which will be one of the Gesture subclasses, from a Frame object.

Since
1.0
Gesture ( Gesture  rhs)

Constructs a new copy of an Gesture object.

Gesture copy = new Gesture(gesture);
Deprecated:
3.0

Member Function Documentation

long duration ( )

The elapsed duration of the recognized movement up to the frame containing this Gesture object, in microseconds.

float microseconds = gesture.duration();

The duration reported for the first Gesture in the sequence (with the STATE_START state) will typically be a small positive number since the movement must progress far enough for the Leap Motion software to recognize it as an intentional gesture.

Returns
int64_t the elapsed duration in microseconds.
Deprecated:
3.0
float durationSeconds ( )

The elapsed duration in seconds.

float seconds = gesture.durationSeconds();
See also
duration()
Returns
float the elapsed duration in seconds.
Deprecated:
3.0
boolean equals ( Gesture  rhs)

Compare Gesture object equality.

Boolean gestureIsEqual = thisGesture.equals(thatGesture);

Two Gestures are equal if they represent the same snapshot of the same recognized movement.

Deprecated:
3.0
Frame frame ( )

The Frame containing this Gesture instance.

Frame frameOfGesture = gesture.frame();
Returns
Frame The parent Frame object.
Deprecated:
3.0
HandList hands ( )

The list of hands associated with this Gesture, if any.

HandList handsForGesture = gesture.hands();

If no hands are related to this gesture, the list is empty.

Returns
HandList the list of related Hand objects.
Deprecated:
3.0
int id ( )

The gesture ID.

All Gesture objects belonging to the same recognized movement share the same ID value. Use the ID value with the Frame::gesture() method to find updates related to this Gesture object in subsequent frames.

int gestureToFind = gesture.id();
GestureList manyGestures = frame.gestures(olderFrame);
for(Gesture gestureObject : manyGestures)
{
if (gestureObject.id() == gestureToFind) {
//Process it...
}
}
Returns
int32_t the ID of this Gesture.
Deprecated:
3.0
static Gesture invalid ( )
static

Returns an invalid Gesture object.

Gesture trackedGesture = frame.gesture(gestureID);
if (!trackedGesture.equals(Gesture.invalid())) {
//Process it...
}
Returns
The invalid Gesture instance.
Deprecated:
3.0
boolean isValid ( )

Reports whether this Gesture instance represents a valid Gesture.

if (gesture.isValid()) {
// Process it...
}
Returns
bool True, if this is a valid Gesture instance; false, otherwise.
Deprecated:
3.0
PointableList pointables ( )

The list of fingers and tools associated with this Gesture, if any.

If no Pointable objects are related to this gesture, the list is empty.

PointableList pointablesForGesture = gesture.pointables();
Returns
PointableList the list of related Pointable objects.
Deprecated:
3.0
Gesture.State state ( )

The gesture state.

Recognized movements occur over time and have a beginning, a middle, and an end. The 'state()' attribute reports where in that sequence this Gesture object falls.

for(Gesture gestureObj : frame.gestures())
{
switch (gesture.state()) {
case STATE_START:
//Handle starting gestures
break;
case STATE_UPDATE:
//Handle continuing gestures
break;
case STATE_STOP:
//Handle ending gestures
break;
default:
//Handle unrecognized states
break;
}
}
Returns
Gesture::State A value from the Gesture::State enumeration.
Deprecated:
3.0
String toString ( )

A string containing a brief, human-readable description of this Gesture.

for(Gesture gesture : frame.gestures()){
System.out.println(gesture.toString());
}
Deprecated:
3.0
Gesture.Type type ( )

The gesture type.

for(Gesture gesture : frame.gestures())
{
switch (gesture.type()) {
case TYPE_CIRCLE:
//Handle circle gestures
break;
case TYPE_KEY_TAP:
//Handle key tap gestures
break;
case TYPE_SCREEN_TAP:
//Handle screen tap gestures
break;
case TYPE_SWIPE:
//Handle swipe gestures
break;
default:
//Handle unrecognized gestures
break;
}
}
Returns
Gesture::Type A value from the Gesture::Type enumeration.
Deprecated:
3.0