protected void actionMove(MotionEvent event) { if (this.pointerIdCount == 2) { int state = this.getState(); if (state == WorldWind.POSSIBLE) { if (this.shouldRecognize(event)) { this.transitionToState(event, WorldWind.BEGAN); } } else if (state == WorldWind.BEGAN || state == WorldWind.CHANGED) { float angle = this.currentTouchAngle(event); float newRotation = (float) WWMath.normalizeAngle180(angle - this.referenceAngle); this.rotation = this.lowPassFilter(this.rotation, newRotation); this.transitionToState(event, WorldWind.CHANGED); } } }
protected void handleRotate(GestureRecognizer recognizer) { int state = recognizer.getState(); float rotation = ((RotationRecognizer) recognizer).getRotation(); if (state == WorldWind.BEGAN) { this.gestureDidBegin(); this.lastRotation = 0; } else if (state == WorldWind.CHANGED) { // Apply the change in rotation to the navigator, relative to the navigator's current values. double headingDegrees = this.lastRotation - rotation; this.lookAt.heading = WWMath.normalizeAngle360(this.lookAt.heading + headingDegrees); this.lastRotation = rotation; this.wwd.getNavigator().setAsLookAt(this.wwd.getGlobe(), this.lookAt); this.wwd.requestRedraw(); } else if (state == WorldWind.ENDED || state == WorldWind.CANCELLED) { this.gestureDidEnd(); } }
protected void prepareToRecognize(MotionEvent event) { this.referenceAngle = this.currentTouchAngle(event); this.rotation = 0; }
@Override protected void handleRotate(GestureRecognizer recognizer) { int state = recognizer.getState(); float rotation = ((RotationRecognizer) recognizer).getRotation(); if (state == WorldWind.BEGAN) { this.gestureDidBegin(); this.lastRotation = 0; } else if (state == WorldWind.CHANGED) { // Apply the change in rotation to the navigator, relative to the navigator's current values. double headingDegrees = this.lastRotation - rotation; this.camera.heading = WWMath.normalizeAngle360(this.camera.heading + headingDegrees); this.lastRotation = rotation; this.wwd.getNavigator().setAsCamera(this.wwd.getGlobe(), this.camera); this.wwd.requestRedraw(); } else if (state == WorldWind.ENDED || state == WorldWind.CANCELLED) { this.gestureDidEnd(); } }
protected void actionDown(MotionEvent event) { int pointerIndex = event.getActionIndex(); int pointerId = event.getPointerId(pointerIndex); if (this.pointerIdCount < 2) { this.pointerIds[this.pointerIdCount++] = pointerId; // add it to the pointer ID array if (this.pointerIdCount == 2) { this.referenceAngle = this.currentTouchAngle(event); this.rotationOffset += this.rotation; this.rotation = 0; } } }
protected boolean shouldRecognize(MotionEvent event) { if (event.getPointerCount() != 2) { return false; // require exactly two pointers to recognize the gesture } float angle = this.currentTouchAngle(event); float rotation = (float) WWMath.normalizeAngle180(angle - this.referenceAngle); return Math.abs(rotation) > this.interpretAngle; }