List of usage examples for android.graphics Canvas getHeight
public int getHeight()
From source file:com.github.topbottomsnackbar.TBSnackbar.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP) private static Bitmap getBitmap(VectorDrawable vectorDrawable) { Bitmap bitmap = Bitmap.createBitmap(vectorDrawable.getIntrinsicWidth(), vectorDrawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);//w ww . j av a 2 s . c om Canvas canvas = new Canvas(bitmap); vectorDrawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight()); vectorDrawable.draw(canvas); return bitmap; }
From source file:io.jawg.osmcontributor.ui.utils.views.customs.ImageProgressBar.java
@Override public void draw(Canvas canvas) { oval.set(canvas.getWidth() / 2 - radius, canvas.getHeight() / 2 - radius, canvas.getWidth() / 2 + radius, canvas.getHeight() / 2 + radius); drawCircle(canvas, level, color);//from w ww .j ava2 s. co m }
From source file:com.freshdigitable.udonroad.MediaImageView.java
public MediaImageView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); setContentDescription(getResources().getString(R.string.tweet_media_descs)); setVisibility(GONE);/*from w w w . java 2 s . c o m*/ if (playIcon == null) { final Drawable drawable = ContextCompat.getDrawable(getContext(), R.drawable.ld_play_icon); playIcon = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(playIcon); drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight()); drawable.draw(canvas); } }
From source file:com.microsoft.mimickeralarm.onboarding.BubblePagerIndicator.java
@Override protected void onDraw(Canvas canvas) { int width = canvas.getWidth(); int height = canvas.getHeight(); if (mTotalPositions == 0) { return;//from w w w . j a v a 2 s.c o m } mPaint.setAlpha(122); float buckets = (float) width / mTotalPositions; float radius = Math.min(buckets / 2f, height / 2f); for (int i = 0; i < mTotalPositions; i++) { canvas.drawCircle(i * buckets + buckets / 2f, height / 2f, radius, mPaint); } mPaint.setAlpha(255); canvas.drawCircle(mPosition * buckets + buckets / 2f, height / 2f, radius, mPaint); }
From source file:app.philm.in.view.BackdropImageView.java
@Override protected void onDraw(Canvas canvas) { if (mOffset != 0) { canvas.save();//from ww w .ja va 2 s .c o m canvas.translate(0f, mOffset); canvas.clipRect(0f, 0f, canvas.getWidth(), canvas.getHeight() + mOffset); super.onDraw(canvas); canvas.restore(); } else { super.onDraw(canvas); } }
From source file:com.creationgroundmedia.nytimessearch.adapters.ArticlesAdapter.java
private Bitmap bitmapFromResource(int resId) { Drawable sendIcon = ContextCompat.getDrawable(mContext, resId); Bitmap bitmap = Bitmap.createBitmap(sendIcon.getIntrinsicWidth(), sendIcon.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);/*from www . j ava2 s. co m*/ Canvas canvas = new Canvas(bitmap); sendIcon.setBounds(0, 0, canvas.getWidth(), canvas.getHeight()); sendIcon.draw(canvas); return bitmap; }
From source file:android.support.car.ui.CircleBitmapDrawable.java
/** * Convert the drawable to a bitmap.//from w w w.j a v a 2s .co m * @param size The target size of the bitmap in pixels. * @return A bitmap representation of the drawable. */ public Bitmap toBitmap(int size) { Bitmap largeIcon = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(largeIcon); Rect bounds = getBounds(); setBounds(0, 0, canvas.getWidth(), canvas.getHeight()); draw(canvas); setBounds(bounds); return largeIcon; }
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);// w ww. j ava 2 s .c o m } else { canvas.drawCircle(DISTANCE * i + BULLET_RADIUS * 2, canvas.getHeight() / 2f, BULLET_RADIUS, fillPaint); } } } }
From source file:com.keylesspalace.tusky.view.ProgressImageView.java
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); float angle = (progress / 100f) * 360 - 90; float halfWidth = canvas.getWidth() / 2; float halfHeight = canvas.getHeight() / 2; progressRect.set(halfWidth * 0.75f, halfHeight * 0.75f, halfWidth * 1.25f, halfHeight * 1.25f); biggerRect.set(progressRect);/*from w w w. j a v a 2 s .co m*/ int margin = 8; biggerRect.set(progressRect.left - margin, progressRect.top - margin, progressRect.right + margin, progressRect.bottom + margin); canvas.saveLayer(biggerRect, null, Canvas.ALL_SAVE_FLAG); if (progress != -1) { canvas.drawOval(progressRect, circlePaint); canvas.drawArc(biggerRect, angle, 360 - angle - 90, true, clearPaint); } canvas.restore(); int circleRadius = Utils.dpToPx(getContext(), 14); int circleMargin = Utils.dpToPx(getContext(), 14); int circleY = canvas.getHeight() - circleMargin - circleRadius / 2; int circleX = canvas.getWidth() - circleMargin - circleRadius / 2; canvas.drawCircle(circleX, circleY, circleRadius, markBgPaint); captionDrawable.setBounds(canvas.getWidth() - circleMargin - circleRadius, canvas.getHeight() - circleMargin - circleRadius, canvas.getWidth() - circleMargin, canvas.getHeight() - circleMargin); DrawableCompat.setTint(captionDrawable, Color.WHITE); captionDrawable.draw(canvas); }
From source file:org.stockchart.core.Crosshair.java
public void draw(Plot plot, Canvas c, Rect clipRect) { float xxx = fX * c.getWidth(); float yyy = fY * c.getHeight(); PointF p = plot.getRelativePosition(xxx, yyy); this.fAppearance.applyOutline(fPaint); if (this.fDrawVertical) PaintUtils.drawLine(c, p.x, clipRect.top, p.x, clipRect.bottom, fPaint); if (this.fDrawHorizontal) PaintUtils.drawLine(c, clipRect.left, p.y, clipRect.right, p.y, fPaint); Area parent = (Area) plot.getParent(); Axis hAxis = parent.getAxis(fHorizontalAxis); Axis vAxis = parent.getAxis(fVerticalAxis); double realXValue = hAxis.getValueByCoordinate(p.x, false); double realYValue = vAxis.getValueByCoordinate(p.y, false); String text = null;/*w w w.j a v a 2s .c om*/ if (fLabelFormatProvider != null) text = fLabelFormatProvider.getLabel(this, plot, realXValue, realYValue); else text = String.format("X: %.2f, Y: %.2f", realXValue, realYValue); if (null != text) { fAppearance.applyText(fPaint); SizeF f = fAppearance.measureTextSize(text, fPaint, false); float ow = fAppearance.getOutlineWidth() + 1f; float textX = clipRect.right - p.x > p.x ? p.x + ow : p.x - f.width - ow; float textY = clipRect.bottom - p.y > p.y ? p.y + f.height + ow : p.y - f.height; if (!fDrawVertical) textX = 1f; if (!fDrawHorizontal) textY = f.height + 1f; c.drawText(text, textX, textY, fPaint); } }