From 34ee11ce2339ebdae4783e5765583a6ae13c2920 Mon Sep 17 00:00:00 2001 From: Marko Luukkainen Date: Mon, 12 Nov 2018 18:18:53 +0200 Subject: [PATCH] Utilize SVGNode's transformation when generating SVG image gitlab #195 Change-Id: Ibc3199eff5a342f24dba66eb483cacaf6f0a9e59 --- .../src/org/simantics/modeling/SCLScenegraph.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/bundles/org.simantics.modeling/src/org/simantics/modeling/SCLScenegraph.java b/bundles/org.simantics.modeling/src/org/simantics/modeling/SCLScenegraph.java index 55ed12656..4e4811c5a 100644 --- a/bundles/org.simantics.modeling/src/org/simantics/modeling/SCLScenegraph.java +++ b/bundles/org.simantics.modeling/src/org/simantics/modeling/SCLScenegraph.java @@ -851,7 +851,22 @@ public class SCLScenegraph { } } else if (node instanceof SVGNode) { SVGNode svg = (SVGNode)node; + AffineTransform at = svg.getTransform(); + if (!at.isIdentity()) { + if(at.getScaleX() == 1.0 && at.getScaleY() == 1.0 && at.getShearX() == 0.0 && at.getShearY() == 0.0) { + String m = "translate(" + at.getTranslateX() + " " + at.getTranslateY() + ")"; + parentBuilder.append(MAIN_SECTION, "\n"); + } else { + double[] ds = new double[6]; + at.getMatrix(ds); + String m = "matrix(" + ds[0] + " " + ds[1] + " " + ds[2] + " " + ds[3] + " " + ds[4] + " " + ds[5] + ")"; + parentBuilder.append(MAIN_SECTION, "\n"); + } + } parentBuilder.append(MAIN_SECTION, svg.getSVGText()); + if (!at.isIdentity()) { + parentBuilder.append(MAIN_SECTION, "\n"); + } } else if (node instanceof G2DParentNode) { AffineTransform at = node.getTransform(); if(node instanceof SingleElementNode) { -- 2.47.1