Example usage for android.graphics Canvas drawLine

List of usage examples for android.graphics Canvas drawLine

Introduction

In this page you can find the example usage for android.graphics Canvas drawLine.

Prototype

public void drawLine(float startX, float startY, float stopX, float stopY, @NonNull Paint paint) 

Source Link

Document

Draw a line segment with the specified start and stop x,y coordinates, using the specified paint.

Usage

From source file:org.telegram.ui.Cells.DividerCell.java

@Override
protected void onDraw(Canvas canvas) {
    if (paint == null) {
        createPaint();//from   w  w  w  .  j a v  a 2 s .c  om
    }
    canvas.drawLine(getPaddingLeft(), AndroidUtilities.dp(8), getWidth() - getPaddingRight(),
            AndroidUtilities.dp(8), paint);
}

From source file:org.telegram.ui.Cells.HashtagSearchCell.java

@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    if (needDivider) {
        canvas.drawLine(0, getHeight() - 1, getWidth(), getHeight() - 1, paint);
    }/*ww w . j av a 2 s.  c  o  m*/
}

From source file:cn.ieclipse.af.demo.common.ui.MainBottomTab.java

@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    canvas.drawLine(0, 0, getWidth(), 1, p);
}

From source file:org.telegram.ui.Cells.TextColorCell.java

@Override
protected void onDraw(Canvas canvas) {
    if (needDivider) {
        canvas.drawLine(getPaddingLeft(), getHeight() - 1, getWidth() - getPaddingRight(), getHeight() - 1,
                paint);//from w  ww . j ava2s.  co m
    }
    if (currentColor != 0 && colorDrawable != null) {
        int x;
        int y = (getMeasuredHeight() - colorDrawable.getMinimumHeight()) / 2;
        if (!LocaleController.isRTL) {
            x = getMeasuredWidth() - colorDrawable.getIntrinsicWidth() - AndroidUtilities.dp(14.5f);
        } else {
            x = AndroidUtilities.dp(14.5f);
        }
        colorDrawable.setBounds(x, y, x + colorDrawable.getIntrinsicWidth(),
                y + colorDrawable.getIntrinsicHeight());
        colorDrawable.draw(canvas);
    }
}

From source file:org.telegram.ui.Cells.CheckBoxCell.java

@Override
protected void onDraw(Canvas canvas) {
    if (needDivider) {
        canvas.drawLine(getPaddingLeft(), getHeight() - 1, getWidth() - getPaddingRight(), getHeight() - 1,
                paint);/*from   w ww.j  av a2  s.c  o  m*/
    }
}

From source file:com.xgf.inspection.qrcode.google.zxing.client.CaptureActivity.java

private static void drawLine(Canvas canvas, Paint paint, ResultPoint a, ResultPoint b) {
    canvas.drawLine(a.getX(), a.getY(), b.getX(), b.getY(), paint);
}

From source file:foam.jellyfish.StarwispCanvas.java

public void DrawLine(Canvas canvas, JSONArray prim, float sx, float sy) {
    try {//from   w  ww .j  a v a2  s.  c o  m
        JSONArray v = prim.getJSONArray(3);
        canvas.drawLine(v.getInt(0) * sx, v.getInt(1) * sy, v.getInt(2) * sx, v.getInt(3) * sy,
                getPaint(canvas, prim));
    } catch (JSONException e) {
        Log.e("starwisp", "Error parsing data " + e.toString());
    }
}

