コード例 #1
0
        ///
        ///	 <summary> * Get an existing or append a Color Element with RawName=rawName and Name =
        ///	 * Name
        ///	 *  </summary>
        ///	 * <param name="colorName">
        ///	 *            the name of the color </param>
        ///	 * <param name="rawName">
        ///	 *            he 8 bit representation of the rawName of the color
        ///	 *  </param>
        ///	 * <returns> JDFColor the color with the matching name or null JDFColor if no
        ///	 *         matching element exists </returns>
        ///
        public virtual JDFColor getCreateColorWithName(string colorName, string rawName)
        {
            JDFColor col = rawName != null?getColorWithRawName(rawName) : null;

            if (col != null)
            {
                return(col);
            }

            // it only defaulted throught the transcoder, therefor redo
            col = getColorWithName(colorName);

            if (col == null)
            {
                col = appendColor();
                if (rawName != null)
                {
                    col.set8BitNames(Encoding.Default.GetBytes(rawName));
                }
                col.setName(colorName);
            }
            else
            {
                if (col.hasAttribute(AttributeName.RAWNAME) && rawName != null)
                {
                    // snafu - the rawname is different
                    throw new JDFException("JDFColorPool.getCreateColorWithName color is inconsistent: " + colorName);
                }
            }

            return(col);
        }
コード例 #2
0
        ///
        ///	 <summary> * does this ColorPool have Color elements with identical Name or RawName
        ///	 * eattributes return false if no Color elements with identical Name or
        ///	 * RawName tags exist </summary>
        ///
        public virtual VString getDuplicateColors()
        {
            VElement v = getChildElementVector(ElementName.COLOR, null, null, true, 0, false);

            SupportClass.HashSetSupport <string> vName = new SupportClass.HashSetSupport <string>();
            int     nCols = v.Count;
            VString vRet  = new VString();

            for (int i = 0; i < nCols; i++)
            {
                JDFColor color     = (JDFColor)v[i];
                string   colorName = color.getName();
                if (vName.Contains(colorName))
                {
                    vRet.appendUnique(colorName);
                }
                string rawName = color.get8BitName();
                if (vName.Contains(rawName))
                {
                    vRet.appendUnique(colorName);
                }
                vName.Add(colorName);
                vName.Add(rawName);
            }

            return(vRet.Count == 0 ? null : vRet);
        }
コード例 #3
0
        public virtual void testSetRawName()
        {
            JDFColor c = cp.appendColor();

            byte[] b = Encoding.Default.GetBytes("grün");
            c.set8BitNames(b);
            Assert.AreEqual("grün", c.get8BitName());
        }
コード例 #4
0
        public void testActualColorName()
        {
            colParams.setXMLComment("Note that all Strings in ColorantParams etc. use Color/@Name, NOT Color/@ActualColorName");
            colParams.setSeparations(new VString("Spot1,BlackText", ","));
            colControl.setXMLComment("Simple colorantcontrol from MIS: CMYK + 1 spot+ 1 black text version; knows no more");
            d.write2File(sm_dirTestDataTemp + "ActualColorName_MIS.jdf", 2, false);

            colControl.setXMLComment("ColorantControl after prepress has correctly set ActualColorName based on pdl content");
            JDFColor co = colPool.appendColorWithName("Black", null);

            co.setXMLComment("Color that maps the predefined separation Black\n" + "ActualColorName is the new attribute that replaces ExposedMedia/@DescriptiveName as the \"Main\" PDL color");
            co.setCMYK(new JDFCMYKColor(0, 0, 0, 1));
            Assert.IsTrue(co.isValid(EnumValidationLevel.Incomplete));
            co.setAttribute("ActualColorName", "Schwarz");

            co = colPool.appendColorWithName("Yellow", null);
            co.setAttribute("ActualColorName", "Gelb");
            co.setCMYK(new JDFCMYKColor(0, 0, 1, 0));

            co = colPool.appendColorWithName("Cyan", null);
            co.setXMLComment("ActualColorName defaults to Name if not specified");
            co.setCMYK(new JDFCMYKColor(1, 0, 0, 0));

            co = colPool.appendColorWithName("Magenta", null);
            co = colPool.appendColorWithName("Spot1", null);
            co.setAttribute("ActualColorName", "Acme Aqua");
            co.setCMYK(new JDFCMYKColor(0.7, 0.2, 0.03, 0.1));

            co = colPool.appendColorWithName("BlackText", null);
            co.setAttribute("ActualColorName", "VersionsText");
            co.setCMYK(new JDFCMYKColor(0, 0, 0, 1));

            d.write2File(sm_dirTestDataTemp + "ActualColorName_Prepress.jdf", 2, false);

            JDFColorantAlias ca = colControl.appendColorantAlias();

            ca.setXMLComment("ColorantAlias that maps the additional representation (noir) to the predefined separation Black");
            ca.setReplacementColorantName("Black");
            Assert.IsTrue(ca.isValid(EnumValidationLevel.Incomplete));
            Assert.IsFalse(ca.isValid(EnumValidationLevel.Complete));
            VString vAlias = new VString("noir schwärz", null);

            ca.setSeparations(vAlias);
            Assert.IsTrue(ca.isValid(EnumValidationLevel.Complete));
            byte[] b        = Encoding.Default.GetBytes(vAlias.stringAt(0));
            string rawNames = StringUtil.setHexBinaryBytes(b, -1) + " ";

            b         = Encoding.Default.GetBytes(vAlias.stringAt(1));
            rawNames += StringUtil.setHexBinaryBytes(b, -1);
            ca.setAttribute("RawNames", rawNames);
            d.write2File(sm_dirTestDataTemp + "ActualColorName_with_CA.jdf", 2, false);
        }
