class RainbowColorMap implements ColorMap<Number> {

    @Override
    public Color valueToColor(Number value) {
        Color color = new Color(EMPTY, EMPTY, EMPTY);
        
        // if there is only one value make it RED
        int index = 0;
        if (range.extent != 0.0d) {
            double coef = (value.doubleValue() - range.min) / range.extent;
            index = (int)Math.floor(coef * MAX_VALUES);
        }

        if (index >= RED && index < RED_TO_YELLOW) {
            int addToGreen = index - RED;
            int red = FULL;
            int green = EMPTY + addToGreen;
            int blue = EMPTY;
            color = new Color(red, green, blue);
        } else if (index >= RED_TO_YELLOW && index < YELLOW_TO_GREEN) {
            int removeFromRed = index - RED_TO_YELLOW;
            int red = FULL - removeFromRed;
            int green = FULL;
            int blue = EMPTY;
            color = new Color(red, green, blue);
        } else if (index >= YELLOW_TO_GREEN && index < GREEN_TO_TEAL) {
            int addToBlue = index - YELLOW_TO_GREEN;
            int red = EMPTY;
            int green = FULL;
            int blue = EMPTY + addToBlue;
            color = new Color(red, green, blue);
        } else if (index >= GREEN_TO_TEAL && index < TEAL_TO_BLUE) {
            int removeFromGreen = index - GREEN_TO_TEAL;
            int red = EMPTY;
            int green = FULL - removeFromGreen;
            int blue = FULL;
            color = new Color(red, green, blue);
        } else if (index >= TEAL_TO_BLUE && index <= BLUE_TO_PURPLE) {
            int addToRed = index - TEAL_TO_BLUE;
            int red = EMPTY + addToRed;
            int green = EMPTY;
            int blue = FULL;
            color = new Color(red, green, blue);
        }
        
        return color;
    }

    public  RainbowColorMap(AttributeRange range);

}