use of com.codename1.charts.compat.PathMeasure in project CodenameOne by codenameone.
the class CubicLineChart method drawPath.
@Override
protected void drawPath(Canvas canvas, List<Float> points, Paint paint, boolean circular) {
GeneralPath p = new GeneralPath();
float x = points.get(0);
float y = points.get(1);
p.moveTo(x, y);
int length = points.size();
if (circular) {
length -= 4;
}
Point p1 = new Point();
Point p2 = new Point();
Point p3 = new Point();
for (int i = 0; i < length; i += 2) {
int nextIndex = i + 2 < length ? i + 2 : i;
int nextNextIndex = i + 4 < length ? i + 4 : nextIndex;
calc(points, p1, i, nextIndex, mSecondMultiplier);
p2.setX(points.get(nextIndex));
p2.setY(points.get(nextIndex + 1));
calc(points, p3, nextIndex, nextNextIndex, mFirstMultiplier);
// From last point, approaching x1/y1 and x2/y2 and ends up at x3/y3
p.curveTo(p1.getX(), p1.getY(), p2.getX(), p2.getY(), p3.getX(), p3.getY());
}
mPathMeasure = new PathMeasure(p, false);
if (circular) {
for (int i = length; i < length + 4; i += 2) {
p.lineTo(points.get(i), points.get(i + 1));
}
p.lineTo(points.get(0), points.get(1));
}
canvas.drawPath(p, paint);
}
Aggregations