本文整理汇总了Java中android.view.ScaleGestureDetector.getScaleFactor方法的典型用法代码示例。如果您正苦于以下问题:Java ScaleGestureDetector.getScaleFactor方法的具体用法?Java ScaleGestureDetector.getScaleFactor怎么用?Java ScaleGestureDetector.getScaleFactor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.view.ScaleGestureDetector
的用法示例。
在下文中一共展示了ScaleGestureDetector.getScaleFactor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onScale
import android.view.ScaleGestureDetector; //导入方法依赖的package包/类
public boolean onScale(ScaleGestureDetector det) {
if (bitmap != null) {
float focusX = det.getFocusX();
float focusY = det.getFocusY();
float scaleFactor = det.getScaleFactor();
float pageFocusX = (focusX + scrollX) / viewScale;
float pageFocusY = (focusY + scrollY) / viewScale;
viewScale *= scaleFactor;
if (viewScale < minScale) viewScale = minScale;
if (viewScale > maxScale) viewScale = maxScale;
bitmapW = (int)(bitmap.getWidth() * viewScale);
bitmapH = (int)(bitmap.getHeight() * viewScale);
scrollX = (int)(pageFocusX * viewScale - focusX);
scrollY = (int)(pageFocusY * viewScale - focusY);
scroller.forceFinished(true);
invalidate();
}
return true;
}
示例2: 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;
}
示例3: zoom
import android.view.ScaleGestureDetector; //导入方法依赖的package包/类
public void zoom(ScaleGestureDetector scaleGestureDetector)
{
if (mDrawingState != DRAW_STATE_zooming) {
zoomStart(scaleGestureDetector);
}
if (mDrawingState == DRAW_STATE_zooming) {
// mScaleFactor =
// scaleGestureDetector.getScaleFactor() * scaleGestureDetector.getCurrentSpan()
// / mCurrentSpan;
mScaleFactor = scaleGestureDetector.getScaleFactor();
// double invertScale = 1 / mScaleFactor;
// double offX = (1 - invertScale) * (mCurrentFocusLocation.x);
// double offY = (1 - invertScale) * (mCurrentFocusLocation.y);
// mCurrentFocusOffset.set((float) offX, (float) offY);
mMapDrawing.scale(mScaleFactor, mCurrentFocusLocation.x, mCurrentFocusLocation.y);
requestRender(DrawState.DS_PRESERVED);
}
}
示例4: 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();
scaleRecognized = true;
return true;
}catch(IllegalArgumentException e){
e.printStackTrace();
}
}
return false;
}
示例5: onScale
import android.view.ScaleGestureDetector; //导入方法依赖的package包/类
@Override
public boolean onScale(ScaleGestureDetector detector) {
if (mZoomEnabled) {
mFromZoomRegion = false;
mZoomFactor *= detector.getScaleFactor();
mZoomFactor = Math.max(1f, Math.min(mZoomFactor, mMaxZoomFactor));
mZoomFactor = mZoomFactor > mMaxZoomFactor ? mMaxZoomFactor : mZoomFactor < 1f ? 1f : mZoomFactor;
mZoomCenterX = detector.getFocusX() / mZoomFactor + mCanvasClipBounds.left;
mZoomCenterY = detector.getFocusY() / mZoomFactor + mCanvasClipBounds.top;
if (mZoomFactor > 1f)
showHideZoomRegionView(VISIBLE);
else
showHideZoomRegionView(INVISIBLE);
invalidate();
}
return false;
}
示例6: 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;
}
示例7: onScale
import android.view.ScaleGestureDetector; //导入方法依赖的package包/类
@Override
public boolean onScale(ScaleGestureDetector detector) {
float span = detector.getCurrentSpan() - detector.getPreviousSpan();
float targetScale = getScale() * detector.getScaleFactor();
if (mScaleEnabled) {
if (mScaled && span != 0) {
mUserScaled = true;
targetScale = Math.min(getMaxScale(), Math.max(targetScale, getMinScale() - MIN_SCALE_DIFF));
zoomTo(targetScale, detector.getFocusX(), detector.getFocusY());
mDoubleTapDirection = 1;
invalidate();
return true;
}
// This is to prevent a glitch the first time
// image is scaled.
if (!mScaled) {
mScaled = true;
}
}
return true;
}
示例8: onScale
import android.view.ScaleGestureDetector; //导入方法依赖的package包/类
@Override
public boolean onScale(ScaleGestureDetector detector) {
float scale = getScale();
float scaleFactor = detector.getScaleFactor();
if (getDrawable() == null)
return true;
if ((scale < SCALE_MAX && scaleFactor > SCALE_MIN)
|| (scale > mScale && scaleFactor < SCALE_MIN)) {
if (scaleFactor * scale < SCALE_MIN) {
scaleFactor = SCALE_MIN / scale;
}
if (scaleFactor * scale > SCALE_MAX) {
scaleFactor = SCALE_MAX / scale;
}
mScaleMatrix.postScale(scaleFactor, scaleFactor,
detector.getFocusX(), detector.getFocusY());
checkBorder();
setImageMatrix(mScaleMatrix);
}
return true;
}
示例9: onScale
import android.view.ScaleGestureDetector; //导入方法依赖的package包/类
@Override
public boolean onScale(ScaleGestureDetector detector) {
if (isZoomEnabled) {
float scale = 2.0f - detector.getScaleFactor();
if (Float.isInfinite(scale)) {
scale = 1;
}
return chartZoomer.scale(computator, detector.getFocusX(), detector.getFocusY(), scale);
}
return false;
}
示例10: onScale
import android.view.ScaleGestureDetector; //导入方法依赖的package包/类
@Override
public boolean onScale(ScaleGestureDetector detector) {
if (mCurrentStatus == STATUS_CHANGE) {
// 每次缩放倍数
mScaledRatio = detector.getScaleFactor();
mTotalScale *= mScaledRatio;
// 控制图片的缩放范围
mTotalScale = Math.max(mInitScale, Math.min(mTotalScale, mInitScale * 4));
//mScaledRatio是用来在图片缩放时,计算位移的,如果图片没有缩放,mScaledRatio始终为1,避免错误计算。
if (mTotalScale == mInitScale * 4) {
mScaledRatio = 1;
}
}
return true;
}
示例11: onScale
import android.view.ScaleGestureDetector; //导入方法依赖的package包/类
@Override
public boolean onScale(ScaleGestureDetector detector) {
if (selectedEntity != null) {
float scaleFactorDiff = detector.getScaleFactor();
Log.w(TAG, "ScaleFactorDiff: " + scaleFactorDiff);
selectedEntity.getLayer().postScale(scaleFactorDiff - 1.0F);
selectedEntity.updateEntity();
updateUI();
}
return true;
}
示例12: onScale
import android.view.ScaleGestureDetector; //导入方法依赖的package包/类
@SuppressLint("NewApi")
@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());
checkBorderAndCenterWhenScale();
setImageMatrix(mScaleMatrix);
}
return true;
}
示例13: onScale
import android.view.ScaleGestureDetector; //导入方法依赖的package包/类
@Override
public boolean onScale(ScaleGestureDetector detector) {
// factor > 1, zoom
// factor < 1, pinch
mScaleFactor *= detector.getScaleFactor();
// Don't let the object get too small or too large.
mScaleFactor = Math.max(0.01f, Math.min(mScaleFactor, 1.0f));
return mListener != null && mListener.onZoomValueChanged(mScaleFactor);
}
示例14: onScale
import android.view.ScaleGestureDetector; //导入方法依赖的package包/类
@Override
public boolean onScale(ScaleGestureDetector detector) {
if (setState(PINCHING)) {
float eps = 0.0001f;
if (Math.abs(mAbsTargetX) < eps || Math.abs(mAbsTargetY) < eps) {
// We want to interpret this as a scaled value, to work with the *actual* zoom.
@ScaledPan float scaledFocusX = -detector.getFocusX();
@ScaledPan float scaledFocusY = -detector.getFocusY();
LOG.i("onScale:", "Setting focus.", "detectorFocusX:", scaledFocusX, "detectorFocusX:", scaledFocusY);
// Account for current pan.
scaledFocusX += getScaledPanX();
scaledFocusY += getScaledPanY();
// Transform to an absolute, scale-independent value.
mAbsTargetX = unresolvePan(scaledFocusX);
mAbsTargetY = unresolvePan(scaledFocusY);
LOG.i("onScale:", "Setting focus.", "absTargetX:", mAbsTargetX, "absTargetY:", mAbsTargetY);
}
// Having both overPinch and overScroll is hard to manage, there are lots of bugs if we do.
float factor = detector.getScaleFactor();
float newZoom = mZoom * factor;
applyPinch(newZoom, mAbsTargetX, mAbsTargetY, true);
return true;
}
return false;
}
示例15: onScale
import android.view.ScaleGestureDetector; //导入方法依赖的package包/类
public boolean onScale(ScaleGestureDetector detector) {
if (!ChartTouchHandler.this.isZoomEnabled) {
return false;
}
float scale = 2.0f - detector.getScaleFactor();
if (Float.isInfinite(scale)) {
scale = 1.0f;
}
return ChartTouchHandler.this.chartZoomer.scale(ChartTouchHandler.this.computator, detector.getFocusX(), detector.getFocusY(), scale);
}