ShapeTransformUtil { public static Path transformPath(Path path, Matrix ctm) { Path newPath = new Path(); for (Subpath subpath : path.getSubpaths()) { Subpath transformedSubpath = transformSubpath(subpath, ctm); newPath.addSubpath(transformedSubpath); } return newPath; }  static BezierCurve transformBezierCurve(BezierCurve bezierCurve, Matrix ctm); static Line transformLine(Line line, Matrix ctm); static Path transformPath(Path path, Matrix ctm);  }
@Test public void transformPathTest() { Line inLine = new Line(new Point(0, 0), new Point(10, 10)); BezierCurve inBezierCurve = new BezierCurve(Arrays.asList(new Point(0, 0), new Point(0, 5), new Point(5, 5), new Point(5, 0))); Subpath inSubpath = new Subpath(); inSubpath.addSegment(inLine); inSubpath.addSegment(inBezierCurve); Path inPath = new Path(Arrays.asList(inSubpath)); Matrix ctm = new Matrix(1, 0, 0, 1, 5, 5); Path outPath = ShapeTransformUtil.transformPath(inPath, ctm); Line cmpLine = new Line(new Point(-5, -5), new Point(5, 5)); BezierCurve cmpBezierCurve = new BezierCurve(Arrays.asList(new Point(-5, -5), new Point(-5, 0), new Point(0, 0), new Point(0, -5))); Subpath cmpSubpath = new Subpath(); inSubpath.addSegment(cmpLine); inSubpath.addSegment(cmpBezierCurve); Path cmpPath = new Path(Arrays.asList(cmpSubpath)); for (int i = 0; i < cmpPath.getSubpaths().size(); i++) { Subpath subpath = cmpPath.getSubpaths().get(i); for (int j = 0; j < subpath.getSegments().size(); j++) { IShape cmpShape = subpath.getSegments().get(j); IShape outShape = outPath.getSubpaths().get(i).getSegments().get(j); Assert.assertArrayEquals(cmpShape.getBasePoints().toArray(), outShape.getBasePoints().toArray()); } } }