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);
}
Aggregations