/** * Establishes the color for missing values ({@code Double.NaN}). * * @param color the color for missing values */ public void setNanColor(Color color) { this.nanColor = color; this.updateUI(); }
/** * Sets the heat map font. * * @param font the heat map font */ public void setHeatmapFont(Font font) { this.font = ofNullable(font); this.colorKey.setFont(font); this.fixCellSize(); this.updateUI(); }
private void initializeColors() { double min = getLowValue(); double max = getHighValue(); Color[] colorGradient = getColorGradient(); doubleToColor = new Function<Double, Color>() { @Override public Color apply(Double t) { if (isNaN(t)) { return nanColor; } else { double normalized = normalize(checkRange(t), max, min); int colorIndex = (int) ((normalized * (DEFAULT_STEPS - 1))); return colorGradient[colorIndex]; } } private double checkRange(Double t) { if (t > max) { return max; } else if (t < min) { return min; } else { return t; } } private double normalize(double d, double max, double min) { return (d - min) / (max - min); } }; this.updateUI(); }