Java tutorial
/** * 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 yellow to red. */ public static Color yrColor(int i) { int[][] rgb = { { 255, 202, 0 }, { 255, 180, 0 }, { 255, 157, 0 }, { 255, 135, 0 }, { 255, 112, 0 }, { 255, 90, 0 }, { 255, 67, 0 }, { 255, 45, 0 }, { 255, 22, 0 }, { 255, 0, 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]); } }