public Path(Path path) { addSubpaths(path.getSubpaths()); }
private void transformClippingPath(Matrix newCtm) { Path path = new Path(); for (Subpath subpath : clippingPath.getSubpaths()) { Subpath transformedSubpath = transformSubpath(subpath, newCtm); path.addSubpath(transformedSubpath); } clippingPath = path; }
/** * Adds all iText {@link Subpath}s of the iText {@link Path} to the {@link ClipperOffset} object with one * note: it doesn't add degenerate subpaths. * * @return {@link java.util.List} consisting of all degenerate iText {@link Subpath}s of the path. */ public static List<Subpath> addPath(ClipperOffset offset, com.itextpdf.kernel.geom.Path path, IClipper.JoinType joinType, IClipper.EndType endType) { List<Subpath> degenerateSubpaths = new ArrayList<>(); for (Subpath subpath : path.getSubpaths()) { if (subpath.isDegenerate()) { degenerateSubpaths.add(subpath); continue; } if (!subpath.isSinglePointClosed() && !subpath.isSinglePointOpen()) { IClipper.EndType et; if (subpath.isClosed()) { // Offsetting is never used for path being filled et = IClipper.EndType.CLOSED_LINE; } else { et = endType; } List<com.itextpdf.kernel.geom.Point> linearApproxPoints = subpath.getPiecewiseLinearApproximation(); offset.addPath(new Path(convertToLongPoints(linearApproxPoints)), joinType, et); } } return degenerateSubpaths; }
/** * Adds iText {@link Path} to the given {@link IClipper} object. * @param clipper The {@link IClipper} object. * @param path The {@link com.itextpdf.kernel.geom.Path} object to be added to the {@link IClipper}. * @param polyType See {@link IClipper.PolyType}. */ public static void addPath(IClipper clipper, com.itextpdf.kernel.geom.Path path, IClipper.PolyType polyType) { for (Subpath subpath : path.getSubpaths()) { if (!subpath.isSinglePointClosed() && !subpath.isSinglePointOpen()) { List<com.itextpdf.kernel.geom.Point> linearApproxPoints = subpath.getPiecewiseLinearApproximation(); clipper.addPath(new Path(convertToLongPoints(linearApproxPoints)), polyType, subpath.isClosed()); } } }