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


Java RectF.width方法代码示例

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


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

示例1: pointToAlpha

import android.graphics.RectF; //导入方法依赖的package包/类
private int pointToAlpha(int x){

		final RectF rect = mAlphaRect;
		final int width = (int) rect.width();

		if(x < rect.left){
			x = 0;
		}
		else if(x > rect.right){
			x = width;
		}
		else{
			x = x - (int)rect.left;
		}

		return 0xff - (x * 0xff / width);

	}
 
开发者ID:WrBug,项目名称:GravityBox,代码行数:19,代码来源:ColorPickerView.java

示例2: initWaterDropHolders

import android.graphics.RectF; //导入方法依赖的package包/类
private void initWaterDropHolders(RectF bottleRect, RectF waterRect) {
    float bottleRadius = bottleRect.width() / 2.0f;
    float lowestWaterPointY = waterRect.top;
    float twoSidesInterval = 0.2f * bottleRect.width();
    float atLeastDelayDuration = 0.1f;

    float unitDuration = 0.1f;
    float delayDurationRange = 0.6f;
    int radiusRandomRange = MAX_WATER_DROP_RADIUS - MIN_WATER_DROP_RADIUS;
    float currentXRandomRange = bottleRect.width() * 0.6f;

    for (int i = 0; i < DEFAULT_WATER_DROP_COUNT; i++) {
        WaterDropHolder waterDropHolder = new WaterDropHolder();
        waterDropHolder.mRadius = MIN_WATER_DROP_RADIUS + mRandom.nextInt(radiusRandomRange);
        waterDropHolder.mInitX = bottleRect.left + twoSidesInterval + mRandom.nextFloat() * currentXRandomRange;
        waterDropHolder.mInitY = lowestWaterPointY + waterDropHolder.mRadius / 2.0f;
        waterDropHolder.mRiseHeight = getMaxRiseHeight(bottleRadius, waterDropHolder.mRadius, waterDropHolder.mInitX - bottleRect.left)
                * (0.2f + 0.8f * mRandom.nextFloat());
        waterDropHolder.mDelayDuration = atLeastDelayDuration + mRandom.nextFloat() * delayDurationRange;
        waterDropHolder.mDuration = waterDropHolder.mRiseHeight / bottleRadius * unitDuration;

        mWaterDropHolders.add(waterDropHolder);
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:25,代码来源:WaterBottleLoadingRenderer.java

示例3: center

import android.graphics.RectF; //导入方法依赖的package包/类
protected void center() {
    final Bitmap bitmap = bitmapDisplayed.getBitmap();
    if (bitmap == null) {
        return;
    }
    Matrix m = getImageViewMatrix();

    RectF rect = new RectF(0, 0, bitmap.getWidth(), bitmap.getHeight());
    m.mapRect(rect);

    float height = rect.height();
    float width  = rect.width();

    float deltaX = 0, deltaY = 0;

    deltaY = centerVertical(rect, height, deltaY);
    deltaX = centerHorizontal(rect, width, deltaX);

    postTranslate(deltaX, deltaY);
    setImageMatrix(getImageViewMatrix());
}
 
开发者ID:mityung,项目名称:XERUNG,代码行数:22,代码来源:ImageViewTouchBase.java

示例4: calcTextBounds

import android.graphics.RectF; //导入方法依赖的package包/类
/**
 * Returns the bounding rectangle of the given _text, with the size and style defined in the _textPaint centered in the middle of the _textBounds
 *
 * @param _text       The text.
 * @param _textPaint  The paint defining the text size and style.
 * @param _textBounds The rect where the text will be centered.
 * @return The bounding box of the text centered in the _textBounds.
 */
private RectF calcTextBounds(String _text, Paint _textPaint, RectF _textBounds) {

    Rect textBoundsTmp = new Rect();

    //get current text bounds
    _textPaint.getTextBounds(_text, 0, _text.length(), textBoundsTmp);
    float width = textBoundsTmp.left + textBoundsTmp.width();
    float height = textBoundsTmp.bottom + textBoundsTmp.height() * 0.93f; // the height of calcTextBounds is a bit to high, therefore  * 0.93
    //center in circle
    RectF textRect = new RectF();
    textRect.left = (_textBounds.left + ((_textBounds.width() - width) / 2));
    textRect.top = _textBounds.top + ((_textBounds.height() - height) / 2);
    textRect.right = textRect.left + width;
    textRect.bottom = textRect.top + height;


    return textRect;
}
 
开发者ID:VRLoser,项目名称:greendao_expand,代码行数:27,代码来源:CircleProgressView.java

示例5: scaleRect

import android.graphics.RectF; //导入方法依赖的package包/类
/**
 * 缩放指定矩形
 * 
 * @param rect
 */
private static void scaleRect(RectF rect, float scaleX, float scaleY) {
	float w = rect.width();
	float h = rect.height();

	float newW = scaleX * w;
	float newH = scaleY * h;

	float dx = (newW - w) / 2;
	float dy = (newH - h) / 2;

	rect.left -= dx;
	rect.top -= dy;
	rect.right += dx;
	rect.bottom += dy;
}
 
开发者ID:viseator,项目名称:MontageCam,代码行数:21,代码来源:CropImageView.java

示例6: getCenter

import android.graphics.RectF; //导入方法依赖的package包/类
protected RectF getCenter(Matrix supportMatrix, boolean horizontal, boolean vertical) {
	final Drawable drawable = getDrawable();

	if (drawable == null)
		return new RectF(0, 0, 0, 0);

	mCenterRect.set(0, 0, 0, 0);
	RectF rect = getBitmapRect(supportMatrix);
	float height = rect.height();
	float width = rect.width();
	float deltaX = 0, deltaY = 0;
	if (vertical) {
		int viewHeight = mThisHeight;
		if (height < viewHeight) {
			deltaY = (viewHeight - height) / 2 - rect.top;
		} else if (rect.top > 0) {
			deltaY = -rect.top;
		} else if (rect.bottom < viewHeight) {
			deltaY = mThisHeight - rect.bottom;
		}
	}
	if (horizontal) {
		int viewWidth = mThisWidth;
		if (width < viewWidth) {
			deltaX = (viewWidth - width) / 2 - rect.left;
		} else if (rect.left > 0) {
			deltaX = -rect.left;
		} else if (rect.right < viewWidth) {
			deltaX = viewWidth - rect.right;
		}
	}
	mCenterRect.set(deltaX, deltaY, 0, 0);
	return mCenterRect;
}
 
开发者ID:junchenChow,项目名称:exciting-app,代码行数:35,代码来源:ImageViewTouchBase.java

示例7: checkBorderAndCenterWhenScale

import android.graphics.RectF; //导入方法依赖的package包/类
/**
 * 在缩放时,进行图片显示范围的控制
 */
private void checkBorderAndCenterWhenScale() {

        RectF rect = getMatrixRectF();
        float deltaX = 0;
        float deltaY = 0;

        int width = getWidth();
        int height = getHeight();

        // 如果宽或高大于屏幕,则控制范围
        if (rect.width() >= width) {
                if (rect.left > 0) {
                        deltaX = -rect.left;
                }
                if (rect.right < width) {
                        deltaX = width - rect.right;
                }
        }
        if (rect.height() >= height) {
                if (rect.top > 0) {
                        deltaY = -rect.top;
                }
                if (rect.bottom < height) {
                        deltaY = height - rect.bottom;
                }
        }
        // 如果宽或高小于屏幕,则让其居中
        if (rect.width() < width) {
                deltaX = width * 0.5f - rect.right + 0.5f * rect.width();
        }
        if (rect.height() < height) {
                deltaY = height * 0.5f - rect.bottom + 0.5f * rect.height();
        }
        Log.e(TAG, "deltaX = " + deltaX + " , deltaY = " + deltaY);

        mScaleMatrix.postTranslate(deltaX, deltaY);

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

示例8: setContentSize

import android.graphics.RectF; //导入方法依赖的package包/类
/**
 * Notifies the helper of the content size (be it a child View, a Bitmap, or whatever else).
 * This is needed for the helper to start working.
 *
 * @param rect the content rect
 */
public void setContentSize(RectF rect) {
    if (rect.width() <= 0 || rect.height() <= 0) return;
    if (!rect.equals(mContentBaseRect)) {
        init(mViewWidth, mViewHeight, rect);
    }
}
 
开发者ID:natario1,项目名称:ZoomLayout,代码行数:13,代码来源:ZoomEngine.java

示例9: limitTransAndScale

import android.graphics.RectF; //导入方法依赖的package包/类
/**
 * limits the maximum scale and X translation of the given matrix
 *
 * @param matrix
 */
public void limitTransAndScale(Matrix matrix, RectF content) {

    matrix.getValues(matrixBuffer);

    float curTransX = matrixBuffer[Matrix.MTRANS_X];
    float curScaleX = matrixBuffer[Matrix.MSCALE_X];

    float curTransY = matrixBuffer[Matrix.MTRANS_Y];
    float curScaleY = matrixBuffer[Matrix.MSCALE_Y];

    // min scale-x is 1f
    mScaleX = Math.min(Math.max(mMinScaleX, curScaleX), mMaxScaleX);

    // min scale-y is 1f
    mScaleY = Math.min(Math.max(mMinScaleY, curScaleY), mMaxScaleY);

    float width = 0f;
    float height = 0f;

    if (content != null) {
        width = content.width();
        height = content.height();
    }

    float maxTransX = -width * (mScaleX - 1f);
    mTransX = Math.min(Math.max(curTransX, maxTransX - mTransOffsetX), mTransOffsetX);

    float maxTransY = height * (mScaleY - 1f);
    mTransY = Math.max(Math.min(curTransY, maxTransY + mTransOffsetY), -mTransOffsetY);

    matrixBuffer[Matrix.MTRANS_X] = mTransX;
    matrixBuffer[Matrix.MSCALE_X] = mScaleX;

    matrixBuffer[Matrix.MTRANS_Y] = mTransY;
    matrixBuffer[Matrix.MSCALE_Y] = mScaleY;

    matrix.setValues(matrixBuffer);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:44,代码来源:ViewPortHandler.java

示例10: performStarSizeAssociatedCalculations

import android.graphics.RectF; //导入方法依赖的package包/类
/**
 * Performs auxiliary calculations to later speed up drawing phase.
 * @param width
 * @param height
 */
private void performStarSizeAssociatedCalculations(int width, int height) {
    float totalStarsWidth = calculateTotalWidth(currentStarSize, numberOfStars, starsSeparation, false);
    float totalStarsHeight = calculateTotalHeight(currentStarSize, numberOfStars, starsSeparation, false);
    float startingX = (width - getPaddingLeft() - getPaddingRight())/2 - totalStarsWidth/2 + getPaddingLeft();
    float startingY = (height - getPaddingTop() - getPaddingBottom())/2 - totalStarsHeight/2 + getPaddingTop();
    starsDrawingSpace = new RectF(startingX, startingY, startingX + totalStarsWidth, startingY + totalStarsHeight);
    float aux = starsDrawingSpace.width() * 0.05f;
    starsTouchSpace = new RectF(starsDrawingSpace.left - aux, starsDrawingSpace.top, starsDrawingSpace.right + aux, starsDrawingSpace.bottom);

    float bottomFromMargin = currentStarSize * 0.2f;
    float triangleSide = currentStarSize * 0.35f;
    float half = currentStarSize * 0.5f;
    float tipVerticalMargin = currentStarSize * 0.05f;
    float tipHorizontalMargin = currentStarSize * 0.03f;
    float innerUpHorizontalMargin = currentStarSize * 0.38f;
    float innerBottomHorizontalMargin = currentStarSize * 0.32f;
    float innerBottomVerticalMargin = currentStarSize * 0.55f;
    float innerCenterVerticalMargin = currentStarSize * 0.27f;

    starVertex = new float[] {
            tipHorizontalMargin, innerUpHorizontalMargin, // top left
            tipHorizontalMargin + triangleSide, innerUpHorizontalMargin, half, tipVerticalMargin, // top tip
            currentStarSize - tipHorizontalMargin - triangleSide, innerUpHorizontalMargin,
            currentStarSize - tipHorizontalMargin, innerUpHorizontalMargin, // top right
            currentStarSize - innerBottomHorizontalMargin, innerBottomVerticalMargin,
            currentStarSize - bottomFromMargin, currentStarSize - tipVerticalMargin, // bottom right
            half, currentStarSize - innerCenterVerticalMargin, bottomFromMargin, currentStarSize - tipVerticalMargin, // bottom left
            innerBottomHorizontalMargin, innerBottomVerticalMargin
    };
}
 
开发者ID:sega4revenge,项目名称:Sega,代码行数:36,代码来源:SimpleRatingBar.java

示例11: setRectToRect

import android.graphics.RectF; //导入方法依赖的package包/类
public static void setRectToRect(Matrix matrix, RectF src, RectF dst, int rotation, Matrix.ScaleToFit align) {
    float tx, sx;
    float ty, sy;
    if (rotation == 90 || rotation == 270) {
        sx = dst.height() / src.width();
        sy = dst.width() / src.height();
    } else {
        sx = dst.width() / src.width();
        sy = dst.height() / src.height();
    }
    if (align != Matrix.ScaleToFit.FILL) {
        if (sx > sy) {
            sx = sy;
        } else {
            sy = sx;
        }
    }
    tx = -src.left * sx;
    ty = -src.top * sy;

    matrix.setTranslate(dst.left, dst.top);
    if (rotation == 90) {
        matrix.preRotate(90);
        matrix.preTranslate(0, -dst.width());
    } else if (rotation == 180) {
        matrix.preRotate(180);
        matrix.preTranslate(-dst.width(), -dst.height());
    } else if (rotation == 270) {
        matrix.preRotate(270);
        matrix.preTranslate(-dst.height(), 0);
    }

    matrix.preScale(sx, sy);
    matrix.preTranslate(tx, ty);
}
 
开发者ID:pooyafaroka,项目名称:PlusGram,代码行数:36,代码来源:AndroidUtilities.java

示例12: forceUpdate

import android.graphics.RectF; //导入方法依赖的package包/类
public boolean forceUpdate() {
    Log.i(LOG_TAG, "forceUpdate");

    RectF cropRect = getCropRectF();
    RectF drawRect = getDrawRect();

    if (mEditableContent != null) {

        final float textWidth = mContent.getCurrentWidth();
        final float textHeight = mContent.getCurrentHeight();

        updateRatio();

        RectF textRect = new RectF(cropRect);
        getMatrix().mapRect(textRect);

        float dx = textWidth - textRect.width();
        float dy = textHeight - textRect.height();

        float[] fpoints = new float[] { dx, dy };

        Matrix rotateMatrix = new Matrix();
        rotateMatrix.postRotate(-mRotation);

        dx = fpoints[0];
        dy = fpoints[1];

        float xDelta = dx * (cropRect.width() / drawRect.width());
        float yDelta = dy * (cropRect.height() / drawRect.height());

        if (xDelta != 0 || yDelta != 0) {
            growBy(xDelta / 2, yDelta / 2, false);
        }

        invalidate();
        return true;
    }
    return false;
}
 
开发者ID:Sherchen,项目名称:AnimationsDemo,代码行数:40,代码来源:MyHighlightView.java

示例13: calculateRectTranslateMatrix

import android.graphics.RectF; //导入方法依赖的package包/类
/**
 * 计算两个矩形之间的变换矩阵
 *
 * unknownMatrix.mapRect(to, from)
 * 已知from矩形和to矩形,求unknownMatrix
 *
 * @param from
 * @param to
 * @param result unknownMatrix
 */
public static void calculateRectTranslateMatrix(RectF from, RectF to, Matrix result) {
    if (from == null || to == null || result == null) {
        return;
    }
    if (from.width() == 0 || from.height() == 0) {
        return;
    }
    result.reset();
    result.postTranslate(-from.left, -from.top);
    result.postScale(to.width() / from.width(), to.height() / from.height());
    result.postTranslate(to.left, to.top);
}
 
开发者ID:WeGdufe,项目名称:MovingGdufe-Android,代码行数:23,代码来源:PinchImageView.java

示例14: onDraw

import android.graphics.RectF; //导入方法依赖的package包/类
@Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        paintText.setColor(textColor);
        paintRectF.setColor(bgColor);
        paintPro.setColor(proColor);

        RectF mRectF = new RectF();                           //RectF对象
        mRectF.left = mPadding + mSpac;
        mRectF.top = mPadding;
        mRectF.right = getMeasuredWidth() - mPadding - mSpac;
        mRectF.bottom = getMeasuredHeight() - mPadding;
        mRadius = (getMeasuredHeight() - 2 * mPadding) / 2;

        canvas.drawRoundRect(mRectF, mRadius, mRadius, paintRectF);

        if (mRectF.width() == mRectF.height() && !mStop) {
            setClickable(true);
            RectF mRectFPro = new RectF();
            mRectFPro.left = getMeasuredWidth() / 2.0f - mRectF.width() / 4;
            mRectFPro.top = getMeasuredHeight() / 2.0f - mRectF.width() / 4;
            mRectFPro.right = getMeasuredWidth() / 2.0f + mRectF.width() / 4;
            mRectFPro.bottom = getMeasuredHeight() / 2.0f + mRectF.width() / 4;
            canvas.drawArc(mRectFPro, startAngle, 100, false, paintPro);
        }

        if (mSpac < (getMeasuredWidth() - getMeasuredHeight()) / 2.0f) {

//        if (mRectF.width() > getFontlength(paintText, text)) {
            canvas.drawText(text,
                    getMeasuredWidth() / 2.0f - getFontlength(paintText, text) / 2.0f,
                    getMeasuredHeight() / 2.0f + getFontHeight(paintText, text) / 3.0f,
                    paintText);
//        }
        }

    }
 
开发者ID:li-yu,项目名称:Huahui-Android,代码行数:38,代码来源:ProgressButton.java

示例15: onSingleTapConfirmed

import android.graphics.RectF; //导入方法依赖的package包/类
@Override
public boolean onSingleTapConfirmed(MotionEvent e) {
    if (this.photoViewAttacher == null)
        return false;
    try {
        ImageView imageView = photoViewAttacher.getImageView();

        if (null != photoViewAttacher.getOnPhotoTapListener()) {
            final RectF displayRect = photoViewAttacher.getDisplayRect();

            if (null != displayRect) {
                final float x = e.getX(), y = e.getY();

                // Check to see if the user tapped on the photo
                if (displayRect.contains(x, y)) {

                    float xResult = (x - displayRect.left)
                            / displayRect.width();
                    float yResult = (y - displayRect.top)
                            / displayRect.height();

                    photoViewAttacher.getOnPhotoTapListener().onPhotoTap(imageView, xResult, yResult);
                    return true;
                }
            }
        }
        if (null != photoViewAttacher.getOnViewTapListener()) {
            photoViewAttacher.getOnViewTapListener().onViewTap(imageView, e.getX(), e.getY());
        }
    }catch ( Exception e1){}
    return false;
}
 
开发者ID:yun2win,项目名称:tvConnect_android,代码行数:33,代码来源:DefaultOnDoubleTapListener.java


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