Example usage for android.graphics RectF RectF

List of usage examples for android.graphics RectF RectF

Introduction

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

Prototype

public RectF() 

Source Link

Document

Create a new empty RectF.

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

/**
 * Creates a simple region from the given path.
 *
 * @param path given path/*  www.j ava 2  s  .  co m*/
 * @return region object
 */
public static Region createRegionFromPath(Path path) {
    Region region = new Region();
    if (path != null) {
        RectF box = new RectF();
        path.computeBounds(box, true);
        region.setPath(path, new Region((int) box.left, (int) box.top, (int) box.right, (int) box.bottom));
    }
    return region;
}

From source file:Main.java

public static boolean setImageToScreenMatrix(Matrix dst, RectF image, RectF screen, int rotation) {
    RectF rotatedImage = new RectF();
    dst.setRotate(rotation, image.centerX(), image.centerY());
    if (!dst.mapRect(rotatedImage, image)) {
        return false; // fails for rotations that are not multiples of 90
                      // degrees
    }// w  w  w  .  ja  va2s .  c o  m
    boolean rToR = dst.setRectToRect(rotatedImage, screen, Matrix.ScaleToFit.CENTER);
    boolean rot = dst.preRotate(rotation, image.centerX(), image.centerY());
    return rToR && rot;
}

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);/*from w  ww . ja  v  a  2 s . c  o  m*/
    canvas.drawRect(r, p);
    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:Main.java

static void offsetDescendantRect(ViewGroup group, View child, Rect rect) {
    Matrix m = sMatrix.get();/*from w w  w .j  ava  2s  .  co m*/
    if (m == null) {
        m = new Matrix();
        sMatrix.set(m);
    } else {
        m.set(IDENTITY);
    }

    offsetDescendantMatrix(group, child, m);

    RectF rectF = sRectF.get();
    if (rectF == null) {
        rectF = new RectF();
    }
    rectF.set(rect);
    m.mapRect(rectF);
    rect.set((int) (rectF.left + 0.5f), (int) (rectF.top + 0.5f), (int) (rectF.right + 0.5f),
            (int) (rectF.bottom + 0.5f));
}

From source file:Main.java

public static void offsetDescendantRect(ViewGroup group, View child, Rect rect) {
    Matrix m = sMatrix.get();//  w w w  .  j a va2 s . com
    if (m == null) {
        m = new Matrix();
        sMatrix.set(m);
    } else {
        m.reset();
    }

    offsetDescendantMatrix(group, child, m);

    RectF rectF = sRectF.get();
    if (rectF == null) {
        rectF = new RectF();
        sRectF.set(rectF);
    }
    rectF.set(rect);
    m.mapRect(rectF);
    rect.set((int) (rectF.left + 0.5f), (int) (rectF.top + 0.5f), (int) (rectF.right + 0.5f),
            (int) (rectF.bottom + 0.5f));
}

From source file:Main.java

public static void offsetDescendantRect(ViewGroup group, View child, Rect rect) {
    Matrix m = sMatrix.get();//from   w  ww  . j av  a  2s. c  om
    if (m == null) {
        m = new Matrix();
        sMatrix.set(m);
    } else {
        m.set(IDENTITY);
    }

    offsetDescendantMatrix(group, child, m);

    RectF rectF = sRectF.get();
    if (rectF == null) {
        rectF = new RectF();
    }
    rectF.set(rect);
    m.mapRect(rectF);
    rect.set((int) (rectF.left + 0.5f), (int) (rectF.top + 0.5f), (int) (rectF.right + 0.5f),
            (int) (rectF.bottom + 0.5f));
}

From source file:org.mariotaku.twidere.text.OriginalStatusSpan.java

public OriginalStatusSpan(Context context) {
    mBounds = new RectF();
    mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mDarkLightColors = new int[2];
    final float density = context.getResources().getDisplayMetrics().density;
    mCornerRadius = density * 2;//w  w w . ja v a2  s  .c  o  m
    mPaint.setStrokeWidth(density);
    mPadding = (int) (density * 4);
    ThemeUtils.getDarkLightForegroundColors(context, mDarkLightColors);
}

From source file:com.tr4android.support.extension.widget.CollapsingDrawableHelper.java

public CollapsingDrawableHelper(View view) {
    mView = view;//from  w  w w  .  ja  v  a2  s  . c  o  m

    mCollapsedBounds = new Rect();
    mExpandedBounds = new Rect();
    mCurrentBounds = new RectF();
}

From source file:com.efunds.moa.component.customview.process.AnnularView.java

private void init(Context context) {
    mWhitePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mWhitePaint.setStyle(Paint.Style.STROKE);
    mWhitePaint.setStrokeWidth(Helper.dpToPixel(3, getContext()));
    mWhitePaint.setColor(Color.WHITE);

    mGreyPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mGreyPaint.setStyle(Paint.Style.STROKE);
    mGreyPaint.setStrokeWidth(Helper.dpToPixel(3, getContext()));
    mGreyPaint.setColor(ContextCompat.getColor(context, R.color.progress_default_color));

    mBound = new RectF();
}