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(Rect r) 

Source Link

Usage

From source file:com.benefit.buy.library.http.query.callback.BitmapAjaxCallback.java

private static Bitmap getRoundedCornerBitmap(Bitmap bitmap, int pixels) {
    Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Config.ARGB_8888);
    Canvas canvas = new Canvas(output);
    final int color = 0xff424242;
    final Paint paint = new Paint();
    final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());
    final RectF rectF = new RectF(rect);
    final float roundPx = pixels;
    paint.setAntiAlias(true);/*from www .  j a va 2s  .  c  om*/
    canvas.drawARGB(0, 0, 0, 0);
    paint.setColor(color);
    canvas.drawRoundRect(rectF, roundPx, roundPx, paint);
    paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));
    canvas.drawBitmap(bitmap, rect, rect, paint);
    return output;
}

From source file:com.appbase.androidquery.callback.BitmapAjaxCallback.java

private static Bitmap getRoundedCornerBitmap(Bitmap bitmap, int pixels) {

    Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Config.ARGB_8888);
    Canvas canvas = new Canvas(output);

    final int color = 0xff424242;
    final Paint paint = new Paint();
    final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());
    final RectF rectF = new RectF(rect);
    final float roundPx = pixels;

    paint.setAntiAlias(true);/*from w ww  . j  av a 2  s . c o  m*/
    canvas.drawARGB(0, 0, 0, 0);
    paint.setColor(color);
    canvas.drawRoundRect(rectF, roundPx, roundPx, paint);

    paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));
    canvas.drawBitmap(bitmap, rect, rect, paint);

    return output;
}

From source file:com.android.gallery3d.filtershow.imageshow.ImageShow.java

private void constrainTranslation(Point translation, float scale) {
    int currentEdgeEffect = 0;
    if (scale <= 1) {
        mCurrentEdgeEffect = 0;/*from  w ww .ja v a 2 s.com*/
        mEdgeEffect.finish();
        return;
    }

    Matrix originalToScreen = MasterImage.getImage().originalImageToScreen();
    Rect originalBounds = MasterImage.getImage().getOriginalBounds();
    RectF screenPos = new RectF(originalBounds);
    originalToScreen.mapRect(screenPos);

    boolean rightConstraint = screenPos.right < getWidth() - mShadowMargin;
    boolean leftConstraint = screenPos.left > mShadowMargin;
    boolean topConstraint = screenPos.top > mShadowMargin;
    boolean bottomConstraint = screenPos.bottom < getHeight() - mShadowMargin;

    if (screenPos.width() > getWidth()) {
        if (rightConstraint && !leftConstraint) {
            float tx = screenPos.right - translation.x * scale;
            translation.x = (int) ((getWidth() - mShadowMargin - tx) / scale);
            currentEdgeEffect = EDGE_RIGHT;
        } else if (leftConstraint && !rightConstraint) {
            float tx = screenPos.left - translation.x * scale;
            translation.x = (int) ((mShadowMargin - tx) / scale);
            currentEdgeEffect = EDGE_LEFT;
        }
    } else {
        float tx = screenPos.right - translation.x * scale;
        float dx = (getWidth() - 2 * mShadowMargin - screenPos.width()) / 2f;
        translation.x = (int) ((getWidth() - mShadowMargin - tx - dx) / scale);
    }

    if (screenPos.height() > getHeight()) {
        if (bottomConstraint && !topConstraint) {
            float ty = screenPos.bottom - translation.y * scale;
            translation.y = (int) ((getHeight() - mShadowMargin - ty) / scale);
            currentEdgeEffect = EDGE_BOTTOM;
        } else if (topConstraint && !bottomConstraint) {
            float ty = screenPos.top - translation.y * scale;
            translation.y = (int) ((mShadowMargin - ty) / scale);
            currentEdgeEffect = EDGE_TOP;
        }
    } else {
        float ty = screenPos.bottom - translation.y * scale;
        float dy = (getHeight() - 2 * mShadowMargin - screenPos.height()) / 2f;
        translation.y = (int) ((getHeight() - mShadowMargin - ty - dy) / scale);
    }

    if (mCurrentEdgeEffect != currentEdgeEffect) {
        if (mCurrentEdgeEffect == 0 || currentEdgeEffect != 0) {
            mCurrentEdgeEffect = currentEdgeEffect;
            mEdgeEffect.finish();
        }
        mEdgeEffect.setSize(getWidth(), mEdgeSize);
    }
    if (currentEdgeEffect != 0) {
        mEdgeEffect.onPull(mEdgeSize);
    }
}

From source file:com.undatech.opaque.RemoteCanvas.java

/**
 * Moves soft cursor into a particular location.
 * @param x//from ww  w  . ja  v a  2  s. com
 * @param y
 */

synchronized void softCursorMove(int x, int y) {
    if (myDrawable.isNotInitSoftCursor()) {
        initializeSoftCursor();
    }

    if (!cursorBeingMoved) {
        pointer.setX(x);
        pointer.setY(y);
        RectF prevR = new RectF(myDrawable.getCursorRect());
        // Move the cursor.
        myDrawable.moveCursorRect(x, y);
        // Show the cursor.
        RectF r = myDrawable.getCursorRect();
        reDraw(r.left, r.top, r.width(), r.height());
        reDraw(prevR.left, prevR.top, prevR.width(), prevR.height());
    }
}

From source file:cn.androidy.androiddevelopmentpatterns.interactivechart.InteractiveLineGraphView.java

/**
 * Returns the current viewport (visible extremes for the chart domain and range.)
 */
public RectF getCurrentViewport() {
    return new RectF(mCurrentViewport);
}

From source file:com.iiordanov.bVNC.RemoteCanvas.java

/**
 * Moves soft cursor into a particular location.
 * @param x/*w w  w  . j  ava  2 s.c o  m*/
 * @param y
 */
synchronized void softCursorMove(int x, int y) {
    if (bitmapData.isNotInitSoftCursor()) {
        initializeSoftCursor();
    }

    if (!inScrolling) {
        pointer.setX(x);
        pointer.setY(y);
        RectF prevR = new RectF(bitmapData.getCursorRect());
        // Move the cursor.
        bitmapData.moveCursorRect(x, y);
        // Show the cursor.
        RectF r = bitmapData.getCursorRect();
        reDraw(r.left, r.top, r.width(), r.height());
        reDraw(prevR.left, prevR.top, prevR.width(), prevR.height());
    }
}