use of org.jfree.chart.legend.LegendItemCollection in project ES-LEI-2Sem-2022-Grupo-1 by tmrbo-iscte.
the class PiePlotTest method testGetLegendItems.
/**
* Some checks for the getLegendItems() method.
*/
@Test
public void testGetLegendItems() {
DefaultPieDataset<String> 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.legend.LegendItemCollection in project ES-LEI-2Sem-2022-Grupo-1 by tmrbo-iscte.
the class SpiderWebPlot method getLegendItems.
/**
* Returns a collection of legend items for the spider web chart.
*
* @return The legend items (never {@code null}).
*/
@Override
public LegendItemCollection getLegendItems() {
LegendItemCollection result = new LegendItemCollection();
if (getDataset() == null) {
return result;
}
List keys = null;
if (this.dataExtractOrder == TableOrder.BY_ROW) {
keys = this.dataset.getRowKeys();
} else if (this.dataExtractOrder == TableOrder.BY_COLUMN) {
keys = this.dataset.getColumnKeys();
}
if (keys == null) {
return result;
}
int series = 0;
Iterator iterator = keys.iterator();
Shape shape = getLegendItemShape();
while (iterator.hasNext()) {
Comparable key = (Comparable) iterator.next();
String label = key.toString();
String description = label;
Paint paint = getSeriesPaint(series);
Paint outlinePaint = getSeriesOutlinePaint(series);
Stroke stroke = getSeriesOutlineStroke(series);
LegendItem item = new LegendItem(label, description, null, null, shape, paint, stroke, outlinePaint);
item.setDataset(getDataset());
item.setSeriesKey(key);
item.setSeriesIndex(series);
result.add(item);
series++;
}
return result;
}
use of org.jfree.chart.legend.LegendItemCollection in project ES-LEI-2Sem-2022-Grupo-1 by tmrbo-iscte.
the class CombinedDomainXYPlot 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) {
for (XYPlot plot : this.subplots) {
LegendItemCollection more = plot.getLegendItems();
result.addAll(more);
}
}
}
return result;
}
use of org.jfree.chart.legend.LegendItemCollection in project ES-LEI-2Sem-2022-Grupo-1 by tmrbo-iscte.
the class CombinedDomainCategoryPlot 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) {
for (CategoryPlot plot : this.subplots) {
LegendItemCollection more = plot.getLegendItems();
result.addAll(more);
}
}
}
return result;
}
use of org.jfree.chart.legend.LegendItemCollection in project ES-LEI-2Sem-2022-Grupo-1 by tmrbo-iscte.
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) {
for (XYPlot plot : this.subplots) {
LegendItemCollection more = plot.getLegendItems();
result.addAll(more);
}
}
}
return result;
}
Aggregations