コード例 #5
0
        ///
        ///	 <summary> * Get the Color Element with RawName=rawName or Name=rawName in the
        ///	 * momentary encoding
        ///	 *  </summary>
        ///	 * <param name="String">
        ///	 *            rawName the 8 bit representation of the rawName of the color
        ///	 *  </param>
        ///	 * <returns> JDFColor the color with the matching name, null if no matching
        ///	 *         element exists </returns>
        ///
        public virtual JDFColor getColorWith8BitName(string rawName)
        {
            VElement v = getChildElementVector(ElementName.COLOR, null, null, true, 0, false);

            for (int i = 0; i < v.Count; i++)
            {
                JDFColor c        = (JDFColor)v[i];
                string   pRawName = Encoding.Default.GetString(StringUtil.getRawBytes(c.get8BitName()));
                if (pRawName.Equals(rawName))
                {
                    return(c);
                }
            }

            return(null);
        }
コード例 #6
0
        public virtual void removeColor(string strColorName)
        {
            VElement vElem = getChildElementVector(ElementName.COLOR, null, null, true, 0, false);

            if (vElem != null)
            {
                int size = vElem.Count;
                for (int i = 0; i < size; i++)
                {
                    JDFColor c = (JDFColor)vElem[i];
                    if (strColorName.Equals(c.getActualColorName()))
                    {
                        c.deleteNode();
                    }
                }
            }
        }
コード例 #7
0
        ///
        ///	 <summary> * Append a Color Element with RawName=rawName and Name = Name
        ///	 *  </summary>
        ///	 * <param name="String">
        ///	 *            name the name of the color </param>
        ///	 * <param name="String">
        ///	 *            rawName he 8 bit representation of the rawName of the color
        ///	 *  </param>
        ///	 * <returns> JDFColor the color with the matching name, or null f no matching
        ///	 *         element exists </returns>
        ///
        public virtual JDFColor appendColorWithName(string colorName, string rawName)
        {
            JDFColor col = getColorWithName(colorName);

            if (col == null)
            {
                col = getColorWith8BitName(rawName);
            }
            if (col == null)
            {
                col = appendColor();
                if (rawName != null)
                {
                    col.set8BitNames(Encoding.Default.GetBytes(rawName));
                }
                col.setName(colorName);
            }
            else
            {
                throw new JDFException("JDFColorPool::AppendColorWithName color exists: " + colorName + "/" + rawName);
            }

            return(col);
        }
コード例 #8
0
        ///
        ///	 <summary> * Get the Color Element with Name=name
        ///	 *  </summary>
        ///	 * <param name="String">
        ///	 *            name the name of the color
        ///	 *  </param>
        ///	 * <returns> JDFColor the color with the matching name, or null if no matching
        ///	 *         element exists </returns>
        ///
        public virtual JDFColor getColorWithName(string colorName)
        {
            JDFColor color = null;

            if (colorName == null)
            {
                throw new JDFException("Bad colorname:" + colorName);
            }

            VElement v = getChildElementVector(ElementName.COLOR, null, null, true, 0, false);

            if (v != null)
            {
                int pos = -1;
                int siz = v.Count;
                for (int i = 0; i < siz; i++)
                {
                    color = (JDFColor)v[i];
                    if (colorName.Equals(color.getName()) || colorName.Equals(color.getActualColorName()))
                    {
                        if (pos < 0)
                        {
                            pos = i;
                        }
                        else
                        {
                            throw new JDFException("Multiple colors exist for:" + colorName);
                        }
                    }
                }

                color = (JDFColor)(pos == -1 ? null : v[pos]);
            }

            return(color);
        }