import org.simantics.scenegraph.g2d.nodes.BoundsNode;
import org.simantics.scenegraph.g2d.nodes.ConnectionNode;
import org.simantics.scenegraph.g2d.nodes.DataNode;
+import org.simantics.scenegraph.g2d.nodes.LinkNode;
import org.simantics.scenegraph.g2d.nodes.NavigationNode;
import org.simantics.scenegraph.g2d.nodes.SVGNode;
import org.simantics.scenegraph.g2d.nodes.SelectionNode;
// get the bounds of the content
Rectangle2D content = rtreeBounds;
- // To account for dynamic padding of selection rectangles (5 units + stroke width)
- int offset = 6;
- double scale = width < 0 || height < 0 ? 1.0 : Math.min((width - 2*offset) / content.getWidth(), (height - 2*offset) / content.getHeight());
-
- AffineTransform tr = new AffineTransform();
- tr.translate(offset, offset);
- tr.scale(scale, scale);
- tr.translate(-content.getX(), -content.getY());
- tr.getMatrix(matrix);
+ if (content != null) {
+ // To account for dynamic padding of selection rectangles (5 units + stroke width)
+ int offset = 6;
+
+ double scale = width < 0 || height < 0 ? 1.0 : Math.min((width - 2*offset) / content.getWidth(), (height - 2*offset) / content.getHeight());
+
+ AffineTransform tr = new AffineTransform();
+ tr.translate(offset, offset);
+ tr.scale(scale, scale);
+ tr.translate(-content.getX(), -content.getY());
+ tr.getMatrix(matrix);
+ svgGenerator.setSVGCanvasSize(new Dimension((int)Math.ceil(scale * content.getWidth()) + 2*offset, (int)Math.ceil(scale * content.getHeight()) + 2*offset));
+ } else {
+ svgGenerator.setSVGCanvasSize(new Dimension(100, 100));
+ }
//svgGenerator.translate(offset, offset);
//svgGenerator.scale(scale, scale);
// translate svgGenerator to the x and y coordinates of current content
//svgGenerator.translate(-content.getX(), -content.getY());
- svgGenerator.setSVGCanvasSize(new Dimension((int)Math.ceil(scale * content.getWidth()) + 2*offset, (int)Math.ceil(scale * content.getHeight()) + 2*offset));
+
//svgGenerator.setClip(content);
result.append(MAIN_SECTION, "<g class=\"symbols\">");
parentBuilder.append(ALL_SECTIONS, "\n<g transform=\"" + m + "\">");
}
}
+ } else if (!(node instanceof RouteGraphNode) && !(node instanceof LinkNode)){
+ try {
+ Element doc = renderSVGNode(svgGenerator, (IG2DNode)node);
+ if (doc.getElementsByTagName("g").getLength() == 0)
+ return;
+ String svg = printSVGDocument(doc);
+ parentBuilder.append(MAIN_SECTION, "<g>");
+ parentBuilder.append(MAIN_SECTION, svg);
+ parentBuilder.append(MAIN_SECTION, "\n</g>");
+ } catch (Exception e) {
+ // TODO: There are nodes that do not behave well when rendered to SVG. For backwards compatibility, we don't handle the exceptions.
+ }
}
//enters.put(node, b.length());