GraphicsUtils { public static double[] xyz2rgb(double[] xyz, double[] rgb) { if (rgb == null) { rgb = new double[xyz.length]; } for (int i = 0; i < xyz.length; i++) { rgb[i] = MATRIX_XYZ2SRGB_D50[i*3 + 0]*xyz[0] + MATRIX_XYZ2SRGB_D50[i*3 + 1]*xyz[1] + MATRIX_XYZ2SRGB_D50[i*3 + 2]*xyz[2]; } for (int i = 0; i < rgb.length; i++) { if (rgb[i] <= 0.0031308) { rgb[i] = 12.92*rgb[i]; } else { rgb[i] = 1.055*Math.pow(rgb[i], 1.0/2.4) - 0.055; } } return rgb; } protected  GraphicsUtils(); static Shape getOutline(String text, Font font, float wrappingWidth,
			double alignment); static void fillPaintedShape(Graphics2D graphics, Shape shape,
			Paint paint, Rectangle2D paintBounds); static void drawPaintedShape(Graphics2D graphics, Shape shape,
			Paint paint, Rectangle2D paintBounds, Stroke stroke); static double[] rgb2xyz(double[] rgb, double[] xyz); static double[] luv2xyz(double[] luv, double[] xyz); static double[] xyz2rgb(double[] xyz, double[] rgb); static double[] xyz2luv(double[] xyz, double[] luv); static double[] rgb2luv(double[] rgb, double[] luv); static double[] luv2rgb(double[] luv, double[] rgb); static Color blend(Color color1, Color color2, double weight); static Color deriveWithAlpha(Color color, int alpha); static Color deriveDarker(Color color); static Color deriveBrighter(Color color);  }
@Test public void testXyz2Rgb() { double[] rgb = new double[3]; GraphicsUtils.xyz2rgb(new double[] { 0.0, 0.0, 0.0 }, rgb); assertEqualsArray(new double[] { 0.0000000000000000, 0.0000000000000000, 0.0000000000000000 }, rgb, DELTA); GraphicsUtils.xyz2rgb(new double[] { 0.0, 0.5, 1.0 }, rgb); assertEqualsArray(new double[] {-16.7836995140000020, 0.9962651704966786, 1.1183734614873770 }, rgb, DELTA); GraphicsUtils.xyz2rgb(new double[] { 0.5, 0.5, 0.5 }, rgb); assertEqualsArray(new double[] { 0.7439767101458333, 0.7256668703074206, 0.8118445228904296 }, rgb, DELTA); GraphicsUtils.xyz2rgb(new double[] { 1.0, 0.5, 0.0 }, rgb); assertEqualsArray(new double[] { 1.4445522116235023,-0.2674136380000002,-0.5497511680000000 }, rgb, DELTA); GraphicsUtils.xyz2rgb(new double[] { 1.0, 1.0, 1.0 }, rgb); assertEqualsArray(new double[] { 1.0115059552563181, 0.9870652513165344, 1.1020986165231543 }, rgb, DELTA); GraphicsUtils.xyz2rgb(new double[] { 0.96422103200000000, 0.99999914400000000, 0.82521159400000000 }, rgb); assertEqualsArray(new double[] { 1.0000016663766877, 0.9999988622306825, 1.0000011147183525 }, rgb, DELTA); }