/** * Closes all subpathes contained in this path. */ public void closeAllSubpaths() { for (Subpath subpath : subpaths) { subpath.setClosed(true); } }
/** * Adds additional line to each closed subpath and makes the subpath unclosed. * The line connects the last and the first points of the subpaths. * * @return Indices of modified subpaths. */ public List<Integer> replaceCloseWithLine() { List<Integer> modifiedSubpathsIndices = new ArrayList<>(); int i = 0; /* It could be replaced with "for" cycle, because IList in C# provides effective * access by index. In Java List interface has at least one implementation (LinkedList) * which is "bad" for access elements by index. */ for (Subpath subpath : subpaths) { if (subpath.isClosed()) { subpath.setClosed(false); subpath.addSegment(new Line(subpath.getLastPoint(), subpath.getStartPoint())); modifiedSubpathsIndices.add(i); } ++i; } return modifiedSubpathsIndices; }
private Subpath transformSubpath(Subpath subpath, Matrix newCtm) { Subpath newSubpath = new Subpath(); newSubpath.setClosed(subpath.isClosed()); for (IShape segment : subpath.getSegments()) { IShape transformedSegment = transformSegment(segment, newCtm); newSubpath.addSegment(transformedSegment); } return newSubpath; }
/** * Closes the current subpath. */ public void closeSubpath() { if (!isEmpty()) { Subpath lastSubpath = getLastSubpath(); lastSubpath.setClosed(true); Point startPoint = lastSubpath.getStartPoint(); moveTo((float) startPoint.getX(), (float) startPoint.getY()); } }