示例#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> * 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);
        }