]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Change opacity to 0.0001 in SCLScenegraph 74/2474/1
authorjsimomaa <jani.simomaa@gmail.com>
Tue, 20 Nov 2018 08:35:53 +0000 (10:35 +0200)
committerjsimomaa <jani.simomaa@gmail.com>
Tue, 20 Nov 2018 08:35:53 +0000 (10:35 +0200)
gitlab #208

Change-Id: I5e53cdff7849d67cf20827611c8e11e6812913a4

bundles/org.simantics.modeling/src/org/simantics/modeling/SCLScenegraph.java

index ef2fb5d66cbeff9faa4f5458dc91955be12fea98..d3fd1cca9b9314cf4933c78d331fe22f349d85be 100644 (file)
@@ -93,9 +93,16 @@ public class SCLScenegraph {
        private static final String MAIN_SECTION = "main";
        private static final String SELECTION_SECTION = "selection";
        private static final String SELECTION_MASK_SECTION = "selectionMask";
-       
+
        private static final String[] ALL_SECTIONS = { MAIN_SECTION, SELECTION_SECTION, SELECTION_MASK_SECTION };
 
+       // Changed from 0.001 to 0.0001 to prevent creation of huge BufferedImage's when
+       // generating PDF from SVG. If SVG contains any transparency then Batik uses
+       // bitmap-rendering which remarkably slows things down
+       // See org.apache.batik.gvt.AbstractGraphicsNode.paint(Graphics2D) where decisions are made
+       // if AlphaComposite should be painted 
+       private static final String OPACITY = "0.0001";
+
        @Deprecated
        public static ICanvasSceneGraphProvider getICanvasSceneGraphProvider(Resource model, Resource diagram, String diagramRVI) throws DatabaseException, InterruptedException {
                ICanvasSceneGraphProvider provider = DiagramNodeUtil.loadSceneGraphProvider(model, diagram, diagramRVI);
@@ -793,7 +800,7 @@ public class SCLScenegraph {
                 String key = getKey((ConnectionNode) node);
                 parentBuilder.append(MAIN_SECTION, "\n<g class=\"connection\" id=\"" + key + "\">");
                 parentBuilder.append(SELECTION_SECTION, "\n<g style=\"visibility:hidden\" class=\"selection\" id=\"" + key + "\">");
-                parentBuilder.append(SELECTION_MASK_SECTION, "\n<g class=\"selectionMask\" opacity=\"0.001\" id=\"" + key + "\">");
+                parentBuilder.append(SELECTION_MASK_SECTION, "\n<g class=\"selectionMask\" opacity=\"" + OPACITY + "\" id=\"" + key + "\">");
                 
                 Element doc = renderSVGNode(svgGenerator, (IG2DNode)node);
                 String svg = printSVGDocument(doc);
@@ -841,7 +848,7 @@ public class SCLScenegraph {
                     Rectangle2D rect = n.getRect();
                     // NaN
                     if(rect.getHeight() == rect.getHeight() && rect.getWidth() == rect.getWidth()) {
-                           parentBuilder2.append(SELECTION_MASK_SECTION,"<rect style=\"fill:#fff\" opacity=\"0.001\"");
+                           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>");