Search in sources :

Example 1 with DefaultPolarItemRenderer

use of org.jfree.chart.renderer.DefaultPolarItemRenderer in project SIMVA-SoS by SESoS.

the class PolarPlotTest method testGetLegendItems.

/**
 * 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());
}
Also used : XYSeries(org.jfree.data.xy.XYSeries) LegendItem(org.jfree.chart.LegendItem) LegendItemCollection(org.jfree.chart.LegendItemCollection) DefaultPolarItemRenderer(org.jfree.chart.renderer.DefaultPolarItemRenderer) XYSeriesCollection(org.jfree.data.xy.XYSeriesCollection) Test(org.junit.Test)

Example 2 with DefaultPolarItemRenderer

use of org.jfree.chart.renderer.DefaultPolarItemRenderer in project SIMVA-SoS by SESoS.

the class ChartFactory method createPolarChart.

/**
 * 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;
}
Also used : NumberAxis(org.jfree.chart.axis.NumberAxis) PolarPlot(org.jfree.chart.plot.PolarPlot) DefaultPolarItemRenderer(org.jfree.chart.renderer.DefaultPolarItemRenderer) RectangleInsets(org.jfree.ui.RectangleInsets)

Example 3 with DefaultPolarItemRenderer

use of org.jfree.chart.renderer.DefaultPolarItemRenderer in project SIMVA-SoS by SESoS.

the class PolarPlotTest method testGetLegendItems2.

/**
 * 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());
}
Also used : XYSeries(org.jfree.data.xy.XYSeries) LegendItem(org.jfree.chart.LegendItem) LegendItemCollection(org.jfree.chart.LegendItemCollection) DefaultPolarItemRenderer(org.jfree.chart.renderer.DefaultPolarItemRenderer) XYSeriesCollection(org.jfree.data.xy.XYSeriesCollection) Test(org.junit.Test)

Aggregations

DefaultPolarItemRenderer (org.jfree.chart.renderer.DefaultPolarItemRenderer)3 LegendItem (org.jfree.chart.LegendItem)2 LegendItemCollection (org.jfree.chart.LegendItemCollection)2 XYSeries (org.jfree.data.xy.XYSeries)2 XYSeriesCollection (org.jfree.data.xy.XYSeriesCollection)2 Test (org.junit.Test)2 NumberAxis (org.jfree.chart.axis.NumberAxis)1 PolarPlot (org.jfree.chart.plot.PolarPlot)1 RectangleInsets (org.jfree.ui.RectangleInsets)1