From source file:com.jjoe64.graphview_demos.fragments.PointsGraph.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_main, container, false);

    GraphView graph = (GraphView) rootView.findViewById(R.id.graph);
    PointsGraphSeries<DataPoint> series = new PointsGraphSeries<DataPoint>(
            new DataPoint[] { new DataPoint(0, -2), new DataPoint(1, 5), new DataPoint(2, 3),
                    new DataPoint(3, 2), new DataPoint(4, 6) });
    graph.addSeries(series);/*w  ww  . j  a v a 2 s .  c om*/
    series.setShape(PointsGraphSeries.Shape.POINT);

    PointsGraphSeries<DataPoint> series2 = new PointsGraphSeries<DataPoint>(
            new DataPoint[] { new DataPoint(0, -1), new DataPoint(1, 4), new DataPoint(2, 2),
                    new DataPoint(3, 1), new DataPoint(4, 5) });
    graph.addSeries(series2);
    series2.setShape(PointsGraphSeries.Shape.RECTANGLE);
    series2.setColor(Color.RED);

    PointsGraphSeries<DataPoint> series3 = new PointsGraphSeries<DataPoint>(
            new DataPoint[] { new DataPoint(0, 0), new DataPoint(1, 3), new DataPoint(2, 1),
                    new DataPoint(3, 0), new DataPoint(4, 4) });
    graph.addSeries(series3);
    series3.setShape(PointsGraphSeries.Shape.TRIANGLE);
    series3.setColor(Color.YELLOW);

    PointsGraphSeries<DataPoint> series4 = new PointsGraphSeries<DataPoint>(
            new DataPoint[] { new DataPoint(0, 1), new DataPoint(1, 2), new DataPoint(2, 0),
                    new DataPoint(3, -1), new DataPoint(4, 3) });
    graph.addSeries(series4);
    series4.setColor(Color.GREEN);
    series4.setCustomShape(new PointsGraphSeries.CustomShape() {
        @Override
        public void draw(Canvas canvas, Paint paint, float x, float y, DataPointInterface dataPoint) {
            paint.setStrokeWidth(10);
            canvas.drawLine(x - 20, y - 20, x + 20, y + 20, paint);
            canvas.drawLine(x + 20, y - 20, x - 20, y + 20, paint);
        }
    });

    return rootView;
}

From source file:org.telegram.ui.Cells.ArchivedStickerSetCell.java

@Override
protected void onDraw(Canvas canvas) {
    if (needDivider) {
        canvas.drawLine(0, getHeight() - 1, getWidth() - getPaddingRight(), getHeight() - 1, paint);
    }/*from www.j  av  a 2 s  .  c o  m*/
}

From source file:com.filemanager.free.ui.views.SizeDrawable.java

@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);

    // canvas.drawLine((getWidth() - twenty)-2,0,(getWidth() - twenty),0,mPaint1);
    if (angle2 != 0)
        canvas.drawLine(0, getHeight() - (getHeight() * angle1), 0, getHeight() - (getHeight() * angle2),
                mPaint2);//from   w w w.j a va2s  . co m
    canvas.drawLine(0, getHeight(), 0, getHeight() - (getHeight() * angle), mPaint);
    if (angle1 != 0)
        canvas.drawLine(0, getHeight() - (getHeight() * angle), 0, getHeight() - (getHeight() * angle1),
                mPaint1);
    /* Paint paint = new Paint();
     paint.setColor(Color.WHITE);
     paint.setStyle(Paint.Style.STROKE);
     paint.setTextSize(20);
     canvas.drawText(Math.round(angle * 100)+"%",(getWidth() - twenty)*angle/2, 25,paint);
     if(angle1>0.20)canvas.drawText(Math.round((angle1-angle)*100)+"%",(getWidth() - twenty)*angle+(getWidth() - twenty)*(angle1-angle)/2, 25,paint);
     if(angle2>0.20)canvas.drawText(Math.round((angle2-angle1)*100)+"%",(getWidth() - twenty)*angle1+(getWidth() - twenty)*(angle2-angle1)/2, 25,paint);
            
            
     canvas.drawArc(rectF, startangle, angle, true, mPaint);
     canvas.drawArc(rectF, startangle1, angle1, true, mPaint1);
     canvas.drawArc(rectF, startangle2, angle2, true, mPaint2);
    */
}