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