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);
}
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);
}
}
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;
}
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;
}
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;
}
Aggregations