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 n-dimensional array of colors for given nx3 integer array of RGB values. 
     */
    public static Color[] getColorScale(int[][] rgb) {
        if (rgb == null)
            return null;
        Color[] clr = new Color[rgb.length];
        for (int i = 0; i < rgb.length; i++) {
            float[] hsb = Color.RGBtoHSB(rgb[i][0], rgb[i][1], rgb[i][2], null);
            clr[i] = Color.getHSBColor(hsb[0], hsb[1], hsb[2]);
        }
        return clr;
    }
}