当前位置: 首页>>代码示例>>Java>>正文


Java Arc2D.setArc方法代码示例

本文整理汇总了Java中java.awt.geom.Arc2D.setArc方法的典型用法代码示例。如果您正苦于以下问题:Java Arc2D.setArc方法的具体用法?Java Arc2D.setArc怎么用?Java Arc2D.setArc使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.geom.Arc2D的用法示例。


在下文中一共展示了Arc2D.setArc方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: draw

import java.awt.geom.Arc2D; //导入方法依赖的package包/类
/**
 * Draws the scale on the dial plot.
 *
 * @param g2  the graphics target (<code>null</code> not permitted).
 * @param plot  the dial plot (<code>null</code> not permitted).
 * @param frame  the reference frame that is used to construct the
 *     geometry of the plot (<code>null</code> not permitted).
 * @param view  the visible part of the plot (<code>null</code> not 
 *     permitted).
 */
public void draw(Graphics2D g2, DialPlot plot, Rectangle2D frame, 
        Rectangle2D view) {
    
    Rectangle2D arcRect = DialPlot.rectangleByRadius(frame, 
            this.tickRadius, this.tickRadius);
    Rectangle2D arcRectInner = DialPlot.rectangleByRadius(frame, 
            this.tickRadius - this.minorTickLength, 
            this.tickRadius - this.minorTickLength);
    Rectangle2D arcRectForLabels = DialPlot.rectangleByRadius(frame, 
            this.tickRadius - this.tickLabelOffset, 
            this.tickRadius - this.tickLabelOffset);
    
    boolean firstLabel = true;
    
    Arc2D arc = new Arc2D.Double();
    for (double v = this.lowerBound; v <= this.upperBound; 
            v += this.majorTickIncrement) {
        arc.setArc(arcRect, this.startAngle, valueToAngle(v) 
                - this.startAngle, Arc2D.OPEN);
        Point2D pt0 = arc.getEndPoint();
        arc.setArc(arcRectInner, this.startAngle, valueToAngle(v) 
                - this.startAngle, Arc2D.OPEN);
        Point2D pt1 = arc.getEndPoint();
        g2.setPaint(this.majorTickPaint);
        g2.setStroke(this.majorTickStroke);
        g2.draw(new Line2D.Double(pt0, pt1));
        arc.setArc(arcRectForLabels, this.startAngle, valueToAngle(v) 
                - this.startAngle, Arc2D.OPEN);
        Point2D pt2 = arc.getEndPoint();
        
        if (tickLabelsVisible) {
            if (!firstLabel || this.firstTickLabelVisible) {
                g2.setFont(this.tickLabelFont);
                TextUtilities.drawAlignedString(String.valueOf(v), g2, 
                        (float) pt2.getX(), (float) pt2.getY(), 
                        TextAnchor.CENTER);
            }
        }
        firstLabel = false;
        
        // now do the minor tick marks
        if (this.minorTickCount > 0) {
            double minorTickIncrement = this.majorTickIncrement 
                    / (this.minorTickCount + 1);
            for (int i = 0; i < this.minorTickCount; i++) {
                double vv = v + ((i + 1) * minorTickIncrement);
                if (vv >= this.upperBound) {
                    break;
                }
                double angle = valueToAngle(vv);
               
                arc.setArc(arcRect, this.startAngle, angle 
                        - this.startAngle, Arc2D.OPEN);
                pt0 = arc.getEndPoint();
                arc.setArc(arcRectInner, this.startAngle, angle 
                        - this.startAngle, Arc2D.OPEN);
                Point2D pt3 = arc.getEndPoint();
                g2.setStroke(new BasicStroke(1.0f));
                g2.draw(new Line2D.Double(pt0, pt3));
            }
        }
        
    }
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:75,代码来源:StandardDialScale.java


注:本文中的java.awt.geom.Arc2D.setArc方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。