]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Utilize SVGNode's transformation when generating SVG image 54/2454/1
authorMarko Luukkainen <marko.luukkainen@semantum.fi>
Mon, 12 Nov 2018 16:18:53 +0000 (18:18 +0200)
committerMarko Luukkainen <marko.luukkainen@semantum.fi>
Mon, 12 Nov 2018 16:18:53 +0000 (18:18 +0200)
gitlab #195

Change-Id: Ibc3199eff5a342f24dba66eb483cacaf6f0a9e59

bundles/org.simantics.modeling/src/org/simantics/modeling/SCLScenegraph.java

index 55ed12656131c0629595cd7ded70c4f4bd064234..4e4811c5a15fe066d6ecf645accbe8fc26a4ca93 100644 (file)
@@ -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<g transform=\"" + m + "\">");
+                     } 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<g transform=\"" + m + "\">");
+                     }
+                }
                 parentBuilder.append(MAIN_SECTION, svg.getSVGText());
+                if (!at.isIdentity()) {
+                       parentBuilder.append(MAIN_SECTION, "\n</g>");
+                }
             } else if (node instanceof G2DParentNode) {
                 AffineTransform at = node.getTransform();
                 if(node instanceof SingleElementNode) {