private Point[] transformPoints(Matrix transformationMatrix, Point... points) { try { AffineTransform t = new AffineTransform( transformationMatrix.get(Matrix.I11), transformationMatrix.get(Matrix.I12), transformationMatrix.get(Matrix.I21), transformationMatrix.get(Matrix.I22), transformationMatrix.get(Matrix.I31), transformationMatrix.get(Matrix.I32) ); t = t.createInverse(); Point[] transformed = new Point[points.length]; t.transform(points, 0, transformed, 0, points.length); return transformed; } catch (NoninvertibleTransformException e) { throw new RuntimeException(e.getMessage(), e); } } }
if (partOfClipPath) { try { inverseMatrix = translation.createInverse(); } catch (NoninvertibleTransformException ex) { LoggerFactory.getLogger(UseSvgNodeRenderer.class)
@Override public void drawBackground(DrawContext drawContext) { PdfCanvas canvas = drawContext.getCanvas(); Matrix ctm = canvas.getGraphicsState().getCtm(); // Avoid rotation Float angle = this.getPropertyAsFloat(Property.ROTATION_ANGLE); boolean avoidRotation = null != angle && hasProperty(Property.BACKGROUND); boolean restoreRotation = hasOwnProperty(Property.ROTATION_ANGLE); if (avoidRotation) { AffineTransform transform = new AffineTransform(ctm.get(0), ctm.get(1), ctm.get(3), ctm.get(4), ctm.get(6), ctm.get(7)); try { transform = transform.createInverse(); } catch (NoninvertibleTransformException e) { throw new RuntimeException(e.getMessage(), e); } transform.concatenate(new AffineTransform()); canvas.concatMatrix(transform); setProperty(Property.ROTATION_ANGLE, null); } super.drawBackground(drawContext); // restore concat matrix and rotation angle if (avoidRotation) { if (restoreRotation) { setProperty(Property.ROTATION_ANGLE, angle); } else { deleteOwnProperty(Property.ROTATION_ANGLE); } canvas.concatMatrix(new AffineTransform(ctm.get(0), ctm.get(1), ctm.get(3), ctm.get(4), ctm.get(6), ctm.get(7))); } }
@Override public void drawBackground(DrawContext drawContext) { PdfCanvas canvas = drawContext.getCanvas(); Matrix ctm = canvas.getGraphicsState().getCtm(); // Avoid rotation Float angle = this.getPropertyAsFloat(Property.ROTATION_ANGLE); boolean avoidRotation = null != angle && hasProperty(Property.BACKGROUND); boolean restoreRotation = hasOwnProperty(Property.ROTATION_ANGLE); if (avoidRotation) { AffineTransform transform = new AffineTransform(ctm.get(0), ctm.get(1), ctm.get(3), ctm.get(4), ctm.get(6), ctm.get(7)); try { transform = transform.createInverse(); } catch (NoninvertibleTransformException e) { throw new RuntimeException(e.getMessage(), e); } transform.concatenate(new AffineTransform()); canvas.concatMatrix(transform); setProperty(Property.ROTATION_ANGLE, null); } super.drawBackground(drawContext); // restore concat matrix and rotation angle if (avoidRotation) { if (restoreRotation) { setProperty(Property.ROTATION_ANGLE, angle); } else { deleteOwnProperty(Property.ROTATION_ANGLE); } canvas.concatMatrix(new AffineTransform(ctm.get(0), ctm.get(1), ctm.get(3), ctm.get(4), ctm.get(6), ctm.get(7))); } }