本文整理汇总了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));
}
}
}
}