Example usage for com.itextpdf.text.pdf.parser.clipper ClipperOffset addPath

List of usage examples for com.itextpdf.text.pdf.parser.clipper ClipperOffset addPath

Introduction

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

Prototype

public void addPath(Path path, JoinType joinType, EndType endType) 

Source Link

Usage

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

License:Open Source License

/**
 * Adds all subpaths of the path to the {@link ClipperOffset} object with one
 * note: it doesn't add degenerate subpaths.
 *
 * @return {@link java.util.List} consisting of all degenerate subpaths of the path.
 *///from  ww w .ja  v a  2 s. c  o  m
private static List<Subpath> addPath(ClipperOffset offset, Path path, JoinType joinType, EndType endType) {
    List<Subpath> degenerateSubpaths = new ArrayList<Subpath>();

    for (Subpath subpath : path.getSubpaths()) {
        if (subpath.isDegenerate()) {
            degenerateSubpaths.add(subpath);
            continue;
        }

        if (!subpath.isSinglePointClosed() && !subpath.isSinglePointOpen()) {
            EndType et;

            if (subpath.isClosed()) {
                // Offsetting is never used for path being filled
                et = EndType.CLOSED_LINE;
            } else {
                et = endType;
            }

            List<Point2D> linearApproxPoints = subpath.getPiecewiseLinearApproximation();
            offset.addPath(convertToIntPoints(linearApproxPoints), joinType, et);
        }
    }

    return degenerateSubpaths;
}