GraphicsUtils { public static double[] rgb2xyz(double[] rgb, double[] xyz) { if (xyz == null) { xyz = new double[rgb.length]; } double[] rgbLin = new double[rgb.length]; for (int i = 0; i < rgb.length; i++) { if (rgb[i] <= 0.04045) { rgbLin[i] = rgb[i]/12.92; } else { rgbLin[i] = Math.pow((rgb[i] + 0.055)/1.055, 2.4); } } for (int i = 0; i < xyz.length; i++) { xyz[i] = MATRIX_SRGB2XYZ_D50[i*3 + 0]*rgbLin[0] + MATRIX_SRGB2XYZ_D50[i*3 + 1]*rgbLin[1] + MATRIX_SRGB2XYZ_D50[i*3 + 2]*rgbLin[2]; } return xyz; } 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 testRgb2Xyz() { double[] xyz = new double[3]; GraphicsUtils.rgb2xyz(new double[] { 0.0, 0.0, 0.0 }, xyz); assertEqualsArray(new double[] { 0.0, 0.0, 0.0}, xyz, DELTA); GraphicsUtils.rgb2xyz(new double[] { 0.0, 0.5, 1.0 }, xyz); assertEqualsArray(new double[] { 0.22551071734443490, 0.21406459587821420, 0.73496822304548560 }, xyz, DELTA); GraphicsUtils.rgb2xyz(new double[] { 0.5, 0.5, 0.5 }, xyz); assertEqualsArray(new double[] { 0.20638296936623524, 0.21404095726301628, 0.17662923071892103 }, xyz, DELTA); GraphicsUtils.rgb2xyz(new double[] { 1.0, 0.5, 0.0 }, xyz); assertEqualsArray(new double[] { 0.51847532834443490, 0.37593470787821420, 0.03471187504548562 }, xyz, DELTA); GraphicsUtils.rgb2xyz(new double[] { 1.0, 1.0, 1.0 }, xyz); assertEqualsArray(new double[] { 0.96422103200000000, 0.99999914400000000, 0.82521159400000000 }, xyz, DELTA); }