import org.simantics.scenegraph.ScenegraphUtils;
import org.simantics.scenegraph.g2d.G2DNode;
import org.simantics.scenegraph.g2d.G2DPDFRenderingHints;
+import org.simantics.scenegraph.g2d.G2DRenderingHints;
+import org.simantics.scenegraph.g2d.G2DRenderingHints.TextRenderingMode;
import org.simantics.scenegraph.g2d.events.Event;
import org.simantics.scenegraph.g2d.events.EventTypes;
import org.simantics.scenegraph.g2d.events.KeyEvent.KeyPressedEvent;
import org.simantics.scenegraph.g2d.events.MouseEvent.MouseDoubleClickedEvent;
import org.simantics.scenegraph.g2d.events.MouseEvent.MouseDragBegin;
import org.simantics.scenegraph.g2d.events.MouseEvent.MouseMovedEvent;
-import org.simantics.scenegraph.g2d.events.NodeEventHandler;
import org.simantics.scenegraph.g2d.events.command.CommandEvent;
import org.simantics.scenegraph.g2d.events.command.Commands;
import org.simantics.scenegraph.utils.GeometryUtils;
// PDF
PdfWriter writer = (PdfWriter) g.getRenderingHint(G2DPDFRenderingHints.KEY_PDF_WRITER);
- boolean isRenderingPdf = writer != null;
+ TextRenderingMode renderingMode = (TextRenderingMode) g.getRenderingHint(G2DRenderingHints.KEY_TEXT_RENDERING_MODE);
+ boolean renderAsText = writer != null || renderingMode == TextRenderingMode.AS_TEXT;
/// PDF
Color backgroundColor = hasState(STATE_VALID) ? this.backgroundColor : Color.red;
// Base text
g.setColor(color);
- renderText(g, xOffset, isRenderingPdf);
+ renderText(g, xOffset, renderAsText);
Shape clip = g.getClip();
g.fill(selShape);
g.setColor(Color.WHITE);
// #6459: render as text in PDF and paths on screen
- if (isRenderingPdf)
+ if (renderAsText)
g.drawString(line.getText(), 0, 0);
else
line.layout.draw(g, 0, 0);
if (renderText) {
g.setColor(color);
- renderText(g, 0, isRenderingPdf);
+ renderText(g, 0, renderAsText);
}
}
}
}
}
- private void renderText(Graphics2D g, float xOffset, boolean isRenderingPdf) {
+ private void renderText(Graphics2D g, float xOffset, boolean renderAsText) {
//g.draw(tightBoundsCache); // DEBUG
for (Line line : lines) {
// #6459: render as text in PDF and paths on screen
- if (isRenderingPdf)
+ if (renderAsText)
g.drawString(line.getText(), line.alignedPosX + xOffset, line.alignedPosY);
else
line.layout.draw(g, line.alignedPosX + xOffset, line.alignedPosY);
protected void renderSelectedHover(Graphics2D g, boolean isSelected, boolean isHovering) {
}
+ public String editText(String text) {
+
+ String error = validator != null ? validator.apply(text) : null;
+ if (error == null) {
+ this.text = text;
+ if (textListener != null) {
+ textListener.textEditingEnded();
+ }
+ }
+ return error;
+ }
+
/**
* Replaces the current selection with the content or inserts
* the content at caret. After the insertion the caret
protected boolean mouseDragged(MouseDragBegin e) {
if (isHovering()
&& (isControlDown(e) || isShiftDown(e))
- && e.context instanceof NodeEventHandler
&& (dataRVI != null || text != null))
{
List<Transferable> trs = new ArrayList<>(2);