/** * Delegates events to the pick handler or the native WorldWind navigation handlers. */ @Override public boolean onTouchEvent(MotionEvent event) { boolean consumed = super.onTouchEvent(event); if (!consumed) { consumed = this.pickGestureDetector.onTouchEvent(event); } return consumed; }
@Override public void gestureStateChanged(MotionEvent event, GestureRecognizer recognizer) { if (recognizer == this.panRecognizer) { this.handlePan(recognizer); } else if (recognizer == this.pinchRecognizer) { this.handlePinch(recognizer); } else if (recognizer == this.rotationRecognizer) { this.handleRotate(recognizer); } else if (recognizer == this.tiltRecognizer) { this.handleTilt(recognizer); } }
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 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 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(); } }
this.gestureDidBegin(); this.lastX = 0; this.lastY = 0; this.wwd.requestRedraw(); } else if (state == WorldWind.ENDED || state == WorldWind.CANCELLED) { this.gestureDidEnd();
/** * Delegates events to the pick handler or the native WorldWind navigation handlers. */ @Override public boolean onTouchEvent(MotionEvent event) { // Allow pick listener to process the event first. boolean consumed = this.pickGestureDetector.onTouchEvent(event); // If event was not consumed by the pick operation, pass it on the globe navigation handlers if (!consumed) { // The super class performs the pan, tilt, rotate and zoom return super.onTouchEvent(event); } return consumed; }
/** * Delegates events to the pick handler or the native WorldWind navigation handlers. */ @Override public boolean onTouchEvent(MotionEvent event) { // Allow pick listener to process the event first. boolean consumed = this.pickGestureDetector.onTouchEvent(event); // If event was not consumed by the pick operation, pass it on the globe navigation handlers if (!consumed) { // The super class performs the pan, tilt, rotate and zoom return super.onTouchEvent(event); } return consumed; }
/** * Delegates events to the select/drag handlers or the native WorldWind navigation handlers. */ @Override public boolean onTouchEvent(MotionEvent event) { // Allow our select and drag handlers to process the event first. They'll set the state flags which will // either preempt or allow the event to be subsequently processed by the globe's navigation event handlers. boolean consumed = this.selectDragDetector.onTouchEvent(event); // Is a dragging operation started or in progress? Any ACTION_UP event cancels a drag operation. if (this.isDragging && event.getAction() == MotionEvent.ACTION_UP) { this.isDragging = false; this.isDraggingArmed = false; } // Preempt the globe's pan navigation recognizer if we're dragging super.panRecognizer.setEnabled(!isDragging); // Pass on the event on to the default globe navigation handlers if (!consumed) { consumed = super.onTouchEvent(event); } return consumed; }
/** * Delegates events to the select/drag handlers or the native World Wind navigation handlers. */ @Override public boolean onTouchEvent(MotionEvent event) { // Allow our select and drag handlers to process the event first. They'll set the state flags which will // either preempt or allow the event to be subsequently processed by the globe's navigation event handlers. boolean consumed = this.selectDragDetector.onTouchEvent(event); // Is a dragging operation started or in progress? Any ACTION_UP event cancels a drag operation. if (this.isDragging && event.getAction() == MotionEvent.ACTION_UP) { this.isDragging = false; this.isDraggingArmed = false; } // Preempt the globe's pan navigation recognizer if we're dragging super.panRecognizer.setEnabled(!isDragging); // Pass on the event on to the default globe navigation handlers if (!consumed) { consumed = super.onTouchEvent(event); } return consumed; }