Esempio n. 1
0
 public LayoutRect(com.itextpdf.layout.layout.LayoutRect lr)
 {
     this.x      = lr.x;
     this.y      = lr.y;
     this.width  = lr.width;
     this.height = lr.height;
 }
Esempio n. 2
0
        /// <summary>Calculates the common rectangle which includes all the input rectangles.
        ///     </summary>
        /// <param name="rectangles">list of input rectangles.</param>
        /// <returns>common rectangle.</returns>
        public static com.itextpdf.layout.layout.LayoutRect GetCommonRectangle(params com.itextpdf.layout.layout.LayoutRect
                                                                               [] rectangles)
        {
            float ury = -float.MaxValue;
            float llx = float.MaxValue;
            float lly = float.MaxValue;
            float urx = -float.MaxValue;

            foreach (com.itextpdf.layout.layout.LayoutRect rectangle in rectangles)
            {
                com.itextpdf.layout.layout.LayoutRect rec = new com.itextpdf.layout.layout.LayoutRect
                                                                (rectangle);
                if (rec.GetHeight() == null)
                {
                    rec.SetHeight(0f);
                }
                if (rec.GetWidth() == null)
                {
                    rec.SetWidth(0f);
                }
                if (rec.GetY() < lly)
                {
                    lly = rec.GetY();
                }
                if (rec.GetX() < llx)
                {
                    llx = rec.GetX();
                }
                if (rec.GetY() + rec.GetHeight() > ury)
                {
                    ury = rec.GetY() + rec.GetHeight();
                }
                if (rec.GetX() + rec.GetWidth() > urx)
                {
                    urx = rec.GetX() + rec.GetWidth();
                }
            }
            return(new com.itextpdf.layout.layout.LayoutRect(llx, lly, urx - llx, ury - lly));
        }