public boolean intersects(Rectangle r) { return !intersection(r).isEmpty(); }
public boolean intersects(Rectangle r) { return !intersection(r).isEmpty(); }
@Override public Rectangle2D createIntersection(Rectangle2D r) { if (r instanceof Rectangle) { return intersection((Rectangle) r); } Rectangle2D dst = new Rectangle2D.Double(); Rectangle2D.intersect(this, r, dst); return dst; }
@Override public Rectangle2D createIntersection(Rectangle2D r) { if (r instanceof Rectangle) { return intersection((Rectangle) r); } Rectangle2D dst = new Rectangle2D.Double(); Rectangle2D.intersect(this, r, dst); return dst; }
/** * 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(final String boxName, final Rectangle intersectingRectangle) { Rectangle pdfRectangle = pdf.getBoxSize(boxName); if ( pdfRectangle == null || intersectingRectangle == null ) { // no intersection return null; } com.itextpdf.awt.geom.Rectangle boxRect = new com.itextpdf.awt.geom.Rectangle(pdfRectangle); com.itextpdf.awt.geom.Rectangle intRect = new com.itextpdf.awt.geom.Rectangle(intersectingRectangle); com.itextpdf.awt.geom.Rectangle outRect = boxRect.intersection(intRect); if ( outRect.isEmpty() ) { // no intersection return null; } Rectangle output = new Rectangle((float) outRect.getX(), (float) outRect.getY(), (float) (outRect.getX() + outRect.getWidth()), (float) (outRect.getY() + outRect.getHeight())); output.normalize(); return output; }
/** * 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(final String boxName, final Rectangle intersectingRectangle) { Rectangle pdfRectangle = pdf.getBoxSize(boxName); if ( pdfRectangle == null || intersectingRectangle == null ) { // no intersection return null; } com.itextpdf.awt.geom.Rectangle boxRect = new com.itextpdf.awt.geom.Rectangle(pdfRectangle); com.itextpdf.awt.geom.Rectangle intRect = new com.itextpdf.awt.geom.Rectangle(intersectingRectangle); com.itextpdf.awt.geom.Rectangle outRect = boxRect.intersection(intRect); if ( outRect.isEmpty() ) { // no intersection return null; } Rectangle output = new Rectangle((float) outRect.getX(), (float) outRect.getY(), (float) (outRect.getX() + outRect.getWidth()), (float) (outRect.getY() + outRect.getHeight())); output.normalize(); return output; }