protected void handleActionUp(MotionEvent event) { this.actionUp(event); int state = this.getState(); if (state == WorldWind.POSSIBLE) { this.transitionToState(event, WorldWind.FAILED); } else if (state == WorldWind.BEGAN || state == WorldWind.CHANGED) { this.transitionToState(event, WorldWind.ENDED); } this.reset(); }
protected void handleActionCancel(MotionEvent event) { this.actionCancel(event); int state = this.getState(); if (state == WorldWind.POSSIBLE) { this.transitionToState(event, WorldWind.FAILED); } else if (state == WorldWind.BEGAN || state == WorldWind.CHANGED) { this.transitionToState(event, WorldWind.CANCELLED); } this.reset(); }
protected void handleActionPointerDown(MotionEvent event) { this.centroidChanged(event); this.actionDown(event); }
protected void handleActionPointerUp(MotionEvent event) { this.centroidChanged(event); this.actionUp(event); }
protected void handleActionMove(MotionEvent event) { this.eventCentroid(event, this.centroidArray); float dx = this.centroidArray[0] - this.startX + this.centroidShiftX; float dy = this.centroidArray[1] - this.startY + this.centroidShiftY; this.x = this.centroidArray[0]; this.y = this.centroidArray[1]; this.translationX = this.lowPassFilter(this.translationX, dx); this.translationY = this.lowPassFilter(this.translationY, dy); this.actionMove(event); }
protected void handleTilt(GestureRecognizer recognizer) { int state = recognizer.getState(); float dx = recognizer.getTranslationX(); float dy = recognizer.getTranslationY(); if (state == WorldWind.BEGAN) { this.gestureDidBegin(); this.lastRotation = 0; } else if (state == WorldWind.CHANGED) { // Apply the change in tilt to the navigator, relative to when the gesture began. double headingDegrees = 180 * dx / this.wwd.getWidth(); double tiltDegrees = -180 * dy / this.wwd.getHeight(); this.lookAt.heading = WWMath.normalizeAngle360(this.beginLookAt.heading + headingDegrees); this.lookAt.tilt = this.beginLookAt.tilt + tiltDegrees; this.applyLimits(this.lookAt); this.wwd.getNavigator().setAsLookAt(this.wwd.getGlobe(), this.lookAt); this.wwd.requestRedraw(); } else if (state == WorldWind.ENDED || state == WorldWind.CANCELLED) { this.gestureDidEnd(); } }
protected void handlePinch(GestureRecognizer recognizer) { int state = recognizer.getState(); float scale = ((PinchRecognizer) recognizer).getScale(); if (state == WorldWind.BEGAN) { this.gestureDidBegin(); } else if (state == WorldWind.CHANGED) { if (scale != 0) { // Apply the change in scale to the navigator, relative to when the gesture began. this.lookAt.range = this.beginLookAt.range / scale; this.applyLimits(this.lookAt); this.wwd.getNavigator().setAsLookAt(this.wwd.getGlobe(), this.lookAt); this.wwd.requestRedraw(); } } else if (state == WorldWind.ENDED || state == WorldWind.CANCELLED) { this.gestureDidEnd(); } }
protected void centroidChanged(MotionEvent event) { this.centroidShiftX += this.x; this.centroidShiftY += this.y; this.eventCentroid(event, this.centroidArray); this.x = this.centroidArray[0]; this.y = this.centroidArray[1]; this.centroidShiftX -= this.centroidArray[0]; this.centroidShiftY -= this.centroidArray[1]; }
public BasicWorldWindowController() { this.panRecognizer.addListener(this); this.pinchRecognizer.addListener(this); this.rotationRecognizer.addListener(this); this.tiltRecognizer.addListener(this); ((PanRecognizer) this.panRecognizer).setMaxNumberOfPointers(2); ((PanRecognizer) this.tiltRecognizer).setMinNumberOfPointers(3); // TODO support for two-finger tilt gestures }
protected void handleActionDown(MotionEvent event) { int index = event.getActionIndex(); this.x = event.getX(index); this.y = event.getY(index); this.startX = this.x; this.startY = this.y; this.translationX = 0; this.translationY = 0; this.centroidShiftX = 0; this.centroidShiftY = 0; this.actionDown(event); }
@Override protected void handleTilt(GestureRecognizer recognizer) { int state = recognizer.getState(); float dx = recognizer.getTranslationX(); float dy = recognizer.getTranslationY(); if (state == WorldWind.BEGAN) { this.gestureDidBegin(); this.lastRotation = 0; } else if (state == WorldWind.CHANGED) { // Apply the change in tilt to the navigator, relative to when the gesture began. double headingDegrees = 180 * dx / this.wwd.getWidth(); double tiltDegrees = -180 * dy / this.wwd.getHeight(); this.camera.heading = WWMath.normalizeAngle360(this.beginCamera.heading + headingDegrees); this.camera.tilt = this.beginCamera.tilt + tiltDegrees; this.applyLimits(camera); this.wwd.getNavigator().setAsCamera(this.wwd.getGlobe(), this.camera); this.wwd.requestRedraw(); } else if (state == WorldWind.ENDED || state == WorldWind.CANCELLED) { this.gestureDidEnd(); } }
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(); } }
@Override protected void handlePan(GestureRecognizer recognizer) { int state = recognizer.getState(); float dx = recognizer.getTranslationX(); float dy = recognizer.getTranslationY();
@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 handlePan(GestureRecognizer recognizer) { int state = recognizer.getState(); float dx = recognizer.getTranslationX(); float dy = recognizer.getTranslationY();
@Override protected void handlePinch(GestureRecognizer recognizer) { int state = recognizer.getState(); float scale = ((PinchRecognizer) recognizer).getScale(); if (state == WorldWind.BEGAN) { this.gestureDidBegin(); } else if (state == WorldWind.CHANGED) { if (scale != 0) { // Apply the change in scale to the navigator, relative to when the gesture began. scale = ((scale - 1) * 0.1f) + 1; // dampen the scale factor this.camera.altitude = this.camera.altitude * scale; this.applyLimits(this.camera); this.wwd.getNavigator().setAsCamera(this.wwd.getGlobe(), this.camera); this.wwd.requestRedraw(); } } else if (state == WorldWind.ENDED || state == WorldWind.CANCELLED) { this.gestureDidEnd(); } }