Esempio n. 1
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);
        }
Esempio n. 2
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);
        }