*
* @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