/** * Returns a <code>float</code> array containing the color and alpha components of the <code>Color * </code>, in the <code>ColorSpace</code> specified by the <code>cspace</code> parameter. If * <code>compArray</code> is <code>null</code>, an array with length equal to the number of * components in <code>cspace</code> plus one is created for the return value. Otherwise, <code> * compArray</code> must have at least this length, and it is filled in with the components and * returned. * * @param cspace a specified <code>ColorSpace</code> * @param compArray an array that this method fills with the color and alpha components of this * <code>Color</code> in the specified <code>ColorSpace</code> and returns * @return the color and alpha components in a <code>float</code> array. */ @Override public float[] getComponents(ColorSpace cspace, float[] compArray) { if (cs == null) { cs = ColorSpace.getInstance(ColorSpace.CS_sRGB); } float f[]; if (fvalue == null) { f = new float[3]; f[0] = ((float) getRed()) / 255f; f[1] = ((float) getGreen()) / 255f; f[2] = ((float) getBlue()) / 255f; } else { f = fvalue; } float tmp[] = cs.toCIEXYZ(f); float tmpout[] = cspace.fromCIEXYZ(tmp); if (compArray == null) { compArray = new float[tmpout.length + 1]; } for (int i = 0; i < tmpout.length; i++) { compArray[i] = tmpout[i]; } if (fvalue == null) { compArray[tmpout.length] = ((float) getAlpha()) / 255f; } else { compArray[tmpout.length] = falpha; } return compArray; }