当前位置: 首页>>代码示例>>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;未经允许,请勿转载。