當前位置: 首頁>>代碼示例>>Java>>正文


Java ScaleGestureDetector類代碼示例

本文整理匯總了Java中android.view.ScaleGestureDetector的典型用法代碼示例。如果您正苦於以下問題:Java ScaleGestureDetector類的具體用法?Java ScaleGestureDetector怎麽用?Java ScaleGestureDetector使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ScaleGestureDetector類屬於android.view包,在下文中一共展示了ScaleGestureDetector類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onScale

import android.view.ScaleGestureDetector; //導入依賴的package包/類
@Override
public boolean onScale( ScaleGestureDetector detector )
{	
	// Check if the detector is in progress in order to proceed
	if(detector!=null && detector.isInProgress() ){
		try{
			// Grab the scale
			float targetScale = getScale() * detector.getScaleFactor();
			// Correct for the min scale
			targetScale = Math.min( maxZoom(), Math.max( targetScale, 1.0f) );

			// Zoom and invalidate the view
			zoomTo( targetScale, detector.getFocusX(), detector.getFocusY() );
			invalidate();

			return true;
		}catch(IllegalArgumentException e){
			e.printStackTrace();
		}
	}
	return false;
}
 
開發者ID:lpy19930103,項目名稱:MinimalismJotter,代碼行數:23,代碼來源:ZoomableImageView.java

示例2: onScaleEnd

import android.view.ScaleGestureDetector; //導入依賴的package包/類
@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);
    }
}
 
開發者ID:rozdoum,項目名稱:social-app-android,代碼行數:21,代碼來源:TouchImageView.java

示例3: sharedConstructing

import android.view.ScaleGestureDetector; //導入依賴的package包/類
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());
}
 
開發者ID:prshntpnwr,項目名稱:Monolith,代碼行數:23,代碼來源:TouchImageView.java

示例4: sharedConstructing

import android.view.ScaleGestureDetector; //導入依賴的package包/類
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 = 6;
    superMinScale = SUPER_MIN_MULTIPLIER * minScale;
    superMaxScale = SUPER_MAX_MULTIPLIER * maxScale;
    setImageMatrix(matrix);
    setScaleType(ScaleType.MATRIX);
    setState(State.NONE);
    onDrawReady = false;
    super.setOnTouchListener(new PrivateOnTouchListener());
}
 
開發者ID:wajahatkarim3,項目名稱:LongImageCamera,代碼行數:23,代碼來源:TouchImageView.java

示例5: onScale

import android.view.ScaleGestureDetector; //導入依賴的package包/類
@Override
public boolean onScale(ScaleGestureDetector detector) {
    float mScaleFactor = detector.getScaleFactor();
    float origScale = saveScale;
    saveScale *= mScaleFactor;
    if (saveScale > maxScale) {
        saveScale = maxScale;
        mScaleFactor = maxScale / origScale;
    } else if (saveScale < minScale) {
        saveScale = minScale;
        mScaleFactor = minScale / origScale;
    }

    if (origWidth * saveScale <= viewWidth
            || origHeight * saveScale <= viewHeight)
        matrix.postScale(mScaleFactor, mScaleFactor, viewWidth / 2,
                viewHeight / 2);
    else
        matrix.postScale(mScaleFactor, mScaleFactor,
                detector.getFocusX(), detector.getFocusY());

    fixTrans();
    return true;
}
 
開發者ID:gsantner,項目名稱:memetastic,代碼行數:25,代碼來源:TouchImageView.java

示例6: onScaleEnd

import android.view.ScaleGestureDetector; //導入依賴的package包/類
@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);
	}
}
 
開發者ID:MobileDev418,項目名稱:chat-sdk-android-push-firebase,代碼行數:21,代碼來源:TouchImageView.java

示例7: onScaleEnd

import android.view.ScaleGestureDetector; //導入依賴的package包/類
public void onScaleEnd(ScaleGestureDetector detector) {
    super.onScaleEnd(detector);
    TouchImageView.this.setState(State.NONE);
    boolean animateToZoomBoundary = false;
    float targetZoom = TouchImageView.this.normalizedScale;
    if (TouchImageView.this.normalizedScale > TouchImageView.this.maxScale) {
        targetZoom = TouchImageView.this.maxScale;
        animateToZoomBoundary = true;
    } else if (TouchImageView.this.normalizedScale < TouchImageView.this.minScale) {
        targetZoom = TouchImageView.this.minScale;
        animateToZoomBoundary = true;
    }
    if (animateToZoomBoundary) {
        TouchImageView.this.compatPostOnAnimation(new DoubleTapZoom(targetZoom, (float)
                (TouchImageView.this.viewWidth / 2), (float) (TouchImageView.this
                .viewHeight / 2), true));
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:19,代碼來源:TouchImageView.java

示例8: sharedConstructing

import android.view.ScaleGestureDetector; //導入依賴的package包/類
private void sharedConstructing(Context context) {
    super.setClickable(true);
    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());
}
 
開發者ID:sinhaDroid,項目名稱:BlogBookApp,代碼行數:22,代碼來源:ZoomImageView.java

示例9: sharedConstructing

import android.view.ScaleGestureDetector; //導入依賴的package包/類
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());
}
 
開發者ID:MobileDev418,項目名稱:AndroidBackendlessChat,代碼行數:23,代碼來源:TouchImageView.java

示例10: ZoomImageView

