*
* @return The legend items (never <code>null</code>).
*/
public LegendItemCollection getLegendItems() {
final LegendItemCollection result = new LegendItemCollection();
if (this.dataset == null) {
return result;
}
final List keys = this.dataset.getKeys();
int section = 0;
this.getLegendItemShape();
final Rectangle shape = new Rectangle(0, 0, 8, 8);
final Iterator iterator = keys.iterator();
while (iterator.hasNext()) {
final Comparable key = (Comparable) iterator.next();
final Number n = this.dataset.getValue(key);
boolean include = true;
if (n == null) {
include = !this.ignoreNullValues;
} else {
final double v = n.doubleValue();
if (v == 0.0) {
include = !this.ignoreZeroValues;
} else {
include = v > 0.0;
}
}
if (include) {
final String label = this.legendLabelGenerator
.generateSectionLabel(this.dataset, key);
if (label != null) {
final 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);
}
final Color Color = this.lookupSectionPaint(key, true);
final Color outlinePaint = this
.lookupSectionOutlinePaint(key);
final Stroke outlineStroke = this
.lookupSectionOutlineStroke(key);
final LegendItem item = new LegendItem(label, description,
toolTipText, urlText, true, shape, true, Color,
true, outlinePaint,
outlineStroke,
false, // line
// not
// visible
new Rectangle(0, 0, 0, 0), new Stroke(1),
StaticColorChecker.dublicateColor(SWT.COLOR_BLACK));
// Display
// .getDefault().getSystemColor(
// SWT.COLOR_BLACK));
item.setDataset(this.getDataset());
result.add(item);
}
section++;
} else {
section++;
}