DeviceRgb extends Color { public static DeviceRgb makeLighter(DeviceRgb rgbColor) { float r = rgbColor.getColorValue()[0]; float g = rgbColor.getColorValue()[1]; float b = rgbColor.getColorValue()[2]; float v = Math.max(r, Math.max(g, b)); if (v == 0f) { return new DeviceRgb(0x54, 0x54, 0x54); } float multiplier = Math.min(1f, v + 0.33f) / v; r = multiplier * r; g = multiplier * g; b = multiplier * b; return new DeviceRgb(r, g, b); } DeviceRgb(int r, int g, int b);  DeviceRgb(float r, float g, float b);  DeviceRgb(java.awt.Color color);  DeviceRgb(); static DeviceRgb makeLighter(DeviceRgb rgbColor); static DeviceRgb makeDarker(DeviceRgb rgbColor); static final Color BLACK; static final Color WHITE; static final Color RED; static final Color GREEN; static final Color BLUE; }
@Test public void makeLighterTest() { DeviceRgb rgbColor = new DeviceRgb(50, 100, 150); DeviceRgb darkerRgbColor = DeviceRgb.makeLighter(rgbColor); float multiplier = Math.min(1f, 150f / 255 + 0.33f) / (150f / 255); Assert.assertEquals(multiplier * (50f / 255), darkerRgbColor.getColorValue()[0], 0.0001); Assert.assertEquals(multiplier * (100f / 255), darkerRgbColor.getColorValue()[1], 0.0001); Assert.assertEquals(multiplier * (150f / 255), darkerRgbColor.getColorValue()[2], 0.0001); }