]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.modeling/src/org/simantics/modeling/SCLScenegraph.java
Separate TextNode handling for SCLSceneGraph
[simantics/platform.git] / bundles / org.simantics.modeling / src / org / simantics / modeling / SCLScenegraph.java
index fad803ce41a4a84bdb11991a06f73e0bdc3a3451..db65b4de38c33193a1c1fe7e9492c799ab4544e2 100644 (file)
@@ -914,6 +914,39 @@ public class SCLScenegraph {
                         parentBuilder.append(ALL_SECTIONS, "\n<g transform=\"" + m + "\">");
                     }
                 }
+            } else if (node instanceof TextNode) {
+                TextNode text = (TextNode)node;
+                               
+                 SingleElementNode parentSEN = (SingleElementNode)NodeUtil.getNearestParentOfType(node, SingleElementNode.class);
+                 if(parentSEN != null) {
+                        
+                        text.setShowSelection(false);
+                        Element doc = renderSVGNode(svgGenerator, (IG2DNode)node);
+                     String svg = printSVGDocument(doc);
+                     parentBuilder.append(MAIN_SECTION, svg);
+                     
+                        RenderSVGContext parentBuilder2 = getParentBuilder(parentSEN);
+                     
+                     String key = getKey(parentSEN);
+                     text.setShowSelection(true);
+                     doc = renderSVGNode(svgGenerator, (IG2DNode)node);
+                     svg = printSVGDocument(doc);
+                     
+                     parentBuilder2.append(SELECTION_SECTION, "\n<g style=\"visibility:hidden\" class=\"selection\" id=\"" + key + "\">");
+                     parentBuilder2.append(SELECTION_SECTION, svg);
+                     parentBuilder2.append(SELECTION_SECTION, "\n</g>");
+                     parentBuilder2.append(SELECTION_MASK_SECTION, "\n<g class=\"selectionMask\" id=\"" + key /*+ "\" transform=\"" + matrixString + "\"*/+ "\">");
+                     Rectangle2D rect = text.getBounds();
+                     // NaN
+                     if(rect.getHeight() == rect.getHeight() && rect.getWidth() == rect.getWidth()) {
+                           parentBuilder2.append(SELECTION_MASK_SECTION,"<rect style=\"fill:#fff\" opacity=\"" + OPACITY + "\"");
+                           parentBuilder2.append(SELECTION_MASK_SECTION," x=\"" + rect.getX() + "\" y=\"" + rect.getY() + "\"");
+                           parentBuilder2.append(SELECTION_MASK_SECTION," width=\"" + rect.getWidth() + "\" height=\"" + rect.getHeight() + "\"");
+                           parentBuilder2.append(SELECTION_MASK_SECTION,"></rect>");
+                     }
+                     parentBuilder2.append(SELECTION_MASK_SECTION,"\n</g>");
+                    
+                 }
             } else if (!(node instanceof RouteGraphNode) && !(node instanceof LinkNode)){
                try {
                        Element doc = renderSVGNode(svgGenerator, (IG2DNode)node);