From: Marko Luukkainen Date: Wed, 11 Sep 2019 10:06:27 +0000 (+0300) Subject: Add node class names to generated SVG X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=80811f572d7a686a6581840f4f0bcf2912ff9735;p=simantics%2Fplatform.git Add node class names to generated SVG gitlab #380 Change-Id: I721d774f8adf8864704409ec48c88f3a06fe15a3 (cherry picked from commit addea10db1cded33d342f78a7b5007c9f061752c) --- 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 40a526585..fad803ce4 100644 --- a/bundles/org.simantics.modeling/src/org/simantics/modeling/SCLScenegraph.java +++ b/bundles/org.simantics.modeling/src/org/simantics/modeling/SCLScenegraph.java @@ -85,6 +85,7 @@ import org.slf4j.LoggerFactory; import org.w3c.dom.DOMImplementation; import org.w3c.dom.Document; import org.w3c.dom.Element; +import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class SCLScenegraph { @@ -916,10 +917,21 @@ public class SCLScenegraph { } else if (!(node instanceof RouteGraphNode) && !(node instanceof LinkNode)){ try { Element doc = renderSVGNode(svgGenerator, (IG2DNode)node); - if (doc.getElementsByTagName("g").getLength() == 0) + NodeList gList = doc.getElementsByTagName("g"); + if (gList.getLength() == 0) return; + boolean hasContent = false; + for (int i = 0; i < gList.getLength(); i++) { + Node gNode = gList.item(i); + if (gNode.hasChildNodes()) { + hasContent = true; + break; + } + } + if (!hasContent) + return; String svg = printSVGDocument(doc); - parentBuilder.append(MAIN_SECTION, ""); + parentBuilder.append(MAIN_SECTION, ""); parentBuilder.append(MAIN_SECTION, svg); parentBuilder.append(MAIN_SECTION, "\n"); } catch (Exception e) {