List of usage examples for org.jfree.chart.plot Plot getClass
@HotSpotIntrinsicCandidate public final native Class<?> getClass();
From source file:org.openfaces.component.chart.impl.plots.PlotUtil.java
private static void setRangeGridlinesVisible(Plot plot, boolean value) { if (plot instanceof CategoryPlot) ((CategoryPlot) plot).setRangeGridlinesVisible(value); else if (plot instanceof XYPlot) ((XYPlot) plot).setRangeGridlinesVisible(value); else// w ww .j av a2s . c om throw new IllegalArgumentException("Unknown plot type: " + plot.getClass().getName()); }
From source file:org.openfaces.component.chart.impl.plots.PlotUtil.java
private static void setDomainGridlinesVisible(Plot plot, boolean value) { if (plot instanceof CategoryPlot) ((CategoryPlot) plot).setDomainGridlinesVisible(value); else if (plot instanceof XYPlot) ((XYPlot) plot).setDomainGridlinesVisible(value); else// w w w . j a va 2s .co m throw new IllegalArgumentException("Unknown plot type: " + plot.getClass().getName()); }
From source file:org.openfaces.component.chart.impl.plots.PlotUtil.java
private static void setRangeGridlineStrokeAndPaint(Plot plot, Stroke stroke, Paint paint) { if (plot instanceof CategoryPlot) { ((CategoryPlot) plot).setRangeGridlinePaint(paint); ((CategoryPlot) plot).setRangeGridlineStroke(stroke); } else if (plot instanceof XYPlot) { ((XYPlot) plot).setRangeGridlinePaint(paint); ((XYPlot) plot).setRangeGridlineStroke(stroke); } else/* w w w. j a v a 2s .c o m*/ throw new IllegalArgumentException("Unknown plot type: " + plot.getClass().getName()); }
From source file:org.openfaces.component.chart.impl.plots.PlotUtil.java
private static void setDomainGridlineStrokeAndPaint(Plot plot, Stroke stroke, Paint paint) { if (plot instanceof CategoryPlot) { ((CategoryPlot) plot).setDomainGridlinePaint(paint); ((CategoryPlot) plot).setDomainGridlineStroke(stroke); } else if (plot instanceof XYPlot) { ((XYPlot) plot).setDomainGridlinePaint(paint); ((XYPlot) plot).setDomainGridlineStroke(stroke); } else//from w ww . j a v a2 s . co m throw new IllegalArgumentException("Unknown plot type: " + plot.getClass().getName()); }
From source file:net.sf.dynamicreports.test.jasper.chart.PieChartTest.java
@Override public void test() { super.test(); numberOfPagesTest(1);//from www . ja v a 2 s . c o m JFreeChart chart = getChart("summary.chart1", 0); Plot plot = chart.getPlot(); Assert.assertEquals("plot", PiePlot.class, plot.getClass()); Assert.assertFalse("circular", ((PiePlot) plot).isCircular()); Assert.assertEquals("label format", "label {0}", ((StandardPieSectionLabelGenerator) ((PiePlot) plot).getLabelGenerator()).getLabelFormat()); Assert.assertEquals("legend label format", "legend label {0}", ((StandardPieSectionLabelGenerator) ((PiePlot) plot).getLegendLabelGenerator()).getLabelFormat()); chart = getChart("summary.chart2", 0); plot = chart.getPlot(); Assert.assertNull("label format", ((PiePlot) plot).getLabelGenerator()); }
From source file:net.sf.dynamicreports.test.jasper.chart.Pie3DChartTest.java
@Override public void test() { super.test(); numberOfPagesTest(1);//from ww w .j a v a 2 s .c o m JFreeChart chart = getChart("summary.chart1", 0); Plot plot = chart.getPlot(); Assert.assertEquals("plot", PiePlot3D.class, plot.getClass()); Assert.assertTrue("circular", ((PiePlot) plot).isCircular()); Assert.assertEquals("label format", "label {0}", ((StandardPieSectionLabelGenerator) ((PiePlot) plot).getLabelGenerator()).getLabelFormat()); Assert.assertEquals("legend label format", "legend label {0}", ((StandardPieSectionLabelGenerator) ((PiePlot) plot).getLegendLabelGenerator()).getLabelFormat()); Assert.assertEquals("depth factor", 0.5, ((PiePlot3D) plot).getDepthFactor()); chart = getChart("summary.chart2", 0); plot = chart.getPlot(); Assert.assertNull("label format", ((PiePlot) plot).getLabelGenerator()); }
From source file:net.sf.dynamicreports.test.jasper.chart.MeterChartTest.java
@Override public void test() { super.test(); numberOfPagesTest(1);//from w w w . j a v a 2 s . c om JFreeChart chart = getChart("summary.chart1", 0); Plot plot = chart.getPlot(); Assert.assertEquals("renderer", MeterPlot.class, plot.getClass()); MeterPlot meterPlot = (MeterPlot) plot; Assert.assertEquals("value", 15, meterPlot.getDataset().getValue()); Assert.assertEquals("data range low", 3d, meterPlot.getRange().getLowerBound()); Assert.assertEquals("data range high", 30d, meterPlot.getRange().getUpperBound()); Assert.assertEquals("value color", Color.BLUE, meterPlot.getValuePaint()); Assert.assertEquals("value mask", "15.0", meterPlot.getTickLabelFormat().format(15)); Assert.assertEquals("value font", new Font("Arial", Font.PLAIN, 10), meterPlot.getValueFont()); Assert.assertEquals("shape", DialShape.CIRCLE, meterPlot.getDialShape()); Assert.assertEquals("meter angle", 270, meterPlot.getMeterAngle()); Assert.assertEquals("units", "units", meterPlot.getUnits()); Assert.assertEquals("tick interval", 3d, meterPlot.getTickSize()); Assert.assertEquals("background color", Color.LIGHT_GRAY, meterPlot.getDialBackgroundPaint()); Assert.assertEquals("needle color", Color.CYAN, meterPlot.getNeedlePaint()); Assert.assertEquals("tick color", Color.MAGENTA, meterPlot.getTickPaint()); Assert.assertEquals("tick label font", new Font("Courier New", Font.PLAIN, 10), meterPlot.getTickLabelFont()); Assert.assertEquals("intervals size", 2, meterPlot.getIntervals().size()); intervalTest((MeterInterval) meterPlot.getIntervals().get(0), "red", new Color(1f, 0f, 0f, 0.8f), 25d, 30d); intervalTest((MeterInterval) meterPlot.getIntervals().get(1), "yellow", new Color(1f, 1f, 0f, 0.5f), 20d, 25d); }
From source file:net.sf.dynamicreports.test.jasper.chart.ThermometerChartTest.java
@Override public void test() { super.test(); numberOfPagesTest(1);//w w w . j a v a2 s .co m JFreeChart chart = getChart("summary.chart1", 0); Plot plot = chart.getPlot(); Assert.assertEquals("renderer", ThermometerPlot.class, plot.getClass()); ThermometerPlot thermometerPlot = (ThermometerPlot) plot; Assert.assertEquals("value", 15, thermometerPlot.getDataset().getValue()); Assert.assertEquals("data range low", 3d, thermometerPlot.getLowerBound()); Assert.assertEquals("data range high", 30d, thermometerPlot.getUpperBound()); Assert.assertEquals("value color", Color.BLUE, thermometerPlot.getValuePaint()); try { Field field = thermometerPlot.getClass().getDeclaredField("valueFormat"); field.setAccessible(true); Assert.assertEquals("value mask", "15.0", ((NumberFormat) field.get(thermometerPlot)).format(15)); } catch (Exception e) { e.printStackTrace(); Assert.fail(e.getMessage()); } Assert.assertEquals("value font", new Font("Arial", Font.PLAIN, 10), thermometerPlot.getValueFont()); Assert.assertEquals("value location", ThermometerPlot.BULB, thermometerPlot.getValueLocation()); Assert.assertEquals("mercury color", Color.LIGHT_GRAY, thermometerPlot.getMercuryPaint()); try { Field field = thermometerPlot.getClass().getDeclaredField("subrangeInfo"); field.setAccessible(true); double[][] subrangeInfo = (double[][]) field.get(thermometerPlot); Assert.assertEquals("low data range low", 8d, subrangeInfo[2][0]); Assert.assertEquals("low data range high", 10d, subrangeInfo[2][1]); Assert.assertEquals("medium data range low", 18d, subrangeInfo[1][0]); Assert.assertEquals("medium data range high", 20d, subrangeInfo[1][1]); Assert.assertEquals("high data range low", 28d, subrangeInfo[0][0]); Assert.assertEquals("high data range high", 30d, subrangeInfo[0][1]); } catch (Exception e) { e.printStackTrace(); Assert.fail(e.getMessage()); } }
From source file:net.sf.maltcms.common.charts.api.overlay.AbstractChartOverlay.java
/** * * @param chartPanel//from w w w . ja v a2 s . co m * @param x1 * @param y1 * @return */ public static AffineTransform getModelToViewTransformXY(ChartPanel chartPanel, double x1, double y1) { double zoomX = chartPanel.getScaleX(); double zoomY = chartPanel.getScaleY(); Insets insets = chartPanel.getInsets(); AffineTransform at = getTranslateInstance(insets.left, insets.top); at.concatenate(getScaleInstance(zoomX, zoomY)); Plot plot = chartPanel.getChart().getPlot(); if (plot instanceof XYPlot) { XYPlot xyp = (XYPlot) plot; RectangleEdge xAxisLocation = xyp.getDomainAxisEdge(); RectangleEdge yAxisLocation = xyp.getRangeAxisEdge(); PlotOrientation orientation = xyp.getOrientation(); Rectangle2D dataArea = chartPanel.getChartRenderingInfo().getPlotInfo().getDataArea(); double transX = xyp.getDomainAxis().valueToJava2D(x1, dataArea, xAxisLocation); double transY = xyp.getRangeAxis().valueToJava2D(y1, dataArea, yAxisLocation); if (orientation == PlotOrientation.HORIZONTAL) { double tmp = transX; transX = transY; transY = tmp; } at.concatenate(getTranslateInstance(transX, transY)); return at; } throw new IllegalArgumentException("Unsupported plot type: " + plot.getClass()); }
From source file:org.openfaces.component.chart.impl.configuration.PlotGridLinesConfigurator.java
private void setRangeGridlinesVisible(Plot plot, boolean value) { if (plot instanceof CategoryPlot) ((CategoryPlot) plot).setRangeGridlinesVisible(value); else if (plot instanceof XYPlot) ((XYPlot) plot).setRangeGridlinesVisible(value); else//from www . ja v a 2 s. c o m throw new IllegalArgumentException("Unknown plot type: " + plot.getClass().getName()); }