ColorHelper { public static BufferedImage getColorSpaceImage(){ BufferedImage colorSpace = new BufferedImage(150,250, BufferedImage.TYPE_INT_RGB); Graphics g2 = colorSpace.getGraphics(); double dh = (double) DEGREES / (colorSpace.getHeight() - 1); double dl = 1.0 / (colorSpace.getWidth() - 1); g2.setColor(Color.red); g2.fillRect(0, 0, colorSpace.getWidth(), colorSpace.getHeight()); int x, y; double h, s, l; s = 0.5f; for (x = 0; x < colorSpace.getWidth(); x++) { l = (x * dl); for (y = 0; y < colorSpace.getHeight(); y++) { h = dh*y; Color hslColor = ColorHelper.getColorFromHSL(h, s, l); g2.setColor(hslColor); g2.fillRect(x, y, 1, 1); } } return colorSpace; } 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 testColorSpace() throws IOException{ BufferedImage colorSpace = ColorHelper.getColorSpaceImage(); File file = new File("/tmp/colorSpace.png"); ImageIO.write(colorSpace, "png", file); }