本文整理汇总了Java中org.jfree.chart.plot.dial.DialPlot.rectangleByRadius方法的典型用法代码示例。如果您正苦于以下问题:Java DialPlot.rectangleByRadius方法的具体用法?Java DialPlot.rectangleByRadius怎么用?Java DialPlot.rectangleByRadius使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jfree.chart.plot.dial.DialPlot
的用法示例。
在下文中一共展示了DialPlot.rectangleByRadius方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: draw
import org.jfree.chart.plot.dial.DialPlot; //导入方法依赖的package包/类
/**
* Draws the range.
*
* @param g2 the graphics target.
* @param plot the plot.
* @param frame the dial's reference frame (in Java2D space).
* @param view the dial's view rectangle (in Java2D space).
*/
@Override
public void draw(Graphics2D g2, DialPlot plot, Rectangle2D frame,
Rectangle2D view) {
Rectangle2D arcRectInner = DialPlot.rectangleByRadius(frame,
this.getInnerRadius(), this.getInnerRadius());
Rectangle2D arcRectOuter = DialPlot.rectangleByRadius(frame,
this.getOuterRadius(), this.getOuterRadius());
DialScale scale = plot.getScale(this.getScaleIndex());
if (scale == null) {
throw new RuntimeException("No scale for scaleIndex = "
+ this.getScaleIndex());
}
double angleMin = scale.valueToAngle(this.getLowerBound());
double angleMax = scale.valueToAngle(this.getUpperBound());
Arc2D arcInner = new Arc2D.Double(arcRectInner, angleMin,
angleMax - angleMin, Arc2D.OPEN);
Arc2D arcOuter = new Arc2D.Double(arcRectOuter, angleMax,
angleMin - angleMax, Arc2D.OPEN);
g2.setPaint(this.getPaint());
g2.setStroke(new BasicStroke(this.lineWidth, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER));
g2.draw(arcInner);
g2.draw(arcOuter);
}
示例2: draw
import org.jfree.chart.plot.dial.DialPlot; //导入方法依赖的package包/类
/**
* Draws the background to the specified graphics device. If the dial
* frame specifies a window, the clipping region will already have been
* set to this window before this method is called.
*
* @param g2 the graphics device (<code>null</code> not permitted).
* @param plot the plot (ignored here).
* @param frame the dial frame (ignored here).
* @param view the view rectangle (<code>null</code> not permitted).
*/
@Override
public void draw(Graphics2D g2, DialPlot plot, Rectangle2D frame,
Rectangle2D view) {
// work out the anchor point
Rectangle2D f = DialPlot.rectangleByRadius(frame, getRadius(),
this.getRadius());
Arc2D arc = new Arc2D.Double(f, this.getAngle(), 0.0, Arc2D.OPEN);
Point2D pt = arc.getStartPoint();
// calculate the bounds of the template value
FontMetrics fm = g2.getFontMetrics(this.getFont());
String s = this.getNumberFormat().format(this.getTemplateValue());
Rectangle2D tb = TextUtilities.getTextBounds(s, g2, fm);
// align this rectangle to the frameAnchor
Rectangle2D bounds = RectangleAnchor.createRectangle(new Size2D(
tb.getWidth(), tb.getHeight()), pt.getX(), pt.getY(),
this.getFrameAnchor());
// add the insets
Rectangle2D fb = this.getInsets().createOutsetRectangle(bounds);
// draw the background
g2.setPaint(this.getBackgroundPaint());
g2.fill(fb);
// draw the border
g2.setStroke(this.getOutlineStroke());
g2.setPaint(this.getOutlinePaint());
g2.draw(fb);
// now find the text anchor point
String valueStr = this.getNumberFormat().format(ChartThemesUtilities.getScaledValue(plot.getValue(this.getDatasetIndex()), scale));
Point2D pt2 = RectangleAnchor.coordinates(bounds, this.getValueAnchor());
g2.setPaint(this.getPaint());
g2.setFont(this.getFont());
TextUtilities.drawAlignedString(valueStr, g2, (float) pt2.getX(),
(float) pt2.getY(), this.getTextAnchor());
}