Here you can find the source of toRGB(ColorSpace colorSpace, float... components)
public static int toRGB(ColorSpace colorSpace, float... components)
//package com.java2s; /*//from w w w . ja v a 2 s . co m * @(#)ColorUtil.java * * Copyright (c) 2010 by the original authors of JHotDraw and all its * contributors. All rights reserved. * * You may not use, copy or modify this file, except in compliance with the * license agreement you entered into with the copyright holders. For details * see accompanying license terms. */ import java.awt.color.ColorSpace; public class Main { /** Returns an rgb value from color components in the specified color space. */ public static int toRGB(ColorSpace colorSpace, float... components) { float[] rgb = colorSpace.toRGB(components); // If the color is not displayable in RGB, we return transparent black. if (rgb[0] < 0f || rgb[1] < 0f || rgb[2] < 0f || rgb[0] > 1f || rgb[1] > 1f || rgb[2] > 1f) { return 0; } return 0xff000000 | ((int) (rgb[0] * 255f) << 16) | ((int) (rgb[1] * 255f) << 8) | (int) (rgb[2] * 255f); } }