use of org.jfree.chart.legend.LegendItemCollection in project ES-LEI-2Sem-2022-Grupo-1 by tmrbo-iscte.
the class MultiplePiePlot method getLegendItems.
/**
* Returns a collection of legend items for the pie chart.
*
* @return The legend items.
*/
@Override
public LegendItemCollection getLegendItems() {
LegendItemCollection result = new LegendItemCollection();
if (this.dataset == null) {
return result;
}
List 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 (Object o : keys) {
Comparable key = (Comparable) o;
// TODO: use a generator here
String label = key.toString();
String description = label;
Paint 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;
}
use of org.jfree.chart.legend.LegendItemCollection in project ES-LEI-2Sem-2022-Grupo-1 by tmrbo-iscte.
the class PiePlot method getLegendItems.
/**
* Returns a collection of legend items for the pie chart.
*
* @return The legend items (never {@code null}).
*/
@Override
public LegendItemCollection getLegendItems() {
LegendItemCollection result = new LegendItemCollection();
if (this.dataset == null) {
return result;
}
List<K> keys = this.dataset.getKeys();
int section = 0;
Shape shape = getLegendItemShape();
for (K key : keys) {
Number n = this.dataset.getValue(key);
boolean include;
if (n == null) {
include = !this.ignoreNullValues;
} else {
double v = n.doubleValue();
if (v == 0.0) {
include = !this.ignoreZeroValues;
} else {
include = v > 0.0;
}
}
if (include) {
String label = this.legendLabelGenerator.generateSectionLabel(this.dataset, key);
if (label != null) {
String description = label;
String toolTipText = null;
if (this.legendLabelToolTipGenerator != null) {
toolTipText = this.legendLabelToolTipGenerator.generateSectionLabel(this.dataset, key);
}
String urlText = null;
if (this.legendLabelURLGenerator != null) {
urlText = this.legendLabelURLGenerator.generateURL(this.dataset, key, this.pieIndex);
}
Paint paint = lookupSectionPaint(key);
Paint outlinePaint = lookupSectionOutlinePaint(key);
Stroke outlineStroke = lookupSectionOutlineStroke(key);
LegendItem item = new LegendItem(label, description, toolTipText, urlText, true, shape, true, paint, true, outlinePaint, outlineStroke, // line not visible
false, new Line2D.Float(), new BasicStroke(), Color.BLACK);
item.setDataset(getDataset());
item.setSeriesIndex(this.dataset.getIndex(key));
item.setSeriesKey(key);
result.add(item);
}
section++;
} else {
section++;
}
}
return result;
}
use of org.jfree.chart.legend.LegendItemCollection in project ES-LEI-2Sem-2022-Grupo-1 by tmrbo-iscte.
the class WaferMapRenderer method getLegendCollection.
/**
* Builds the list of legend entries. called by getLegendItems in
* WaferMapPlot to populate the plot legend.
*
* @return The legend items.
*/
public LegendItemCollection getLegendCollection() {
LegendItemCollection result = new LegendItemCollection();
if (this.paintIndex != null && this.paintIndex.size() > 0) {
if (this.paintIndex.size() <= this.paintLimit) {
for (Iterator i = this.paintIndex.entrySet().iterator(); i.hasNext(); ) {
// in this case, every color has a unique value
Map.Entry entry = (Map.Entry) i.next();
String label = entry.getKey().toString();
String description = label;
Shape shape = new Rectangle2D.Double(1d, 1d, 1d, 1d);
Paint paint = lookupSeriesPaint(((Integer) entry.getValue()).intValue());
Paint outlinePaint = Color.BLACK;
Stroke outlineStroke = DEFAULT_STROKE;
result.add(new LegendItem(label, description, null, null, shape, paint, outlineStroke, outlinePaint));
}
} else {
// in this case, every color has a range of values
Set unique = new HashSet();
for (Iterator i = this.paintIndex.entrySet().iterator(); i.hasNext(); ) {
Map.Entry entry = (Map.Entry) i.next();
if (unique.add(entry.getValue())) {
String label = getMinPaintValue((Integer) entry.getValue()).toString() + " - " + getMaxPaintValue((Integer) entry.getValue()).toString();
String description = label;
Shape shape = new Rectangle2D.Double(1d, 1d, 1d, 1d);
Paint paint = getSeriesPaint(((Integer) entry.getValue()).intValue());
Paint outlinePaint = Color.BLACK;
Stroke outlineStroke = DEFAULT_STROKE;
result.add(new LegendItem(label, description, null, null, shape, paint, outlineStroke, outlinePaint));
}
}
// end foreach map entry
}
// end else
}
return result;
}
use of org.jfree.chart.legend.LegendItemCollection in project ES-LEI-2Sem-2022-Grupo-1 by tmrbo-iscte.
the class AbstractXYItemRenderer method getLegendItems.
/**
* Returns a (possibly empty) collection of legend items for the series
* that this renderer is responsible for drawing.
*
* @return The legend item collection (never {@code null}).
*/
@Override
public LegendItemCollection getLegendItems() {
if (this.plot == null) {
return new LegendItemCollection();
}
LegendItemCollection result = new LegendItemCollection();
int index = this.plot.getIndexOf(this);
XYDataset dataset = this.plot.getDataset(index);
if (dataset != null) {
int seriesCount = dataset.getSeriesCount();
for (int i = 0; i < seriesCount; i++) {
if (isSeriesVisibleInLegend(i)) {
LegendItem item = getLegendItem(index, i);
if (item != null) {
result.add(item);
}
}
}
}
return result;
}
Aggregations