Here you can find the source of generateGrayScaleColor(double min, double max, double value)
public static Color generateGrayScaleColor(double min, double max, double value)
//package com.java2s; //License from project: Open Source License import java.awt.*; public class Main { public static Color generateGrayScaleColor(double min, double max, double value) { assert value >= min && value <= max; if (value < min || value > max) { throw new IllegalArgumentException("Value must be between min and max values, it was not."); }/*from w w w.j a va2s.c o m*/ double power = (value - min) / (max - min); //will be between 0 and 1 return Color.getHSBColor(0, 0, 1 - (float) power); } }