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 {
} 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, "<g>");
+ parentBuilder.append(MAIN_SECTION, "<g class=\"" +node.getSimpleClassName() +"\">");
parentBuilder.append(MAIN_SECTION, svg);
parentBuilder.append(MAIN_SECTION, "\n</g>");
} catch (Exception e) {