Util.java Source code

Java tutorial

Introduction

Here is the source code for Util.java

Source

/**
 * Utilities for GUI work.
 * @author Alex Kurzhanskiy
 * @version $Id: UtilGUI.java 38 2010-02-08 22:59:00Z akurzhan $
 */

import java.awt.Color;

public class Util {

    /**
     * Returns color based on 0-9 scale ranging from black to green.
     */
    public static Color kgColor(int i) {
        int[][] rgb = { { 21, 0, 0 }, { 99, 0, 0 }, { 177, 0, 0 }, { 255, 0, 0 }, { 255, 85, 0 }, { 255, 170, 0 },
                { 255, 255, 0 }, { 150, 225, 0 }, { 65, 194, 0 }, { 0, 164, 0 } };
        int ii = 0;
        if (i > 9)
            ii = 9;
        else
            ii = Math.max(i, ii);
        float[] hsb = Color.RGBtoHSB(rgb[ii][0], rgb[ii][1], rgb[ii][2], null);
        return Color.getHSBColor(hsb[0], hsb[1], hsb[2]);
    }

}