本文整理汇总了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;
}
示例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);
}
}
示例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());
}
示例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());
}
示例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;
}
示例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);
}
}
示例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));
}
}
示例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());
}
示例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());
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
示例14: onScaleEnd
import android.view.ScaleGestureDetector; //导入依赖的package包/类
@Override
public void onScaleEnd(ScaleGestureDetector detector) {
if (!levelChanged) {
animateLevelTransition();
scaleFactor = getScaleFactor(target.getCurrentLevel().getSizePercent());
}
}
示例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);
}