@Override public boolean onScale(ScaleGestureDetector detector) { float xScale = ((float) detector.getCurrentSpanX()) / detector.getPreviousSpanX(); yAmplifier *= (((float) detector.getCurrentSpanY()) / detector.getPreviousSpanY()); yAmplifier = Math.max(Math.min(yAmplifier, MAX_YAMP), MIN_YAMP); shownDataAmount /= xScale; shownDataAmount = Math.min(Math.max(1, (shownDataAmount)), MAXSAMPLEPACKETS); return true; }
@Override public boolean onScale(ScaleGestureDetector scaleGestureDetector) { float spanX = scaleGestureDetector.getCurrentSpanX() - scaleGestureDetector.getPreviousSpanX(); float spanY = scaleGestureDetector.getCurrentSpanY() - scaleGestureDetector.getPreviousSpanY(); LayoutParams lParams = (LayoutParams) getLayoutParams(); float newWidth = lParams.width + spanX; float newHeight = lParams.height + spanY; lParams.width = (int) newWidth; lParams.height = (int) newHeight; setLayoutParams(lParams); Log.i("spanX", spanX + ""); Log.i("spanY", spanY + ""); return true; }
//// TODO: 16/12/15 Still get better method to judge the rotate gesture private boolean judgeRotate(ScaleGestureDetector detector) { boolean res = false; double preDistX = detector.getPreviousSpanX(); double preDistY = detector.getPreviousSpanY(); double curDistX = detector.getCurrentSpanX(); double curDistY = detector.getCurrentSpanY(); double atanPre = Math.atan2(preDistY, preDistX); double atanCur = Math.atan2(curDistY, curDistX); rotate = atanCur - atanPre; if (Math.abs(rotate) > ROTATE_THRESHOLD) { res = true; gestureName = GESTURE_ROTATE; focus_x = detector.getFocusX(); focus_y = detector.getFocusY(); gestureLabel.setText( gestureName + "\n x:" + focus_x + " y:" + focus_y + "\ndeltaAngel:" + rotate); } return res; }