Search in sources :

Example 66 with Path

use of android.graphics.Path in project carat by amplab.

the class LineChart method drawLinearFill.

protected void drawLinearFill(LineDataSet dataSet, ArrayList<Entry> entries) {
    // mDrawCanvas.drawVertices(VertexMode.TRIANGLE_STRIP,
    // valuePoints.length, valuePoints, 0,
    // null, 0, null, 0, null, 0, 0, paint);
    mRenderPaint.setStyle(Paint.Style.FILL);
    mRenderPaint.setColor(dataSet.getFillColor());
    // filled is drawn with less alpha
    mRenderPaint.setAlpha(dataSet.getFillAlpha());
    // mRenderPaint.setShader(dataSet.getShader());
    Path filled = generateFilledPath(entries, mFillFormatter.getFillLinePosition(dataSet, mData, mYChartMax, mYChartMin));
    mTrans.pathValueToPixel(filled);
    mDrawCanvas.drawPath(filled, mRenderPaint);
    // restore alpha
    mRenderPaint.setAlpha(255);
// mRenderPaint.setShader(null);
}
Also used : Path(android.graphics.Path)

Example 67 with Path

use of android.graphics.Path in project carat by amplab.

the class LineChart method drawLinear.

protected void drawLinear(LineDataSet dataSet, ArrayList<Entry> entries) {
    mRenderPaint.setStyle(Paint.Style.STROKE);
    // more than 1 color
    if (dataSet.getColors() == null || dataSet.getColors().size() > 1) {
        float[] valuePoints = mTrans.generateTransformedValuesLineScatter(entries, mPhaseY);
        for (int j = 0; j < (valuePoints.length - 2) * mPhaseX; j += 2) {
            if (isOffContentRight(valuePoints[j]))
                break;
            // bounds
            if (j != 0 && isOffContentLeft(valuePoints[j - 1]) && isOffContentTop(valuePoints[j + 1]) && isOffContentBottom(valuePoints[j + 1]))
                continue;
            // get the color that is set for this line-segment
            mRenderPaint.setColor(dataSet.getColor(j / 2));
            mDrawCanvas.drawLine(valuePoints[j], valuePoints[j + 1], valuePoints[j + 2], valuePoints[j + 3], mRenderPaint);
        }
    } else {
        // only one color per dataset
        mRenderPaint.setColor(dataSet.getColor());
        Path line = generateLinePath(entries);
        mTrans.pathValueToPixel(line);
        mDrawCanvas.drawPath(line, mRenderPaint);
    }
    mRenderPaint.setPathEffect(null);
    // if drawing filled is enabled
    if (dataSet.isDrawFilledEnabled() && entries.size() > 0) {
        drawLinearFill(dataSet, entries);
    }
}
Also used : Path(android.graphics.Path) Paint(android.graphics.Paint)

Example 68 with Path

use of android.graphics.Path in project carat by amplab.

the class LineChart method generateLinePath.

/**
     * Generates the path that is used for drawing a single line.
     * 
     * @param entries
     * @return
     */
private Path generateLinePath(ArrayList<Entry> entries) {
    Path line = new Path();
    line.moveTo(entries.get(0).getXIndex(), entries.get(0).getVal() * mPhaseY);
    // create a new path
    for (int x = 1; x < entries.size() * mPhaseX; x++) {
        Entry e = entries.get(x);
        line.lineTo(e.getXIndex(), e.getVal() * mPhaseY);
    }
    return line;
}
Also used : Path(android.graphics.Path) Entry(com.github.mikephil.charting.data.Entry) Paint(android.graphics.Paint)

Example 69 with Path

use of android.graphics.Path in project platform_frameworks_base by android.

the class OrientedBoundingBox method toPath.

/**
     * Currently used for debugging purpose only.
     *
     * @hide
     */
public Path toPath() {
    Path path = new Path();
    float[] point = new float[2];
    point[0] = -width / 2;
    point[1] = height / 2;
    Matrix matrix = new Matrix();
    matrix.setRotate(orientation);
    matrix.postTranslate(centerX, centerY);
    matrix.mapPoints(point);
    path.moveTo(point[0], point[1]);
    point[0] = -width / 2;
    point[1] = -height / 2;
    matrix.mapPoints(point);
    path.lineTo(point[0], point[1]);
    point[0] = width / 2;
    point[1] = -height / 2;
    matrix.mapPoints(point);
    path.lineTo(point[0], point[1]);
    point[0] = width / 2;
    point[1] = height / 2;
    matrix.mapPoints(point);
    path.lineTo(point[0], point[1]);
    path.close();
    return path;
}
Also used : Path(android.graphics.Path) Matrix(android.graphics.Matrix)

Example 70 with Path

use of android.graphics.Path in project platform_frameworks_base by android.

the class Gesture method toPath.

public Path toPath(Path path) {
    if (path == null)
        path = new Path();
    final ArrayList<GestureStroke> strokes = mStrokes;
    final int count = strokes.size();
    for (int i = 0; i < count; i++) {
        path.addPath(strokes.get(i).getPath());
    }
    return path;
}
Also used : Path(android.graphics.Path) Paint(android.graphics.Paint)

Aggregations

Path (android.graphics.Path)631 Paint (android.graphics.Paint)237 RectF (android.graphics.RectF)142 Rect (android.graphics.Rect)40 Canvas (android.graphics.Canvas)39 Matrix (android.graphics.Matrix)36 TextPaint (android.text.TextPaint)27 Bitmap (android.graphics.Bitmap)26 ObjectAnimator (android.animation.ObjectAnimator)18 LinearGradient (android.graphics.LinearGradient)18 PointF (android.graphics.PointF)18 Point (android.graphics.Point)16 View (android.view.View)16 RadialGradient (android.graphics.RadialGradient)15 Animator (android.animation.Animator)13 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)12 PathMeasure (android.graphics.PathMeasure)11 PropertyValuesHolder (android.animation.PropertyValuesHolder)10 InflateException (android.view.InflateException)10 ViewGroup (android.view.ViewGroup)10