import android.view.ScaleGestureDetector; //導入依賴的package包/類
public ZoomImageView(Context context, AttributeSet attrs) {
    super(context, attrs);
    setScaleType(ScaleType.MATRIX);
    mGestureDetector = new GestureDetector(context,
            new SimpleOnGestureListener() {
                @Override
                public boolean onDoubleTap(MotionEvent e) {
                    if (isAutoScale)
                        return true;
                    float x = e.getX();
                    float y = e.getY();
                    if (getScale() < SCALE_MID) {
                        postDelayed(new ScaleRunnable(SCALE_MID, x, y), 16);
                        isAutoScale = true;
                    } else {
                        postDelayed(new ScaleRunnable(mScale, x, y), 16);
                        isAutoScale = true;
                    }
                    return true;
                }
            });
    mScaleGestureDetector = new ScaleGestureDetector(context, this);
    this.setOnTouchListener(this);
}
 
開發者ID:hsj-xiaokang,項目名稱:OSchina_resources_android,代碼行數:25,代碼來源:ZoomImageView.java

示例11: onScale

import android.view.ScaleGestureDetector; //導入依賴的package包/類
@Override
public boolean onScale(ScaleGestureDetector detector) {
    if (!mSupportsZoom) return true;
    //store old sclale factor

    float oldScaleFator = mScaleFactor;
    mScaleFactor *= (detector.getScaleFactor()*detector.getScaleFactor());

    // Don't let the object get too small or too large.
    mScaleFactor = Math.max(0.1f, Math.min(mScaleFactor, 10.0f));

    mFocusX = detector.getFocusX ();
    mFocusY = detector.getFocusY ();

    //distance between focus and old origin
    float dx = mFocusX-mPosX;
    float dy = mFocusY-mPosY;
    //distance between focus and new origin after rescale
    float dxSc = dx * mScaleFactor / oldScaleFator;
    float dySc = dy * mScaleFactor / oldScaleFator;

    // calcul of the new origin
    mPosX = mFocusX - dxSc;
    mPosY = mFocusY - dySc;

    invalidate();
    return true;
}
 
開發者ID:jkobject,項目名稱:PiPle,代碼行數:29,代碼來源:PanZoomView.java

示例12: onScale

import android.view.ScaleGestureDetector; //導入依賴的package包/類
@Override
public boolean onScale(ScaleGestureDetector detector) {
    if (!isEnabled()) {
        return false;
    }
    if (!hasLoad()) {
        return false;
    }
    float newScale;
    newScale = mScale * detector.getScaleFactor();
    if (newScale > maxScale) {
        newScale = maxScale;
    } else if (newScale < minScale) {
        newScale = minScale;
    }
    setScale(newScale, (int) detector.getFocusX(), (int) detector.getFocusY());
    return true;
}
 
開發者ID:jeasinlee,項目名稱:AndroidBasicLibs,代碼行數:19,代碼來源:LargeImageView.java

示例13: onFinishInflate

import android.view.ScaleGestureDetector; //導入依賴的package包/類
@Override
public void onFinishInflate() {
    super.onFinishInflate();

    mWorkspaceView = (WorkspaceView) findViewById(R.id.workspace);
    // Setting the child view's pivot point to (0,0) means scaling leaves top-left corner in
    // place means there is no need to adjust view translation.
    mWorkspaceView.setPivotX(0);
    mWorkspaceView.setPivotY(0);

    setWillNotDraw(false);
    setHorizontalScrollBarEnabled(mScrollable);
    setVerticalScrollBarEnabled(mScrollable);

    mScaleGestureDetector = new ScaleGestureDetector(getContext(), new ScaleGestureListener());
    mTapGestureDetector = new GestureDetector(getContext(), new TapGestureListener());
    mGridRenderer.updateGridBitmap(mViewScale);
    mImeManager = (InputMethodManager) getContext()
            .getSystemService(Context.INPUT_METHOD_SERVICE);
}
 
開發者ID:Axe-Ishmael,項目名稱:Blockly,代碼行數:21,代碼來源:VirtualWorkspaceView.java

示例14: onScaleEnd

import android.view.ScaleGestureDetector; //導入依賴的package包/類
@Override
public void onScaleEnd(ScaleGestureDetector detector) {
    if (!levelChanged) {
        animateLevelTransition();
        scaleFactor = getScaleFactor(target.getCurrentLevel().getSizePercent());
    }
}
 
開發者ID:tsalik,項目名稱:target-layout,代碼行數:8,代碼來源:TargetLayout.java

示例15: ZoomEngine

import android.view.ScaleGestureDetector; //導入依賴的package包/類
/**
 * Constructs an helper instance.
 *
 * @param context a valid context
 * @param container the view hosting the zoomable content
 * @param listener a listener for events
 */
public ZoomEngine(Context context, View container, Listener listener) {
    mView = container;
    mListener = listener;

    mFlingScroller = new OverScroller(context);
    mScaleDetector = new ScaleGestureDetector(context, new PinchListener());
    if (Build.VERSION.SDK_INT >= 19) mScaleDetector.setQuickScaleEnabled(false);
    mFlingDragDetector = new GestureDetector(context, new FlingScrollListener());
    container.getViewTreeObserver().addOnGlobalLayoutListener(this);
}
 
開發者ID:natario1,項目名稱:ZoomLayout,代碼行數:18,代碼來源:ZoomEngine.java


注:本文中的android.view.ScaleGestureDetector類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。