ColorHelper { public static Color invert(Color c){ int a = c.getAlpha(); int r = MAX_RGB_VALUE - c.getRed(); int g = MAX_RGB_VALUE - c.getGreen(); int b = MAX_RGB_VALUE - c.getBlue(); if ((r + g + b > 740) || (r + g + b < 20)){ return new Color(MAX_RGB_VALUE, MAX_RGB_VALUE, 40, a); } else{ return new Color(r,g,b,a); } } private  ColorHelper(); static Color getColorWithAlpha(Color c, double alpha); static Color invert(Color c); static Color getColorFromHSL(double h, double s, double l); static BufferedImage getColorSpaceImage(); static float getHue(Color color); static float getLightness(Color color); static final int MAX_RGB_VALUE; }
@Test public void testInvert() { System.out.println("invert"); Color c = new Color(40, 40, 40); Color expResult = new Color(215, 215, 215); Color result = ColorHelper.invert(c); assertEquals(expResult, result); c = new Color(5,5,5); expResult = new Color(ColorHelper.MAX_RGB_VALUE, ColorHelper.MAX_RGB_VALUE, 40); result = ColorHelper.invert(c); assertEquals(expResult, result); c = new Color(250,250,250); expResult = new Color(ColorHelper.MAX_RGB_VALUE, ColorHelper.MAX_RGB_VALUE, 40); result = ColorHelper.invert(c); assertEquals(expResult, result); }