Example usage for android.graphics Paint setStrokeWidth

List of usage examples for android.graphics Paint setStrokeWidth

Introduction

In this page you can find the example usage for android.graphics Paint setStrokeWidth.

Prototype

public void setStrokeWidth(float width) 

Source Link

Document

Set the width for stroking.

Usage

From source file:net.droidsolutions.droidcharts.core.plot.XYPlot.java

/**
 * Utility method for drawing a horizontal line across the data area of the
 * plot.// www.  j av  a  2s .com
 * 
 * @param g2
 *            the graphics device.
 * @param dataArea
 *            the data area.
 * @param value
 *            the coordinate, where to draw the line.
 * @param stroke
 *            the stroke to use.
 * @param paint
 *            the paint to use.
 */
protected void drawHorizontalLine(Canvas g2, Rectangle2D dataArea, double value, Float stroke, Paint paint) {

    ValueAxis axis = getRangeAxis();
    if (getOrientation() == PlotOrientation.HORIZONTAL) {
        axis = getDomainAxis();
    }
    if (axis.getRange().contains(value)) {
        double yy = axis.valueToJava2D(value, dataArea, RectangleEdge.LEFT);
        Line2D line = new Line2D.Double(dataArea.getMinX(), yy, dataArea.getMaxX(), yy);
        paint.setStyle(Paint.Style.STROKE);
        paint.setStrokeWidth(stroke);
        g2.drawLine((float) line.getX1(), (float) line.getY1(), (float) line.getX2(), (float) line.getY2(),
                paint);
    }

}

From source file:net.droidsolutions.droidcharts.core.plot.XYPlot.java

/**
 * Utility method for drawing a vertical line on the data area of the plot.
 * //from   w w w . j a v a2 s .  c  o  m
 * @param g2
 *            the graphics device.
 * @param dataArea
 *            the data area.
 * @param value
 *            the coordinate, where to draw the line.
 * @param stroke
 *            the stroke to use.
 * @param paint
 *            the paint to use.
 */
protected void drawVerticalLine(Canvas g2, Rectangle2D dataArea, double value, Float stroke, Paint paint) {

    ValueAxis axis = getDomainAxis();
    if (getOrientation() == PlotOrientation.HORIZONTAL) {
        axis = getRangeAxis();
    }
    if (axis.getRange().contains(value)) {
        double xx = axis.valueToJava2D(value, dataArea, RectangleEdge.BOTTOM);
        Line2D line = new Line2D.Double(xx, dataArea.getMinY(), xx, dataArea.getMaxY());
        paint.setStyle(Paint.Style.STROKE);
        paint.setStrokeWidth(stroke);
        g2.drawLine((float) line.getX1(), (float) line.getY1(), (float) line.getX2(), (float) line.getY2(),
                paint);
    }

}

From source file:net.droidsolutions.droidcharts.core.plot.XYPlot.java

/**
 * Draws a domain crosshair.//from   w  w  w . ja v a 2s  .c  o m
 * 
 * @param g2
 *            the graphics target.
 * @param dataArea
 *            the data area.
 * @param orientation
 *            the plot orientation.
 * @param value
 *            the crosshair value.
 * @param axis
 *            the axis against which the value is measured.
 * @param stroke
 *            the stroke used to draw the crosshair line.
 * @param paint
 *            the paint used to draw the crosshair line.
 * 
 * @since 1.0.4
 */
protected void drawDomainCrosshair(Canvas g2, Rectangle2D dataArea, PlotOrientation orientation, double value,
        ValueAxis axis, Float stroke, Paint paint) {

    if (axis.getRange().contains(value)) {
        Line2D line = null;
        if (orientation == PlotOrientation.VERTICAL) {
            double xx = axis.valueToJava2D(value, dataArea, RectangleEdge.BOTTOM);
            line = new Line2D.Double(xx, dataArea.getMinY(), xx, dataArea.getMaxY());
        } else {
            double yy = axis.valueToJava2D(value, dataArea, RectangleEdge.LEFT);
            line = new Line2D.Double(dataArea.getMinX(), yy, dataArea.getMaxX(), yy);
        }
        paint.setStyle(Paint.Style.STROKE);
        paint.setStrokeWidth(stroke);
        g2.drawLine((float) line.getX1(), (float) line.getY1(), (float) line.getX2(), (float) line.getY2(),
                paint);
    }

}

From source file:net.droidsolutions.droidcharts.core.plot.XYPlot.java

/**
 * Draws a range crosshair./*from   w w w .j  av  a 2 s  .co m*/
 * 
 * @param g2
 *            the graphics target.
 * @param dataArea
 *            the data area.
 * @param orientation
 *            the plot orientation.
 * @param value
 *            the crosshair value.
 * @param axis
 *            the axis against which the value is measured.
 * @param stroke
 *            the stroke used to draw the crosshair line.
 * @param paint
 *            the paint used to draw the crosshair line.
 * 
 * @since 1.0.4
 */
protected void drawRangeCrosshair(Canvas g2, Rectangle2D dataArea, PlotOrientation orientation, double value,
        ValueAxis axis, Float stroke, Paint paint) {

    if (axis.getRange().contains(value)) {
        Line2D line = null;
        if (orientation == PlotOrientation.HORIZONTAL) {
            double xx = axis.valueToJava2D(value, dataArea, RectangleEdge.BOTTOM);
            line = new Line2D.Double(xx, dataArea.getMinY(), xx, dataArea.getMaxY());
        } else {
            double yy = axis.valueToJava2D(value, dataArea, RectangleEdge.LEFT);
            line = new Line2D.Double(dataArea.getMinX(), yy, dataArea.getMaxX(), yy);
        }
        paint.setStyle(Paint.Style.STROKE);
        paint.setStrokeWidth(stroke);
        g2.drawLine((float) line.getX1(), (float) line.getY1(), (float) line.getX2(), (float) line.getY2(),
                paint);
    }

}