GraphicsUtils { public static double[] luv2xyz(double[] luv, double[] xyz) { if (xyz == null) { xyz = new double[luv.length]; } if (luv[0] > CIE_KAPPA*CIE_EPSILON) { xyz[1] = (luv[0] + 16.0)/116.0; xyz[1] = xyz[1]*xyz[1]*xyz[1]; } else { xyz[1] = luv[0]/CIE_KAPPA; } double a = (luv[0] != 0.0 || luv[1] != 0.0) ? ((52.0*luv[0])/(luv[1] + 13.0*luv[0]*XYZ_R_D50_U0) - 1.0)/3.0 : 0.0; double b = -5*xyz[1]; double c = -1.0/3.0; double d = (luv[0] != 0.0 || luv[2] != 0.0) ? xyz[1]*((39.0*luv[0])/(luv[2] + 13.0*luv[0]*XYZ_R_D50_V0) - 5.0) : 0.0; xyz[0] = !MathUtils.almostEqual(a, c, 1e-15) ? (d - b)/(a - c) : 0.0; xyz[2] = xyz[0]*a + b; 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 testLuv2Xyz() { double[] xyz = new double[3]; GraphicsUtils.luv2xyz(new double[] { 0.0, 0.0, 0.0 }, xyz); assertEqualsArray(new double[] { 0.0000000000000000000, 0.0000000000000000000, 0.00000000000000000000 }, xyz, DELTA); GraphicsUtils.luv2xyz(new double[] { 0.0, 0.5, 1.0 }, xyz); assertEqualsArray(new double[] { 0.0000000000000000000, 0.0000000000000000000, 0.00000000000000000000 }, xyz, DELTA); GraphicsUtils.luv2xyz(new double[] { 0.5, 0.5, 0.5 }, xyz); assertEqualsArray(new double[] { 0.0006306220545989307, 0.0005535282299397269,-0.00003874159659988680 }, xyz, DELTA); GraphicsUtils.luv2xyz(new double[] { 1.0, 0.5, 0.0 }, xyz); assertEqualsArray(new double[] { 0.0012637351588200229, 0.0011070564598794539, 0.00084812581097405170 }, xyz, DELTA); GraphicsUtils.luv2xyz(new double[] { 1.0, 1.0, 1.0 }, xyz); assertEqualsArray(new double[] { 0.0012612441091978614, 0.0011070564598794539,-0.00007748319319977360 }, xyz, DELTA); GraphicsUtils.luv2xyz(new double[] { 100.00000000000000, 1.7759188446137468, -18.705788588473464 }, xyz); assertEqualsArray(new double[] { 1.0000000000000000000, 1.0000000000000000000, 1.00000000000000000000 }, xyz, DELTA); }