Leap Motion Java API Reference  0.8.0
com.leapmotion.leap.SwipeGesture Class Reference

The SwipeGesture class represents a swiping motion of a finger or tool. More...

Inherits com.leapmotion.leap.Gesture.

Public Member Functions

Vector direction ()
 The unit direction vector parallel to the swipe motion.
 
Pointable pointable ()
 The finger performing the swipe gesture.
 
Vector position ()
 The current position of the swipe.
 
float speed ()
 The swipe speed in mm/second.
 
Vector startPosition ()
 The position where the swipe began.
 
 SwipeGesture (Gesture rhs)
 Constructs a SwipeGesture object from an instance of the Gesture class.
 
- Public Member Functions inherited from com.leapmotion.leap.Gesture
long duration ()
 The elapsed duration of the recognized movement up to the frame containing this Gesture object, in microseconds.
 
float durationSeconds ()
 The elapsed duration in seconds.
 
boolean equals (Gesture rhs)
 Compare Gesture object equality.
 
Frame frame ()
 The Frame containing this Gesture instance.
 
 Gesture ()
 Constructs a new Gesture object.
 
 Gesture (Gesture rhs)
 Constructs a new copy of an Gesture object.
 
HandList hands ()
 The list of hands associated with this Gesture, if any.
 
int id ()
 The gesture ID.
 
boolean isValid ()
 Reports whether this Gesture instance represents a valid Gesture.
 
PointableList pointables ()
 The list of fingers and tools associated with this Gesture, if any.
 
Gesture.State state ()
 The gesture state.
 
String toString ()
 A string containing a brief, human-readable description of this Gesture.
 
Gesture.Type type ()
 The gesture type.
 

Static Public Member Functions

static Gesture.Type classType ()
 The swipe gesture type.
 
- Static Public Member Functions inherited from com.leapmotion.leap.Gesture
static Gesture invalid ()
 Returns an invalid Gesture object.
 

Detailed Description

The SwipeGesture class represents a swiping motion of a finger or tool.

Leap_Gesture_Swipe.png

Important: To use swipe gestures in your application, you must enable recognition of the swipe gesture. You can enable recognition with:

controller.enableGesture(Gesture.Type.TYPE_SWIPE);

Swipe gestures are continuous.

You can set the minimum length and velocity required for a movement to be recognized as a swipe using the config attribute of a connected Controller object. Use the following keys to configure swipe recognition:

Key string Value type Default value Units
Gesture.Swipe.MinLength float 150 mm
Gesture.Swipe.MinVelocity float 1000 mm/s

The following example demonstrates how to set the swipe configuration parameters:

if(controller.config().setFloat("Gesture.Swipe.MinLength", 200.0f) &&
controller.config().setFloat("Gesture.Swipe.MinVelocity", 750f))
controller.config().save();

Constructor & Destructor Documentation

com.leapmotion.leap.SwipeGesture.SwipeGesture ( Gesture  rhs)

Constructs a SwipeGesture object from an instance of the Gesture class.

Parameters
rhsThe Gesture instance to specialize. This Gesture instance must be a SwipeGesture object.

Member Function Documentation

static Gesture.Type com.leapmotion.leap.SwipeGesture.classType ( )
static

The swipe gesture type.

Returns
Type The type value designating a swipe gesture.
Vector com.leapmotion.leap.SwipeGesture.direction ( )

The unit direction vector parallel to the swipe motion.

You can compare the components of the vector to classify the swipe as appropriate for your application. For example, if you are using swipes for two dimensional scrolling, you can compare the x and y values to determine if the swipe is primarily horizontal or vertical.

Returns
Vector The unit direction vector representing the swipe motion.
Pointable com.leapmotion.leap.SwipeGesture.pointable ( )

The finger performing the swipe gesture.

Returns
Pointable A Pointable object representing the swiping finger.
Vector com.leapmotion.leap.SwipeGesture.position ( )

The current position of the swipe.

Returns
Vector The current swipe position within the Leap Motion frame of reference, in mm.
float com.leapmotion.leap.SwipeGesture.speed ( )

The swipe speed in mm/second.

Returns
float The speed of the finger performing the swipe gesture in millimeters per second.
Vector com.leapmotion.leap.SwipeGesture.startPosition ( )

The position where the swipe began.

Returns
Vector The starting position within the Leap Motion frame of reference, in mm.