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(float left, float top, float right, float bottom) 

Source Link

Document

Create a new rectangle with the specified coordinates.

Usage

From source file:Main.java

public static RectF getReduceRectF(RectF aRectF, int aReduceSize) {
    RectF rectF = new RectF(aRectF.left + aReduceSize, aRectF.top + aReduceSize, aRectF.right - aReduceSize,
            aRectF.bottom - aReduceSize);
    return rectF;
}

From source file:Main.java

public static Path addRoundPath3(int width, int height, float radius) {
    Path path = new Path();
    path.addRoundRect(new RectF(0, 0, width, height), radius, radius, Path.Direction.CW);
    return path;// www  .j a  v a  2s  . co m
}

From source file:Main.java

public static RectF zoom(final RectF rect, final float zoom) {
    return new RectF(zoom * rect.left, zoom * rect.top, zoom * rect.right, zoom * rect.bottom);
}

From source file:Main.java

public static RectF trapToRect(float[] array) {
    RectF r = new RectF(Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY, Float.NEGATIVE_INFINITY,
            Float.NEGATIVE_INFINITY);
    for (int i = 1; i < array.length; i += 2) {
        float x = round(array[i - 1] * 10) / 10.f;
        float y = round(array[i] * 10) / 10.f;
        r.left = (x < r.left) ? x : r.left;
        r.top = (y < r.top) ? y : r.top;
        r.right = (x > r.right) ? x : r.right;
        r.bottom = (y > r.bottom) ? y : r.bottom;
    }/*w w w .  ja  v  a2  s  . c o  m*/
    r.sort();
    return r;
}

From source file:Main.java

public static RectF createBaseRect(RectF graphRect, RectF marginRect) {
    Log.d("GammaGraph", "function createDrawRect");
    return new RectF(graphRect.left + marginRect.left, graphRect.top + marginRect.top, graphRect.right,
            graphRect.bottom);//from   www . j av  a2  s  . c  o  m
}

From source file:Main.java

public static RectF getRectWithPadding(float paddingLeft, float paddingTop, float paddingRight,
        float paddingBottom, int screenW, int screenH) {
    RectF rect = new RectF(paddingLeft, paddingTop, screenW - paddingRight, screenH - paddingBottom);
    return rect;// w w w.j av  a 2  s  . c  om
}

From source file:Main.java

public static RectF toRectF(String flattened) {
    float[] bounds = new float[4];
    String[] strings = flattened.split(" ");
    for (int i = 0; i < 4; i++)
        bounds[i] = Float.parseFloat(strings[i]);
    return new RectF(bounds[0], bounds[1], bounds[2], bounds[3]);
}

From source file:Main.java

private static void drawAndroidBody(Canvas canvas, Paint paint, float w, float h) {
    paint.setColor(Color.parseColor("#43A047"));
    canvas.drawRoundRect(new RectF(-w / 2, 0, w / 2, h), w / 10, w / 10, paint);
}

From source file:Main.java

/**
 * Creates square based on circle.//from  ww w. j a v a 2s  . c  o m
 *
 * @param centerX x of center point
 * @param centerY y of center point
 * @param radius  radius
 * @return square object
 */
public static RectF createSquare(float centerX, float centerY, float radius) {
    return new RectF(centerX - radius, centerY - radius, centerX + radius, centerY + radius);
}

From source file:Main.java

/**
 * Takes an array of 2D coordinates representing corners and returns the
 * smallest rectangle containing those coordinates.
 *
 * @param array array of 2D coordinates//from w  w w  .  ja  v  a 2 s.  c o m
 * @return smallest rectangle containing coordinates
 */
public static RectF trapToRect(float[] array) {
    RectF r = new RectF(Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY, Float.NEGATIVE_INFINITY,
            Float.NEGATIVE_INFINITY);
    for (int i = 1; i < array.length; i += 2) {
        float x = array[i - 1];
        float y = array[i];
        r.left = (x < r.left) ? x : r.left;
        r.top = (y < r.top) ? y : r.top;
        r.right = (x > r.right) ? x : r.right;
        r.bottom = (y > r.bottom) ? y : r.bottom;
    }
    r.sort();
    return r;
}