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:org.appcelerator.titanium.util.TiUIHelper.java

public static RectF insetRect(final RectF source, final RectF inset) {
    if (inset == null)
        return source;
    return new RectF(source.left + inset.left, source.top + inset.top, source.right - inset.right,
            source.bottom - inset.bottom);
}

From source file:org.appcelerator.titanium.util.TiUIHelper.java

public static RectF insetRect(final RectF source, final float inset) {
    if (inset == 0.0)
        return source;
    return new RectF(source.left + inset, source.top + inset, source.right - inset, source.bottom - inset);
}

From source file:com.bizcom.vc.widget.cus.SubsamplingScaleImageView.java

/**
 * Convert source rect to screen rect.//w  ww  . j  av a  2  s. c  o m
 */
private RectF sourceToViewRect(RectF sRect) {
    PointF vLT = sourceToViewCoord(new PointF(sRect.left, sRect.top));
    PointF vRB = sourceToViewCoord(new PointF(sRect.right, sRect.bottom));
    return new RectF(vLT.x, vLT.y, vRB.x, vRB.y);
}

From source file:com.bizcom.vc.widget.cus.SubsamplingScaleImageView.java

/**
 * Convert screen rect to source rect.//from ww w . ja  v  a 2s .c  o  m
 */
private RectF viewToSourceRect(RectF vRect) {
    PointF sLT = viewToSourceCoord(new PointF(vRect.left, vRect.top));
    PointF sRB = viewToSourceCoord(new PointF(vRect.right, vRect.bottom));
    return new RectF(sLT.x, sLT.y, sRB.x, sRB.y);
}

From source file:com.bizcom.vc.widget.cus.SubsamplingScaleImageView.java

/**
 * Int to float rect conversion.
 */
private RectF convertRect(Rect rect) {
    return new RectF(rect.left, rect.top, rect.right, rect.bottom);
}

From source file:com.skytree.epubtest.BookViewActivity.java

@SuppressLint({ "DrawAllocation", "DrawAllocation" })
@Override/*from w  w w .  java 2  s  .c o m*/
protected void onDraw(Canvas canvas) {
    Paint paint = new Paint();

    float sl, sr, st, sb;
    sl = 0;
    sr = this.getWidth();
    float ah = this.arrowHeight; // arrow Height;
    if (this.isArrowDown) {
        st = 0;
        sb = this.getHeight() - ah;
    } else {
        st = ah - 10;
        sb = this.getHeight() - 10;
    }

    Path boxPath = new Path();
    boxPath.addRoundRect(new RectF(sl, st, sr, sb), 20, 20, Path.Direction.CW);

    if (arrowPosition <= arrowHeight * 1.5f) {
        arrowPosition = arrowHeight * 1.5f;
    } else if (arrowPosition >= this.getWidth() - arrowHeight * 1.5f) {
        arrowPosition = this.getWidth() - arrowHeight * 1.5f;
    }

    Path arrowPath = new Path();
    if (isArrowDown) {
        arrowPath.moveTo(arrowPosition, sb + ah);
        arrowPath.lineTo((float) (arrowPosition - ah * 0.75), sb - 10);
        arrowPath.lineTo((float) (arrowPosition + ah * 0.75), sb - 10);
        arrowPath.close();
    } else {
        arrowPath.moveTo(arrowPosition, 0);
        arrowPath.lineTo((float) (arrowPosition - ah * 0.75), ah + 10);
        arrowPath.lineTo((float) (arrowPosition + ah * 0.75), ah + 10);
        arrowPath.close();
    }

    paint.setColor(this.strokeColor);
    paint.setStyle(Paint.Style.FILL);
    boxPath.addPath(arrowPath);
    canvas.drawPath(boxPath, paint);

    paint.setColor(this.boxColor);
    paint.setStyle(Paint.Style.FILL);
    boxPath.addPath(arrowPath);
    canvas.save();
    float sf = 0.995f;
    float ox = (this.getWidth() - (this.getWidth() * sf)) / 2.0f;
    float oy = ((this.getHeight() - arrowHeight) - ((this.getHeight() - arrowHeight) * sf)) / 2.0f;

    canvas.translate(ox, oy);
    canvas.scale(sf, sf);
    canvas.drawPath(boxPath, paint);
    canvas.restore();

    if (layoutChanged) {
        this.recalcLayout();
        layoutChanged = false;
    }
}

From source file:com.cognizant.trumobi.PersonaLauncher.java

