List of usage examples for org.jfree.chart.plot.dial DialPlot getScale
public DialScale getScale(int index)
From source file:org.pentaho.chart.plugin.jfreechart.dial.JFreeDialChartGeneratorIT.java
public void testScale() throws Exception { JFreeChart chart = getJFreeChart("testchart.xml", new Object[][] { { 8D } }); //$NON-NLS-1$ DialPlot plot = (DialPlot) chart.getPlot(); StandardDialScale scale = (StandardDialScale) plot.getScale(0); assertEquals(-20D, scale.getLowerBound()); assertEquals(20D, scale.getUpperBound()); assertEquals(-135D, scale.getStartAngle()); assertEquals(-180D, scale.getExtent()); assertEquals(5D, scale.getMajorTickIncrement()); assertEquals(2, scale.getMinorTickCount()); assertEquals(new Color(255, 105, 180) /*hotpink*/, scale.getTickLabelPaint()); assertEquals(12, scale.getTickLabelFont().getSize()); assertEquals(Font.ITALIC | Font.BOLD, scale.getTickLabelFont().getStyle()); // had trouble getting a font comparison to work without breaking it down into size, style, and name assertEquals("Monospaced", scale.getTickLabelFont().getName()); //$NON-NLS-1$ assertEquals(5F, ((BasicStroke) scale.getMajorTickStroke()).getLineWidth()); assertEquals(3F, ((BasicStroke) scale.getMinorTickStroke()).getLineWidth()); assertEquals(0.10D, scale.getMajorTickLength()); assertEquals(0.05D, scale.getMinorTickLength()); }
From source file:net.sf.fspdfs.chartthemes.spring.ScaledDialRange.java
/** * Draws the range./*from w w w. j a v a 2 s .com*/ * * @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). */ 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); }
From source file:net.sf.jasperreports.chartthemes.spring.ScaledDialRange.java
/** * Draws the range./*from w w w . j a va2 s . c om*/ * * @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); }