List of usage examples for android.graphics RectF RectF
public RectF(Rect r)
From source file:nu.yona.app.utils.AppUtils.java
/** * Gets circle bitmap./*from w w w. j av a 2s. c o m*/ * * @param bitmap the bitmap * @return the circle bitmap */ public static Bitmap getCircleBitmap(Bitmap bitmap) { final Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888); final Canvas canvas = new Canvas(output); final int color = Color.BLUE; final Paint paint = new Paint(); final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight()); final RectF rectF = new RectF(rect); paint.setAntiAlias(true); canvas.drawARGB(0, 0, 0, 0); paint.setColor(color); canvas.drawOval(rectF, paint); paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN)); canvas.drawBitmap(bitmap, rect, rect, paint); bitmap.recycle(); return output; }
From source file:com.github.kubatatami.RoundedView.java
private void drawText(Canvas canvas) { Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); paint.setTextSize(getResources().getDimension(R.dimen.item_circle_text_size)); Rect areaRect = new Rect(0, 0, canvas.getWidth(), canvas.getHeight()); RectF bounds = new RectF(areaRect); bounds.right = paint.measureText(text, 0, text.length()); bounds.bottom = paint.descent() - paint.ascent(); bounds.left += (areaRect.width() - bounds.right) / 2.0f; bounds.top += (areaRect.height() - bounds.bottom) / 2.0f; paint.setColor(Color.WHITE);//from w w w . ja v a 2 s. co m canvas.drawText(text, bounds.left, bounds.top - paint.ascent(), paint); }
From source file:it.jaschke.alexandria.BarcodeTrackerFactory.java
/** * Draws the barcode annotations for position, size, and raw value on the supplied canvas. */// w w w . j a v a2 s. c o m @Override public void draw(Canvas canvas) { Barcode barcode = mBarcode; if (barcode == null) { return; } // Draws the bounding box around the barcode. RectF rect = new RectF(barcode.getBoundingBox()); rect.left = translateX(rect.left); //rect.top = translateY(rect.top); //rect.right = translateX(rect.right); rect.bottom = translateY(rect.bottom); //canvas.drawRect(rect, mRectPaint); // Draws a label at the bottom of the barcode indicate the barcode value that was detected. canvas.drawText(barcode.rawValue, rect.left, rect.bottom, mTextPaint); sendMessage(barcode.rawValue); }
From source file:com.example.zhangyangjing.roundcornerimageview.BezelImageView.java
@Override protected boolean setFrame(int l, int t, int r, int b) { final boolean changed = super.setFrame(l, t, r, b); mBounds = new Rect(0, 0, r - l, b - t); mBoundsF = new RectF(mBounds); if (changed) { mCacheValid = false;//from w ww. j a v a 2 s . com } return changed; }
From source file:ar.uba.fi.splitapp.MockServer.java
private static Bitmap getCircleBitmap(Bitmap bitmap) { final Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888); final Canvas canvas = new Canvas(output); final int color = Color.RED; final Paint paint = new Paint(); final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight()); final RectF rectF = new RectF(rect); paint.setAntiAlias(true);/*w w w . ja v a 2s .c o m*/ canvas.drawARGB(0, 0, 0, 0); paint.setColor(color); canvas.drawOval(rectF, paint); paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN)); canvas.drawBitmap(bitmap, rect, rect, paint); bitmap.recycle(); return output; }
From source file:org.mozilla.gecko.gfx.ViewportMetrics.java
public ViewportMetrics(ViewportMetrics viewport) { mPageSize = new FloatSize(viewport.getPageSize()); mViewportRect = new RectF(viewport.getViewport()); PointF offset = viewport.getViewportOffset(); mViewportOffset = new PointF(offset.x, offset.y); mZoomFactor = viewport.getZoomFactor(); mViewportBias = viewport.mViewportBias; }
From source file:com.micabytes.gfx.ImageHandler.java
@SuppressWarnings("unused") @Nullable/*from w ww . ja v a 2 s .c om*/ public static Bitmap getSceneBitmap(int bkg, int left, int right) { Bitmap bitmap = get(bkg); Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(output); Paint paint = new Paint(); Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight()); RectF rectF = new RectF(rect); paint.setAntiAlias(true); canvas.drawARGB(0, 0, 0, 0); int color = COLOR_RED; paint.setColor(color); float roundPx = PIXEL_ROUNDING; canvas.drawRoundRect(rectF, roundPx, roundPx, paint); paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN)); canvas.drawBitmap(bitmap, rect, rect, paint); if (left > 0) { canvas.drawBitmap(get(left), 0, 0, null); } if (right > 0) { canvas.drawBitmap(get(right), 0, 0, null); // canvas.drawBitmap(get(right), bitmap.getWidth()/2, 0, null); } return output; }
From source file:app.geochat.ui.widgets.BezelImageView.java
@Override protected boolean setFrame(int l, int t, int r, int b) { final boolean changed = super.setFrame(l, t, r, b); mBounds = new Rect(0, 0, r - l, b - t); mBoundsF = new RectF(mBounds); if (mBorderDrawable != null) { mBorderDrawable.setBounds(mBounds); }//from w w w.j av a 2 s .c o m if (mMaskDrawable != null) { mMaskDrawable.setBounds(mBounds); } if (changed) { mCacheValid = false; } return changed; }
From source file:cl.monsoon.s1next.widget.BezelImageView.java
@Override protected boolean setFrame(int l, int t, int r, int b) { final boolean changed = super.setFrame(l, t, r, b); mBounds = new Rect(0, 0, r - l, b - t); mBoundsF = new RectF(mBounds); if (mBorderDrawable != null) { mBorderDrawable.setBounds(mBounds); }/*from w w w.j a v a 2s. c om*/ if (mMaskDrawable != null) { mMaskDrawable.setBounds(mBounds); } if (changed) { mCacheValid = false; } return changed; }
From source file:com.vincestyling.traversaless_testcase.TopTabIndicator.java
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); if (mViewPager == null) return;/*from w ww. j ava 2 s . c om*/ final int count = getCount(); if (count == 0) return; Rect areaRect = new Rect(); areaRect.left = getPaddingLeft(); areaRect.right = getWidth() - getPaddingRight(); areaRect.top = getPaddingTop(); areaRect.bottom = getHeight() - getPaddingBottom(); int btnWidth = areaRect.width() / count; Rect tabRect = new Rect(areaRect); tabRect.top = tabRect.height() - mUnderlineHeight; tabRect.left += (mScrollingToPage + mPageOffset) * btnWidth; tabRect.right = tabRect.left + btnWidth; mPaint.setColor(mUnderlineColor); canvas.drawRect(tabRect, mPaint); mPaint.setColor(mTextColor); mPaint.setTextSize(mTextSize); for (int pos = 0; pos < count; pos++) { tabRect.set(areaRect); tabRect.left += pos * btnWidth; tabRect.right = tabRect.left + btnWidth; String pageTitle = getPageTitle(pos); RectF bounds = new RectF(tabRect); bounds.right = mPaint.measureText(pageTitle, 0, pageTitle.length()); bounds.bottom = mPaint.descent() - mPaint.ascent(); bounds.left += (tabRect.width() - bounds.right) / 2.0f; bounds.top += (tabRect.height() - bounds.bottom) / 2.0f; canvas.drawText(pageTitle, bounds.left, bounds.top - mPaint.ascent(), mPaint); } }