本文整理汇总了Java中com.leapmotion.leap.CircleGesture类的典型用法代码示例。如果您正苦于以下问题:Java CircleGesture类的具体用法?Java CircleGesture怎么用?Java CircleGesture使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CircleGesture类属于com.leapmotion.leap包,在下文中一共展示了CircleGesture类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: circleGestureListener
import com.leapmotion.leap.CircleGesture; //导入依赖的package包/类
@Override
public void circleGestureListener(CircleGesture circle) {
if(mouseOn){
String clockwiseness;
if (circle.state() == Gesture.State.STATE_STOP && circle.radius() < 10){
if (circle.pointable().direction().angleTo(circle.normal()) <= Math.PI/4) {
// Clockwise if angle is less than 90 degrees
clockwiseness = "clockwise";
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
Debug.getInstance().mouse("raduis:" + circle.radius());
} else {
clockwiseness = "counterclockwise";
robot.mousePress(InputEvent.BUTTON3_MASK);
robot.mouseRelease(InputEvent.BUTTON3_MASK);
}
Debug.getInstance().mouse("end of swipe "+ clockwiseness);
}
}
}
示例2: circleGestureRecognized
import com.leapmotion.leap.CircleGesture; //导入依赖的package包/类
@Override
public void circleGestureRecognized(CircleGesture detectedGesture) {
if (detectedGesture.state() == Gesture.State.STATE_STOP) {
//This may have been already consumed, we are not sure.
if (!consumedCircleGestureBuffer.contains(detectedGesture.id()))
circleGestureBuffer.put(detectedGesture.id(), detectedGesture);
logger.debug("//////////////////////////////////////");
logger.debug("Gesture type: " + detectedGesture.type().toString());
logger.debug("ID: " + detectedGesture.id());
logger.debug("Radius: " + detectedGesture.radius());
logger.debug("Normal: " + detectedGesture.normal());
logger.debug("Clockwise: " + JitterSystem.isClockwise(detectedGesture));
logger.debug("Turns: " + detectedGesture.progress());
logger.debug("Center: " + detectedGesture.center());
logger.debug("Duration: " + detectedGesture.durationSeconds() + "s");
logger.debug("//////////////////////////////////////");
} else if (detectedGesture.state() == Gesture.State.STATE_START) {
circleGestureBuffer.put(detectedGesture.id(), detectedGesture);
} else if (detectedGesture.state() == Gesture.State.STATE_UPDATE) {
if (!consumedCircleGestureBuffer.contains(detectedGesture.id()))
circleGestureBuffer.put(detectedGesture.id(), detectedGesture);
}
}
示例3: nextCircleBatch
import com.leapmotion.leap.CircleGesture; //导入依赖的package包/类
/**
* Returns the next CircleGesture in buffer, if any.
* Note that consuming buffered gestures does not respect different ways to use the gesture.
* If it is returned for use just once it is considered spent and will not be returned again.
* @return a CircleGesture or null if none are available
*/
public Set<CircleGesture> nextCircleBatch() {
Set<CircleGesture> circleBatch = new HashSet<CircleGesture>();
for (CircleGesture circleGesture : circleGestureBuffer.values()) {
// Automatically add every circle to the return batch since we have no constraints to test here
circleBatch.add(circleGesture);
// Consume (if that's enabled)
consumeCircle(circleGesture);
// Remove stopped circles from the buffer as they won't be seen again.
removeStoppedCircles(circleGesture);
}
return circleBatch;
}
示例4: circleGesture
import com.leapmotion.leap.CircleGesture; //导入依赖的package包/类
private boolean circleGesture(CircleGesture circle) {
boolean clockwise; // Calculate clock direction using the angle between circle normal and pointable
// Clockwise if angle is less than 90 degrees
if (clockwise = (circle.pointable().direction().angleTo(circle.normal()) <= Math.PI / 4))
callObservers(Gestures.RIGHT_CIRCLE);
else
callObservers(Gestures.LEFT_CIRCLE);
System.out.println(LeapMotionListenerC.onCircle + " id: " + circle.id() + ", "
+ circle.state() + ", progress: " + circle.progress()
+ ", clockwise: " + clockwise);
return true;
}
示例5: consumeCircle
import com.leapmotion.leap.CircleGesture; //导入依赖的package包/类
private void consumeCircle(CircleGesture circleGesture) {
// If gestures of this type are considered consumed when returned for processing then flag & remove
if (consumptionEnabled) {
logger.debug("Consuming circle gesture with id: " + circleGesture.id());
consumedCircleGestureBuffer.add(circleGesture.id()); // Mark circle as consumed so it won't get re-added
circleGestureBuffer.remove(circleGesture.id()); // Remove it from the buffer so it won't be tested again
}
}
示例6: removeStoppedCircles
import com.leapmotion.leap.CircleGesture; //导入依赖的package包/类
private void removeStoppedCircles(CircleGesture circleGesture) {
if (circleGesture.state() == Gesture.State.STATE_STOP) {
circleGestureBuffer.remove(circleGesture.id());
if (consumptionEnabled) {
consumedCircleGestureBuffer.remove(circleGesture.id());
logger.debug("Just removed gesture with id " + circleGesture.id() + " from the 'consumed' list");
}
}
}
示例7: onFrame
import com.leapmotion.leap.CircleGesture; //导入依赖的package包/类
@Override
public void onFrame(Controller controller) {
Frame frame = controller.frame();
if (!frame.hands().isEmpty()) {
numHands.set(frame.hands().count());
Screen screen = controller.locatedScreens().get(0);
if (screen != null && screen.isValid()){
Hand hand;
if(numHands.get()>1){
hand=frame.hands().leftmost();
} else {
hand=frame.hands().get(0);
}
z1.set(hand.palmPosition().getZ());
pitchLeftAverage.add(new Double(hand.direction().pitch()));
rollLeftAverage.add(new Double(hand.palmNormal().roll()));
yawLeftAverage.add(new Double(hand.direction().yaw()));
pitchLeft.set(dAverage(pitchLeftAverage));
rollLeft.set(dAverage(rollLeftAverage));
yawLeft.set(dAverage(yawLeftAverage));
Vector intersect = screen.intersect(hand.palmPosition(),hand.direction(), true);
posLeftAverage.add(intersect);
Vector avIntersect=vAverage(posLeftAverage);
posHandLeft.setValue(new Point3D(screen.widthPixels()*Math.min(1d,Math.max(0d,avIntersect.getX())),
screen.heightPixels()*Math.min(1d,Math.max(0d,(1d-avIntersect.getY()))),
hand.palmPosition().getZ()));
}
}
GestureList gestures = frame.gestures();
for (int i = 0; i < gestures.count(); i++) {
Gesture gesture = gestures.get(i);
if(gesture.type()==Type.TYPE_CIRCLE){
CircleGesture cGesture = new CircleGesture(gesture);
if(numHands.get()>1){
for(Hand h:cGesture.hands()){
if(h.equals(frame.hands().rightmost())){
circle.set(cGesture);
break;
}
}
}
break;
}
}
}
示例8: printGestureDetails
import com.leapmotion.leap.CircleGesture; //导入依赖的package包/类
private void printGestureDetails(Gesture gesture, Controller controller) {
switch (gesture.type()) {
case TYPE_CIRCLE:
CircleGesture circle = new CircleGesture(gesture);
// Calculate clock direction using the angle between circle normal and pointable
String clockwise;
if (circle.pointable().direction().angleTo(circle.normal()) <= Math.PI / 4) {
// Clockwise if angle is less than 90 degrees
clockwise = "clockwise";
} else {
clockwise = "counterclockwise";
}
// Calculate angle swept since last frame
double sweptAngle = 0;
if (circle.state() != State.STATE_START) {
CircleGesture previousUpdate =
new CircleGesture(controller.frame(1).gesture(circle.id()));
sweptAngle = (circle.progress() - previousUpdate.progress()) * 2 * Math.PI;
}
logger.debug("Circle id: " + circle.id() + ", " + circle.state() + ", progress: "
+ circle.progress() + ", radius: " + circle.radius() + ", angle: "
+ Math.toDegrees(sweptAngle) + ", " + clockwise);
break;
case TYPE_SWIPE:
SwipeGesture swipe = new SwipeGesture(gesture);
logger.debug("Swipe id: " + swipe.id() + ", " + swipe.state() + ", position: "
+ swipe.position() + ", direction: " + swipe.direction() + ", speed: " + swipe.speed());
break;
case TYPE_SCREEN_TAP:
ScreenTapGesture screenTap = new ScreenTapGesture(gesture);
logger.debug("Screen Tap id: " + screenTap.id() + ", " + screenTap.state()
+ ", position: " + screenTap.position() + ", direction: " + screenTap.direction());
break;
case TYPE_KEY_TAP:
KeyTapGesture keyTap = new KeyTapGesture(gesture);
logger.debug("Key Tap id: " + keyTap.id() + ", " + keyTap.state() + ", position: "
+ keyTap.position() + ", direction: " + keyTap.direction());
break;
default:
logger.debug("Unknown gesture type.");
break;
}
}
示例9: circleGestureRecognized
import com.leapmotion.leap.CircleGesture; //导入依赖的package包/类
/**
* Called when the Leap Listener detects a circle gesture.
* @param gesture the CircleGesture detected
*/
void circleGestureRecognized(CircleGesture gesture);
示例10: circleProperty
import com.leapmotion.leap.CircleGesture; //导入依赖的package包/类
public ObservableValue<CircleGesture> circleProperty(){ return circle; }
示例11: circleGestureListener
import com.leapmotion.leap.CircleGesture; //导入依赖的package包/类
public void circleGestureListener(CircleGesture circle);