@Test public void testGetLegendItems() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.addValue(35.0, "S1", "C1"); dataset.addValue(45.0, "S1", "C2"); dataset.addValue(55.0, "S2", "C1"); dataset.addValue(15.0, "S2", "C2"); MultiplePiePlot plot = new MultiplePiePlot(dataset); List<LegendItem> legendItems = plot.getLegendItems(); assertEquals(2, legendItems.size()); LegendItem item1 = legendItems.get(0); assertEquals("S1", item1.getLabel()); assertEquals("S1", item1.getSeriesKey()); assertEquals(0, item1.getSeriesIndex()); assertEquals(dataset, item1.getDataset()); assertEquals(0, item1.getDatasetIndex()); LegendItem item2 = legendItems.get(1); assertEquals("S2", item2.getLabel()); assertEquals("S2", item2.getSeriesKey()); assertEquals(1, item2.getSeriesIndex()); assertEquals(dataset, item2.getDataset()); assertEquals(0, item2.getDatasetIndex()); }
@Override public List<LegendItem> getLegendItems() { List<LegendItem> result = new ArrayList<LegendItem>(); if (this.dataset == null) { return result; } List<Comparable> keys = null; prefetchSectionPaints(); if (this.dataExtractOrder == TableOrder.BY_ROW) { keys = this.dataset.getColumnKeys(); } else if (this.dataExtractOrder == TableOrder.BY_COLUMN) { keys = this.dataset.getRowKeys(); } if (keys == null) { return result; } int section = 0; for (Comparable key : keys) { String label = key.toString(); String description = label; Paint paint = this.sectionPaints.get(key); LegendItem item = new LegendItem(label, description, null, null, getLegendItemShape(), paint, Plot.DEFAULT_OUTLINE_STROKE, paint); item.setSeriesKey(key); item.setSeriesIndex(section); item.setDataset(getDataset()); result.add(item); section++; } if (this.limit > 0.0) { LegendItem a = new LegendItem(this.aggregatedItemsKey.toString(), this.aggregatedItemsKey.toString(), null, null, getLegendItemShape(), this.aggregatedItemsPaint, Plot.DEFAULT_OUTLINE_STROKE, this.aggregatedItemsPaint); result.add(a); } return result; }
MultiplePiePlot extends Plot implements Cloneable, Serializable { @Override public List<LegendItem> getLegendItems() { List<LegendItem> result = new ArrayList<LegendItem>(); if (this.dataset == null) { return result; } List<Comparable> keys = null; prefetchSectionPaints(); if (this.dataExtractOrder == TableOrder.BY_ROW) { keys = this.dataset.getColumnKeys(); } else if (this.dataExtractOrder == TableOrder.BY_COLUMN) { keys = this.dataset.getRowKeys(); } if (keys == null) { return result; } int section = 0; for (Comparable key : keys) { String label = key.toString(); String description = label; Paint paint = this.sectionPaints.get(key); LegendItem item = new LegendItem(label, description, null, null, getLegendItemShape(), paint, Plot.DEFAULT_OUTLINE_STROKE, paint); item.setSeriesKey(key); item.setSeriesIndex(section); item.setDataset(getDataset()); result.add(item); section++; } if (this.limit > 0.0) { LegendItem a = new LegendItem(this.aggregatedItemsKey.toString(), this.aggregatedItemsKey.toString(), null, null, getLegendItemShape(), this.aggregatedItemsPaint, Plot.DEFAULT_OUTLINE_STROKE, this.aggregatedItemsPaint); result.add(a); } return result; } }
MultiplePiePlot extends Plot implements Cloneable, Serializable { @Override public List<LegendItem> getLegendItems() { List<LegendItem> result = new ArrayList<LegendItem>(); if (this.dataset == null) { return result; } List<Comparable> keys = null; prefetchSectionPaints(); if (this.dataExtractOrder == TableOrder.BY_ROW) { keys = this.dataset.getColumnKeys(); } else if (this.dataExtractOrder == TableOrder.BY_COLUMN) { keys = this.dataset.getRowKeys(); } if (keys == null) { return result; } int section = 0; for (Comparable key : keys) { String label = key.toString(); String description = label; Paint paint = this.sectionPaints.get(key); LegendItem item = new LegendItem(label, description, null, null, getLegendItemShape(), paint, Plot.DEFAULT_OUTLINE_STROKE, paint); item.setSeriesKey(key); item.setSeriesIndex(section); item.setDataset(getDataset()); result.add(item); section++; } if (this.limit > 0.0) { LegendItem a = new LegendItem(this.aggregatedItemsKey.toString(), this.aggregatedItemsKey.toString(), null, null, getLegendItemShape(), this.aggregatedItemsPaint, Plot.DEFAULT_OUTLINE_STROKE, this.aggregatedItemsPaint); result.add(a); } return result; } MultiplePiePlot();  MultiplePiePlot(CategoryDataset dataset); }
MultiplePiePlot extends Plot implements Cloneable, Serializable { @Override public List<LegendItem> getLegendItems() { List<LegendItem> result = new ArrayList<LegendItem>(); if (this.dataset == null) { return result; } List<Comparable> keys = null; prefetchSectionPaints(); if (this.dataExtractOrder == TableOrder.BY_ROW) { keys = this.dataset.getColumnKeys(); } else if (this.dataExtractOrder == TableOrder.BY_COLUMN) { keys = this.dataset.getRowKeys(); } if (keys == null) { return result; } int section = 0; for (Comparable key : keys) { String label = key.toString(); String description = label; Paint paint = this.sectionPaints.get(key); LegendItem item = new LegendItem(label, description, null, null, getLegendItemShape(), paint, Plot.DEFAULT_OUTLINE_STROKE, paint); item.setSeriesKey(key); item.setSeriesIndex(section); item.setDataset(getDataset()); result.add(item); section++; } if (this.limit > 0.0) { LegendItem a = new LegendItem(this.aggregatedItemsKey.toString(), this.aggregatedItemsKey.toString(), null, null, getLegendItemShape(), this.aggregatedItemsPaint, Plot.DEFAULT_OUTLINE_STROKE, this.aggregatedItemsPaint); result.add(a); } return result; } MultiplePiePlot();  MultiplePiePlot(CategoryDataset dataset); CategoryDataset getDataset(); void setDataset(CategoryDataset dataset); JFreeChart getPieChart(); void setPieChart(JFreeChart pieChart); TableOrder getDataExtractOrder(); void setDataExtractOrder(TableOrder order); double getLimit(); void setLimit(double limit); Comparable getAggregatedItemsKey(); void setAggregatedItemsKey(Comparable key); Paint getAggregatedItemsPaint(); void setAggregatedItemsPaint(Paint paint); @Override String getPlotType(); Shape getLegendItemShape(); void setLegendItemShape(Shape shape); @Override void draw(Graphics2D g2,
                     Rectangle2D area,
                     Point2D anchor,
                     PlotState parentState,
                     PlotRenderingInfo info); @Override List<LegendItem> getLegendItems(); @Override boolean equals(Object obj); @Override Object clone(); }
