From: Antti Villberg Date: Sat, 18 Nov 2017 19:24:12 +0000 (+0200) Subject: renderSVG fails if a SingleElementNode does not contain a resource X-Git-Tag: v1.31.0~30 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F36%2F1236%2F2;p=simantics%2Fplatform.git renderSVG fails if a SingleElementNode does not contain a resource refs #7625 Change-Id: I5c0eee38a060207c2a31078586a4c4c85b2c902f --- 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 c7f3fe4ec..e0c198388 100644 --- a/bundles/org.simantics.modeling/src/org/simantics/modeling/SCLScenegraph.java +++ b/bundles/org.simantics.modeling/src/org/simantics/modeling/SCLScenegraph.java @@ -759,10 +759,14 @@ public class SCLScenegraph { private String getKey(SingleElementNode node) { String key; - if (mappings.containsKey(node.getKey())) - key = mappings.get(node.getKey()).toString(); - else - key = node.getKey().toString(); + if(node.getKey() != null) { + if (mappings.containsKey(node.getKey())) + key = mappings.get(node.getKey()).toString(); + else + key = node.getKey().toString(); + } else { + key = Long.toString(node.getId()); + } return key; } @@ -813,7 +817,7 @@ public class SCLScenegraph { SelectionNode n = (SelectionNode)node; SingleElementNode parentSEN = (SingleElementNode)NodeUtil.getNearestParentOfType(node, SingleElementNode.class); - if(parentSEN != null && parentSEN.getKey() != null) { + if(parentSEN != null) { RenderSVGContext parentBuilder2 = getParentBuilder(parentSEN); @@ -844,15 +848,13 @@ public class SCLScenegraph { AffineTransform at = node.getTransform(); if(node instanceof SingleElementNode) { SingleElementNode sen = (SingleElementNode)node; - if(sen.getKey() != null) { - String key = getKey(sen); - String typeClass = sen.getTypeClass(); - String clazz = "definedElement"; - if(typeClass != null && !typeClass.isEmpty()) - clazz = clazz + " " + typeClass; - - parentBuilder.append(MAIN_SECTION, "\n"); - } + String key = getKey(sen); + String typeClass = sen.getTypeClass(); + String clazz = "definedElement"; + if(typeClass != null && !typeClass.isEmpty()) + clazz = clazz + " " + typeClass; + + parentBuilder.append(MAIN_SECTION, "\n"); senBuilders.put(sen, new RenderSVGContext()); } if(!at.isIdentity()) { @@ -898,16 +900,12 @@ public class SCLScenegraph { RenderSVGContext b = senBuilders.get(sen); String content = b.get(MAIN_SECTION); if(content.isEmpty()) { - if(sen.getKey() != null) { - - for(SelectionNode n : NodeUtil.collectNodes(node, SelectionNode.class)) { - n.setIgnore(true); - } - - Element doc = renderSVGNode((IG2DNode)node); - String svg = printSVGDocument(doc); - parentBuilder.append(MAIN_SECTION, svg); + for(SelectionNode n : NodeUtil.collectNodes(node, SelectionNode.class)) { + n.setIgnore(true); } + Element doc = renderSVGNode((IG2DNode)node); + String svg = printSVGDocument(doc); + parentBuilder.append(MAIN_SECTION, svg); } else { parentBuilder.append(b); } @@ -919,9 +917,9 @@ public class SCLScenegraph { } if(node instanceof SingleElementNode) { SingleElementNode sen = (SingleElementNode)node; - if(sen.getKey() != null) { + //if(sen.getKey() != null) { parentBuilder.append(MAIN_SECTION, ""); - } + //} } } indent --;