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


Java RectF.offset方法代码示例

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


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

示例1: computeRect

import android.graphics.RectF; //导入方法依赖的package包/类
private void computeRect(RectF r, View view) {
    r.set(0.0f, 0.0f, (float) view.getWidth(), (float) view.getHeight());
    Matrix m = this.mTempMatrix;
    m.reset();
    transformMatrix(m, view);
    this.mTempMatrix.mapRect(r);
    r.offset((float) view.getLeft(), (float) view.getTop());
    if (r.right < r.left) {
        float f = r.right;
        r.right = r.left;
        r.left = f;
    }
    if (r.bottom < r.top) {
        f = r.top;
        r.top = r.bottom;
        r.bottom = f;
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:19,代码来源:AnimatorProxy.java

示例2: 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) {
    if (null == mTextureView || null == mPreviewSize) {
        return;
    }
    int rotation = mWindowManager.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:lytcom,项目名称:CameraKitView,代码行数:32,代码来源:Camera2.java

示例3: generateRectangles

import android.graphics.RectF; //导入方法依赖的package包/类
private void generateRectangles() {
    for (BackportAppointment a : dayAppointments) {
        // Default, left aligned (not shifted) rectangle
        RectF a_rect = layoutRectangle(a);

        // Check for each rects if intersection is present
        boolean check_intersect = true;
        int i = 0;
        start_intersection_check:
        while (check_intersect) {
            for (RectF r : eventRectangles.values()) {
                if (r.contains(a_rect) || RectF.intersects(r, a_rect)) {
                    if (++i > shiftX_max) shiftX_max = i;
                    // shift one unit to the right and start again
                    a_rect.offset(dp(2 * X_OFFSET + X_WIDTH), 0);
                    continue start_intersection_check;
                } // else check next
            }

            // finish
            check_intersect = false;
        }

        eventRectangles.put(a, a_rect);
    }
}
 
开发者ID:dhbw-timetable,项目名称:dhbw-timetable-android,代码行数:27,代码来源:WeekdayView.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(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:hpi-xnor,项目名称:android-image-classification,代码行数:33,代码来源:CameraFrameCapture.java

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

示例6: 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) {
    int rotation = mWindowManager.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:lytcom,项目名称:CameraKitView,代码行数:29,代码来源:Camera1.java

示例7: 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:hpi-xnor,项目名称:android-image-classification,代码行数:34,代码来源:CameraConnectionFragment.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(final int viewWidth, final int viewHeight) {
    if (mPreviewSize == null) return;

    final int rotation = mActivity.getWindowManager().getDefaultDisplay().getRotation();
    final Matrix matrix = new Matrix();
    final RectF viewRect = new RectF(0, 0, viewWidth, viewHeight);
    final RectF bufferRect = new RectF(0, 0, mPreviewSize.getHeight(), mPreviewSize.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 / 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);
    }
    mAutoFitTextureView.setTransform(matrix);
}
 
开发者ID:kevalpatel2106,项目名称:smart-lens,代码行数:30,代码来源:Camera2Api.java

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

示例10: TextureFilm

import android.graphics.RectF; //导入方法依赖的package包/类
public TextureFilm(TextureFilm atlas, Object key, int width, int height) {

		texWidth = atlas.texWidth;
		texHeight = atlas.texHeight;

		RectF patch = atlas.get(key);

		float uw = (float) width / texWidth;
		float vh = (float) height / texHeight;
		int cols = (int) (width(patch) / width);
		int rows = (int) (height(patch) / height);

		for (int i = 0; i < rows; i++) {
			for (int j = 0; j < cols; j++) {
				RectF rect = new RectF(j * uw, i * vh, (j + 1) * uw, (i + 1) * vh);
				rect.offset(patch.left, patch.top);
				add(i * cols + j, rect);
			}
		}
	}
 
开发者ID:G2159687,项目名称:ESPD,代码行数:21,代码来源:TextureFilm.java

示例11: configureTransform

import android.graphics.RectF; //导入方法依赖的package包/类
@DebugLog
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:SimonCherryGZ,项目名称:face-landmark-android,代码行数:27,代码来源:ARMaskFragment.java

示例12: configureTransform

import android.graphics.RectF; //导入方法依赖的package包/类
/**
 * 在确定相机预览大小后应调用此方法
 *
 * @param viewWidth  宽
 * @param viewHeight 高
 */
private void configureTransform(int viewWidth, int viewHeight) {
    if (null == mPreviewSize) {
        return;
    }
    int rotation = getDisplayRotation();
    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);
    }
    this.setTransform(matrix);
}
 
开发者ID:shenhuanet,项目名称:Ocr-android,代码行数:30,代码来源:CameraPreview.java

示例13: processText

import android.graphics.RectF; //导入方法依赖的package包/类
@Override
public void processText(String text) {
	if (visible()) {
		android.graphics.Rect rect = new android.graphics.Rect();
		// Get text bounding box (for offset 0)
		state.fillPaint.getTextBounds(text, 0, text.length(), rect);
		RectF textbounds = new RectF(rect);
		// Adjust bounds to offset at text position
		textbounds.offset(x, y);
		// Merge with accumulated bounding box
		bbox.union(textbounds);
	}

	// Update the current text position
	x += state.fillPaint.measureText(text);
}
 
开发者ID:mkulesh,项目名称:microMathematics,代码行数:17,代码来源:SVGAndroidRenderer.java

示例14: 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`
 */
@DebugLog
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:SimonCherryGZ,项目名称:face-landmark-android,代码行数:35,代码来源:CameraConnectionFragment.java

示例15: generateShortcutPreview

import android.graphics.RectF; //导入方法依赖的package包/类
private Bitmap generateShortcutPreview(BaseActivity launcher, ShortcutConfigActivityInfo info,
        int maxWidth, int maxHeight, Bitmap preview) {
    int iconSize = launcher.getDeviceProfile().iconSizePx;
    int padding = launcher.getResources()
            .getDimensionPixelSize(R.dimen.widget_preview_shortcut_padding);

    int size = iconSize + 2 * padding;
    if (maxHeight < size || maxWidth < size) {
        throw new RuntimeException("Max size is too small for preview");
    }
    final Canvas c = new Canvas();
    if (preview == null || preview.getWidth() < size || preview.getHeight() < size) {
        preview = Bitmap.createBitmap(size, size, Config.ARGB_8888);
        c.setBitmap(preview);
    } else {
        if (preview.getWidth() > size || preview.getHeight() > size) {
            preview.reconfigure(size, size, preview.getConfig());
        }

        // Reusing bitmap. Clear it.
        c.setBitmap(preview);
        c.drawColor(0, PorterDuff.Mode.CLEAR);
    }
    Paint p = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG);
    RectF boxRect = drawBoxWithShadow(c, p, size, size);

    Bitmap icon = LauncherIcons.createScaledBitmapWithoutShadow(
            mutateOnMainThread(info.getFullResIcon(mIconCache)), mContext, Build.VERSION_CODES.O);
    Rect src = new Rect(0, 0, icon.getWidth(), icon.getHeight());

    boxRect.set(0, 0, iconSize, iconSize);
    boxRect.offset(padding, padding);
    c.drawBitmap(icon, src, boxRect, p);
    c.setBitmap(null);
    return preview;
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:37,代码来源:WidgetPreviewLoader.java


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