From d1860919acc0768cf723960406d2bea078bcb621 Mon Sep 17 00:00:00 2001 From: Tuukka Lehtonen Date: Mon, 7 Nov 2016 22:33:53 +0200 Subject: [PATCH] Sync git svn branch with SVN repository r33368. refs #6459 --- .../simantics/diagram/elements/TextNode.java | 21 ++++++++++++------- .../scenegraph/g2d/nodes/FlagNode.java | 9 ++++++-- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/bundles/org.simantics.diagram/src/org/simantics/diagram/elements/TextNode.java b/bundles/org.simantics.diagram/src/org/simantics/diagram/elements/TextNode.java index 96cd573cc..b407796e7 100644 --- a/bundles/org.simantics.diagram/src/org/simantics/diagram/elements/TextNode.java +++ b/bundles/org.simantics.diagram/src/org/simantics/diagram/elements/TextNode.java @@ -673,6 +673,7 @@ public class TextNode extends G2DNode implements IDynamicSelectionPainterNode, L // PDF PdfWriter writer = (PdfWriter) g.getRenderingHint(G2DPDFRenderingHints.KEY_PDF_WRITER); + boolean isRenderingPdf = writer != null; boolean isPdfField = false; String fieldName = null; if (writer != null) { @@ -702,7 +703,7 @@ public class TextNode extends G2DNode implements IDynamicSelectionPainterNode, L // Base text g.setColor(color); - renderText(g, xOffset); + renderText(g, xOffset, isRenderingPdf); Shape clip = g.getClip(); @@ -715,8 +716,11 @@ public class TextNode extends G2DNode implements IDynamicSelectionPainterNode, L g.setColor(SELECTION_BACKGROUND_COLOR); g.fill(selShape); g.setColor(Color.WHITE); - //line.layout.draw(g, 0, 0); - g.drawString(line.getText(), 0, 0); + // #6459: render as text in PDF and paths on screen + if (isRenderingPdf) + g.drawString(line.getText(), 0, 0); + else + line.layout.draw(g, 0, 0); line.translateInv(g, xOffset, 0); } } @@ -732,7 +736,7 @@ public class TextNode extends G2DNode implements IDynamicSelectionPainterNode, L if (renderText) { g.setColor(color); - renderText(g, 0); + renderText(g, 0, isRenderingPdf); } } @@ -883,11 +887,14 @@ public class TextNode extends G2DNode implements IDynamicSelectionPainterNode, L } } } - private void renderText(Graphics2D g, float xOffset) { + private void renderText(Graphics2D g, float xOffset, boolean isRenderingPdf) { //g.draw(tightBoundsCache); // DEBUG for (Line line : lines) { - //line.layout.draw(g, line.alignedPosX + xOffset, line.alignedPosY); - g.drawString(line.getText(), line.alignedPosX + xOffset, line.alignedPosY); + // #6459: render as text in PDF and paths on screen + if (isRenderingPdf) + g.drawString(line.getText(), line.alignedPosX + xOffset, line.alignedPosY); + else + line.layout.draw(g, line.alignedPosX + xOffset, line.alignedPosY); //g.draw(line.abbox); // DEBUG } } diff --git a/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/nodes/FlagNode.java b/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/nodes/FlagNode.java index 2d18495af..c62fc84da 100644 --- a/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/nodes/FlagNode.java +++ b/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/g2d/nodes/FlagNode.java @@ -27,6 +27,7 @@ import java.awt.geom.Rectangle2D; import java.util.Arrays; import org.simantics.scenegraph.g2d.G2DNode; +import org.simantics.scenegraph.g2d.G2DPDFRenderingHints; import org.simantics.scenegraph.utils.GeometryUtils; public class FlagNode extends G2DNode { @@ -308,6 +309,7 @@ public class FlagNode extends G2DNode { lineDist *= gScaleRecip; double y = startY; double textAreaWidth = textArea.getWidth() * gScaleRecip; + boolean isRenderingPdf = g.getRenderingHint(G2DPDFRenderingHints.KEY_PDF_WRITER) != null; for (int i = 0; i < flagText.length; ++i) { //String line = flagText[i]; @@ -339,8 +341,11 @@ public class FlagNode extends G2DNode { if (DEBUG) System.out.println(" DRAW: '" + flagText[i] + "' with " + g.getTransform()); - //textLayout[i].draw(g, (float) x, (float) y); - g.drawString(flagText[i], (float) x, (float) y); + // #6459: render as text in PDF and paths on screen + if (isRenderingPdf) + g.drawString(flagText[i], (float) x, (float) y); + else + textLayout[i].draw(g, (float) x, (float) y); y += lineDist; y += rect.getHeight(); -- 2.47.1