Example usage for com.itextpdf.text.pdf.parser.clipper Clipper execute

List of usage examples for com.itextpdf.text.pdf.parser.clipper Clipper execute

Introduction

In this page you can find the example usage for com.itextpdf.text.pdf.parser.clipper Clipper execute.

Prototype

public boolean execute(ClipType clipType, PolyTree polytree, PolyFillType subjFillType,
            PolyFillType clipFillType);

Source Link

Usage

From source file:mkl.testarea.itext5.pdfcleanup.PdfCleanUpRegionFilter.java

License:Open Source License

/**
 * Note: this method will close all unclosed subpaths of the passed path.
 *
 * @param fillingRule If the subpath is contour, pass any value.
 *//*w w w . j av a  2s.  c o  m*/
protected Path filterFillPath(Path path, Matrix ctm, int fillingRule) {
    path.closeAllSubpaths();

    Clipper clipper = new DefaultClipper();
    addPath(clipper, path);

    for (Rectangle rectangle : rectangles) {
        Point2D[] transfRectVertices = transformPoints(ctm, true, getVertices(rectangle));
        addRect(clipper, transfRectVertices, PolyType.CLIP);
    }

    PolyFillType fillType = PolyFillType.NON_ZERO;

    if (fillingRule == PathPaintingRenderInfo.EVEN_ODD_RULE) {
        fillType = PolyFillType.EVEN_ODD;
    }

    PolyTree resultTree = new PolyTree();
    clipper.execute(ClipType.DIFFERENCE, resultTree, fillType, PolyFillType.NON_ZERO);

    return convertToPath(resultTree);
}

From source file:mkl.testarea.itext5.pdfcleanup.PdfCleanUpRegionFilter.java

License:Open Source License

private boolean intersect(Point2D[] rect1, Point2D[] rect2) {
    Clipper clipper = new DefaultClipper();
    addRect(clipper, rect1, PolyType.SUBJECT);
    addRect(clipper, rect2, PolyType.CLIP);

    Paths paths = new Paths();
    clipper.execute(ClipType.INTERSECTION, paths, PolyFillType.NON_ZERO, PolyFillType.NON_ZERO);

    return !paths.isEmpty();
}