Search in sources :

Example 1 with EndType

use of com.itextpdf.kernel.pdf.canvas.parser.clipper.IClipper.EndType in project i7j-pdfsweep by itext.

the class PdfCleanUpFilter method filterStrokePath.

private com.itextpdf.kernel.geom.Path filterStrokePath(com.itextpdf.kernel.geom.Path sourcePath, Matrix ctm, float lineWidth, int lineCapStyle, int lineJoinStyle, float miterLimit, LineDashPattern lineDashPattern) {
    com.itextpdf.kernel.geom.Path path = sourcePath;
    JoinType joinType = ClipperBridge.getJoinType(lineJoinStyle);
    EndType endType = ClipperBridge.getEndType(lineCapStyle);
    if (lineDashPattern != null && !lineDashPattern.isSolid()) {
        path = LineDashPattern.applyDashPattern(path, lineDashPattern);
    }
    ClipperOffset offset = new ClipperOffset(miterLimit, PdfCleanUpTool.arcTolerance * PdfCleanUpTool.floatMultiplier);
    List<Subpath> degenerateSubpaths = ClipperBridge.addPath(offset, path, joinType, endType);
    PolyTree resultTree = new PolyTree();
    offset.execute(resultTree, lineWidth * PdfCleanUpTool.floatMultiplier / 2);
    com.itextpdf.kernel.geom.Path offsetedPath = ClipperBridge.convertToPath(resultTree);
    if (degenerateSubpaths.size() > 0) {
        if (endType == EndType.OPEN_ROUND) {
            List<Subpath> circles = convertToCircles(degenerateSubpaths, lineWidth / 2);
            offsetedPath.addSubpaths(circles);
        } else if (endType == EndType.OPEN_SQUARE && lineDashPattern != null) {
            List<Subpath> squares = convertToSquares(degenerateSubpaths, lineWidth, sourcePath);
            offsetedPath.addSubpaths(squares);
        }
    }
    return filterFillPath(offsetedPath, ctm, PdfCanvasConstants.FillingRule.NONZERO_WINDING);
}
Also used : Subpath(com.itextpdf.kernel.geom.Subpath) PolyTree(com.itextpdf.kernel.pdf.canvas.parser.clipper.PolyTree) ClipperOffset(com.itextpdf.kernel.pdf.canvas.parser.clipper.ClipperOffset) JoinType(com.itextpdf.kernel.pdf.canvas.parser.clipper.IClipper.JoinType) EndType(com.itextpdf.kernel.pdf.canvas.parser.clipper.IClipper.EndType) List(java.util.List) ArrayList(java.util.ArrayList)

Aggregations

Subpath (com.itextpdf.kernel.geom.Subpath)1 ClipperOffset (com.itextpdf.kernel.pdf.canvas.parser.clipper.ClipperOffset)1 EndType (com.itextpdf.kernel.pdf.canvas.parser.clipper.IClipper.EndType)1 JoinType (com.itextpdf.kernel.pdf.canvas.parser.clipper.IClipper.JoinType)1 PolyTree (com.itextpdf.kernel.pdf.canvas.parser.clipper.PolyTree)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1