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


Java RectF.centerX方法代码示例

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


在下文中一共展示了RectF.centerX方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: configureTransform

import android.graphics.RectF; //导入方法依赖的package包/类
/**
 * Configures the necessary {@link Matrix} transformation to `mTextureView`.
 * This method should be called after the camera preview size is determined in
 * setUpCameraOutputs and also the size of `mTextureView` is fixed.
 *
 * @param viewWidth  The width of `mTextureView`
 * @param viewHeight The height of `mTextureView`
 */
private void configureTransform(int viewWidth, int viewHeight) {
    Activity activity = getActivity();
    if (null == mTextureView || null == mPreviewSize || null == activity) {
        return;
    }
    int rotation = activity.getWindowManager().getDefaultDisplay().getRotation();
    Matrix matrix = new Matrix();
    RectF viewRect = new RectF(0, 0, viewWidth, viewHeight);
    RectF bufferRect = new RectF(0, 0, mPreviewSize.getHeight(), mPreviewSize.getWidth());
    float centerX = viewRect.centerX();
    float centerY = viewRect.centerY();
    if (Surface.ROTATION_90 == rotation || Surface.ROTATION_270 == rotation) {
        bufferRect.offset(centerX - bufferRect.centerX(), centerY - bufferRect.centerY());
        matrix.setRectToRect(viewRect, bufferRect, Matrix.ScaleToFit.FILL);
        float scale = Math.max(
                (float) viewHeight / mPreviewSize.getHeight(),
                (float) viewWidth / mPreviewSize.getWidth());
        matrix.postScale(scale, scale, centerX, centerY);
        matrix.postRotate(90 * (rotation - 2), centerX, centerY);
    } else if (Surface.ROTATION_180 == rotation) {
        matrix.postRotate(180, centerX, centerY);
    }
    mTextureView.setTransform(matrix);
}
 
开发者ID:vulovicv23,项目名称:opencv-documentscanner-android,代码行数:33,代码来源:Camera2BasicFragment.java

示例2: createLeftEyeCircle

