/** {@inheritDoc} */ public String toString() { return "Named Color Space: " + getColorName(); }
/** * Creates a new named color. * @param name the color name * @param xyz the CIE XYZ coordinates (valid values: 0.0f to 1.0f, although * values slightly larger than 1.0f are common) * @param profileName Optional profile name associated with this color space * @param profileURI Optional profile URI associated with this color space */ public NamedColorSpace(String name, float[] xyz, String profileName, String profileURI) { super(ColorSpace.TYPE_GRAY, 1); checkNumComponents(xyz, 3); if (name == null || name.trim().length() == 0) { throw new IllegalArgumentException("No name provided for named color space"); } this.name = name.trim(); this.xyz = new float[3]; System.arraycopy(xyz, 0, this.xyz, 0, 3); this.profileName = profileName; this.profileURI = profileURI; }
/** {@inheritDoc} */ public float getMinValue(int component) { return getMaxValue(component); //same as min, i.e. always 1.0 }
/** * Create a new Separation color space. * @param res the resource context (may be null) * @param ncs the named color space to map to a separation color space * @return the newly created Separation color space */ public PDFSeparationColorSpace makeSeparationColorSpace(PDFResourceContext res, NamedColorSpace ncs) { String colorName = ncs.getColorName(); final Double zero = 0d; final Double one = 1d; List domain = Arrays.asList(new Double[] {zero, one}); List range = Arrays.asList(new Double[] {zero, one, zero, one, zero, one}); float[] cZero = new float[] {1f, 1f, 1f}; float[] cOne = ncs.getRGBColor().getColorComponents(null); PDFFunction tintFunction = makeFunction(domain, range, cZero, cOne, 1.0d); PDFSeparationColorSpace cs = new PDFSeparationColorSpace(colorName, tintFunction); getDocument().registerObject(cs); if (res != null) { res.getPDFResources().addColorSpace(cs); } else { getDocument().getResources().addColorSpace(cs); } return cs; }
result[i] = new NamedColorSpace(name, colorvalue, profileName, profileURI); break; case ColorSpace.TYPE_Lab: result[i] = new NamedColorSpace(name, labCS.toColor(colorvalue, 1.0f), profileName, profileURI); break;
/** * Returns an sRGB-based color representing the full-tint color defined by this named color * space. * @return the sRGB color */ public Color getRGBColor() { float[] comps = toRGB(this.xyz); return new Color(comps[0], comps[1], comps[2]); }
colorSpace = ColorSpaces.getDeviceCMYKColorSpace(); } else if (SEPARATION_PSEUDO_PROFILE.equalsIgnoreCase(iccProfileName)) { colorSpace = new NamedColorSpace(args[5], sRGB, SEPARATION_PSEUDO_PROFILE, null); } else {
/** * Returns a named color. * @param name the color name * @return the named color (or null if it is not available) */ public NamedColorSpace getNamedColor(String name) { if (this.namedColors != null) { for (NamedColorSpace namedColor : this.namedColors) { if (namedColor.getColorName().equals(name)) { return namedColor; } } } return null; }
functionName = "fop-rgb-named-color"; sb.append(",").append(ncs.getColorName()); } else { functionName = "fop-rgb-icc";
private PDFSeparationColorSpace getSeparationColorSpace(NamedColorSpace cs) { PDFName colorName = new PDFName(cs.getColorName()); PDFSeparationColorSpace sepcs = (PDFSeparationColorSpace)this.resources.getColorSpace( colorName); if (sepcs == null) { //color space is not in the PDF, yet PDFFactory factory = getDocument().getFactory(); sepcs = factory.makeSeparationColorSpace(null, cs); } return sepcs; }