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

The ScreenList class represents a list of Screen objects. More...

Inherits com.leapmotion.leap.Interface, and Iterable< Screen >.

Public Member Functions

Screen closestScreen (Vector position)
 Gets the Screen closest to the specified position.
 
Screen closestScreenHit (Pointable pointable)
 Gets the closest Screen intercepting a ray projecting from the specified Pointable object.
 
Screen closestScreenHit (Vector position, Vector direction)
 Gets the closest Screen intercepting a ray projecting from the specified position in the specified direction.
 
int count ()
 Returns the number of screens in this list.
 
boolean empty ()
 Deprecated.
 
Screen get (int index)
 Access a list member by its position in the list.
 
boolean isEmpty ()
 Reports whether the list is empty.
 
 ScreenList ()
 Constructs an empty list of screens.
 

Detailed Description

The ScreenList class represents a list of Screen objects.

The list always contains at least one entry representing the default screen. If the user has not registered the location of this default screen, then the coordinates, directions, and other values reported by the functions in its Screen object will not be accurate. Other monitor screens only appear in the list if their positions have been registered using the Leap Motion Screen Locator.

Get a ScreenList object by calling Controller::locatedScreens().

ScreenList screens = this.controller.locatedScreens();

Constructor & Destructor Documentation

com.leapmotion.leap.ScreenList.ScreenList ( )

Constructs an empty list of screens.

Member Function Documentation

Screen com.leapmotion.leap.ScreenList.closestScreen ( Vector  position)

Gets the Screen closest to the specified position.

The specified position is projected along each screen's normal vector onto the screen's plane. The screen whose projected point is closest to the specified position is returned. Call Screen::project(position) on the returned Screen object to find the projected point.

Frame frame = this.controller.frame();
if (frame.pointables().count() > 0) {
Pointable pointable = frame.pointables().get(0);
ScreenList screens = controller.locatedScreens();
Screen screen = screens.closestScreen(pointable.tipPosition());
}
Parameters
positionThe position from which to check for screen projection.
Returns
The closest Screen onto which the specified position is projected.
Screen com.leapmotion.leap.ScreenList.closestScreenHit ( Pointable  pointable)

Gets the closest Screen intercepting a ray projecting from the specified Pointable object.

The projected ray emanates from the Pointable tipPosition along the Pointable's direction vector. If the projected ray does not intersect any screen surface directly, then the Leap Motion software checks for intersection with the planes extending from the surfaces of the known screens and returns the Screen with the closest intersection.

Frame frame = this.controller.frame();
if (frame.pointables().count() > 0) {
Pointable pointable = frame.pointables().get(0);
ScreenList screens = controller.locatedScreens();
Screen screen = screens.closestScreenHit(pointable);
}

If no intersections are found (i.e. the ray is directed parallel to or away from all known screens), then an invalid Screen object is returned.

Note: Be sure to test whether the Screen object returned by this method is valid. Attempting to use an invalid Screen object will lead to incorrect results.

Parameters
pointableThe Pointable object to check for screen intersection.
Returns
The closest Screen toward which the specified Pointable object is pointing, or, if the pointable is not pointing in the direction of any known screen, an invalid Screen object.
Screen com.leapmotion.leap.ScreenList.closestScreenHit ( Vector  position,
Vector  direction 
)

Gets the closest Screen intercepting a ray projecting from the specified position in the specified direction.

The projected ray emanates from the position along the direction vector. If the projected ray does not intersect any screen surface directly, then the Leap Motion software checks for intersection with the planes extending from the surfaces of the known screens and returns the Screen with the closest intersection.

Frame frame = this.controller.frame();
if (frame.pointables().count() > 0) {
Pointable pointable = frame.pointables().get(0);
ScreenList screens = controller.locatedScreens();
Screen screen = screens.closestScreen(pointable.tipPosition());
}

If no intersections are found (i.e. the ray is directed parallel to or away from all known screens), then an invalid Screen object is returned.

Note: Be sure to test whether the Screen object returned by this method is valid. Attempting to use an invalid Screen object will lead to incorrect results.

Parameters
positionThe position from which to check for screen intersection.
directionThe direction in which to check for screen intersection.
Returns
The closest Screen toward which the specified ray is pointing, or, if the ray is not pointing in the direction of any known screen, an invalid Screen object.
int com.leapmotion.leap.ScreenList.count ( )

Returns the number of screens in this list.

Returns
The number of screens in this list.
boolean com.leapmotion.leap.ScreenList.empty ( )

Deprecated.

Use ScreenList::isEmpty() instead.

See Also
ScreenList::isEmpty()
Screen com.leapmotion.leap.ScreenList.get ( int  index)

Access a list member by its position in the list.

Parameters
indexThe zero-based list position index.
Returns
The Screen object at the specified index.
boolean com.leapmotion.leap.ScreenList.isEmpty ( )

Reports whether the list is empty.

Returns
True, if the list has no members.