]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Merge "Utilize SVGNode's transformation when generating SVG image"
authorMarko Luukkainen <marko.luukkainen@semantum.fi>
Mon, 12 Nov 2018 17:03:35 +0000 (17:03 +0000)
committerGerrit Code Review <gerrit2@simantics>
Mon, 12 Nov 2018 17:03:35 +0000 (17:03 +0000)
1  2 
bundles/org.simantics.modeling/src/org/simantics/modeling/SCLScenegraph.java

index 630e41abe6326de3d2fd426a1e94cc012a900e72,4e4811c5a15fe066d6ecf645accbe8fc26a4ca93..ef2fb5d66cbeff9faa4f5458dc91955be12fea98
@@@ -849,17 -849,24 +849,32 @@@ public class SCLScenegraph 
                      parentBuilder2.append(SELECTION_MASK_SECTION,"\n</g>");
                     
                  }
 +            } else if (node instanceof SelectionNode) {
 +
 +                Element doc = renderSVGNode(svgGenerator, (IG2DNode)node);
 +                String svg = printSVGDocument(doc);
 +                parentBuilder.append(MAIN_SECTION, "<g>");
 +                parentBuilder.append(MAIN_SECTION, svg);
 +                parentBuilder.append(MAIN_SECTION, "\n</g>");
 +
              } 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) {