android.view.ScaleGestureDetector Java Examples
The following examples show how to use
android.view.ScaleGestureDetector.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ZoomableScrollView.java From android-periodic-table with GNU General Public License v3.0 | 6 votes |
private void initZoomableScrollView(Context context) { setWillNotDraw(false); setHorizontalScrollBarEnabled(true); setVerticalScrollBarEnabled(true); setClickable(true); mOverScroller = new OverScroller(context); mZoomer = new Zoomer(context); mScaleDetector = new ScaleGestureDetector(context, this); mGestureDetector = new GestureDetector(context, this); mEdgeEffectTop = new EdgeEffectCompat(context); mEdgeEffectBottom = new EdgeEffectCompat(context); mEdgeEffectLeft = new EdgeEffectCompat(context); mEdgeEffectRight = new EdgeEffectCompat(context); }
Example #2
Source File: TouchImageView.java From ScaleLayout with Apache License 2.0 | 6 votes |
@Override public void onScaleEnd(ScaleGestureDetector detector) { super.onScaleEnd(detector); setState(State.NONE); boolean animateToZoomBoundary = false; float targetZoom = normalizedScale; if (normalizedScale > maxScale) { targetZoom = maxScale; animateToZoomBoundary = true; } else if (normalizedScale < minScale) { targetZoom = minScale; animateToZoomBoundary = true; } if (animateToZoomBoundary) { DoubleTapZoom doubleTap = new DoubleTapZoom(targetZoom, viewWidth / 2, viewHeight / 2, true); compatPostOnAnimation(doubleTap); } }
Example #3
Source File: BaseRateView.java From kAndroid with Apache License 2.0 | 6 votes |
private void initView() { setWillNotDraw(false); mPoints = new ArrayList<>(); mBackgroundColor = Color.parseColor("#2A2D4F"); mBackgroundPaint.setColor(mBackgroundColor); mGridPaint.setColor(Color.parseColor("#15FFFFFF")); //网格线颜色 mGridPaint.setStrokeWidth(dp2px(1)); mDetector = new GestureDetectorCompat(getContext(), this); mScaleDetector = new ScaleGestureDetector(getContext(), this); mAnimator = ValueAnimator.ofFloat(0f, 1f); mAnimator.setDuration(mAnimationDuration); mAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { invalidate(); } }); }
Example #4
Source File: TouchImageView.java From PhotoPicker with Apache License 2.0 | 6 votes |
private void sharedConstructing(Context context) { super.setClickable(true); this.context = context; mScaleDetector = new ScaleGestureDetector(context, new ScaleListener()); mGestureDetector = new GestureDetector(context, new GestureListener()); matrix = new Matrix(); prevMatrix = new Matrix(); m = new float[9]; normalizedScale = 1; if (mScaleType == null) { mScaleType = ScaleType.FIT_CENTER; } minScale = 1; maxScale = 3; superMinScale = SUPER_MIN_MULTIPLIER * minScale; superMaxScale = SUPER_MAX_MULTIPLIER * maxScale; setImageMatrix(matrix); setScaleType(ScaleType.MATRIX); setState(State.NONE); onDrawReady = false; super.setOnTouchListener(new PrivateOnTouchListener()); }
Example #5
Source File: TouchImageView.java From cordova-plugin-video-picture-preview-picker-V2 with MIT License | 6 votes |
private void sharedConstructing(Context context) { super.setClickable(true); this.context = context; mScaleDetector = new ScaleGestureDetector(context, new ScaleListener()); mGestureDetector = new GestureDetector(context, new GestureListener()); matrix = new Matrix(); prevMatrix = new Matrix(); m = new float[9]; normalizedScale = 1; if (mScaleType == null) { mScaleType = ScaleType.FIT_CENTER; } minScale = 1; maxScale = 3; superMinScale = SUPER_MIN_MULTIPLIER * minScale; superMaxScale = SUPER_MAX_MULTIPLIER * maxScale; setImageMatrix(matrix); setScaleType(ScaleType.MATRIX); setState(State.NONE); onDrawReady = false; super.setOnTouchListener(new PrivateOnTouchListener()); }
Example #6
Source File: TouchImageView.java From CodePolitan with Apache License 2.0 | 6 votes |
@Override public void onScaleEnd(ScaleGestureDetector detector) { super.onScaleEnd(detector); setState(State.NONE); boolean animateToZoomBoundary = false; float targetZoom = normalizedScale; if (normalizedScale > maxScale) { targetZoom = maxScale; animateToZoomBoundary = true; } else if (normalizedScale < minScale) { targetZoom = minScale; animateToZoomBoundary = true; } if (animateToZoomBoundary) { DoubleTapZoom doubleTap = new DoubleTapZoom(targetZoom, viewWidth / 2, viewHeight / 2, true); compatPostOnAnimation(doubleTap); } }
Example #7
Source File: TouchImageView.java From Document-Scanner with GNU General Public License v3.0 | 6 votes |
@Override public void onScaleEnd(ScaleGestureDetector detector) { super.onScaleEnd(detector); setState(State.NONE); boolean animateToZoomBoundary = false; float targetZoom = normalizedScale; if (normalizedScale > maxScale) { targetZoom = maxScale; animateToZoomBoundary = true; } else if (normalizedScale < minScale) { targetZoom = minScale; animateToZoomBoundary = true; } if (animateToZoomBoundary) { DoubleTapZoom doubleTap = new DoubleTapZoom(targetZoom, viewWidth / 2, viewHeight / 2, true); compatPostOnAnimation(doubleTap); } }
Example #8
Source File: ZoomImageView.java From PicturePicker with Apache License 2.0 | 6 votes |
private void sharedConstructing(Context context) { super.setClickable(true); this.context = context; mScaleDetector = new ScaleGestureDetector(context, new ScaleListener()); mGestureDetector = new GestureDetector(context, new GestureListener()); matrix = new Matrix(); prevMatrix = new Matrix(); m = new float[9]; normalizedScale = 1; if (mScaleType == null) { mScaleType = ScaleType.FIT_CENTER; } minScale = 1; maxScale = 3; superMinScale = SUPER_MIN_MULTIPLIER * minScale; superMaxScale = SUPER_MAX_MULTIPLIER * maxScale; setImageMatrix(matrix); setScaleType(ScaleType.MATRIX); setState(State.NONE); onDrawReady = false; super.setOnTouchListener(new PrivateOnTouchListener()); }
Example #9
Source File: TouchImageView.java From ImageGallery with Apache License 2.0 | 6 votes |
@Override public void onScaleEnd(ScaleGestureDetector detector) { super.onScaleEnd(detector); setState(State.NONE); boolean animateToZoomBoundary = false; float targetZoom = normalizedScale; if (normalizedScale > maxScale) { targetZoom = maxScale; animateToZoomBoundary = true; } else if (normalizedScale < minScale) { targetZoom = minScale; animateToZoomBoundary = true; } if (animateToZoomBoundary) { DoubleTapZoom doubleTap = new DoubleTapZoom(targetZoom, viewWidth / 2, viewHeight / 2, true); compatPostOnAnimation(doubleTap); } }
Example #10
Source File: TouchImageView.java From chat21-android-sdk with GNU Affero General Public License v3.0 | 6 votes |
@Override public void onScaleEnd(ScaleGestureDetector detector) { super.onScaleEnd(detector); setState(State.NONE); boolean animateToZoomBoundary = false; float targetZoom = normalizedScale; if (normalizedScale > maxScale) { targetZoom = maxScale; animateToZoomBoundary = true; } else if (normalizedScale < minScale) { targetZoom = minScale; animateToZoomBoundary = true; } if (animateToZoomBoundary) { DoubleTapZoom doubleTap = new DoubleTapZoom(targetZoom, viewWidth / 2, viewHeight / 2, true); compatPostOnAnimation(doubleTap); } }
Example #11
Source File: TouchImageView.java From MultiView with Apache License 2.0 | 6 votes |
@Override public void onScaleEnd(ScaleGestureDetector detector) { super.onScaleEnd(detector); setState(State.NONE); boolean animateToZoomBoundary = false; float targetZoom = normalizedScale; if (normalizedScale > maxScale) { targetZoom = maxScale; animateToZoomBoundary = true; } else if (normalizedScale < minScale) { targetZoom = minScale; animateToZoomBoundary = true; } if (animateToZoomBoundary) { DoubleTapZoom doubleTap = new DoubleTapZoom(targetZoom, viewWidth / 2, viewHeight / 2, true); compatPostOnAnimation(doubleTap); } }
Example #12
Source File: PinchZoomVideoView.java From Slide with GNU General Public License v3.0 | 5 votes |
public PinchZoomVideoView(Context context) { super(context); mScaleGestureDetector = new ScaleGestureDetector(getContext(), new MyScaleGestureListener()); setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { mGestureDetector.onTouchEvent(event); mScaleGestureDetector.onTouchEvent(event); return true; } }); }
Example #13
Source File: CompatibilityScaleGestureDetector.java From Linphone4Android with GNU General Public License v3.0 | 5 votes |
@Override public boolean onScale(ScaleGestureDetector detector) { if (listener == null) { return false; } return listener.onScale(this); }
Example #14
Source File: DrawingView.java From kolabnotes-android with GNU Lesser General Public License v3.0 | 5 votes |
public DrawingView(Context context, AttributeSet attrs) { super(context, attrs); mBrushColor = DEFAULT_BRUSH_COLOR; mBrushSize = DEFAULT_BRUSH_SIZE; mBrushAlpha = DEFAULT_BRUSH_ALPHA; mCanvasColor = DEFAULT_CANVAS_COLOR; mBitmapPaint = new Paint(Paint.DITHER_FLAG); mMultiPointersManager = new MultiPointersManager(MAX_POINTERS); mScaleDetector = new ScaleGestureDetector(context, new ScaleListener()); mScaleMode = false; }
Example #15
Source File: FloatingWindow.java From UCDLive_Android with MIT License | 5 votes |
@Override public boolean onScale(ScaleGestureDetector detector) { scaleFactor *= detector.getScaleFactor(); scaleFactor = Math.max(MIN_SCALE_FACTOR, Math.min(scaleFactor, MAX_SCALE_FACTOR)); int newWidth = (int) (origWidth * scaleFactor); int newHeight = (int) (origHeight * scaleFactor); updateWindowSize(newWidth, newHeight); return true; }
Example #16
Source File: TouchImageView.java From PhotoPicker with Apache License 2.0 | 5 votes |
@Override public boolean onScale(ScaleGestureDetector detector) { scaleImage(detector.getScaleFactor(), detector.getFocusX(), detector.getFocusY(), true); // // OnTouchImageViewListener is set: TouchImageView pinch zoomed by user. // if (touchImageViewListener != null) { touchImageViewListener.onMove(); } return true; }
Example #17
Source File: GestureTouchActivity.java From UltimateAndroid with Apache License 2.0 | 5 votes |
@SuppressWarnings("deprecation") @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.gesture_activity); // Determine the center of the screen to center 'gesture_earth' Display display = getWindowManager().getDefaultDisplay(); mFocusX = display.getWidth()/2f; mFocusY = display.getHeight()/2f; // Set this class as touchListener to the ImageView ImageView view = (ImageView) findViewById(R.id.imageView); view.setOnTouchListener(this); // Determine dimensions of 'gesture_earth' image Drawable d = this.getResources().getDrawable(R.drawable.gesture_earth); mImageHeight = d.getIntrinsicHeight(); mImageWidth = d.getIntrinsicWidth(); // View is scaled and translated by matrix, so scale and translate initially float scaledImageCenterX = (mImageWidth*mScaleFactor)/2; float scaledImageCenterY = (mImageHeight*mScaleFactor)/2; mMatrix.postScale(mScaleFactor, mScaleFactor); mMatrix.postTranslate(mFocusX - scaledImageCenterX, mFocusY - scaledImageCenterY); view.setImageMatrix(mMatrix); // Setup Gesture Detectors mScaleDetector = new ScaleGestureDetector(getApplicationContext(), new ScaleListener()); mRotateDetector = new RotateGestureDetector(getApplicationContext(), new RotateListener()); mMoveDetector = new MoveGestureDetector(getApplicationContext(), new MoveListener()); mShoveDetector = new ShoveGestureDetector(getApplicationContext(), new ShoveListener()); }
Example #18
Source File: ImageSurfaceView.java From WorldmapLibrary with MIT License | 5 votes |
@Override public boolean onScale(ScaleGestureDetector detector) { float scaleFactor = detector.getScaleFactor(); if (scaleFactor!=0f && scaleFactor!=1.0f){ scaleFactor = 1/scaleFactor; screenFocus.set(detector.getFocusX(),detector.getFocusY()); scene.getViewport().zoom( scaleFactor, screenFocus); invalidate(); } lastScaleTime = System.currentTimeMillis(); return true; }
Example #19
Source File: MapViewScaleGestureDetectorListener.java From OpenMapKitAndroid with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public boolean onScaleBegin(ScaleGestureDetector detector) { lastFocusX = detector.getFocusX(); lastFocusY = detector.getFocusY(); firstSpan = detector.getCurrentSpan(); currentScale = 1.0f; if (!this.mapView.isAnimating()) { this.mapView.setIsAnimating(true); this.mapView.getController().aboutToStartAnimation(lastFocusX, lastFocusY); scaling = true; } return true; }
Example #20
Source File: ZoomImageView.java From ZoomImageView with Apache License 2.0 | 5 votes |
public MultiGestureDetector(Context context) { scaleGestureDetector = new ScaleGestureDetector(context, this); gestureDetector = new GestureDetector(context, this); gestureDetector.setOnDoubleTapListener(this); final ViewConfiguration configuration = ViewConfiguration.get(context); scaledMinimumFlingVelocity = configuration.getScaledMinimumFlingVelocity(); scaledTouchSlop = configuration.getScaledTouchSlop(); }
Example #21
Source File: ClipZoomImageView.java From umeng_community_android with MIT License | 5 votes |
@Override public boolean onScale(ScaleGestureDetector detector) { float scale = getScale(); float scaleFactor = detector.getScaleFactor(); if (getDrawable() == null) return true; /** * 缩放的范围控制 */ if ((scale < SCALE_MAX && scaleFactor > 1.0f) || (scale > initScale && scaleFactor < 1.0f)) { /** * 最大值最小值判断 */ if (scaleFactor * scale < initScale) { scaleFactor = initScale / scale; } if (scaleFactor * scale > SCALE_MAX) { scaleFactor = SCALE_MAX / scale; } /** * 设置缩放比例 */ mScaleMatrix.postScale(scaleFactor, scaleFactor, detector.getFocusX(), detector.getFocusY()); checkBorder(); setImageMatrix(mScaleMatrix); } return true; }
Example #22
Source File: DragPinchManager.java From AndroidPdfViewerV1 with Apache License 2.0 | 5 votes |
public DragPinchManager(PDFView pdfView, AnimationManager animationManager) { this.pdfView = pdfView; this.animationManager = animationManager; this.isSwipeEnabled = false; this.swipeVertical = pdfView.isSwipeVertical(); gestureDetector = new GestureDetector(pdfView.getContext(), this); scaleGestureDetector = new ScaleGestureDetector(pdfView.getContext(), this); maxFlingVelocity = ViewConfiguration.get(pdfView.getContext()).getScaledMaximumFlingVelocity(); pdfView.setOnTouchListener(this); }
Example #23
Source File: PinchZoomVideoView.java From Slide with GNU General Public License v3.0 | 5 votes |
@Override public boolean onScaleBegin(ScaleGestureDetector detector) { mW = getWidth(); mH = getHeight(); Log.d("onScaleBegin", "scale=" + detector.getScaleFactor() + ", w=" + mW + ", h=" + mH); return true; }
Example #24
Source File: TouchImageView.java From YiBo with Apache License 2.0 | 5 votes |
@Override public boolean onScale(ScaleGestureDetector detector) { mScaleFactor *= detector.getScaleFactor(); // Don't let the object get too small or too large. mScaleFactor = Math.max(1.0F, Math.min(mScaleFactor, maxZoom())); if (Logger.isDebug()) { Log.d(TAG, "Zoom To : " + mScaleFactor); } zoomTo(mScaleFactor); return true; }
Example #25
Source File: MainActivity.java From Chimee with MIT License | 5 votes |
@Override public boolean onScale(ScaleGestureDetector detector) { mScaleFactor *= detector.getScaleFactor(); mScaleFactor = Math.max(0.1f, Math.min(mScaleFactor, 5.0f)); if (isVerticalScaling(detector)) { resizeInputWindow(initialHeight); } else { resizeText(initialTextSize); } return true; }
Example #26
Source File: PhotoView.java From Dashchan with Apache License 2.0 | 5 votes |
@Override public boolean onScale(ScaleGestureDetector detector) { float factor = detector.getScaleFactor(); // If factor <= 0, the image will be rotated, so let's apply only positive values if (factor > 0f) { onScale(factor, detector.getFocusX(), detector.getFocusY()); } return true; }
Example #27
Source File: ClipImageView.java From RelaxFinger with GNU General Public License v2.0 | 5 votes |
public MultiGestureDetector(Context context) { scaleGestureDetector = new ScaleGestureDetector(context, this); gestureDetector = new GestureDetector(context, this); gestureDetector.setOnDoubleTapListener(this); final ViewConfiguration configuration = ViewConfiguration .get(context); scaledTouchSlop = configuration.getScaledTouchSlop(); }
Example #28
Source File: DragPinchManager.java From AndroidPdfViewerV1 with Apache License 2.0 | 5 votes |
@Override public boolean onScale(ScaleGestureDetector detector) { scaling = true; float dr = detector.getScaleFactor(); float wantedZoom = pdfView.getZoom() * dr; if (wantedZoom < MINIMUM_ZOOM) { dr = MINIMUM_ZOOM / pdfView.getZoom(); } else if (wantedZoom > MAXIMUM_ZOOM) { dr = MAXIMUM_ZOOM / pdfView.getZoom(); } pdfView.zoomCenteredRelativeTo(dr, new PointF(detector.getFocusX(), detector.getFocusY())); return true; }
Example #29
Source File: PhotoImageView.java From MoeQuest with Apache License 2.0 | 5 votes |
@Override public boolean onScale(ScaleGestureDetector detector) { scaleImage(detector.getScaleFactor(), detector.getFocusX(), detector.getFocusY(), true); // // OnTouchImageViewListener is set: TouchImageView pinch zoomed by user. // if (touchImageViewListener != null) { touchImageViewListener.onMove(); } return true; }
Example #30
Source File: GestureController.java From GestureViews with Apache License 2.0 | 5 votes |
protected boolean onScaleBegin(ScaleGestureDetector detector) { isScaleDetected = settings.isZoomEnabled(); if (isScaleDetected) { exitController.onScaleBegin(); } return isScaleDetected; }