当前位置: 首页>>代码示例>>Java>>正文


Java ScaleGestureDetector.getScaleFactor方法代码示例

本文整理汇总了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;
}
 
开发者ID:ArtifexSoftware,项目名称:mupdf-android-viewer-mini,代码行数:20,代码来源:PageView.java

示例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;
}
 
开发者ID:jeasinlee,项目名称:AndroidBasicLibs,代码行数:19,代码来源:LargeImageView.java

示例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);
        }
    }
 
开发者ID:nextgis,项目名称:android_nextgis_mobile,代码行数:22,代码来源:MapGlView.java

示例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;
}
 
开发者ID:newDeepLearing,项目名称:decoy,代码行数:25,代码来源:MultiTouchZoomableImageView.java

示例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;
}
 
开发者ID:rosenpin,项目名称:QuickDrawEverywhere,代码行数:21,代码来源:DrawView.java

示例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;
}
 
开发者ID:gsantner,项目名称:memetastic,代码行数:25,代码来源:TouchImageView.java

示例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;
}
 
开发者ID:StickyTolt,项目名称:ForeverLibrary,代码行数:24,代码来源:ImageViewTouch.java

示例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;

}
 
开发者ID:hsj-xiaokang,项目名称:OSchina_resources_android,代码行数:25,代码来源:ZoomImageView.java

示例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;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:13,代码来源:ChartTouchHandler.java

示例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;
}
 
开发者ID:xiaoqingxu0502,项目名称:GraffitiDemo,代码行数:16,代码来源:GraffitiView.java

示例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;
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:12,代码来源:MotionView.java

示例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;

}
 
开发者ID:HelloChenJinJun,项目名称:TestChat,代码行数:35,代码来源:ZoomImageView.java

示例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);
}
 
开发者ID:pili-engineering,项目名称:pili-react-native,代码行数:12,代码来源:CameraPreviewFrameView.java

示例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;
}
 
开发者ID:natario1,项目名称:ZoomLayout,代码行数:29,代码来源:ZoomEngine.java

示例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);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:11,代码来源:ChartTouchHandler.java


注:本文中的android.view.ScaleGestureDetector.getScaleFactor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。