use of org.jfree.chart.LegendItemCollection in project SIMVA-SoS by SESoS.
the class CombinedRangeXYPlot method getLegendItems.
/**
* Returns a collection of legend items for the plot.
*
* @return The legend items.
*/
@Override
public LegendItemCollection getLegendItems() {
LegendItemCollection result = getFixedLegendItems();
if (result == null) {
result = new LegendItemCollection();
if (this.subplots != null) {
Iterator iterator = this.subplots.iterator();
while (iterator.hasNext()) {
XYPlot plot = (XYPlot) iterator.next();
LegendItemCollection more = plot.getLegendItems();
result.addAll(more);
}
}
}
return result;
}
use of org.jfree.chart.LegendItemCollection in project SIMVA-SoS by SESoS.
the class PiePlotTest method testGetLegendItems.
/**
* Some checks for the getLegendItems() method.
*/
@Test
public void testGetLegendItems() {
DefaultPieDataset dataset = new DefaultPieDataset();
dataset.setValue("Item 1", 1.0);
dataset.setValue("Item 2", 2.0);
dataset.setValue("Item 3", 0.0);
dataset.setValue("Item 4", null);
PiePlot plot = new PiePlot(dataset);
plot.setIgnoreNullValues(false);
plot.setIgnoreZeroValues(false);
LegendItemCollection items = plot.getLegendItems();
assertEquals(4, items.getItemCount());
// check that null items are ignored if requested
plot.setIgnoreNullValues(true);
items = plot.getLegendItems();
assertEquals(3, items.getItemCount());
// check that zero items are ignored if requested
plot.setIgnoreZeroValues(true);
items = plot.getLegendItems();
assertEquals(2, items.getItemCount());
// check that negative items are always ignored
dataset.setValue("Item 5", -1.0);
items = plot.getLegendItems();
assertEquals(2, items.getItemCount());
}
use of org.jfree.chart.LegendItemCollection 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());
}
use of org.jfree.chart.LegendItemCollection in project SIMVA-SoS by SESoS.
the class XYPlotTest method testCloning3.
/**
* Tests cloning for a plot where the fixed legend items have been
* specified.
*/
@Test
public void testCloning3() throws CloneNotSupportedException {
XYPlot p1 = new XYPlot(null, new NumberAxis("Domain Axis"), new NumberAxis("Range Axis"), new StandardXYItemRenderer());
LegendItemCollection c1 = new LegendItemCollection();
p1.setFixedLegendItems(c1);
XYPlot p2 = (XYPlot) p1.clone();
assertTrue(p1 != p2);
assertTrue(p1.getClass() == p2.getClass());
assertTrue(p1.equals(p2));
// verify independence of fixed legend item collection
c1.add(new LegendItem("X"));
assertFalse(p1.equals(p2));
}
use of org.jfree.chart.LegendItemCollection in project SIMVA-SoS by SESoS.
the class CategoryPlot method getLegendItems.
/**
* Returns the legend items for the plot. By default, this method creates
* a legend item for each series in each of the datasets. You can change
* this behaviour by overriding this method.
*
* @return The legend items.
*/
@Override
public LegendItemCollection getLegendItems() {
if (this.fixedLegendItems != null) {
return this.fixedLegendItems;
}
LegendItemCollection result = new LegendItemCollection();
// get the legend items for the datasets...
for (CategoryDataset dataset : this.datasets.values()) {
if (dataset != null) {
int datasetIndex = indexOf(dataset);
CategoryItemRenderer renderer = getRenderer(datasetIndex);
if (renderer != null) {
result.addAll(renderer.getLegendItems());
}
}
}
return result;
}
Aggregations