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(); }
protected void setHeatmapRange() { DoubleRangeInputDialog dialog = new DoubleRangeInputDialog( getDialogParent(), new DoubleRange(heatmap.getLowValue(), heatmap.getHighValue()) ) { private static final long serialVersionUID = 1L; @Override protected String getDescription() { return DESCRIPTION_RANGE_DIALOG; } }; dialog.setVisible(true); if(!dialog.isCanceled()) { heatmap.setValuesRange(dialog.getSelectedRange()); } }