@Override protected void actionMove(MotionEvent event) { int state = this.getState(); if (state == WorldWind.POSSIBLE) { if (this.shouldInterpret(event)) { if (this.shouldRecognize(event)) { this.transitionToState(event, WorldWind.BEGAN); } else { this.transitionToState(event, WorldWind.FAILED); } } } else if (state == WorldWind.BEGAN || state == WorldWind.CHANGED) { this.transitionToState(event, WorldWind.CHANGED); } }
protected boolean shouldInterpret(MotionEvent event) { float dx = this.getTranslationX(); float dy = this.getTranslationY(); float distance = (float) Math.sqrt(dx * dx + dy * dy); return distance > this.interpretDistance; // interpret touches when the touch centroid moves far enough }
@Override protected void prepareToRecognize(MotionEvent event) { // set translation to zero when the pan begins this.setTranslationX(0); this.setTranslationY(0); }
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 }