class ColorUtilities {

    public static int getBrightness(Color color)
    {
        Utilities.checkNull(color, "color");

        /* These factors are somewhat arbitrary but yield good results. If they
         * need to change, Photoshop apparently uses red=0.299, green=0.587, and
         * blue=0.114 */
        final float redFactor = 0.241f;
        final float greenFactor = 0.691f;
        final float blueFactor = 0.068f;

        return (int)Math.round(Math.sqrt(redFactor * color.getRed() * color.getRed()
                + greenFactor * color.getGreen() * color.getGreen() + blueFactor * color.getBlue() * color.getBlue()));
    }

    private  ColorUtilities();

}