List of usage examples for android.graphics Canvas drawLine
public void drawLine(float startX, float startY, float stopX, float stopY, @NonNull Paint paint)
From source file:com.facebook.react.views.slider.ReactSlider.java
private NinePatchDrawable createNineDrawable(Bitmap src) { if (src.getNinePatchChunk() != null) { return NinePatchDrawableFactory.convertBitmap(getResources(), src, null); }// ww w . j a v a 2s . c o m Bitmap desc = Bitmap.createBitmap(src.getWidth() + 4, src.getHeight() + 4, Bitmap.Config.ARGB_4444); PointF center = new PointF(desc.getWidth() / 2, desc.getHeight() / 2); Canvas canvas = new Canvas(desc); canvas.drawBitmap(src, 2, 2, null); Paint p = new Paint(); p.setColor(Color.BLACK); canvas.drawLine(center.x, 0, center.x + 1, 0, p); canvas.drawLine(0, center.y, 0, center.y + 1, p); NinePatchDrawable drawable = NinePatchDrawableFactory.convertBitmap(getResources(), desc, null); desc.recycle(); return drawable; }
From source file:pl.openrnd.multilevellistview.sample.views.LevelBeamView.java
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); for (int lvl = 0; lvl <= mLevel; lvl++) { float LINE_X = mPadding + lvl * mLinesWidth; if (lvl >= 1) { LINE_X += lvl * mLinesOffset; }/* w ww .java 2 s .c o m*/ mLinePaint.setColor(getColor(getColorResIdForLevel(lvl))); canvas.drawLine(LINE_X, 0, LINE_X, canvas.getHeight(), mLinePaint); } }
From source file:org.telegram.ui.Cells.SharedDocumentCell.java
@Override protected void onDraw(Canvas canvas) { if (needDivider) { canvas.drawLine(AndroidUtilities.dp(72), getHeight() - 1, getWidth() - getPaddingRight(), getHeight() - 1, paint); }/*from ww w. j a v a 2 s. c o m*/ }
From source file:ecust.news.myWidgetTabPageIndicator.java
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); ///* w w w . j av a 2 s. c o m*/ int w = Global.dimenConvert.dip2px(dp_FocusedLineHeight) / 2; int y = canvas.getHeight() - w / 2; paint.setColor(Color.WHITE); paint.setStrokeWidth(w); canvas.drawLine(0, y, canvas.getMaximumBitmapWidth(), y, paint); }
From source file:com.grarak.kerneladiutor.views.XYGraph.java
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); int width = getMeasuredWidth(); int height = getMeasuredHeight(); boolean isRTL = Utils.isRTL(this); for (int i = 1; i < 10; i++) { float y = ((float) height / 10) * i; canvas.drawLine(0, y, width, y, mPaintLine); }/*from w ww .jav a 2s .c o m*/ for (int i = 0; i < 7; i++) { float x = ((float) width / 6) * i; float offset = (float) width / 6 / 4 * state; if (isRTL) { x += offset; } else { x -= offset; } canvas.drawLine(x, 0, x, height, mPaintLine); } mPathGraph.reset(); float graphX; if (isRTL) { graphX = ((float) width / 24) * (mPercentages.size() - 1); } else { graphX = width - ((float) width / 24) * (mPercentages.size() - 1); } mPathGraph.moveTo(graphX, height); float x = 0; float y; for (int i = 0; i < mPercentages.size(); i++) { if (isRTL) { x = graphX - ((float) width / 24) * i; } else { x = graphX + ((float) width / 24) * i; } y = ((float) (100 - mPercentages.get(i)) / 100) * height; mPathGraph.lineTo(x, y); } mPathGraph.lineTo(x, height); mPathGraph.close(); canvas.drawPath(mPathGraph, mPaintGraph); canvas.drawPath(mPathGraph, mPaintGraphStroke); if (mEdgeVisible) { canvas.drawRect(0, 0, width, height, mPaintEdge); } }
From source file:net.networksaremadeofstring.rhybudd.ZenossWidgetGraph.java
private Bitmap RenderBarGraph(int CritCount, int ErrCount, int WarnCount) { //Log.i("Counts", Integer.toString(CritCount) + " / " + Integer.toString(ErrCount) + " / " + Integer.toString(WarnCount)); Bitmap emptyBmap = Bitmap.createBitmap(290, 150, Config.ARGB_8888); int width = emptyBmap.getWidth(); int height = emptyBmap.getHeight(); Bitmap charty = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(charty); //final int color = 0xff0B0B61; final Paint paint = new Paint(); paint.setStyle(Paint.Style.FILL); paint.setColor(Color.WHITE);//ww w . j a v a 2 s .c om //y canvas.drawLine(25, 0, 25, 289, paint); //x canvas.drawLine(25, 149, 289, 149, paint); paint.setAntiAlias(true); int Max = 0; if (CritCount > ErrCount && CritCount > WarnCount) Max = CritCount; else if (ErrCount > CritCount && ErrCount > WarnCount) Max = ErrCount; else if (WarnCount > CritCount && WarnCount > ErrCount) Max = WarnCount; else Max = CritCount; if (Max > 0) canvas.drawText(Integer.toString(Max), 0, 10, paint); if (Max > 1) canvas.drawText(Integer.toString(Max / 2), 0, 75, paint); canvas.drawText("0", 0, 148, paint); double divisor = 148 / (double) Max; paint.setAlpha(128); Rect rect = new Rect(32, (int) (148 - (divisor * CritCount)), 64, 148); paint.setColor(Color.argb(200, 208, 0, 0)); //red if (CritCount > 0) canvas.drawRect(new RectF(rect), paint); rect = new Rect(128, (int) (148 - (divisor * ErrCount)), 160, 148); paint.setColor(Color.argb(200, 255, 102, 0));//orange if (ErrCount > 0) canvas.drawRect(new RectF(rect), paint); rect = new Rect(224, (int) (148 - (divisor * WarnCount)), 256, 148); paint.setColor(Color.argb(200, 255, 224, 57)); //yellow if (WarnCount > 0) canvas.drawRect(new RectF(rect), paint); //Return ByteArrayOutputStream out = new ByteArrayOutputStream(); charty.compress(CompressFormat.PNG, 50, out); return BitmapFactory.decodeByteArray(out.toByteArray(), 0, out.size()); }
From source file:com.dragon.lib.IndicatorView.java
private void drawLine(Canvas canvas, float startX, float startY, float radius) { float width = radius * 2; canvas.drawLine(startX, startY, startX + width, startY, mIndicatorPaint); }
From source file:com.ruesga.rview.widget.ActivityStatsChart.java
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); // Draw the grid lines float gap = mViewArea.height() / (MAX_Y_TICKS_LABELS * 1f); float y = mViewArea.top + gap; for (int i = 0; i < MAX_Y_TICKS_LABELS; i++) { canvas.drawLine(mViewArea.left, y, mViewArea.right, y, mGridLinesPaint); y += gap;/*from w w w. j av a 2 s .c o m*/ } // Draw the points data canvas.drawPath(mAreaPath, mAreaPaint); canvas.drawPath(mLinePath, mLinePaint); if (mDataAvailable) { // Draw ticks labels float margin = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 2f, getResources().getDisplayMetrics()); y = mViewArea.top + gap; for (int i = 0; i < MAX_Y_TICKS_LABELS; i++) { canvas.drawText(mYTicksLabels[i], mViewArea.right - margin, y - margin, mTicksPaint); y += gap; } } }
From source file:com.byagowi.persiancalendar.view.QiblaCompassView.java
public void drawQibla(Canvas canvas) { canvas.rotate((float) qiblaInfo.getHeading() - 360, px, py); qiblaPaint.reset();/*from w w w .j av a2 s . c o m*/ qiblaPaint.setColor(Color.GREEN); qiblaPaint.setStyle(Paint.Style.FILL_AND_STROKE); qiblaPaint.setPathEffect(dashPath); qiblaPaint.setStrokeWidth(5.5f); canvas.drawLine(px, py - Radius, px, py + Radius, qiblaPaint); qiblaPaint.setPathEffect(null); canvas.drawBitmap(kaaba, px - kaaba.getWidth() / 2, py - Radius - kaaba.getHeight() / 2, qiblaPaint); canvas.restore(); }
From source file:com.ifoer.util.NetPOSPrinter.java
public Bitmap drawBitFirst() { this.nBitmapFirst = Bitmap.createBitmap(PRINT_WIDTH, 85, Config.RGB_565); Canvas canvas = new Canvas(this.nBitmapFirst); canvas.drawColor(-1);/*from w ww. j a va 2 s .c om*/ Paint p = new Paint(); p.setColor(DefaultRenderer.BACKGROUND_COLOR); p.setTextSize(20.0f); canvas.drawText(this.mContext.getResources().getString(C0136R.string.print_launch), 0.0f, 20.0f, p); canvas.drawLine(0.0f, 40.0f, 384.0f, 40.0f, p); canvas.drawText( this.mContext.getResources().getString(C0136R.string.print_automobile_fault_diagnosis_test_report), 20.0f, 70.0f, p); canvas.drawLine(0.0f, 80.0f, 384.0f, 80.0f, p); return this.nBitmapFirst; }