MultiplePiePlot extends Plot implements Cloneable, Serializable { @Override public List<LegendItem> getLegendItems() { List<LegendItem> result = new ArrayList<LegendItem>(); if (this.dataset == null) { return result; } List<Comparable> keys = null; prefetchSectionPaints(); if (this.dataExtractOrder == TableOrder.BY_ROW) { keys = this.dataset.getColumnKeys(); } else if (this.dataExtractOrder == TableOrder.BY_COLUMN) { keys = this.dataset.getRowKeys(); } if (keys == null) { return result; } int section = 0; for (Comparable key : keys) { String label = key.toString(); String description = label; Paint paint = this.sectionPaints.get(key); LegendItem item = new LegendItem(label, description, null, null, getLegendItemShape(), paint, Plot.DEFAULT_OUTLINE_STROKE, paint); item.setSeriesKey(key); item.setSeriesIndex(section); item.setDataset(getDataset()); result.add(item); section++; } if (this.limit > 0.0) { LegendItem a = new LegendItem(this.aggregatedItemsKey.toString(), this.aggregatedItemsKey.toString(), null, null, getLegendItemShape(), this.aggregatedItemsPaint, Plot.DEFAULT_OUTLINE_STROKE, this.aggregatedItemsPaint); result.add(a); } return result; } MultiplePiePlot();  MultiplePiePlot(CategoryDataset dataset); CategoryDataset getDataset(); void setDataset(CategoryDataset dataset); JFreeChart getPieChart(); void setPieChart(JFreeChart pieChart); TableOrder getDataExtractOrder(); void setDataExtractOrder(TableOrder order); double getLimit(); void setLimit(double limit); Comparable getAggregatedItemsKey(); void setAggregatedItemsKey(Comparable key); Paint getAggregatedItemsPaint(); void setAggregatedItemsPaint(Paint paint); @Override String getPlotType(); Shape getLegendItemShape(); void setLegendItemShape(Shape shape); @Override void draw(Graphics2D g2,
                     Rectangle2D area,
                     Point2D anchor,
                     PlotState parentState,
                     PlotRenderingInfo info); @Override List<LegendItem> getLegendItems(); @Override boolean equals(Object obj); @Override Object clone();  }