LineView.java 文件源码

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

项目:soulissapp 作者:
/**
 * @param canvas The canvas you need to draw on.
 * @param point  The Point consists of the x y coordinates from left bottom to right top.
 *               Like is
 *               <p/>
 *               3
 *               2
 *               1
 *               0 1 2 3 4 5
 */
private void drawPopup(Canvas canvas, String num, Point point, int PopupColor) {
    boolean singularNum = (num.length() == 1);
    int sidePadding = ChartUtils.dip2px(getContext(), singularNum ? 8 : 5);
    int x = point.x;
    int y = point.y - ChartUtils.dip2px(getContext(), 5);
    Rect popupTextRect = new Rect();
    popupTextPaint.getTextBounds(num, 0, num.length(), popupTextRect);
    Rect r = new Rect(x - popupTextRect.width() / 2 - sidePadding,
            y - popupTextRect.height() - bottomTriangleHeight - popupTopPadding * 2 - popupBottomMargin,
            x + popupTextRect.width() / 2 + sidePadding,
            y + popupTopPadding - popupBottomMargin);

    NinePatchDrawable popup = (NinePatchDrawable) getResources().getDrawable(PopupColor);
    popup.setBounds(r);
    popup.draw(canvas);
    canvas.drawText(num, x, y - bottomTriangleHeight - popupBottomMargin, popupTextPaint);
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号