]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.diagram/src/org/simantics/diagram/elements/TextNode.java
TextGrid changes for Solvo
[simantics/platform.git] / bundles / org.simantics.diagram / src / org / simantics / diagram / elements / TextNode.java
index 2991d234c462bdb09e150e7d81892e7c18013f2c..7c684f30b372b6d915baa9c74f7bb4c675856720 100644 (file)
@@ -403,13 +403,14 @@ public class TextNode extends G2DNode implements IDynamicSelectionPainterNode, L
         if (hasState(STATE_EDITING))
             return;
 
-        this.text = new String(text != null ? text : "");
+        this.text = text;
         this.font = font;
         this.color = color;
         this.scale = scale;
         this.scaleRecip = 1.0 / scale;
         this.caret = 0;
         this.selectionTail = 0;
+        
 
         resetCaches();
     }
@@ -469,8 +470,8 @@ public class TextNode extends G2DNode implements IDynamicSelectionPainterNode, L
         // no value => value
         if(this.text == null && text != null) NodeUtil.decreasePending(this);
 
-        this.text = text != null ? text : "";
-        caret = Math.min(caret, this.text.length());
+        this.text = text;
+        caret = text != null ? Math.min(caret, text.length()) : 0;
         selectionTail = caret;
 
         resetCaches();
@@ -631,7 +632,7 @@ public class TextNode extends G2DNode implements IDynamicSelectionPainterNode, L
         boolean hover = hasState(STATE_HOVER);
         boolean editing = hasState(STATE_EDITING);
 
-        if (!isSelected && hover) {
+        if (!isSelected && hover && textListener != null) {
             color = add(color, 120, 120, 120);
         }
 
@@ -1437,6 +1438,9 @@ public class TextNode extends G2DNode implements IDynamicSelectionPainterNode, L
             y += line.layout.getDescent() + line.layout.getLeading() + line.layout.getAscent();
 
             Rectangle2D bbox = line.layout.getLogicalHighlightShape(0, lineText.length()).getBounds2D();
+            // HighlightShape is not large enough, if font is italic.
+            Rectangle2D bbox2 = line.layout.getBounds();
+            bbox.add(bbox2);
             bbox.setFrame(bbox.getX(), bbox.getY() + line.drawPosY, bbox.getWidth(), bbox.getHeight());
             line.bbox = bbox;
         }