From: Marko Luukkainen Date: Mon, 12 Nov 2018 17:03:35 +0000 (+0000) Subject: Merge "Utilize SVGNode's transformation when generating SVG image" X-Git-Tag: v1.43.0~136^2~280 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=1efdd1cea0fcef60df0267f23e4ffda9fab5b23d;p=simantics%2Fplatform.git Merge "Utilize SVGNode's transformation when generating SVG image" --- 1efdd1cea0fcef60df0267f23e4ffda9fab5b23d diff --cc bundles/org.simantics.modeling/src/org/simantics/modeling/SCLScenegraph.java index 630e41abe,4e4811c5a..ef2fb5d66 --- a/bundles/org.simantics.modeling/src/org/simantics/modeling/SCLScenegraph.java +++ b/bundles/org.simantics.modeling/src/org/simantics/modeling/SCLScenegraph.java @@@ -849,17 -849,24 +849,32 @@@ public class SCLScenegraph parentBuilder2.append(SELECTION_MASK_SECTION,"\n"); } + } else if (node instanceof SelectionNode) { + + Element doc = renderSVGNode(svgGenerator, (IG2DNode)node); + String svg = printSVGDocument(doc); + parentBuilder.append(MAIN_SECTION, ""); + parentBuilder.append(MAIN_SECTION, svg); + parentBuilder.append(MAIN_SECTION, "\n"); + } 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) {