PiePlot.java 文件源码

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

项目:jfreechart 作者:
/**
 * Returns a rectangle that can be used to create a pie section (taking
 * into account the amount by which the pie section is 'exploded').
 *
 * @param unexploded  the area inside which the unexploded pie sections are
 *                    drawn.
 * @param exploded  the area inside which the exploded pie sections are
 *                  drawn.
 * @param angle  the start angle.
 * @param extent  the extent of the arc.
 * @param explodePercent  the amount by which the pie section is exploded.
 *
 * @return A rectangle that can be used to create a pie section.
 */
protected Rectangle2D getArcBounds(Rectangle2D unexploded,
                                   Rectangle2D exploded,
                                   double angle, double extent,
                                   double explodePercent) {

    if (explodePercent == 0.0) {
        return unexploded;
    }
    Arc2D arc1 = new Arc2D.Double(unexploded, angle, extent / 2,
            Arc2D.OPEN);
    Point2D point1 = arc1.getEndPoint();
    Arc2D.Double arc2 = new Arc2D.Double(exploded, angle, extent / 2,
            Arc2D.OPEN);
    Point2D point2 = arc2.getEndPoint();
    double deltaX = (point1.getX() - point2.getX()) * explodePercent;
    double deltaY = (point1.getY() - point2.getY()) * explodePercent;
    return new Rectangle2D.Double(unexploded.getX() - deltaX,
            unexploded.getY() - deltaY, unexploded.getWidth(),
            unexploded.getHeight());
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号