LineChartRenderer.java 文件源码

java
阅读 50 收藏 0 点赞 0 评论 0

项目:SmartChart 作者:
private void drawArea(Canvas canvas, Line line) {
    final int lineSize = line.getValues().size();
    if (lineSize < 2) {
        //No point to draw area for one point or empty line.
        return;
    }

    final Rect contentRect = computator.getContentRectMinusAllMargins();
    final float baseRawValue = Math.min(contentRect.bottom, Math.max(computator.computeRawY(baseValue),
            contentRect.top));
    //That checks works only if the last point is the right most one.
    final float left = Math.max(computator.computeRawX(line.getValues().get(0).getX()), contentRect.left);
    final float right = Math.min(computator.computeRawX(line.getValues().get(lineSize - 1).getX()),
            contentRect.right);

    path.lineTo(right, baseRawValue);
    path.lineTo(left, baseRawValue);
    path.close();

    linePaint.setStyle(Paint.Style.FILL);
    linePaint.setAlpha(line.getAreaTransparency());
    linePaint.setShader(line.getGradientToTransparent() ?
            new LinearGradient(0, 0, 0, canvas.getHeight(), line.getColor(),
                    line.getColor() & 0x00ffffff, Shader.TileMode.MIRROR) :
            null);
    canvas.drawPath(path, linePaint);
    linePaint.setStyle(Paint.Style.STROKE);
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号