import android.graphics.RectF; //导入方法依赖的package包/类
private Path createLeftEyeCircle(RectF arcBounds, float offsetY) {
    Path path = new Path();

    //the center of the left eye
    float leftEyeCenterX = arcBounds.centerX() - mEyeInterval / 2.0f - mEyeCircleRadius;
    float leftEyeCenterY = arcBounds.centerY() + offsetY;
    //the bounds of left eye
    RectF leftEyeBounds = new RectF(leftEyeCenterX - mEyeCircleRadius, leftEyeCenterY - mEyeCircleRadius,
            leftEyeCenterX + mEyeCircleRadius, leftEyeCenterY + mEyeCircleRadius);
    path.addArc(leftEyeBounds, 0, DEGREE_180 + 15);
    //the above radian of of the eye
    path.quadTo(leftEyeBounds.left + mAboveRadianEyeOffsetX, leftEyeBounds.top + mEyeCircleRadius * 0.2f,
            leftEyeBounds.left + mAboveRadianEyeOffsetX / 4.0f, leftEyeBounds.top - mEyeCircleRadius * 0.15f);

    return path;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:GhostsEyeLoadingRenderer.java

示例3: configureTransform

import android.graphics.RectF; //导入方法依赖的package包/类
private void configureTransform(TextureView textureView) {
    if (null == textureView || null == mPreviewSize || null == mActivity) {
        return;
    }
    int rotation = mActivity.getWindowManager().getDefaultDisplay().getRotation();
    Matrix matrix = new Matrix();
    RectF viewRect = new RectF(0, 0, textureView.getWidth(), textureView.getHeight());
    RectF bufferRect = new RectF(0, 0, mPreviewSize.y, mPreviewSize.x);
    float centerX = viewRect.centerX();
    float centerY = viewRect.centerY();
    if (Surface.ROTATION_90 == rotation || Surface.ROTATION_270 == rotation) {
        bufferRect.offset(centerX - bufferRect.centerX(), centerY - bufferRect.centerY());
        matrix.setRectToRect(viewRect, bufferRect, Matrix.ScaleToFit.FILL);
        float scale = Math.max(
                (float) textureView.getHeight() / mPreviewSize.y,
                (float) textureView.getWidth() / mPreviewSize.x);
        matrix.postScale(scale, scale, centerX, centerY);
    }
    matrix.postRotate(-90 * rotation, centerX, centerY);
    textureView.setTransform(matrix);
}
 
开发者ID:vbier,项目名称:habpanelviewer,代码行数:22,代码来源:MotionDetectorCamera2.java

示例4: configureTransform

import android.graphics.RectF; //导入方法依赖的package包/类
/**
 * Configures the necessary {@link android.graphics.Matrix} transformation to `mTextureView`.
 * This method should be called after the camera preview size is determined in
 * setUpCameraOutputs and also the size of `mTextureView` is fixed.
 *
 * @param viewWidth  The width of `mTextureView`
 * @param viewHeight The height of `mTextureView`
 */
private void configureTransform(final int viewWidth, final int viewHeight) {
  final Activity activity = getActivity();
  if (null == textureView || null == previewSize || null == activity) {
    return;
  }
  final int rotation = activity.getWindowManager().getDefaultDisplay().getRotation();
  final Matrix matrix = new Matrix();
  final RectF viewRect = new RectF(0, 0, viewWidth, viewHeight);
  final RectF bufferRect = new RectF(0, 0, previewSize.getHeight(), previewSize.getWidth());
  final float centerX = viewRect.centerX();
  final float centerY = viewRect.centerY();
  if (Surface.ROTATION_90 == rotation || Surface.ROTATION_270 == rotation) {
    bufferRect.offset(centerX - bufferRect.centerX(), centerY - bufferRect.centerY());
    matrix.setRectToRect(viewRect, bufferRect, Matrix.ScaleToFit.FILL);
    final float scale =
        Math.max(
            (float) viewHeight / previewSize.getHeight(),
            (float) viewWidth / previewSize.getWidth());
    matrix.postScale(scale, scale, centerX, centerY);
    matrix.postRotate(90 * (rotation - 2), centerX, centerY);
  } else if (Surface.ROTATION_180 == rotation) {
    matrix.postRotate(180, centerX, centerY);
  }
  textureView.setTransform(matrix);
}
 
开发者ID:codekongs,项目名称:ImageClassify,代码行数:34,代码来源:CameraConnectionFragment.java

示例5: configureTransform

import android.graphics.RectF; //导入方法依赖的package包/类
/**
 * 当手机屏幕的朝向改变时,要对获取到的视频流进行方向上的调整
 *
 * @param viewWidth  TextureView的宽度
 * @param viewHeight TextureView的高度
 */
private void configureTransform(int viewWidth, int viewHeight) {

    if (viewCameraDebug == null || previewSize == null) {
        return;
    }
    int rotation = getWindowManager().getDefaultDisplay().getRotation();

    Matrix matrix = new Matrix();
    RectF viewRect = new RectF(0, 0, viewWidth, viewHeight);
    RectF bufferRect = new RectF(0, 0, previewSize.getHeight(), previewSize.getWidth());
    float centerX = viewRect.centerX();
    float centerY = viewRect.centerY();
    if (Surface.ROTATION_90 == rotation || Surface.ROTATION_270 == rotation) {
        bufferRect.offset(centerX - bufferRect.centerX(), centerY - bufferRect.centerY());
        matrix.setRectToRect(viewRect, bufferRect, Matrix.ScaleToFit.FILL);
        float scale = Math.max((float) viewHeight / previewSize.getHeight(),
                (float) viewWidth / previewSize.getWidth());
        matrix.postScale(scale, scale, centerX, centerY);
        matrix.postRotate(90 * (rotation - 2), centerX, centerY);
    } else if (Surface.ROTATION_180 == rotation) {
        matrix.postRotate(180, centerX, centerY);
    }
    viewCameraDebug.setTransform(matrix);
}
 
开发者ID:hgs1217,项目名称:Paper-Melody,代码行数:31,代码来源:CameraDebugActivity.java

示例6: configureTransform

import android.graphics.RectF; //导入方法依赖的package包/类
/**
 * Configures the necessary {@link android.graphics.Matrix} transformation to `mTextureView`.
 * This method should be called after the camera preview size is determined in
 * setUpCameraOutputs and also the size of `mTextureView` is fixed.
 *
 * @param viewWidth  The width of `mTextureView`
 * @param viewHeight The height of `mTextureView`
 */
private void configureTransform(int viewWidth, int viewHeight) {
    if (null == mTextureView || null == mPreviewSize) {
        return;
    }
    int rotation = mDisplayOrientation;
    Matrix matrix = new Matrix();
    RectF viewRect = new RectF(0, 0, viewWidth, viewHeight);
    RectF bufferRect = new RectF(0, 0, mPreviewSize.getHeight(), mPreviewSize.getWidth());
    float centerX = viewRect.centerX();
    float centerY = viewRect.centerY();
    if (Surface.ROTATION_90 == rotation || Surface.ROTATION_270 == rotation) {
        bufferRect.offset(centerX - bufferRect.centerX(), centerY - bufferRect.centerY());
        matrix.setRectToRect(viewRect, bufferRect, Matrix.ScaleToFit.FILL);
        float scale = Math.max(
                (float) viewHeight / mPreviewSize.getHeight(),
                (float) viewWidth / mPreviewSize.getWidth());
        matrix.postScale(scale, scale, centerX, centerY);
        matrix.postRotate(90 * (rotation - 2), centerX, centerY);
    } else if (Surface.ROTATION_180 == rotation) {
        matrix.postRotate(180, centerX, centerY);
    }
    mTextureView.setTransform(matrix);
}
 
开发者ID:EzequielAdrianM,项目名称:Camera2Vision,代码行数:32,代码来源:Camera2Source.java

示例7: configureTransform

import android.graphics.RectF; //导入方法依赖的package包/类
/**
 * 当手机屏幕的朝向改变时,要对获取到的视频流进行方向上的调整
 *
 * @param viewWidth  TextureView的宽度
 * @param viewHeight TextureView的高度
 */
private void configureTransform(int viewWidth, int viewHeight) {

    if (viewPlay == null || previewSize == null) {
        return;
    }
    int rotation = getWindowManager().getDefaultDisplay().getRotation();

    Matrix matrix = new Matrix();
    RectF viewRect = new RectF(0, 0, viewWidth, viewHeight);
    RectF bufferRect = new RectF(0, 0, previewSize.getHeight(), previewSize.getWidth());
    float centerX = viewRect.centerX();
    float centerY = viewRect.centerY();
    if (Surface.ROTATION_90 == rotation || Surface.ROTATION_270 == rotation) {
        bufferRect.offset(centerX - bufferRect.centerX(), centerY - bufferRect.centerY());
        matrix.setRectToRect(viewRect, bufferRect, Matrix.ScaleToFit.FILL);
        float scale = Math.max((float) viewHeight / previewSize.getHeight(),
                (float) viewWidth / previewSize.getWidth());
        matrix.postScale(scale, scale, centerX, centerY);
        matrix.postRotate(90 * (rotation - 2), centerX, centerY);
    } else if (Surface.ROTATION_180 == rotation) {
        matrix.postRotate(180, centerX, centerY);
    }
    viewPlay.setTransform(matrix);
}
 
开发者ID:hgs1217,项目名称:Paper-Melody,代码行数:31,代码来源:PlayActivity.java

示例8: configureTransform

import android.graphics.RectF; //导入方法依赖的package包/类
/**
 * Configures the necessary {@link android.graphics.Matrix} transformation to `mTextureView`.
 * This method should be called after the camera preview size is determined in
 * setUpCameraOutputs and also the size of `mTextureView` is fixed.
 *
 * @param viewWidth  The width of `mTextureView`
 * @param viewHeight The height of `mTextureView`
 */
private void configureTransform(int viewWidth, int viewHeight) {
    Activity activity = getActivity();
    if (null == mTextureView || null == mPreviewSize || null == activity) {
        return;
    }
    int rotation = activity.getWindowManager().getDefaultDisplay().getRotation();
    Matrix matrix = new Matrix();
    RectF viewRect = new RectF(0, 0, viewWidth, viewHeight);
    RectF bufferRect = new RectF(0, 0, mPreviewSize.getHeight(), mPreviewSize.getWidth());
    float centerX = viewRect.centerX();
    float centerY = viewRect.centerY();
    if (Surface.ROTATION_90 == rotation || Surface.ROTATION_270 == rotation) {
        bufferRect.offset(centerX - bufferRect.centerX(), centerY - bufferRect.centerY());
        matrix.setRectToRect(viewRect, bufferRect, Matrix.ScaleToFit.FILL);
        float scale = Math.max(
                (float) viewHeight / mPreviewSize.getHeight(),
                (float) viewWidth / mPreviewSize.getWidth());
        matrix.postScale(scale, scale, centerX, centerY);
        matrix.postRotate(90 * (rotation - 2), centerX, centerY);
    } else if (Surface.ROTATION_180 == rotation) {
        matrix.postRotate(180, centerX, centerY);
    }
    mTextureView.setTransform(matrix);
}
 
开发者ID:TongLi1992,项目名称:Camera_Calibration_Android,代码行数:33,代码来源:Camera2BasicFragment.java

示例9: initDirection

import android.graphics.RectF; //导入方法依赖的package包/类
private void initDirection(MotionEvent ev) {
    int x = (int) ev.getRawX();
    int arcRightXpos;
    int overScreen;
    mArcRange = new RectF(mPoint.x - mRadius, mPoint.y - mRadius, mPoint.x + mRadius, mPoint.y + mRadius);
    int centerX = mWindowCenterPoint.x;
    mEnumOverScreen = EnumOverScreen.TOP;

    if (x < centerX) {
        overScreen = (int) mArcRange.left;
        if (overScreen < 0) {
            mEnumOverScreen = EnumOverScreen.LEFT;
            mEnumOverScreen.setOverScreenDistance(overScreen);
        }

    } else {
        arcRightXpos = (int) (mArcRange.centerX() + mRadius);
        overScreen = arcRightXpos - mRectWindowRange.width();
        if (arcRightXpos > mRectWindowRange.width()) {
            mEnumOverScreen = EnumOverScreen.RIGHT;
            mEnumOverScreen.setOverScreenDistance(overScreen);
        }
    }
}
 
开发者ID:panshen,项目名称:PopupCircleMenu,代码行数:25,代码来源:PopupLayer.java

示例10: moveCenter

import android.graphics.RectF; //导入方法依赖的package包/类
/**
 * Center move only changes the position of the crop window without changing the size.
 */
private void moveCenter(RectF rect, float x, float y, RectF bounds, int viewWidth, int viewHeight, float snapRadius) {
    float dx = x - rect.centerX();
    float dy = y - rect.centerY();
    if (rect.left + dx < 0 || rect.right + dx > viewWidth || rect.left + dx < bounds.left || rect.right + dx > bounds.right) {
        dx /= 1.05f;
        mTouchOffset.x -= dx / 2;
    }
    if (rect.top + dy < 0 || rect.bottom + dy > viewHeight || rect.top + dy < bounds.top || rect.bottom + dy > bounds.bottom) {
        dy /= 1.05f;
        mTouchOffset.y -= dy / 2;
    }
    rect.offset(dx, dy);
    snapEdgesToBounds(rect, bounds, snapRadius);
}
 
开发者ID:chuch0805,项目名称:Android-Demo_ImageCroper,代码行数:18,代码来源:CropWindowMoveHandler.java

示例11: createRightEyeBall

import android.graphics.RectF; //导入方法依赖的package包/类
private RectF createRightEyeBall(RectF arcBounds, float offsetY) {
    //the center of the right eye
    float rightEyeCenterX = arcBounds.centerX() + mEyeInterval / 2.0f + mEyeCircleRadius;
    float rightEyeCenterY = arcBounds.centerY() - mEyeBallOffsetY + offsetY;

    RectF rectF = new RectF(rightEyeCenterX - mEyeBallWidth / 2.0f, rightEyeCenterY - mEyeBallHeight / 2.0f,
            rightEyeCenterX + mEyeBallWidth / 2.0f, rightEyeCenterY + mEyeBallHeight / 2.0f);

    return rectF;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:11,代码来源:GhostsEyeLoadingRenderer.java

示例12: createLeftEyeBall

import android.graphics.RectF; //导入方法依赖的package包/类
private RectF createLeftEyeBall(RectF arcBounds, float offsetY) {
    //the center of the left eye
    float leftEyeCenterX = arcBounds.centerX() - mEyeInterval / 2.0f - mEyeCircleRadius;
    float leftEyeCenterY = arcBounds.centerY() - mEyeBallOffsetY + offsetY;

    RectF rectF = new RectF(leftEyeCenterX - mEyeBallWidth / 2.0f, leftEyeCenterY - mEyeBallHeight / 2.0f,
            leftEyeCenterX + mEyeBallWidth / 2.0f, leftEyeCenterY + mEyeBallHeight / 2.0f);

    return rectF;
}
 
开发者ID:ZhuoKeTeam,项目名称:JueDiQiuSheng,代码行数:11,代码来源:GhostsEyeLoadingRenderer.java

示例13: calculateBounds

import android.graphics.RectF; //导入方法依赖的package包/类
/**
 * Calculate the bounding rectangle for current crop window, handle non-straight rotation angles.<br>
 * If the rotation angle is straight then the bounds rectangle is the bitmap rectangle,
 * otherwsie we find the max rectangle that is within the image bounds starting from the crop window rectangle.
 *
 * @param rect the crop window rectangle to start finsing bounded rectangle from
 * @return true - non straight rotation in place, false - otherwise.
 */
private boolean calculateBounds(RectF rect) {

    float left = BitmapUtils.getRectLeft(mBoundsPoints);
    float top = BitmapUtils.getRectTop(mBoundsPoints);
    float right = BitmapUtils.getRectRight(mBoundsPoints);
    float bottom = BitmapUtils.getRectBottom(mBoundsPoints);

    if (!isNonStraightAngleRotated()) {
        mCalcBounds.set(left, top, right, bottom);
        return false;
    } else {
        float x0 = mBoundsPoints[0];
        float y0 = mBoundsPoints[1];
        float x2 = mBoundsPoints[4];
        float y2 = mBoundsPoints[5];
        float x3 = mBoundsPoints[6];
        float y3 = mBoundsPoints[7];

        if (mBoundsPoints[7] < mBoundsPoints[1]) {
            if (mBoundsPoints[1] < mBoundsPoints[3]) {
                x0 = mBoundsPoints[6];
                y0 = mBoundsPoints[7];
                x2 = mBoundsPoints[2];
                y2 = mBoundsPoints[3];
                x3 = mBoundsPoints[4];
                y3 = mBoundsPoints[5];
            } else {
                x0 = mBoundsPoints[4];
                y0 = mBoundsPoints[5];
                x2 = mBoundsPoints[0];
                y2 = mBoundsPoints[1];
                x3 = mBoundsPoints[2];
                y3 = mBoundsPoints[3];
            }
        } else if (mBoundsPoints[1] > mBoundsPoints[3]) {
            x0 = mBoundsPoints[2];
            y0 = mBoundsPoints[3];
            x2 = mBoundsPoints[6];
            y2 = mBoundsPoints[7];
            x3 = mBoundsPoints[0];
            y3 = mBoundsPoints[1];
        }

        float a0 = (y3 - y0) / (x3 - x0);
        float a1 = -1f / a0;
        float b0 = y0 - a0 * x0;
        float b1 = y0 - a1 * x0;
        float b2 = y2 - a0 * x2;
        float b3 = y2 - a1 * x2;

        float c0 = (rect.centerY() - rect.top) / (rect.centerX() - rect.left);
        float c1 = -c0;
        float d0 = rect.top - c0 * rect.left;
        float d1 = rect.top - c1 * rect.right;

        left = Math.max(left, (d0 - b0) / (a0 - c0) < rect.right ? (d0 - b0) / (a0 - c0) : left);
        left = Math.max(left, (d0 - b1) / (a1 - c0) < rect.right ? (d0 - b1) / (a1 - c0) : left);
        left = Math.max(left, (d1 - b3) / (a1 - c1) < rect.right ? (d1 - b3) / (a1 - c1) : left);
        right = Math.min(right, (d1 - b1) / (a1 - c1) > rect.left ? (d1 - b1) / (a1 - c1) : right);
        right = Math.min(right, (d1 - b2) / (a0 - c1) > rect.left ? (d1 - b2) / (a0 - c1) : right);
        right = Math.min(right, (d0 - b2) / (a0 - c0) > rect.left ? (d0 - b2) / (a0 - c0) : right);

        top = Math.max(top, Math.max(a0 * left + b0, a1 * right + b1));
        bottom = Math.min(bottom, Math.min(a1 * left + b3, a0 * right + b2));

        mCalcBounds.left = left;
        mCalcBounds.top = top;
        mCalcBounds.right = right;
        mCalcBounds.bottom = bottom;
        return true;
    }
}
 
开发者ID:chuch0805,项目名称:Android-Demo_ImageCroper,代码行数:81,代码来源:CropOverlayView.java

示例14: getAccumulatedDelta

import android.graphics.RectF; //导入方法依赖的package包/类
private synchronized PointF getAccumulatedDelta(final long timestamp, final float positionX,
    final float positionY, final float radius) {
  final RectF currPosition = getCurrentPosition(timestamp,
      new RectF(positionX - radius, positionY - radius, positionX + radius, positionY + radius));
  return new PointF(currPosition.centerX() - positionX, currPosition.centerY() - positionY);
}
 
开发者ID:flipper83,项目名称:SortingHatAndroid,代码行数:7,代码来源:ObjectTracker.java

示例15: calculateTouchOffset

import android.graphics.RectF; //导入方法依赖的package包/类
/**
 * Calculates the offset of the touch point from the precise location of the specified handle.<br>
 * Save these values in a member variable since we want to maintain this offset as we drag the handle.
 */
private void calculateTouchOffset(RectF rect, float touchX, float touchY) {

    float touchOffsetX = 0;
    float touchOffsetY = 0;

    // Calculate the offset from the appropriate handle.
    switch (mType) {
        case TOP_LEFT:
            touchOffsetX = rect.left - touchX;
            touchOffsetY = rect.top - touchY;
            break;
        case TOP_RIGHT:
            touchOffsetX = rect.right - touchX;
            touchOffsetY = rect.top - touchY;
            break;
        case BOTTOM_LEFT:
            touchOffsetX = rect.left - touchX;
            touchOffsetY = rect.bottom - touchY;
            break;
        case BOTTOM_RIGHT:
            touchOffsetX = rect.right - touchX;
            touchOffsetY = rect.bottom - touchY;
            break;
        case LEFT:
            touchOffsetX = rect.left - touchX;
            touchOffsetY = 0;
            break;
        case TOP:
            touchOffsetX = 0;
            touchOffsetY = rect.top - touchY;
            break;
        case RIGHT:
            touchOffsetX = rect.right - touchX;
            touchOffsetY = 0;
            break;
        case BOTTOM:
            touchOffsetX = 0;
            touchOffsetY = rect.bottom - touchY;
            break;
        case CENTER:
            touchOffsetX = rect.centerX() - touchX;
            touchOffsetY = rect.centerY() - touchY;
            break;
        default:
            break;
    }

    mTouchOffset.x = touchOffsetX;
    mTouchOffset.y = touchOffsetY;
}
 
开发者ID:l465659833,项目名称:Bigbang,代码行数:55,代码来源:CropWindowMoveHandler.java


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