ColorConverter { public static Float getBrightness(Color color) { float[] hsbValues = new float[MAX_COMPONENT]; Float brightness; Color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(), hsbValues); brightness = hsbValues[BRIGHTNESS]; return brightness; } private  ColorConverter(); static Color offsetHsbColor(Color color, float offsetHue, float offsetSaturation, float offsetBrightness); static Float getBrightness(Color color); static Float getSaturation(Color color); static Float getHue(Color color); static Color offsetRgbColor(Color bgColor, int offsetRed, int offsetGreen, int offsetBlue); static String formatColorStr(String colorStr); static Color colorFromStr(String colorStr); static Color colorFromColorName(String colorStr); static Color colorFromRgbStr(String colorStr); static Color hex2Rgb(String colorStr); static String hex2Rgb(Color color); static String rgb2Hex(Color color); static String rgb2Hsl(Color color);  }
@Test public void testGetBrightness() { System.out.println("---- getBrightness -----"); Color colorA = Color.BLACK; Float expResult = (float) 0.0; Float result = ColorConverter.getBrightness(colorA); System.out.println("BLACK - Brightness: ["+ result +"]"); assertEquals(expResult, result); colorA = Color.WHITE; expResult = (float) 1.0; result = ColorConverter.getBrightness(colorA); System.out.println("WHITE - Brightness: ["+ result +"]"); assertEquals(expResult, result); colorA = new Color(70, 136, 71); expResult = (float) 0.53333336; result = ColorConverter.getBrightness(colorA); System.out.println("rgb(70, 136, 71) - Brightness: ["+ result +"]"); assertEquals(expResult, result); }