Example usage for android.graphics RectF set

List of usage examples for android.graphics RectF set

Introduction

In this page you can find the example usage for android.graphics RectF set.

Prototype

public void set(float left, float top, float right, float bottom) 

Source Link

Document

Set the rectangle's coordinates to the specified values.

Usage

From source file:Main.java

public static Rect getBitmapRect(PointF center, float radius) {
    RectF rectF = new RectF();
    rectF.set(center.x - radius, center.y - radius, center.x + radius, center.y + radius);
    return rectF2Rect(rectF);
}

From source file:Main.java

public static void drawShade(Canvas canvas, RectF bounds) {
    int w = canvas.getWidth();
    int h = canvas.getHeight();
    Paint p = new Paint();
    p.setStyle(Paint.Style.FILL);
    p.setColor(Color.BLACK & 0x88000000);

    RectF r = new RectF();
    r.set(0, 0, w, bounds.top);
    canvas.drawRect(r, p);// ww w.j  a v  a 2  s  .  c o  m
    r.set(0, bounds.top, bounds.left, h);
    canvas.drawRect(r, p);
    r.set(bounds.left, bounds.bottom, w, h);
    canvas.drawRect(r, p);
    r.set(bounds.right, bounds.top, w, bounds.bottom);
    canvas.drawRect(r, p);
}

From source file:com.android.screenspeak.contextmenu.RadialMenuView.java

@SuppressWarnings("SuspiciousNameCombination")
private static void createBounds(RectF target, int diameter, int radius) {
    final float center = (diameter / 2.0f);
    final float left = (center - radius);
    final float right = (center + radius);

    target.set(left, left, right, right);
}

From source file:com.googlecode.eyesfree.widget.RadialMenuView.java

private static void createBounds(RectF target, int diameter, int radius) {
    final float center = (diameter / 2.0f);
    final float left = (center - radius);
    final float right = (center + radius);

    target.set(left, left, right, right);
}

From source file:com.raspi.chatapp.util.Notification.java

private Bitmap getLargeIcon(int bgColor, char letter, float width, boolean round) {
    Bitmap b = Bitmap.createBitmap((int) width, (int) width, Bitmap.Config.ARGB_8888);
    Canvas c = new Canvas(b);

    RectF mInnerRectF = new RectF();
    mInnerRectF.set(0, 0, width, width);
    mInnerRectF.offset(0, 0);//from ww  w. jav  a  2s  .com

    Paint mBgPaint = new Paint();
    mBgPaint.setFlags(Paint.ANTI_ALIAS_FLAG);
    mBgPaint.setStyle(Paint.Style.FILL);
    mBgPaint.setColor(bgColor);

    TextPaint mTitleTextPaint = new TextPaint();
    mTitleTextPaint.setFlags(Paint.ANTI_ALIAS_FLAG);
    mTitleTextPaint.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
    mTitleTextPaint.setTextAlign(Paint.Align.CENTER);
    mTitleTextPaint.setLinearText(true);
    mTitleTextPaint.setColor(Color.WHITE);
    mTitleTextPaint.setTextSize(width * 0.8f);

    float centerX = mInnerRectF.centerX();
    float centerY = mInnerRectF.centerY();

    int xPos = (int) centerX;
    int yPos = (int) (centerY - (mTitleTextPaint.descent() + mTitleTextPaint.ascent()) / 2);

    if (round)
        c.drawOval(mInnerRectF, mBgPaint);
    else
        c.drawRect(mInnerRectF, mBgPaint);
    c.drawText(String.valueOf(letter), xPos, yPos, mTitleTextPaint);

    return b;
}

From source file:com.grepsound.fragments.MyProfileFragment.java

private RectF getOnScreenRect(RectF rect, View view) {
    rect.set(view.getLeft(), view.getTop(), view.getRight(), view.getBottom());
    return rect;
}

From source file:ca.mymenuapp.ui.activities.RestaurantActivity.java

/**
 * Get the position of the view into the given RectF.
 */// www . j a  v  a 2 s .c o m
private RectF getOnScreenRect(RectF rect, View view) {
    rect.set(view.getLeft(), view.getTop(), view.getRight(), view.getBottom());
    return rect;
}

From source file:com.apptentive.android.sdk.util.image.PreviewImageView.java

/**
 * Get image boundary from matrix/* ww  w.j a v a 2 s. c  o  m*/
 *
 * @return
 */
private RectF getMatrixRectF() {
    Matrix matrix = scaleMatrix;
    RectF rect = new RectF();
    Drawable d = getDrawable();
    if (null != d) {
        rect.set(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight());
        matrix.mapRect(rect);
    }
    return rect;
}

From source file:com.actionbarsherlock.internal.nineoldandroids.view.animation.AnimatorProxy.java

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
    r.set(0, 0, w, h);

    final Matrix m = mTempMatrix;
    m.reset();//  ww w  .j  ava  2s .  co m
    transformMatrix(m, view);
    mTempMatrix.mapRect(r);

    r.offset(view.getLeft(), view.getTop());

    // Straighten coords if rotations flipped them
    if (r.right < r.left) {
        final float f = r.right;
        r.right = r.left;
        r.left = f;
    }
    if (r.bottom < r.top) {
        final float f = r.top;
        r.top = r.bottom;
        r.bottom = f;
    }
}

From source file:net.networksaremadeofstring.rhybudd.RhybuddDock.java

private void drawScale(Canvas canvas, Boolean Colors, int Count, int Max) {
    RectF faceRect = new RectF();
    faceRect.set(10, 10, 190, 190);

    Paint scalePaint = new Paint();
    scalePaint.setStyle(Paint.Style.STROKE);
    scalePaint.setColor(getResources().getColor(R.color.WarningGreen));
    scalePaint.setStrokeWidth(1);/*  w  ww.  j  a  va  2s .c o m*/
    scalePaint.setAntiAlias(true);

    scalePaint.setTextSize(12);
    scalePaint.setTypeface(Typeface.createFromAsset(this.getAssets(), "fonts/chivo.ttf"));
    scalePaint.setTextAlign(Paint.Align.CENTER);

    float scalePosition = 10;
    RectF scaleRect = new RectF();
    scaleRect.set(faceRect.left + scalePosition, faceRect.top + scalePosition, faceRect.right - scalePosition,
            faceRect.bottom - scalePosition);

    if (!Colors)
        scalePaint.setColor(Color.WHITE);

    scalePaint.setStrokeWidth(2);
    canvas.save(Canvas.MATRIX_SAVE_FLAG);
    for (int i = 0; i < Max; ++i) {
        if (Colors) {
            if (i > 20)
                scalePaint.setColor(getResources().getColor(R.color.WarningYellow));

            if (i > 40)
                scalePaint.setColor(getResources().getColor(R.color.WarningOrange));

            if (i > 60)
                scalePaint.setColor(getResources().getColor(R.color.WarningRed));
        }

        canvas.drawLine(100, 20, 100, 18, scalePaint);
        int divisor = 5;

        if (Max > 100)
            divisor = 25;

        if (i % divisor == 0) {
            canvas.drawText(Integer.toString(i), 100, 16, scalePaint);
        }

        canvas.rotate((360.0f / Max), 100, 100);
    }

    canvas.restore();
}