/** * Creates a polar plot for the specified dataset (x-values interpreted as * angles in degrees). The chart object returned by this method uses a * {@link PolarPlot} instance as the plot, with a {@link NumberAxis} for * the radial axis. * * @param title the chart title (<code>null</code> permitted). * @param dataset the dataset (<code>null</code> permitted). * @param legend legend required? * @param tooltips tooltips required? * @param urls URLs required? * * @return A chart. */ public static JFreeChart createPolarChart(String title, XYDataset dataset, boolean legend, boolean tooltips, boolean urls) { PolarPlot plot = new PolarPlot(); plot.setDataset(dataset); NumberAxis rangeAxis = new NumberAxis(); rangeAxis.setAxisLineVisible(false); rangeAxis.setTickMarksVisible(false); rangeAxis.setTickLabelInsets(new RectangleInsets(0.0, 0.0, 0.0, 0.0)); plot.setAxis(rangeAxis); plot.setRenderer(new DefaultPolarItemRenderer()); JFreeChart chart = new JFreeChart( title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); return chart; }
/** * Creates a polar plot for the specified dataset (x-values interpreted as angles in degrees). * <P> * The chart object returned by this method uses a {@link PolarPlot} instance as the * plot, with a {@link NumberAxis} for the radial axis. * * @param title the chart title (<code>null</code> permitted). * @param dataset the dataset (<code>null</code> permitted). * @param legend legend required? * @param tooltips tooltips required? * @param urls URLs required? * * @return A chart. */ public static JFreeChart createPolarChart(String title, XYDataset dataset, boolean legend, boolean tooltips, boolean urls) { PolarPlot plot = new PolarPlot(); plot.setDataset(dataset); NumberAxis rangeAxis = new NumberAxis(); rangeAxis.setAxisLineVisible(false); rangeAxis.setTickMarksVisible(false); rangeAxis.setTickLabelInsets(new Insets(0, 0, 0, 0)); plot.setRadialAxis(rangeAxis); plot.setRenderer(new DefaultPolarItemRenderer()); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); return chart; }
/** * Some checks for the getLegendItems() method. */ @Test public void testGetLegendItems() { XYSeriesCollection d = new XYSeriesCollection(); d.addSeries(new XYSeries("A")); d.addSeries(new XYSeries("B")); DefaultPolarItemRenderer r = new DefaultPolarItemRenderer(); PolarPlot plot = new PolarPlot(); plot.setDataset(d); plot.setRenderer(r); LegendItemCollection items = plot.getLegendItems(); assertEquals(2, items.getItemCount()); LegendItem item1 = items.get(0); assertEquals("A", item1.getLabel()); LegendItem item2 = items.get(1); assertEquals("B", item2.getLabel()); }
/** * Some checks for the getLegendItems() method with multiple datasets. */ @Test public void testGetLegendItems2() { XYSeriesCollection d1 = new XYSeriesCollection(); d1.addSeries(new XYSeries("A")); d1.addSeries(new XYSeries("B")); XYSeriesCollection d2 = new XYSeriesCollection(); d2.addSeries(new XYSeries("C")); d2.addSeries(new XYSeries("D")); DefaultPolarItemRenderer r = new DefaultPolarItemRenderer(); PolarPlot plot = new PolarPlot(); plot.setDataset(d1); plot.setDataset(1, d2); plot.setRenderer(r); plot.setRenderer(1, new DefaultPolarItemRenderer()); LegendItemCollection items = plot.getLegendItems(); assertEquals(4, items.getItemCount()); LegendItem item1 = items.get(0); assertEquals("A", item1.getLabel()); LegendItem item2 = items.get(1); assertEquals("B", item2.getLabel()); LegendItem item3 = items.get(2); assertEquals("C", item3.getLabel()); LegendItem item4 = items.get(3); assertEquals("D", item4.getLabel()); }
/** * Creates a polar plot for the specified dataset (x-values interpreted as * angles in degrees). The chart object returned by this method uses a * {@link PolarPlot} instance as the plot, with a {@link NumberAxis} for * the radial axis. * * @param title the chart title (<code>null</code> permitted). * @param dataset the dataset (<code>null</code> permitted). * @param legend legend required? * @param tooltips tooltips required? * @param urls URLs required? * * @return A chart. */ public static JFreeChart createPolarChart(String title, XYDataset dataset, boolean legend, boolean tooltips, boolean urls) { PolarPlot plot = new PolarPlot(); plot.setDataset(dataset); NumberAxis rangeAxis = new NumberAxis(); rangeAxis.setAxisLineVisible(false); rangeAxis.setTickMarksVisible(false); rangeAxis.setTickLabelInsets(new RectangleInsets(0.0, 0.0, 0.0, 0.0)); plot.setAxis(rangeAxis); plot.setRenderer(new DefaultPolarItemRenderer()); JFreeChart chart = new JFreeChart( title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); currentTheme.apply(chart); return chart; }
/** * Creates a polar plot for the specified dataset (x-values interpreted as * angles in degrees). The chart object returned by this method uses a * {@link PolarPlot} instance as the plot, with a {@link NumberAxis} for * the radial axis. * * @param title the chart title ({@code null} permitted). * @param dataset the dataset ({@code null} permitted). * @param legend legend required? * @param tooltips tooltips required? * @param urls URLs required? * * @return A chart. */ public static JFreeChart createPolarChart(String title, XYDataset dataset, boolean legend, boolean tooltips, boolean urls) { PolarPlot plot = new PolarPlot(); plot.setDataset(dataset); NumberAxis rangeAxis = new NumberAxis(); rangeAxis.setAxisLineVisible(false); rangeAxis.setTickMarksVisible(false); rangeAxis.setTickLabelInsets(new RectangleInsets(0.0, 0.0, 0.0, 0.0)); plot.setAxis(rangeAxis); plot.setRenderer(new DefaultPolarItemRenderer()); JFreeChart chart = new JFreeChart( title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); currentTheme.apply(chart); return chart; }
/** * Creates a polar plot for the specified dataset (x-values interpreted as * angles in degrees). The chart object returned by this method uses a * {@link PolarPlot} instance as the plot, with a {@link NumberAxis} for * the radial axis. * * @param title the chart title (<code>null</code> permitted). * @param dataset the dataset (<code>null</code> permitted). * @param legend legend required? * * @return A chart. */ public static JFreeChart createPolarChart(String title, XYDataset dataset, boolean legend) { PolarPlot plot = new PolarPlot(); plot.setDataset(dataset); NumberAxis rangeAxis = new NumberAxis(); rangeAxis.setAxisLineVisible(false); rangeAxis.setTickMarksVisible(false); rangeAxis.setTickLabelInsets(new RectangleInsets(0.0, 0.0, 0.0, 0.0)); plot.setAxis(rangeAxis); plot.setRenderer(new DefaultPolarItemRenderer()); JFreeChart chart = new JFreeChart( title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); currentTheme.apply(chart); return chart; }
private JFreeChart createPolarChart(final XYDataset dataset,String chartName) { if(chartName == null) chartName=FunctionToPlot; final JFreeChart chRt = ChartFactory.createPolarChart( chartName, dataset, true, true, false ); final PolarPlot plot = (PolarPlot) chRt.getPlot(); final DefaultPolarItemRenderer renderer = (DefaultPolarItemRenderer) plot.getRenderer(); renderer.setShapesVisible(false); //renderer.setShapesFilled(false); // renderer.setSeriesFilled(0, false); return chRt; }
/** * Check that the equals() method distinguishes all fields. */ public void testEquals() { DefaultPolarItemRenderer r1 = new DefaultPolarItemRenderer(); DefaultPolarItemRenderer r2 = new DefaultPolarItemRenderer(); assertEquals(r1, r2); r1.setSeriesFilled(1, true); assertFalse(r1.equals(r2)); r2.setSeriesFilled(1, true); assertTrue(r1.equals(r2)); }
/** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { DefaultPolarItemRenderer r1 = new DefaultPolarItemRenderer(); DefaultPolarItemRenderer r2 = new DefaultPolarItemRenderer(); assertTrue(r1.equals(r2)); int h1 = r1.hashCode(); int h2 = r2.hashCode(); assertEquals(h1, h2); }
/** * Some basic checks for the clone() method. */ @Test public void testCloning() throws CloneNotSupportedException { PolarPlot p1 = new PolarPlot(); PolarPlot p2 = (PolarPlot) p1.clone(); assertTrue(p1 != p2); assertTrue(p1.getClass() == p2.getClass()); assertTrue(p1.equals(p2)); // check independence p1.addCornerTextItem("XYZ"); assertFalse(p1.equals(p2)); p2.addCornerTextItem("XYZ"); assertTrue(p1.equals(p2)); p1 = new PolarPlot(new DefaultXYDataset(), new NumberAxis("A1"), new DefaultPolarItemRenderer()); p2 = (PolarPlot) p1.clone(); assertTrue(p1 != p2); assertTrue(p1.getClass() == p2.getClass()); assertTrue(p1.equals(p2)); // check independence p1.getAxis().setLabel("ABC"); assertFalse(p1.equals(p2)); p2.getAxis().setLabel("ABC"); assertTrue(p1.equals(p2)); }