ColorConverter { public static Color offsetRgbColor(Color bgColor, int offsetRed, int offsetGreen, int offsetBlue) { return new Color(bgColor.getRed() + offsetRed, bgColor.getGreen() + offsetGreen, bgColor.getBlue() + offsetBlue); } 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 testOffsetRgbColor() { System.out.println("---------- offsetRgbColor ----------------"); Color colorA; Color expResult; Color result; int offsetRed; int offsetGreen; int offsetBlue; colorA = Color.BLACK; offsetRed = 10; offsetGreen = 20; offsetBlue = 30; expResult = new Color(10, 20, 30); result = ColorConverter.offsetRgbColor(colorA, offsetRed, offsetGreen, offsetBlue); System.out.println("OffsetRgbColor BLACK + ["+ offsetRed +", "+ offsetGreen +", "+ offsetBlue +"] = " + result.toString()); assertEquals(expResult, result); colorA = new Color(70, 136, 71); offsetRed = 100; offsetGreen = 100; offsetBlue = 100; expResult = new Color(170, 236, 171); result = ColorConverter.offsetRgbColor(colorA, offsetRed, offsetGreen, offsetBlue); System.out.println("OffsetRgbColor #468847 + ["+ offsetRed +", "+ offsetGreen +", "+ offsetBlue +"] = " + result.toString()); assertEquals(expResult, result); colorA = Color.WHITE; offsetRed = -10; offsetGreen = -20; offsetBlue = -30; expResult = new Color(245,235,225); result = ColorConverter.offsetRgbColor(colorA, offsetRed, offsetGreen, offsetBlue); System.out.println("OffsetRgbColor WHITE + ["+ offsetRed +", "+ offsetGreen +", "+ offsetBlue +"] = " + result.toString()); assertEquals(expResult, result); colorA = Color.WHITE; offsetRed = 0; offsetGreen = 0; offsetBlue = 0; expResult = new Color(255,255,255); result = ColorConverter.offsetRgbColor(colorA, offsetRed, offsetGreen, offsetBlue); System.out.println("OffsetRgbColor WHITE + ["+ offsetRed +", "+ offsetGreen +", "+ offsetBlue +"] = " + result.toString()); assertEquals(expResult, result); System.out.println("--------------------------"); }