Merge commit 'd186091'
authorTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Mon, 7 Nov 2016 20:34:54 +0000 (22:34 +0200)
committerTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Mon, 7 Nov 2016 20:34:54 +0000 (22:34 +0200)
Sync git svn branch with SVN repository r33368.

refs #6459

bundles/org.simantics.diagram/src/org/simantics/diagram/elements/TextNode.java
bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/nodes/FlagNode.java

index 96cd573cc626860a43d51775d7cb20106ca98a3b..b407796e7b814736614dc620e0274fc4987b3aa1 100644 (file)
@@ -673,6 +673,7 @@ public class TextNode extends G2DNode implements IDynamicSelectionPainterNode, L
 \r
         // PDF \r
         PdfWriter writer = (PdfWriter) g.getRenderingHint(G2DPDFRenderingHints.KEY_PDF_WRITER);\r
+        boolean isRenderingPdf = writer != null;\r
         boolean isPdfField = false;\r
         String fieldName = null;\r
         if (writer != null) {\r
@@ -702,7 +703,7 @@ public class TextNode extends G2DNode implements IDynamicSelectionPainterNode, L
 \r
                 // Base text\r
                 g.setColor(color);\r
-                renderText(g, xOffset);\r
+                renderText(g, xOffset, isRenderingPdf);\r
 \r
                 Shape clip = g.getClip();\r
 \r
@@ -715,8 +716,11 @@ public class TextNode extends G2DNode implements IDynamicSelectionPainterNode, L
                         g.setColor(SELECTION_BACKGROUND_COLOR);\r
                         g.fill(selShape);\r
                         g.setColor(Color.WHITE);\r
-                        //line.layout.draw(g, 0, 0);\r
-                        g.drawString(line.getText(), 0, 0);\r
+                        // #6459: render as text in PDF and paths on screen\r
+                        if (isRenderingPdf)\r
+                            g.drawString(line.getText(), 0, 0);\r
+                        else\r
+                            line.layout.draw(g, 0, 0);\r
                         line.translateInv(g, xOffset, 0);\r
                     }\r
                 }\r
@@ -732,7 +736,7 @@ public class TextNode extends G2DNode implements IDynamicSelectionPainterNode, L
 \r
                 if (renderText) {\r
                     g.setColor(color);\r
-                    renderText(g, 0);\r
+                    renderText(g, 0, isRenderingPdf);\r
                 }\r
 \r
             }\r
@@ -883,11 +887,14 @@ public class TextNode extends G2DNode implements IDynamicSelectionPainterNode, L
           }\r
         }\r
     }\r
-    private void renderText(Graphics2D g, float xOffset) {\r
+    private void renderText(Graphics2D g, float xOffset, boolean isRenderingPdf) {\r
         //g.draw(tightBoundsCache); // DEBUG\r
         for (Line line : lines) {\r
-            //line.layout.draw(g, line.alignedPosX + xOffset, line.alignedPosY);\r
-            g.drawString(line.getText(), line.alignedPosX + xOffset, line.alignedPosY);\r
+            // #6459: render as text in PDF and paths on screen\r
+            if (isRenderingPdf)\r
+                g.drawString(line.getText(), line.alignedPosX + xOffset, line.alignedPosY);\r
+            else\r
+                line.layout.draw(g, line.alignedPosX + xOffset, line.alignedPosY);\r
             //g.draw(line.abbox); // DEBUG\r
         }\r
     }\r
index 2d18495af7cef439b84a477156d885a2544fb591..c62fc84da66af45c2afe503ebe19cebc28cc9c55 100644 (file)
@@ -27,6 +27,7 @@ import java.awt.geom.Rectangle2D;
 import java.util.Arrays;\r
 \r
 import org.simantics.scenegraph.g2d.G2DNode;\r
+import org.simantics.scenegraph.g2d.G2DPDFRenderingHints;\r
 import org.simantics.scenegraph.utils.GeometryUtils;\r
 \r
 public class FlagNode extends G2DNode {\r
@@ -308,6 +309,7 @@ public class FlagNode extends G2DNode {
             lineDist *= gScaleRecip;\r
             double y = startY;\r
             double textAreaWidth = textArea.getWidth() * gScaleRecip;\r
+            boolean isRenderingPdf = g.getRenderingHint(G2DPDFRenderingHints.KEY_PDF_WRITER) != null;\r
 \r
             for (int i = 0; i < flagText.length; ++i) {\r
                 //String line = flagText[i];\r
@@ -339,8 +341,11 @@ public class FlagNode extends G2DNode {
                 if (DEBUG)\r
                     System.out.println(" DRAW: '" + flagText[i] + "' with " + g.getTransform());\r
 \r
-                //textLayout[i].draw(g, (float) x, (float) y);\r
-                g.drawString(flagText[i], (float) x, (float) y);\r
+                // #6459: render as text in PDF and paths on screen\r
+                if (isRenderingPdf)\r
+                    g.drawString(flagText[i], (float) x, (float) y);\r
+                else\r
+                    textLayout[i].draw(g, (float) x, (float) y);\r
 \r
                 y += lineDist;\r
                 y += rect.getHeight();\r