GenericColor extends AbstractDatatype { public GenericColor invert(ColorModel model) { switch (model) { case RGB: return valueOf(this.red.invert(), this.green.invert(), this.blue.invert(), this.alpha); case HSL: return valueOf(this.hue.invert(), this.saturationHsl.invert(), this.lightness.invert(), this.alpha); case HSB: case HSV: return valueOf(this.hue.invert(), this.saturationHsb.invert(), this.brightness.invert(), this.alpha); default : throw new IllegalStateException("" + model); } } protected  GenericColor(); static GenericColor valueOf(String color); static GenericColor valueOf(Color color); static GenericColor valueOf(Red red, Green green, Blue blue, Alpha alpha); static GenericColor valueOf(Hue hue, Saturation saturation, Brightness brightness, Alpha alpha); static GenericColor valueOf(Hue hue, Saturation saturation, Lightness lightness, Alpha alpha); Alpha getAlpha(); Hue getHue(); Saturation getSaturationHsb(); Saturation getSaturationHsl(); Brightness getBrightness(); Lightness getLightness(); Chroma getChroma(); Red getRed(); Blue getBlue(); Green getGreen(); AbstractDoubleSegment<?> getSegment(ColorSegmentType type); Color toColor(); GenericColor invert(ColorModel model); GenericColor lighten(ColorFactor factor); GenericColor darken(ColorFactor factor); @Override String toString(); String toString(ColorModel colorModel); @Override int hashCode(); @Override boolean equals(Object obj);  }
@Test public void testInvert() { checkInvert(GenericColor.valueOf(Color.WHITE), GenericColor.valueOf(Color.BLACK)); checkInvert(GenericColor.valueOf(Color.RED), GenericColor.valueOf(Color.CYAN)); checkInvert(GenericColor.valueOf(Color.GREEN), GenericColor.valueOf(Color.MAGENTA)); checkInvert(GenericColor.valueOf(Color.BLUE), GenericColor.valueOf(Color.YELLOW)); }