Exemplo n.º 1
0
        ///
        ///	 <summary> * isPartOfRange - is range 'r' within this range?
        ///	 *  </summary>
        ///	 * <param name="ra"> the range to test
        ///	 *  </param>
        ///	 * <returns> boolean - true if range 'r' is within this range, else false </returns>
        ///
        public override bool isPartOfRange(JDFRange ra)
        {
            JDFRectangleRange r     = (JDFRectangleRange)ra;
            JDFRectangle      min   = this.LowerValue;
            JDFRectangle      r_min = r.LowerValue;
            JDFRectangle      max   = this.UpperValue;
            JDFRectangle      r_max = r.UpperValue;

            return(r_min.isGreaterOrEqual(min) && r_max.isLessOrEqual(max));
        }
Exemplo n.º 2
0
        ///
        ///	 <summary> * setString - deserialize a string Reads the string, which represents JDFRectangleRangeList, and converts it into
        ///	 * real JDFRectangleRangeList
        ///	 *  </summary>
        ///	 * <param name="s"> string to read
        ///	 *  </param>
        ///	 * <exception cref="FormatException"> - if the String has not a valid format </exception>
        ///
        public virtual void setString(string s)
        {
            if (s.IndexOf(JDFConstants.TILDE) == 0 || s.LastIndexOf(JDFConstants.TILDE) == (s.Length - 1))
            {
                throw new FormatException("JDFRectangleRangeList.setString: Illegal string " + s);
            }
            string zappedWS = StringUtil.zappTokenWS(s, JDFConstants.TILDE); // converts
            // "0 0 1 1 ~ 0 0 4 4"
            // to
            // "0 0 1 1~0 0 4 4"
            VString vs = new VString(zappedWS, JDFConstants.BLANK);

            rangeList.Clear();
            for (int i = 0, size = vs.Count; i < size; i++)
            {
                if (size - i < JDFBaseDataTypes_Fields.MAX_RECTANGLE_DIMENSION) // the last Rectangle is
                // incomplete
                {
                    throw new FormatException("JDFRectangleRangeList.setString: Illegal string " + s);
                }

                StringBuilder str = new StringBuilder(100);
                str.Append(vs[i]).Append(JDFConstants.BLANK).Append(vs[++i]).Append(JDFConstants.BLANK).Append(vs[++i]).Append(JDFConstants.BLANK);
                // the 4-th token 'tildeToken' can be with or without "~"
                string tildeToken = vs[++i];
                str.Append(tildeToken);
                if (tildeToken.IndexOf(JDFConstants.TILDE) != -1) // str -
                // JDFRectangleRange
                {
                    if (size - i < JDFBaseDataTypes_Fields.MAX_RECTANGLE_DIMENSION) // the last
                    // RectangleRange is
                    // incomplete
                    {
                        throw new FormatException("JDFRectangleRangeList.setString: Illegal string " + s);
                    }

                    str.Append(JDFConstants.BLANK).Append(vs[++i]).Append(JDFConstants.BLANK).Append(vs[++i]).Append(JDFConstants.BLANK).Append(vs[++i]);
                }
                try
                {
                    JDFRectangleRange r = new JDFRectangleRange(str.ToString());
                    rangeList.Add(r);
                }
                catch (FormatException)
                {
                    throw new FormatException("JDFRectangleRangeList.setString: Illegal string " + s);
                }
            }
        }
Exemplo n.º 3
0
        ///
        ///	 <summary> * isUniqueOrdered - tests if 'this' is an UniqueOrdered RangeList
        ///	 *  </summary>
        ///	 * <returns> boolean - true if 'this' is an UniqueOrdered RangeList </returns>
        ///
        public override bool isUniqueOrdered()
        {
            int siz = rangeList.Count;

            if (siz == 0)
            {
                return(false); // attempt to operate on a null element
            }

            List <JDFRectangle> v = new List <JDFRectangle>(); // vector of ranges

            for (int i = 0; i < siz; i++)
            {
                JDFRectangleRange r = (JDFRectangleRange)rangeList[i];
                v.Add(r.Left);
                if (!r.Left.Equals(r.Right))
                {
                    v.Add(r.Right);
                }
            }

            int n = v.Count - 1;

            if (n == 0)
            {
                return(true); // single value
            }
            JDFRectangle first = v[0];
            JDFRectangle last  = v[n];

            if (first.Equals(last))
            {
                return(false);
            }
            for (int j = 0; j < n; j++)
            {
                JDFRectangle @value    = v[j];
                JDFRectangle nextvalue = v[j + 1];

                if (((first.isLess(last) && @value.isLess(nextvalue)) || (first.isGreater(last) && @value.isGreater(nextvalue))) == false)
                {
                    return(false);
                }
            }
            return(true);
        }
Exemplo n.º 4
0
        ///
        ///	 <summary> * equals - returns true if both JDFRectangleRanges are equal otherwise false
        ///	 *  </summary>
        ///	 *<param name="other"> the JDFRectangleRange to compare </param>
        ///	 * <returns> boolean - true if equal, otherwise false </returns>
        ///
        public override bool Equals(object other)
        {
            if (this == other)
            {
                return(true);
            }
            if (other == null)
            {
                return(false);
            }
            if (!other.GetType().Equals(this.GetType()))
            {
                return(false);
            }

            JDFRectangleRange range = (JDFRectangleRange)other;

            return(this.Left.Equals(range.Left) && this.Right.Equals(range.Right));
        }
Exemplo n.º 5
0
 ///
 ///	 <summary> * append - adds an element defined by a JDFRectangleRange
 ///	 *  </summary>
 ///	 * <param name="x"> the range to append to the list </param>
 ///
 public virtual void Append(JDFRectangleRange x)
 {
     rangeList.Add(x);
 }
Exemplo n.º 6
0
 ///
 ///	 <summary> * copy constructor - constructs a JDFRectangleRange with the given JDFRectangleRange
 ///	 *  </summary>
 ///	 * <param name="r"> the JDFRectangleRange to copy </param>
 ///
 public JDFRectangleRange(JDFRectangleRange r)
 {
     init(r.Left, r.Right);
 }
Exemplo n.º 7
0
        public void testIsPartOfRange()
        {
            JDFRectangleRange range = new JDFRectangleRange(new JDFRectangle(0, 0, 2, 2), new JDFRectangle(0, 0, 4, 4));

            Assert.IsTrue(range.isPartOfRange(new JDFRectangleRange(new JDFRectangle(0, 0, 3, 3), new JDFRectangle(0, 0, 3.5, 3.5))), "inRange falsch");
        }