Search in sources :

Example 1 with PaintMap

use of org.jfree.chart.PaintMap 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.
        }
    }
}
Also used : PaintMap(org.jfree.chart.PaintMap) TreeSet(java.util.TreeSet) Color(java.awt.Color) DrawingSupplier(org.jfree.chart.plot.DrawingSupplier) Paint(java.awt.Paint)

Aggregations

Color (java.awt.Color)1 Paint (java.awt.Paint)1 TreeSet (java.util.TreeSet)1 PaintMap (org.jfree.chart.PaintMap)1 DrawingSupplier (org.jfree.chart.plot.DrawingSupplier)1