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


Java ScaleGestureDetector.getFocusY方法代码示例

本文整理汇总了Java中android.view.ScaleGestureDetector.getFocusY方法的典型用法代码示例。如果您正苦于以下问题:Java ScaleGestureDetector.getFocusY方法的具体用法?Java ScaleGestureDetector.getFocusY怎么用?Java ScaleGestureDetector.getFocusY使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.view.ScaleGestureDetector的用法示例。


在下文中一共展示了ScaleGestureDetector.getFocusY方法的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 (!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

示例3: onScaleBegin

import android.view.ScaleGestureDetector; //导入方法依赖的package包/类
/**
 * @brief Handles the onScaleBegin event
 * @param detector The class which stores all the event information
 * @return true
 * @details Handles the onScaleBegin event. Calls the canvas method startDrag and gets the x and y coordinates
 */
@Override
public boolean onScaleBegin(ScaleGestureDetector detector) {
	
	zoom = true;
	drag = true;
	canvas.startDrag();
	
	x= (int)(((detector.getFocusX() / scaleFactor) + realX) -detector.getFocusX() ) ;
	y= (int)(((detector.getFocusY() / scaleFactor) + realY) -detector.getFocusY() );

	if(x <0){
		x = 0;
	}
	if(realY < 0){
		y = 0;
	}		
	
	return true;
}
 
开发者ID:CodyyAndroid,项目名称:LibVNCAndroid,代码行数:26,代码来源:CanvasActivity.java

示例4: 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

示例5: onScale

import android.view.ScaleGestureDetector; //导入方法依赖的package包/类
@Override
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public boolean onScale(ScaleGestureDetector detector) {
    RectF rect = mCropWindowHandler.getRect();

    float x = detector.getFocusX();
    float y = detector.getFocusY();
    float dY = detector.getCurrentSpanY() / 2;
    float dX = detector.getCurrentSpanX() / 2;

    float newTop = y - dY;
    float newLeft = x - dX;
    float newRight = x + dX;
    float newBottom = y + dY;

    if (newLeft < newRight &&
            newTop <= newBottom &&
            newLeft >= 0 &&
            newRight <= mCropWindowHandler.getMaxCropWidth() &&
            newTop >= 0 &&
            newBottom <= mCropWindowHandler.getMaxCropHeight()) {

        rect.set(newLeft, newTop, newRight, newBottom);
        mCropWindowHandler.setRect(rect);
        invalidate();
    }

    return true;
}
 
开发者ID:garretyoder,项目名称:Cluttr,代码行数:30,代码来源:CropOverlayView.java

示例6: onScale

import android.view.ScaleGestureDetector; //导入方法依赖的package包/类
public boolean onScale(ScaleGestureDetector detector)
{
	//  new scale factor
	float previousScale = mScale;
	mScale = Math.min(Math.max(mScale * detector.getScaleFactor(), MIN_SCALE), MAX_SCALE);

	//  did we really scale?
	if (mScale == previousScale)
		return true;

	//  scale children
	scaleChildren();

	//  maintain focus while scaling
	double scale = mScale / previousScale;
	double currentFocusX = detector.getFocusX();
	double currentFocusY = detector.getFocusY();
	double viewFocusX = (int) currentFocusX + getScrollX();
	double viewFocusY = (int) currentFocusY + getScrollY();
	int diffX = (int) (viewFocusX * (1 - scale));
	int diffY = (int) (viewFocusY * (1 - scale));
	mXScroll += diffX;
	mYScroll += diffY;

	requestLayout();

	return true;
}
 
开发者ID:ArtifexSoftware,项目名称:mupdf-android-viewer-nui,代码行数:29,代码来源:DocViewBase.java

示例7: onScaleBegin

import android.view.ScaleGestureDetector; //导入方法依赖的package包/类
@Override
public boolean onScaleBegin(ScaleGestureDetector detector) {
    mStartFocusX = detector.getFocusX();
    mStartFocusY = detector.getFocusY();

    mStartScrollX = getScrollX();
    mStartScrollY = getScrollY();

    mStartScale = mViewScale;
    return true;
}
 
开发者ID:Axe-Ishmael,项目名称:Blockly,代码行数:12,代码来源:VirtualWorkspaceView.java

示例8: onScaleBegin

import android.view.ScaleGestureDetector; //导入方法依赖的package包/类
@Override
public boolean onScaleBegin(ScaleGestureDetector scaleGestureDetector) {
    Log.i(TAG, "onScaleBegin");
    mPivotX = scaleGestureDetector.getFocusX();
    mPivotY = scaleGestureDetector.getFocusY();
    return true;
}
 
开发者ID:tringuyen1121,项目名称:Khonsu,代码行数:8,代码来源:ZoomLayout.java

示例9: onScaleBegin

import android.view.ScaleGestureDetector; //导入方法依赖的package包/类
@Override
public boolean onScaleBegin(ScaleGestureDetector detector) {
    lastFocus.x = detector.getFocusX();
    lastFocus.y = detector.getFocusY();
    mCurrentScaleMax = mCurrentScale;
    mCurrentScaleMin = mCurrentScale;
    return true;
}
 
开发者ID:metagalactic,项目名称:ScalableImageView,代码行数:9,代码来源:ScalableImageView.java

示例10: onScale

import android.view.ScaleGestureDetector; //导入方法依赖的package包/类
@Override
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public boolean onScale(ScaleGestureDetector detector) {
  RectF rect = mCropWindowHandler.getRect();

  float x = detector.getFocusX();
  float y = detector.getFocusY();
  float dY = detector.getCurrentSpanY() / 2;
  float dX = detector.getCurrentSpanX() / 2;

  float newTop = y - dY;
  float newLeft = x - dX;
  float newRight = x + dX;
  float newBottom = y + dY;

  if (newLeft < newRight
      && newTop <= newBottom
      && newLeft >= 0
      && newRight <= mCropWindowHandler.getMaxCropWidth()
      && newTop >= 0
      && newBottom <= mCropWindowHandler.getMaxCropHeight()) {

    rect.set(newLeft, newTop, newRight, newBottom);
    mCropWindowHandler.setRect(rect);
    invalidate();
  }

  return true;
}
 
开发者ID:prashantsaini1,项目名称:android-titanium-imagecropper,代码行数:30,代码来源:CropOverlayView.java

示例11: onScale

import android.view.ScaleGestureDetector; //导入方法依赖的package包/类
@Override
public boolean onScale(ScaleGestureDetector scaleGestureDetector) {

    if (!mScaleXEnable) return false;
    if (!mScaleGestureEnable) return super.onScale(scaleGestureDetector);

    float spanX = ScaleGestureDetectorCompat.getCurrentSpanX(scaleGestureDetector);

    float newWidth = lastSpanX / spanX * mCurrentViewport.width();

    if (newWidth < mCurrentViewport.width() && mCurrentViewport.width() < 0.1) {
        return true;
    }

    float focusX = scaleGestureDetector.getFocusX();
    float focusY = scaleGestureDetector.getFocusY();
    hitTest(focusX, focusY, viewportFocus);

    mCurrentViewport.left = viewportFocus.x
            - newWidth * (focusX - mContentRect.left)
            / mContentRect.width();

    mCurrentViewport.right = mCurrentViewport.left + newWidth;
    mCurrentViewport.constrainViewport();
    if (mScaleXEnable) triggerViewportChange();
    lastSpanX = spanX;

    return true;
}
 
开发者ID:donglua,项目名称:JZAndroidChart,代码行数:30,代码来源:Chart.java

示例12: 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

示例13: onScale

import android.view.ScaleGestureDetector; //导入方法依赖的package包/类
@Override
public boolean onScale(ScaleGestureDetector detector) {
	if(source != null) {
		// Zoom horizontal if focus in the main area or always if decoupled axis is deactivated:
		if(!decoupledAxis || detector.getFocusX() > getGridSize()*1.5) {
			float xScale = detector.getCurrentSpanX() / detector.getPreviousSpanX();
			long frequencyFocus = virtualFrequency + (int) ((detector.getFocusX() / width - 0.5) * virtualSampleRate);
			int maxSampleRate = demodulationEnabled ? (int) (source.getSampleRate() * 0.9) : source.getMaxSampleRate();
			if(recordingEnabled)
				maxSampleRate = source.getSampleRate();
			virtualSampleRate = (int) Math.min(Math.max(virtualSampleRate / xScale, MIN_VIRTUAL_SAMPLERATE), maxSampleRate);
			virtualFrequency = Math.min(Math.max(frequencyFocus + (long) ((virtualFrequency - frequencyFocus) / xScale),
					source.getMinFrequency() - source.getSampleRate() / 2), source.getMaxFrequency() + source.getSampleRate() / 2);

			// if we zoomed the channel selector out of the window, reset the channel selector:
			if (demodulationEnabled && channelFrequency < virtualFrequency - virtualSampleRate / 2) {
				channelFrequency = virtualFrequency - virtualSampleRate / 2;
				rfControlInterface.updateChannelFrequency(channelFrequency);
			}
			if (demodulationEnabled && channelFrequency > virtualFrequency + virtualSampleRate / 2) {
				channelFrequency = virtualFrequency + virtualSampleRate / 2;
				rfControlInterface.updateChannelFrequency(channelFrequency);
			}
		}

		// Zoom vertical if enabled and focus in the left grid area or if decoupled axis is deactivated:
		if (verticalZoomEnabled && (!decoupledAxis || detector.getFocusX() <= getGridSize() * 1.5)) {
			float yScale = detector.getCurrentSpanY() / detector.getPreviousSpanY();
			float dBFocus = maxDB - (maxDB - minDB) * (detector.getFocusY() / getFftHeight());
			float newMinDB = Math.min(Math.max(dBFocus - (dBFocus - minDB) / yScale, MIN_DB), MAX_DB - 10);
			float newMaxDB = Math.min(Math.max(dBFocus - (dBFocus - maxDB) / yScale, newMinDB + 10), MAX_DB);
			this.setDBScale(newMinDB, newMaxDB);

			// adjust the squelch if it is outside the visible viewport right now:
			if(squelch < minDB)
				squelch = minDB;
			if(squelch > maxDB)
				squelch = maxDB;
		}

		// Automatically re-adjust the sample rate of the source if we zoom too far out or in
		// (only if not recording or demodulating!)
		if(!recordingEnabled && !demodulationEnabled) {
			if (source.getSampleRate() < virtualSampleRate && virtualSampleRate < source.getMaxSampleRate())
				source.setSampleRate(source.getNextHigherOptimalSampleRate(virtualSampleRate));
			int nextLower = source.getNextLowerOptimalSampleRate(source.getSampleRate());
			if ((virtualSampleRate < nextLower) && (source.getSampleRate() > nextLower)) {
				source.setSampleRate(nextLower);
			}
		}
	}
	return true;
}
 
开发者ID:takyonxxx,项目名称:AndroidSdrRtlTuner,代码行数:54,代码来源:AnalyzerSurface.java

示例14: onScale

import android.view.ScaleGestureDetector; //导入方法依赖的package包/类
@Override
public boolean onScale(ScaleGestureDetector detector) {
    final float oldViewScale = mViewScale;

    final float scaleFactor = detector.getScaleFactor();
    mViewScale *= scaleFactor;

    if (mViewScale < ZOOM_SCALES[0]) {
        mCurrentZoomScaleIndex = 0;
        mViewScale = ZOOM_SCALES[mCurrentZoomScaleIndex];
    } else if (mViewScale > ZOOM_SCALES[ZOOM_SCALES.length - 1]) {
        mCurrentZoomScaleIndex = ZOOM_SCALES.length - 1;
        mViewScale = ZOOM_SCALES[mCurrentZoomScaleIndex];
    } else {
        // find nearest zoom scale
        float minDist = Float.MAX_VALUE;
        // If we reach the end the last one was the closest
        int index = ZOOM_SCALES.length - 1;
        for (int i = 0; i < ZOOM_SCALES.length; i++) {
            float dist = Math.abs(mViewScale - ZOOM_SCALES[i]);
            if (dist < minDist) {
                minDist = dist;
            } else {
                // When it starts increasing again we've found the closest
                index = i - 1;
                break;
            }
        }
        mCurrentZoomScaleIndex = index;
    }

    if (shouldDrawGrid()) {
        mGridRenderer.updateGridBitmap(mViewScale);
    }

    mWorkspaceView.setScaleX(mViewScale);
    mWorkspaceView.setScaleY(mViewScale);

    // Compute scroll offsets based on difference between original and new scaling factor
    // and the focus point where the gesture started. This makes sure that the scroll offset
    // is adjusted to keep the focus point in place on the screen unless there is also a
    // focus point shift (see next scroll component below).
    final float scaleDifference = mViewScale - mStartScale;
    final int scrollScaleX = (int) (scaleDifference * mStartFocusX);
    final int scrollScaleY = (int) (scaleDifference * mStartFocusY);

    // Compute scroll offset based on shift of the focus point. This makes sure the view
    // pans along with the focus.
    final int scrollPanX = (int) (mStartFocusX - detector.getFocusX());
    final int scrollPanY = (int) (mStartFocusY - detector.getFocusY());

    // Apply the computed scroll components for scale and panning relative to the scroll
    // coordinates at the beginning of the gesture.
    scrollTo(mStartScrollX + scrollScaleX + scrollPanX,
            mStartScrollY + scrollScaleY + scrollPanY);

    return true;
}
 
开发者ID:Axe-Ishmael,项目名称:Blockly,代码行数:59,代码来源:VirtualWorkspaceView.java

示例15: onScale

import android.view.ScaleGestureDetector; //导入方法依赖的package包/类
@Override
public boolean onScale(ScaleGestureDetector detector) {
    if (mIsAnimating) {
        return true;
    }

    focus.x = detector.getFocusX();
    focus.y = detector.getFocusY();

    float scale = detector.getScaleFactor();
    mAttemptedScaleMax = Math.max(scale, mAttemptedScaleMax);
    mAttemptedScaleMin = Math.min(scale, mAttemptedScaleMin);
    mCurrentScale = calculateNewScale(mCurrentScale, scale);
    mCurrentScaleMax = Math.max(mCurrentScale, mCurrentScaleMax);
    mCurrentScaleMin = Math.min(mCurrentScale, mCurrentScaleMin);

    if (Float.compare(mCurrentScale, NO_SCALE) > 0) {
        if (!ScaleType.MATRIX.equals(getScaleType())) {
            // Ensure we have the correct scale type
            setScaleType(ScaleType.MATRIX);
        }

        // For now we will always begin with a matrix that simulates a "fitCenter"
        // type of behavior; we can then apply cumulative transformations to this
        // matrix in order to have greater control over the current values of
        // scales, translations, etc.
        mMatrix.set(getFitCenterMatrix(ScalableImageView.this));

        // Scale the matrix to the current scale around the view center
        mMatrix.postScale(
                mCurrentScale,
                mCurrentScale,
                getX() + getWidth() * 0.5f,
                getY() + getHeight() * 0.5f);

        // Re-apply any translations from panning and also translate according to
        // to any lateral motion while scaling.
        mCurrentTranslation.x += focus.x - lastFocus.x;
        mCurrentTranslation.y += focus.y - lastFocus.y;
        mCurrentTranslation = getTranslationInBounds(mCurrentTranslation,
                ScalableImageView.this, mMatrix);
        mMatrix.postTranslate(mCurrentTranslation.x, mCurrentTranslation.y);

        lastFocus.x = focus.x;
        lastFocus.y = focus.y;
        setImageMatrix(mMatrix);
        return true;
    } else {
        resetScaling(hasScaled());
        return false;
    }
}
 
开发者ID:metagalactic,项目名称:ScalableImageView,代码行数:53,代码来源:ScalableImageView.java


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