/** * Adds a segment to the subpath. * Note: each new segment shall start at the end of the previous segment. * @param segment new segment. */ public void addSegment(IShape segment) { if (closed) { return; } if (isSinglePointOpen()) { startPoint = segment.getBasePoints().get(0); } segments.add(segment); }
/** * Begins a new subpath by moving the current point to coordinates <CODE>(x, y)</CODE>. * @param x x-coordinate of the new point * @param y y-coordinate of the new point */ public void moveTo(float x, float y) { currentPoint = new Point(x, y); Subpath lastSubpath = subpaths.size() > 0 ? subpaths.get(subpaths.size() - 1) : null; if (lastSubpath != null && lastSubpath.isSinglePointOpen()) { lastSubpath.setStartPoint(currentPoint); } else { subpaths.add(new Subpath(currentPoint)); } }
/** * 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()); } } }