List of usage examples for android.graphics Canvas drawCircle
public void drawCircle(float cx, float cy, float radius, @NonNull Paint paint)
From source file:com.bamobile.fdtks.util.Tools.java
public static Bitmap getCircularBitmapWithWhiteBorder(Bitmap bitmap, int borderWidth) { if (bitmap == null || bitmap.isRecycled()) { return null; }/* ww w . ja va 2s.c om*/ final int width = bitmap.getWidth() + borderWidth; final int height = bitmap.getHeight() + borderWidth; Bitmap canvasBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); BitmapShader shader = new BitmapShader(bitmap, TileMode.CLAMP, TileMode.CLAMP); Paint paint = new Paint(); paint.setAntiAlias(true); paint.setShader(shader); Canvas canvas = new Canvas(canvasBitmap); float radius = width > height ? ((float) height) / 2f : ((float) width) / 2f; canvas.drawCircle(width / 2, height / 2, radius, paint); paint.setShader(null); paint.setStyle(Paint.Style.STROKE); paint.setColor(Color.BLUE); paint.setStrokeWidth(borderWidth); canvas.drawCircle(width / 2, height / 2, radius - borderWidth / 2, paint); return canvasBitmap; }
From source file:com.grarak.kerneladiutor.elements.SplashView.java
private void draw(Canvas canvas, int x, int y, int radius) { if (radius > 0) canvas.drawCircle(x / 2, y / 2, radius, mPaintCircle); matrix.postRotate(rotate);/*ww w .jav a 2s . co m*/ Bitmap iconRotate = Bitmap.createBitmap(icon, 0, 0, icon.getWidth(), icon.getHeight(), matrix, false); canvas.drawBitmap(iconRotate, x / 2 - iconRotate.getWidth() / 2, y / 2 - iconRotate.getHeight() / 2, mPaintCircle); TextPaint textPaint = new TextPaint(); textPaint.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.BOLD)); textPaint.setColor(textColor); textPaint.setAntiAlias(true); textPaint.setTextAlign(Paint.Align.CENTER); textPaint.setTextSize(textSize); float textHeight = textPaint.descent() - textPaint.ascent(); float textOffset = (textHeight / 2) - textPaint.descent(); canvas.drawText(getResources().getString(R.string.root_waiting), x / 2, y - textOffset - y / 4, textPaint); }
From source file:org.akvo.caddisfly.sensor.colorimetry.strip.widget.PageIndicatorView.java
@Override public void onDraw(@NonNull Canvas canvas) { if (pageCount > 1) { for (int i = 0; i < pageCount; i++) { if (activePage == i) { canvas.drawCircle(DISTANCE * i + BULLET_RADIUS * 2, canvas.getHeight() / 2f, BULLET_RADIUS * 2, fillPaint);//from www . j a v a2 s . co m } else { canvas.drawCircle(DISTANCE * i + BULLET_RADIUS * 2, canvas.getHeight() / 2f, BULLET_RADIUS, fillPaint); } } } }
From source file:com.madgag.android.lazydrawables.samples.DemoListActivity.java
private ImageResourceDownloader<String, Bitmap> slowImageMaker() { return new ImageResourceDownloader<String, Bitmap>() { public Bitmap get(String key) { Log.d(TAG, "Asked to download " + key); try { Thread.sleep(4000L); } catch (InterruptedException e) { }/*w ww. j a v a 2 s .c o m*/ Bitmap bitmap = Bitmap.createBitmap(80, 80, Bitmap.Config.ARGB_8888); Canvas c = new Canvas(bitmap); Paint paint = new Paint(); paint.setColor(0xff0000ff); c.drawCircle(0, 0, 50, paint); paint.setColor(0xffff007f); paint.setStyle(Paint.Style.FILL); paint.setAntiAlias(true); paint.setTextSize(30); c.drawText(key, 0, 3, 0, 60, paint); Log.d(TAG, "Done drawing... " + key); return bitmap; } }; }
From source file:com.ez.gallery.ucrop.view.widget.AspectRatioTextView.java
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); if (isSelected()) { canvas.getClipBounds(mCanvasClipBounds); canvas.drawCircle((mCanvasClipBounds.right - mCanvasClipBounds.left) / 2.0f, mCanvasClipBounds.bottom - mDotSize, mDotSize / 2, mDotPaint); }/*from ww w.ja va2 s . com*/ }
From source file:com.android.datetimepicker.date.TextViewWithCircularIndicator.java
@Override public void onDraw(@NonNull Canvas canvas) { if (mDrawCircle) { final int width = getWidth(); final int height = getHeight(); int radius = Math.min(width, height) / 2; canvas.drawCircle(width / 2, height / 2, radius, mCirclePaint); }/*from ww w. j a v a 2s. co m*/ setSelected(mDrawCircle); super.onDraw(canvas); }
From source file:com.kenmeidearu.materialdatetimepicker.date.TextViewWithCircularIndicator.java
@Override public void onDraw(@NonNull Canvas canvas) { if (mDrawCircle) { final int width = getWidth(); final int height = getHeight(); int radius = Math.min(width, height) / 2; canvas.drawCircle(width / 2, height / 2, radius, mCirclePaint); }//from w w w.j a v a 2s . co m setSelected(mDrawCircle); super.onDraw(canvas); }
From source file:com.appyvet.rangebar.PinView.java
@Override public void draw(Canvas canvas) { canvas.drawCircle(mX, mY, mCircleRadiusPx, mCirclePaint); //Draw pin if pressed if (mPinRadiusPx > 0) { mBounds.set((int) mX - mPinRadiusPx, (int) mY - (mPinRadiusPx * 2) - (int) mPinPadding, (int) mX + mPinRadiusPx, (int) mY - (int) mPinPadding); mPin.setBounds(mBounds);//w w w . j a v a 2 s . c o m String text = mValue; if (this.formatter != null) { text = formatter.format(text); } calibrateTextSize(mTextPaint, text, mBounds.width()); mTextPaint.getTextBounds(text, 0, text.length(), mBounds); mTextPaint.setTextAlign(Paint.Align.CENTER); mPin.setColorFilter(mPinFilter); mPin.draw(canvas); canvas.drawText(text, mX, mY - mPinRadiusPx - mPinPadding + mTextYPadding, mTextPaint); } super.draw(canvas); }
From source file:com.github.kubatatami.RoundedView.java
@Override protected void onDraw(Canvas canvas) { paint.setAntiAlias(true);/* w w w . j a va 2 s . c o m*/ paint.setFilterBitmap(true); paint.setDither(true); canvas.drawARGB(0, 0, 0, 0); paint.setColor(color); canvas.drawCircle(getWidth() / 2, getHeight() / 2, getWidth() / 2, paint); if (text != null && !checked) { drawText(canvas); } if (checked && text == null) { drawChecked(canvas); } }
From source file:airfree.xprojets.airfree.PinView.java
@Override public void draw(Canvas canvas) { canvas.drawCircle(mX, mY, mCircleRadiusPx, mCirclePaint); //Draw pin if pressed if (mPinRadiusPx > 0 && (mHasBeenPressed || !mPinsAreTemporary)) { mBounds.set((int) mX - mPinRadiusPx, (int) mY - (mPinRadiusPx * 2) - (int) mPinPadding, (int) mX + mPinRadiusPx, (int) mY - (int) mPinPadding); mPin.setBounds(mBounds);// w ww .j a v a 2s. co m String text = mValue; if (this.formatter != null) { text = formatter.format(text); } calibrateTextSize(mTextPaint, text, mBounds.width()); mTextPaint.getTextBounds(text, 0, text.length(), mBounds); mTextPaint.setTextAlign(Paint.Align.CENTER); mPin.setColorFilter(mPinFilter); mPin.draw(canvas); canvas.drawText(text, mX, mY - mPinRadiusPx - mPinPadding + mTextYPadding, mTextPaint); } super.draw(canvas); }