Android RectF - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android RectF class.

This code example shows how to use the following methods:height, inset, offset, width
		} 
 
		// Don't let the cropping rectangle grow too fast. 
		// Grow at most half of the difference between the image rectangle and 
		// the cropping rectangle. 
		RectF r = new RectF(mCropRect);
		if (dx > 0F && r.width() + 2 * dx > mImageRect.width()) {
			float adjustment = (mImageRect.width() - r.width()) / 2F;
			dx = adjustment;
			if (mMaintainAspectRatio) {
				dy = dx / mInitialAspectRatio;
			} 
		} 
		if (dy > 0F && r.height() + 2 * dy > mImageRect.height()) {
			float adjustment = (mImageRect.height() - r.height()) / 2F;
			dy = adjustment;
			if (mMaintainAspectRatio) {
				dx = dy * mInitialAspectRatio;
			} 
		} 

8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
	private int alpha = NOT_SET;
 
	public TiBackgroundDrawable() 
	{ 
		background = new ColorDrawable(Color.TRANSPARENT);
		innerRect = new RectF();
	} 
 
	@Override 
	public void draw(Canvas canvas)
	{ 
		if (background != null) {
			background.setBounds((int) innerRect.left, (int) innerRect.top, (int) innerRect.right, (int) innerRect.bottom);
		} 
 
		canvas.save();
 
		if (background != null) {
			if (alpha > NOT_SET) {
				background.setAlpha(alpha);
8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
                canvas.getClipBounds().bottom);
 
        Matrix matrix = new Matrix();
        matrix.setRectToRect(new RectF(0, 0, canvas.getClipBounds().right,
                    canvas.getClipBounds().bottom),
                new RectF(strokeWidth/2, strokeWidth/2, canvas.getClipBounds().right - strokeWidth/2,
                        canvas.getClipBounds().bottom - strokeWidth/2),
                Matrix.ScaleToFit.FILL);
        canvas.concat(matrix);
 
        shape.draw(canvas, fillpaint);
        shape.draw(canvas, strokepaint);
    } 
 
    public static StateListDrawable customButton(int tl, int tr, int br, int bl, int onColor, int offColor, int borderColor, int strokeWidth) {
        Shape shape = new RoundRectShape(new float[] { tl, tl, tr, tr, br, br, bl, bl}, null, null);
        ShapeDrawable sdOn = new CustomBorderDrawable(shape, onColor, borderColor, strokeWidth);
        ShapeDrawable sdOff = new CustomBorderDrawable(shape, offColor, borderColor, strokeWidth);
 
        StateListDrawable stld = new StateListDrawable();
8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:height, width
		 
		return retval;
	} 
	 
	public static Bitmap rotateBitmap(Bitmap input, int degrees) {
		RectF srcRect = new RectF(0, 0, input.getWidth(), input.getHeight());
		Matrix matrix = new Matrix();
		matrix.setRotate(degrees);
		matrix.mapRect(srcRect);
		matrix.postTranslate(0 - srcRect.left, 0 - srcRect.top);
		 
		Bitmap targetBitmap = Bitmap.createBitmap(Math.round(srcRect.width()), Math.round(srcRect.height()), Bitmap.Config.RGB_565);
		Canvas canvas = new Canvas(targetBitmap);
		canvas.drawBitmap(input, matrix, new Paint());
		return targetBitmap;
	} 
	 
	public static Bitmap downsampleBitmap(FileDescriptor fd, int maxArea) {
		BitmapFactory.Options opts = new BitmapFactory.Options();
		opts.inJustDecodeBounds = true;
8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:height, set, width
    @Override 
    protected void onSizeChanged(int w, int h, int oldw, int oldh) {
        float bitmapWidth = w - 2 * mPadding;
        float bitmapHeight = h - 2 * mPadding;
        float radius = Math.min(bitmapWidth / 2, bitmapHeight / 2);
        mRect.set(0, 0, bitmapWidth, bitmapHeight);
        radius *= INNER_RADIUS_RATIO;
        mRectInner.set(bitmapWidth / 2f - radius, bitmapHeight / 2f - radius, bitmapWidth / 2f + radius, bitmapHeight / 2f + radius);
        updateBitmap(); 
    } 
 
    /** 
     * Set the foreground color for this indicator. The foreground is the part 
     * of the indicator that shows the actual progress 
     */ 
    public void setForegroundColor(int color) {
        this.mColorForeground = color;
        mPaintForeground.setColor(color);
        invalidate();
    } 

8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:offset, set, union
            return; 
        } 
 
        final RectF after = mAfter;
        computeRect(after, view);
        after.union(mBefore);
 
        ((View)view.getParent()).invalidate(
                (int) Math.floor(after.left),
                (int) Math.floor(after.top),
                (int) Math.ceil(after.right),
                (int) Math.ceil(after.bottom));
    } 
 
    private void computeRect(final RectF r, View view) {
        // compute current rectangle according to matrix transformation 
        final float w = view.getWidth();
        final float h = view.getHeight();
 
        // use a rectangle at 0,0 to make sure we don't run into issues with scaling 

8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
This code example shows how to use the following methods:height, width
     * 横向、纵向居中 
     */ 
    protected void center(boolean horizontal, boolean vertical) {
        Matrix m = new Matrix();
        m.set(matrix);
        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;
 
        if (vertical) {
            // 图片小于屏幕大小,则居中显示。大于屏幕,上方留空则往上移,下方留空则往下移 
            int screenHeight = dm.heightPixels;
            if (height < screenHeight) {
                deltaY = (screenHeight - height) / 2 - rect.top;
            } else if (rect.top > 0) {
                deltaY = -rect.top;
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:mapRect, inset, offset, set
This code example shows how to use the following methods:height, set, width
    /** 
     * Sets cropped bounds; modifies the bounds if it's smaller than the allowed dimensions. 
     */ 
    public void setCropBounds(RectF bounds) {
        // Avoid cropping smaller than minimum width or height. 
        if (bounds.width() * getPhotoWidth() < MIN_CROP_WIDTH_HEIGHT) {
            bounds.set(0, bounds.top, 1, bounds.bottom);
        } 
        if (bounds.height() * getPhotoHeight() < MIN_CROP_WIDTH_HEIGHT) {
            bounds.set(bounds.left, 0, bounds.right, 1);
        } 
        cropBounds.set(bounds);
        refreshByCropChange(false); 
    } 
 
    private RectF getCropBoundsDisplayed() {
        float width = displayBounds.width();
        float height = displayBounds.height();
        RectF cropped = new RectF(cropBounds.left * width, cropBounds.top * height,
                cropBounds.right * width, cropBounds.bottom * height);
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java

Related Android RectF Questions & Answers:

See Code Examples for Android RectF Methods: