org.jfree.chart.renderer.xy.XYAreaRenderer Java Examples
The following examples show how to use
org.jfree.chart.renderer.xy.XYAreaRenderer.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JPanelProfil.java From Course_Generator with GNU General Public License v3.0 | 6 votes |
private JFreeChart CreateChartProfil(XYDataset dataset) { JFreeChart chart = ChartFactory.createXYAreaChart("", "Distance", // x axis label "Elevation", // y axis label dataset, // data PlotOrientation.VERTICAL, false, // include legend true, // tooltips false // urls ); chart.setBackgroundPaint(Color.white); // Panel background color XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.gray); plot.setRangeGridlinePaint(Color.gray); XYAreaRenderer renderer = new XYAreaRenderer(); renderer.setSeriesPaint(0, new Color(0x99, 0xff, 0x00)); renderer.setOutline(true); renderer.setSeriesOutlineStroke(0, new BasicStroke(2.0f)); plot.setRenderer(renderer); // NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); // rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); return chart; }
Example #2
Source File: ChartFactory.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Creates an area chart using an {@link XYDataset}. * <P> * The chart object returned by this method uses an {@link XYPlot} instance * as the plot, with a {@link NumberAxis} for the domain axis, a * {@link NumberAxis} as the range axis, and a {@link XYAreaRenderer} as * the renderer. * * @param title the chart title (<code>null</code> permitted). * @param xAxisLabel a label for the X-axis (<code>null</code> permitted). * @param yAxisLabel a label for the Y-axis (<code>null</code> permitted). * @param dataset the dataset for the chart (<code>null</code> permitted). * @param legend a flag specifying whether or not a legend is required. * * @return An XY area chart. */ public static JFreeChart createXYAreaChart(String title, String xAxisLabel, String yAxisLabel, XYDataset dataset, boolean legend) { NumberAxis xAxis = new NumberAxis(xAxisLabel); xAxis.setAutoRangeIncludesZero(false); NumberAxis yAxis = new NumberAxis(yAxisLabel); XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null); plot.setForegroundAlpha(0.5f); XYAreaRenderer renderer = new XYAreaRenderer(XYAreaRenderer.AREA); renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); plot.setRenderer(renderer); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); currentTheme.apply(chart); return chart; }
Example #3
Source File: XYAreaRendererTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { XYAreaRenderer r1 = new XYAreaRenderer(); XYAreaRenderer r2 = new XYAreaRenderer(); assertTrue(r1.equals(r2)); int h1 = r1.hashCode(); int h2 = r2.hashCode(); assertEquals(h1, h2); }
Example #4
Source File: StackedXYAreaRendererTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * A test for bug 1593156. */ public void testBug1593156() { boolean success = false; try { DefaultTableXYDataset dataset = new DefaultTableXYDataset(); XYSeries s1 = new XYSeries("Series 1", true, false); s1.add(5.0, 5.0); s1.add(10.0, 15.5); s1.add(15.0, 9.5); s1.add(20.0, 7.5); dataset.addSeries(s1); XYSeries s2 = new XYSeries("Series 2", true, false); s2.add(5.0, 5.0); s2.add(10.0, 15.5); s2.add(15.0, 9.5); s2.add(20.0, 3.5); dataset.addSeries(s2); StackedXYAreaRenderer renderer = new StackedXYAreaRenderer( XYAreaRenderer.LINES); XYPlot plot = new XYPlot(dataset, new NumberAxis("X"), new NumberAxis("Y"), renderer); JFreeChart chart = new JFreeChart(plot); /* BufferedImage image = */ chart.createBufferedImage(300, 200, null); success = true; } catch (NullPointerException e) { e.printStackTrace(); success = false; } assertTrue(success); }
Example #5
Source File: XYAreaRendererTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * A check for the datasetIndex and seriesIndex fields in the LegendItem * returned by the getLegendItem() method. */ public void testGetLegendItemSeriesIndex() { XYSeriesCollection d1 = new XYSeriesCollection(); XYSeries s1 = new XYSeries("S1"); s1.add(1.0, 1.1); XYSeries s2 = new XYSeries("S2"); s2.add(1.0, 1.1); d1.addSeries(s1); d1.addSeries(s2); XYSeriesCollection d2 = new XYSeriesCollection(); XYSeries s3 = new XYSeries("S3"); s3.add(1.0, 1.1); XYSeries s4 = new XYSeries("S4"); s4.add(1.0, 1.1); XYSeries s5 = new XYSeries("S5"); s5.add(1.0, 1.1); d2.addSeries(s3); d2.addSeries(s4); d2.addSeries(s5); XYAreaRenderer r = new XYAreaRenderer(); XYPlot plot = new XYPlot(d1, new NumberAxis("x"), new NumberAxis("y"), r); plot.setDataset(1, d2); /*JFreeChart chart =*/ new JFreeChart(plot); LegendItem li = r.getLegendItem(1, 2); assertEquals("S5", li.getLabel()); assertEquals(1, li.getDatasetIndex()); assertEquals(2, li.getSeriesIndex()); }
Example #6
Source File: XYAreaRendererTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Draws the chart with a <code>null</code> info object to make sure that * no exceptions are thrown (particularly by code in the renderer). */ public void testDrawWithNullInfo() { boolean success = false; try { DefaultTableXYDataset dataset = new DefaultTableXYDataset(); XYSeries s1 = new XYSeries("Series 1", true, false); s1.add(5.0, 5.0); s1.add(10.0, 15.5); s1.add(15.0, 9.5); s1.add(20.0, 7.5); dataset.addSeries(s1); XYSeries s2 = new XYSeries("Series 2", true, false); s2.add(5.0, 5.0); s2.add(10.0, 15.5); s2.add(15.0, 9.5); s2.add(20.0, 3.5); dataset.addSeries(s2); XYPlot plot = new XYPlot(dataset, new NumberAxis("X"), new NumberAxis("Y"), new XYAreaRenderer()); JFreeChart chart = new JFreeChart(plot); /* BufferedImage image = */ chart.createBufferedImage(300, 200, null); success = true; } catch (NullPointerException e) { e.printStackTrace(); success = false; } assertTrue(success); }
Example #7
Source File: XYAreaRendererTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { XYAreaRenderer r1 = new XYAreaRenderer(); XYAreaRenderer r2 = new XYAreaRenderer(); assertTrue(r1.equals(r2)); int h1 = r1.hashCode(); int h2 = r2.hashCode(); assertEquals(h1, h2); }
Example #8
Source File: StackedXYAreaRendererTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * A test for bug 1593156. */ public void testBug1593156() { boolean success = false; try { DefaultTableXYDataset dataset = new DefaultTableXYDataset(); XYSeries s1 = new XYSeries("Series 1", true, false); s1.add(5.0, 5.0); s1.add(10.0, 15.5); s1.add(15.0, 9.5); s1.add(20.0, 7.5); dataset.addSeries(s1); XYSeries s2 = new XYSeries("Series 2", true, false); s2.add(5.0, 5.0); s2.add(10.0, 15.5); s2.add(15.0, 9.5); s2.add(20.0, 3.5); dataset.addSeries(s2); StackedXYAreaRenderer renderer = new StackedXYAreaRenderer( XYAreaRenderer.LINES); XYPlot plot = new XYPlot(dataset, new NumberAxis("X"), new NumberAxis("Y"), renderer); JFreeChart chart = new JFreeChart(plot); /* BufferedImage image = */ chart.createBufferedImage(300, 200, null); success = true; } catch (NullPointerException e) { e.printStackTrace(); success = false; } assertTrue(success); }
Example #9
Source File: XYAreaRendererTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * A check for the datasetIndex and seriesIndex fields in the LegendItem * returned by the getLegendItem() method. */ public void testGetLegendItemSeriesIndex() { XYSeriesCollection d1 = new XYSeriesCollection(); XYSeries s1 = new XYSeries("S1"); s1.add(1.0, 1.1); XYSeries s2 = new XYSeries("S2"); s2.add(1.0, 1.1); d1.addSeries(s1); d1.addSeries(s2); XYSeriesCollection d2 = new XYSeriesCollection(); XYSeries s3 = new XYSeries("S3"); s3.add(1.0, 1.1); XYSeries s4 = new XYSeries("S4"); s4.add(1.0, 1.1); XYSeries s5 = new XYSeries("S5"); s5.add(1.0, 1.1); d2.addSeries(s3); d2.addSeries(s4); d2.addSeries(s5); XYAreaRenderer r = new XYAreaRenderer(); XYPlot plot = new XYPlot(d1, new NumberAxis("x"), new NumberAxis("y"), r); plot.setDataset(1, d2); /*JFreeChart chart =*/ new JFreeChart(plot); LegendItem li = r.getLegendItem(1, 2); assertEquals("S5", li.getLabel()); assertEquals(1, li.getDatasetIndex()); assertEquals(2, li.getSeriesIndex()); }
Example #10
Source File: XYAreaRendererTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Draws the chart with a <code>null</code> info object to make sure that * no exceptions are thrown (particularly by code in the renderer). */ public void testDrawWithNullInfo() { boolean success = false; try { DefaultTableXYDataset dataset = new DefaultTableXYDataset(); XYSeries s1 = new XYSeries("Series 1", true, false); s1.add(5.0, 5.0); s1.add(10.0, 15.5); s1.add(15.0, 9.5); s1.add(20.0, 7.5); dataset.addSeries(s1); XYSeries s2 = new XYSeries("Series 2", true, false); s2.add(5.0, 5.0); s2.add(10.0, 15.5); s2.add(15.0, 9.5); s2.add(20.0, 3.5); dataset.addSeries(s2); XYPlot plot = new XYPlot(dataset, new NumberAxis("X"), new NumberAxis("Y"), new XYAreaRenderer()); JFreeChart chart = new JFreeChart(plot); /* BufferedImage image = */ chart.createBufferedImage(300, 200, null); success = true; } catch (NullPointerException e) { e.printStackTrace(); success = false; } assertTrue(success); }
Example #11
Source File: EyeCandySixtiesChartTheme.java From jasperreports with GNU Lesser General Public License v3.0 | 5 votes |
@Override protected JFreeChart createXyAreaChart() throws JRException { JFreeChart jfreeChart = super.createXyAreaChart(); XYPlot xyPlot = (XYPlot)jfreeChart.getPlot(); SquareXYAreaRenderer squareXyAreaRenderer = new SquareXYAreaRenderer((XYAreaRenderer)xyPlot.getRenderer()); xyPlot.setRenderer(squareXyAreaRenderer); return jfreeChart; }
Example #12
Source File: frmEditCurve.java From Course_Generator with GNU General Public License v3.0 | 5 votes |
/** * Creates the chart * * @param dataset Dataset to display * @return Return a JFreeChart object */ private JFreeChart CreateChartProfile(XYDataset dataset) { JFreeChart chart = ChartFactory.createXYAreaChart("", bundle.getString("frmEditCurve.chart.slope"), // "Slope" x // axis // label bundle.getString("frmEditCurve.chart.speed") + " (" + Utils.uSpeed2String(settings.Unit, settings.isPace) + ")", // "speed" y axis label dataset, // data PlotOrientation.VERTICAL, false, // include legend true, // tooltips false // urls ); chart.setBackgroundPaint(Color.white); // Panel background color XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.gray); plot.setRangeGridlinePaint(Color.gray); // XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); XYAreaRenderer renderer = new XYAreaRenderer(); // Green (safe color) renderer.setSeriesPaint(0, new Color(0x99, 0xff, 0x00)); renderer.setOutline(true); // Width of the outline renderer.setSeriesOutlineStroke(0, new BasicStroke(2.0f)); plot.setRenderer(renderer); // NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); // rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); return chart; }
Example #13
Source File: XYAreaRendererTests.java From astor with GNU General Public License v2.0 | 4 votes |
/** * Verify that this class implements {@link PublicCloneable}. */ public void testPublicCloneable() { XYAreaRenderer r1 = new XYAreaRenderer(); assertTrue(r1 instanceof PublicCloneable); }
Example #14
Source File: JPanelAnalysisTimeTemperature.java From Course_Generator with GNU General Public License v3.0 | 4 votes |
private JFreeChart CreateChart(XYDataset dataset1, XYDataset dataset2) { JFreeChart chart = ChartFactory.createXYLineChart("", // x axis label bundle.getString("JPanelAnalysisTimeDist.labelX"), // "Distance" // y axis label bundle.getString("JPanelAnalysisTimeDist.labelY1"), // "Elevation" dataset1, // data PlotOrientation.VERTICAL, false, // include legend true, // tooltips false // urls ); // -- Background color chart.setBackgroundPaint(Color.white); chart.setAntiAlias(true); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.gray); plot.setRangeGridlinePaint(Color.gray); plot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_RIGHT); XYAreaRenderer renderer = new XYAreaRenderer(); renderer.setSeriesPaint(0, new Color(0x99, 0xff, 0x00)); renderer.setOutline(true); renderer.setSeriesOutlineStroke(0, new BasicStroke(2.0f)); plot.setRenderer(0, renderer); NumberAxis rangeAxis2 = new NumberAxis(bundle.getString("JPanelAnalysisTimeTemperature.labelY2")); // "Time" plot.setRangeAxis(1, rangeAxis2); plot.setDataset(1, dataset2); plot.setRangeAxis(1, rangeAxis2); plot.mapDatasetToRangeAxis(1, 1); StandardXYItemRenderer renderer2 = new StandardXYItemRenderer(); renderer2.setSeriesPaint(0, Color.red); plot.setRenderer(1, renderer2); // -- Select the display order plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); return chart; }
Example #15
Source File: JPanelAnalysisTimeDist.java From Course_Generator with GNU General Public License v3.0 | 4 votes |
private JFreeChart CreateChart(XYDataset dataset1, XYDataset dataset2) { JFreeChart chart = ChartFactory.createXYAreaChart("", // x axis label bundle.getString("JPanelAnalysisTimeDist.labelX"), // "Distance" // y axis label bundle.getString("JPanelAnalysisTimeDist.labelY1"), // "Elevation" dataset1, // data PlotOrientation.VERTICAL, false, // include legend true, // tooltips false // urls ); // -- Background color chart.setBackgroundPaint(Color.white); chart.setAntiAlias(true); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.gray); plot.setRangeGridlinePaint(Color.gray); plot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_RIGHT); XYAreaRenderer renderer = new XYAreaRenderer(); renderer.setSeriesPaint(0, new Color(0x99, 0xff, 0x00)); renderer.setOutline(true); renderer.setSeriesOutlineStroke(0, new BasicStroke(2.0f)); plot.setRenderer(0, renderer); NumberAxis rangeAxis2 = new NumberAxis(bundle.getString("JPanelAnalysisTimeDist.labelY2")); // "Time" plot.setRangeAxis(1, rangeAxis2); plot.setDataset(1, dataset2); plot.setRangeAxis(1, rangeAxis2); plot.mapDatasetToRangeAxis(1, 1); StandardXYItemRenderer renderer2 = new StandardXYItemRenderer(); renderer2.setSeriesPaint(0, Color.red); plot.setRenderer(1, renderer2); // -- Select the display order plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); return chart; }
Example #16
Source File: JPanelAnalysisSpeedSlope.java From Course_Generator with GNU General Public License v3.0 | 4 votes |
private JFreeChart CreateChart(XYDataset dataset1, XYDataset dataset2) { JFreeChart chart = ChartFactory.createScatterPlot("", // x axis label bundle.getString("JPanelAnalysisSpeedSlope.labelX"), // "Slope", // y axis label bundle.getString("JPanelAnalysisSpeedSlope.labelY"), // "Speed", // data dataset1, PlotOrientation.VERTICAL, false, // include legend true, // tooltips false // urls ); chart.setBackgroundPaint(Color.white); // Panel background color chart.setAntiAlias(true); XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.gray); plot.setRangeGridlinePaint(Color.gray); plot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_RIGHT); plot.setRangeCrosshairLockedOnData(false); XYDotRenderer renderer = new XYDotRenderer(); renderer.setSeriesPaint(0, new Color(0x6B, 0xB2, 0x00)); renderer.setDotWidth(2); renderer.setDotHeight(2); plot.setRenderer(renderer); NumberAxis rangeAxis2 = new NumberAxis(); plot.setRangeAxis(1, rangeAxis2); plot.setDataset(1, dataset2); plot.setRangeAxis(1, rangeAxis2); plot.mapDatasetToRangeAxis(1, 1); XYAreaRenderer renderer2 = new XYAreaRenderer(); renderer2.setSeriesPaint(0, new Color(0x99, 0xff, 0x00, 0x80)); renderer2.setOutline(true); renderer2.setSeriesOutlinePaint(0, new Color(0x80, 0x80, 0x80, 0x80)); renderer2.setSeriesOutlineStroke(0, new BasicStroke(2.0f)); plot.setRenderer(1, renderer2); /* * StandardXYItemRenderer renderer2 = new StandardXYItemRenderer(); * renderer2.setSeriesPaint(0, Color.red); plot.setRenderer(1, renderer2); */ // -- Select the display order plot.setDatasetRenderingOrder(DatasetRenderingOrder.REVERSE); return chart; }
Example #17
Source File: JPanelAnalysisSpeed.java From Course_Generator with GNU General Public License v3.0 | 4 votes |
private JFreeChart CreateChart(XYDataset dataset1, XYDataset dataset2) { JFreeChart chart = ChartFactory.createXYAreaChart("", // x axis label bundle.getString("JPanelAnalysisSpeed.labelX"), // "Distance", // y axis label bundle.getString("JPanelAnalysisSpeed.labelY"), // "Speed" dataset1, // data PlotOrientation.VERTICAL, false, // include legend true, // tooltips false // urls ); chart.setBackgroundPaint(Color.white); // Panel background color chart.setAntiAlias(true); XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.gray); plot.setRangeGridlinePaint(Color.gray); plot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_RIGHT); XYAreaRenderer renderer = new XYAreaRenderer(); renderer.setSeriesPaint(0, new Color(0x99, 0xff, 0x00)); renderer.setOutline(true); renderer.setSeriesOutlineStroke(0, new BasicStroke(2.0f)); plot.setRenderer(0, renderer); NumberAxis rangeAxis2 = new NumberAxis(); plot.setRangeAxis(1, rangeAxis2); plot.setDataset(1, dataset2); plot.setRangeAxis(1, rangeAxis2); plot.mapDatasetToRangeAxis(1, 1); StandardXYItemRenderer renderer2 = new StandardXYItemRenderer(); renderer2.setSeriesPaint(0, Color.red); plot.setRenderer(1, renderer2); // -- Select the display order plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); return chart; }
Example #18
Source File: FrmElevationFilter.java From Course_Generator with GNU General Public License v3.0 | 4 votes |
/** * Update the chart * * @param dataset1 * @param dataset2 * @return */ private JFreeChart CreateChart(XYDataset dataset1, XYDataset dataset2) { JFreeChart chart = ChartFactory.createXYAreaChart("", // x axis label bundle.getString("frmElevationFilter.labelX"), // "Distance" // y axis label bundle.getString("frmElevationFilter.labelY1"), // "Elevation" dataset1, // data PlotOrientation.VERTICAL, false, // include legend true, // tooltips false // urls ); // -- Background color chart.setBackgroundPaint(Color.white); chart.setAntiAlias(true); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.gray); plot.setRangeGridlinePaint(Color.gray); plot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_RIGHT); XYAreaRenderer renderer = new XYAreaRenderer(); renderer.setSeriesPaint(0, new Color(0x99, 0xff, 0x00)); renderer.setOutline(true); renderer.setSeriesOutlineStroke(0, new BasicStroke(2.0f)); plot.setRenderer(0, renderer); NumberAxis rangeAxis2 = new NumberAxis("");// bundle.getString("JPanelAnalysisTimeDist.labelY2")); // "Time" // plot.setRangeAxis(1, rangeAxis2); plot.setDataset(1, dataset2); plot.setRangeAxis(1, rangeAxis2); // plot.mapDatasetToRangeAxis(1, 1); StandardXYItemRenderer renderer2 = new StandardXYItemRenderer(); renderer2.setSeriesPaint(0, Color.red); renderer2.setSeriesStroke(0, new BasicStroke(1.0f)); plot.setRenderer(1, renderer2); // -- Select the display order plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); return chart; }
Example #19
Source File: EyeCandySixtiesChartTheme.java From jasperreports with GNU Lesser General Public License v3.0 | 4 votes |
public SquareXYAreaRenderer(XYAreaRenderer parent) { super(XYAreaRenderer.AREA, parent.getBaseToolTipGenerator(), parent.getURLGenerator()); }