/** {@inheritDoc} */ public String toString() { return "Named Color Space: " + getColorName(); }
/** * 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; }
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; }
functionName = "fop-rgb-named-color"; sb.append(",").append(ncs.getColorName()); } else { functionName = "fop-rgb-icc";
/** * 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; }