ArrowPainter.java 文件源码

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

项目:ramus 作者:
/**
 * Малює кінець стрілки.
 *
 * @param g    Область для виводу стрілки.
 * @param x    Координата x кінця стрілки.
 * @param y    Координата y кінця стрілки.
 * @param type Напрямок направленості стрілки, MovingPanel.RIGHT,...
 */

public void paintArrowEnd(final Graphics2D g, double x1, double y1,
                          final double xD, final double yD, int type) {
    final float x = (float) xD;
    final float y = (float) yD;
    final GeneralPath t = new GeneralPath(Path2D.WIND_EVEN_ODD, 3);
    t.moveTo(x, y);
    final float arrowWidth = (float) movingArea
            .getIDoubleOrdinate(ARROW_WIDTH);
    final float arrowHeight = (float) movingArea
            .getIDoubleOrdinate(ARROW_HEIGHT);
    type = MovingPanel.getOpposite(type);
    switch (type) {
        case MovingPanel.BOTTOM: {
            t.lineTo(x - arrowWidth, y - arrowHeight);
            t.lineTo(x + arrowWidth, y - arrowHeight);
        }
        break;
        case MovingPanel.RIGHT: {
            t.lineTo(x - arrowHeight, y - arrowWidth);
            t.lineTo(x - arrowHeight, y + arrowWidth);
        }
        break;
        case MovingPanel.TOP: {
            t.lineTo(x - arrowWidth, y + arrowHeight);
            t.lineTo(x + arrowWidth, y + arrowHeight);
        }
        break;
        case MovingPanel.LEFT: {
            t.lineTo(x + arrowHeight, y - arrowWidth);
            t.lineTo(x + arrowHeight, y + arrowWidth);
        }
        break;
    }
    t.closePath();
    g.fill(t);
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号