예제 #1
0
        virtual public RectangleJ Intersection(RectangleJ r)
        {
            float x1 = Math.Max(x, r.x);
            float y1 = Math.Max(y, r.y);
            float x2 = Math.Min(x + width, r.x + r.width);
            float y2 = Math.Min(y + height, r.y + r.height);

            return(new RectangleJ(x1, y1, x2 - x1, y2 - y1));
        }
예제 #2
0
        /**
         * Method invokes by the PdfContentStreamProcessor.
         * Passes a TextRenderInfo for every text chunk that is encountered.
         * We'll use this object to obtain coordinates.
         * @see com.itextpdf.text.pdf.parser.RenderListener#renderText(com.itextpdf.text.pdf.parser.TextRenderInfo)
         */
        virtual public void RenderText(TextRenderInfo renderInfo) {
            if (textRectangle == null)
                textRectangle = renderInfo.GetDescentLine().GetBoundingRectange();
            else
                textRectangle.Add(renderInfo.GetDescentLine().GetBoundingRectange());
            
            textRectangle.Add(renderInfo.GetAscentLine().GetBoundingRectange());

        }
예제 #3
0
 virtual public void Add(RectangleJ rect) {
     float x1 = Math.Min(Math.Min(x, x + width), Math.Min(rect.x, rect.x + rect.width));
     float x2 = Math.Max(Math.Max(x, x + width), Math.Max(rect.x, rect.x + rect.width));
     float y1 = Math.Min(Math.Min(y, y + height), Math.Min(rect.y, rect.y + rect.height));
     float y2 = Math.Max(Math.Max(y, y + height), Math.Max(rect.y, rect.y + rect.height));
     x = x1;
     y = y1;
     width = x2 - x1;
     height = y2 - y1;
 }
예제 #4
0
        virtual public void Add(RectangleJ rect)
        {
            float x1 = Math.Min(Math.Min(x, x + width), Math.Min(rect.x, rect.x + rect.width));
            float x2 = Math.Max(Math.Max(x, x + width), Math.Max(rect.x, rect.x + rect.width));
            float y1 = Math.Min(Math.Min(y, y + height), Math.Min(rect.y, rect.y + rect.height));
            float y2 = Math.Max(Math.Max(y, y + height), Math.Max(rect.y, rect.y + rect.height));

            x      = x1;
            y      = y1;
            width  = x2 - x1;
            height = y2 - y1;
        }
예제 #5
0
 /**
  * Constructs a filter
  * @param filterRect the rectangle to filter text against.
  */
 public RegionTextRenderFilter(iTextSharp.text.Rectangle filterRect) {
     this.filterRect = new RectangleJ(filterRect);
 }
예제 #6
0
 /**
  * Constructs a filter
  * @param filterRect the rectangle to filter text against.  Note that this is a java.awt.Rectangle !
  */
 public RegionTextRenderFilter(RectangleJ filterRect) {
     this.filterRect = filterRect;
 }
예제 #7
0
 /**
  * Constructs a <CODE>Rectangle</CODE>-object based on a <CODE>com.itextpdf.awt.geom.Rectangle</CODE> object
  * @param rect com.itextpdf.awt.geom.Rectangle
  */
 public Rectangle(RectangleJ rect): this(rect.X, rect.Y, rect.X + rect.Width, rect.Y + rect.Height) {
 }
        /**
         * Returns the intersection between the crop, trim art or bleed box and the parameter intersectingRectangle.
         * This method returns null when
         * - there is no intersection
         * - any of the above boxes are not defined
         * - the parameter intersectingRectangle is null
         *
         * @param boxName crop, trim, art, bleed
         * @param intersectingRectangle the rectangle that intersects the rectangle associated to the boxName
         * @return the intersection of the two rectangles
         */
        public Rectangle GetBoxSize(String boxName, Rectangle intersectingRectangle) {
            Rectangle pdfRectangle = pdf.GetBoxSize(boxName);

            if ( pdfRectangle == null || intersectingRectangle == null ) { // no intersection
                return null;
            }
            //com.itextpdf.awt.geom.Rectangle
            RectangleJ boxRect = new RectangleJ(pdfRectangle);
            RectangleJ intRect = new RectangleJ(intersectingRectangle);
            RectangleJ outRect = boxRect.Intersection(intRect);

            if (outRect.IsEmpty()) { // no intersection
                return null;
            }

            Rectangle output = new Rectangle(outRect.X, outRect.Y, outRect.X + outRect.Width, outRect.Y + outRect.Height);
            output.Normalize();
            return output;
        }
예제 #9
0
        /**
         * @return null if the intersection is empty, {@link com.itextpdf.text.Rectangle} representing intersection otherwise
         */
        private Rectangle Intersection(Rectangle rect1, Rectangle rect2) {
            RectangleJ awtRect1 = new RectangleJ(rect1);
            RectangleJ awtRect2 = new RectangleJ(rect2);
            RectangleJ awtIntersection = awtRect1.Intersection(awtRect2);

            return awtIntersection.IsEmpty() ? null : new Rectangle(awtIntersection);
        }
예제 #10
0
 virtual public RectangleJ Intersection(RectangleJ r) {
     float x1 = Math.Max(x, r.x);
     float y1 = Math.Max(y, r.y);
     float x2 = Math.Min(x + width, r.x + r.width);
     float y2 = Math.Min(y + height, r.y + r.height);
     return new RectangleJ(x1, y1, x2 - x1, y2 - y1);
 }
        private static bool ContainsAll(RectangleJ rect, params Point2D[] points) {
            foreach (Point2D point in points) {
                if (!rect.Contains(point)) {
                    return false;
                }
            }

            return true;
        }