protected void editWidget(final View widget) {
    if (mWorkspace != null) {
        mIsWidgetEditMode = true;/* w w  w.j ava2s . c o  m*/
        final PersonaCellLayout screen = (PersonaCellLayout) mWorkspace
                .getChildAt(mWorkspace.getCurrentScreen());
        if (screen != null) {
            mlauncherAppWidgetInfo = (PersonaLauncherAppWidgetInfo) widget.getTag();

            final Intent motosize = new Intent("com.motorola.blur.home.ACTION_SET_WIDGET_SIZE");
            final int appWidgetId = ((AppWidgetHostView) widget).getAppWidgetId();
            final AppWidgetProviderInfo appWidgetInfo = mAppWidgetManager.getAppWidgetInfo(appWidgetId);
            if (appWidgetInfo != null) {
                motosize.setComponent(appWidgetInfo.provider);
            }
            motosize.putExtra("appWidgetId", appWidgetId);
            motosize.putExtra("com.motorola.blur.home.EXTRA_NEW_WIDGET", true);
            final int minw = (mWorkspace.getWidth() - screen.getLeftPadding() - screen.getRightPadding())
                    / screen.getCountX();
            final int minh = (mWorkspace.getHeight() - screen.getBottomPadding() - screen.getTopPadding())
                    / screen.getCountY();
            mScreensEditor = new PersonaResizeViewHandler(this);
            // Create a default HightlightView if we found no face in the
            // picture.
            int width = (mlauncherAppWidgetInfo.spanX * minw);
            int height = (mlauncherAppWidgetInfo.spanY * minh);

            final Rect screenRect = new Rect(0, 0, mWorkspace.getWidth() - screen.getRightPadding(),
                    mWorkspace.getHeight() - screen.getBottomPadding());
            final int x = mlauncherAppWidgetInfo.cellX * minw;
            final int y = mlauncherAppWidgetInfo.cellY * minh;
            final int[] spans = new int[] { 1, 1 };
            final int[] position = new int[] { 1, 1 };
            final PersonaCellLayout.LayoutParams lp = (PersonaCellLayout.LayoutParams) widget.getLayoutParams();
            RectF widgetRect = new RectF(x, y, x + width, y + height);
            ((PersonaResizeViewHandler) mScreensEditor).setup(null, screenRect, widgetRect, false, false,
                    minw - 10, minh - 10);
            mDragLayer.addView(mScreensEditor);
            ((PersonaResizeViewHandler) mScreensEditor)
                    .setOnValidateSizingRect(new PersonaResizeViewHandler.OnSizeChangedListener() {

                        @Override
                        public void onTrigger(RectF r) {
                            if (r != null) {
                                final float left = Math.round(r.left / minw) * minw;
                                final float top = Math.round(r.top / minh) * minh;
                                final float right = left + (Math.max(Math.round(r.width() / (minw)), 1) * minw);
                                final float bottom = top
                                        + (Math.max(Math.round(r.height() / (minh)), 1) * minh);

                                r.set(left, top, right, bottom);
                            }
                        }
                    });
            final Rect checkRect = new Rect();
            ((PersonaResizeViewHandler) mScreensEditor)
                    .setOnSizeChangedListener(new PersonaResizeViewHandler.OnSizeChangedListener() {
                        @Override
                        public void onTrigger(RectF r) {
                            int[] tmpspans = { Math.max(Math.round(r.width() / (minw)), 1),
                                    Math.max(Math.round(r.height() / (minh)), 1) };
                            int[] tmpposition = { Math.round(r.left / minw), Math.round(r.top / minh) };
                            checkRect.set(tmpposition[0], tmpposition[1], tmpposition[0] + tmpspans[0],
                                    tmpposition[1] + tmpspans[1]);
                            boolean ocupada = getModel().ocuppiedArea(screen.getScreen(), appWidgetId,
                                    checkRect);
                            if (!ocupada) {
                                ((PersonaResizeViewHandler) mScreensEditor).setColliding(false);
                            } else {
                                ((PersonaResizeViewHandler) mScreensEditor).setColliding(true);
                            }
                            if (tmpposition[0] != position[0] || tmpposition[1] != position[1]
                                    || tmpspans[0] != spans[0] || tmpspans[1] != spans[1]) {
                                if (!ocupada) {
                                    position[0] = tmpposition[0];
                                    position[1] = tmpposition[1];
                                    spans[0] = tmpspans[0];
                                    spans[1] = tmpspans[1];
                                    lp.cellX = position[0];
                                    lp.cellY = position[1];
                                    lp.cellHSpan = spans[0];
                                    lp.cellVSpan = spans[1];
                                    widget.setLayoutParams(lp);
                                    mlauncherAppWidgetInfo.cellX = lp.cellX;
                                    mlauncherAppWidgetInfo.cellY = lp.cellY;
                                    mlauncherAppWidgetInfo.spanX = lp.cellHSpan;
                                    mlauncherAppWidgetInfo.spanY = lp.cellVSpan;
                                    widget.setTag(mlauncherAppWidgetInfo);
                                    // send the broadcast
                                    motosize.putExtra("spanX", spans[0]);
                                    motosize.putExtra("spanY", spans[1]);
                                    PersonaLauncher.this.sendBroadcast(motosize);
                                    PersonaLog.d("RESIZEHANDLER", "sent resize broadcast");
                                }
                            }
                        }
                    });
        }
    }
}