use of org.jfree.chart.plot.DrawingSupplier in project processdash by dtuma.
the class StandardDiscItemRenderer method setPaintKeyMapper.
/**
* Install an object that maps data keys to paint keys
* @since 2.2.1
*/
public void setPaintKeyMapper(PaintKeyMapper paintKeyMapper) {
this.paintKeyMapper = paintKeyMapper;
this.discPaintMap = new PaintMap();
DrawingSupplier ds = getDrawingSupplier();
if (paintKeyMapper != null && ds != null) {
try {
Collection<Comparable> keys = paintKeyMapper.getAllPaintKeys();
Paint bg = plot.getBackgroundPaint();
for (Comparable oneKey : new TreeSet<Comparable>(keys)) {
Paint onePaint = ds.getNextPaint();
if (onePaint instanceof Color && bg instanceof Color)
onePaint = PaintUtils.adjustForContrast((Color) onePaint, (Color) bg);
this.discPaintMap.put(oneKey, onePaint);
}
} catch (Throwable t) {
// the "getAllPaintKeys" method was added in PD 2.3. If a
// particular implementor doesn't support it yet, catch the
// error and continue without preassigning colors.
}
}
}
use of org.jfree.chart.plot.DrawingSupplier in project processdash by dtuma.
the class StandardDiscItemRenderer method lookupDiscPaint.
/**
* Returns the paint for the specified disc.
*
* @param key
* the disc key.
* @param autoPopulate
* a flag that controls whether the drawing supplier is used
* to auto-populate the disc paint settings.
*
* @return The paint.
*/
protected Paint lookupDiscPaint(Comparable key, boolean autoPopulate) {
// if a paint key mapper is in effect, use it to translate the key
if (paintKeyMapper != null)
key = paintKeyMapper.getPaintKey(key);
// see if this is the key for the base color
if (key.equals(baseDiscPaintKey))
return baseDiscPaint;
// check if there is a paint defined for the specified key
Paint result = this.discPaintMap.getPaint(key);
if (result != null) {
return result;
}
// nothing defined - do we autoPopulate?
if (autoPopulate) {
DrawingSupplier ds = getDrawingSupplier();
if (ds != null) {
result = ds.getNextPaint();
Paint bg = plot.getBackgroundPaint();
if (result instanceof Color && bg instanceof Color) {
result = PaintUtils.adjustForContrast((Color) result, (Color) bg);
}
this.discPaintMap.put(key, result);
} else {
result = this.baseDiscPaint;
}
} else {
result = this.baseDiscPaint;
}
return result;
}
Aggregations