]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.diagram/src/org/simantics/diagram/elements/TextElementNoBounds.java
Added alternative constructor for inputting text scaling factor
[simantics/platform.git] / bundles / org.simantics.diagram / src / org / simantics / diagram / elements / TextElementNoBounds.java
index 6959e8c439f2bbd4d942eae1137682e687952015..376fadc06c9a40cab935eafb421e6e4534510328 100644 (file)
@@ -49,7 +49,7 @@ public class TextElementNoBounds implements SceneGraph, HandleMouseEvent {
     
     protected static final double DEFAULT_PADDING_X = 0.5;
     protected static final double DEFAULT_PADDING_Y = 0.5;
-    protected static final double SCALE = 0.235;
+    protected static final double DEFAULT_SCALE = 0.235;
 
     protected final double originX;
     protected final double originY;
@@ -59,6 +59,7 @@ public class TextElementNoBounds implements SceneGraph, HandleMouseEvent {
     protected final boolean editable;
     protected final double paddingX;
     protected final double paddingY;
+    protected final double scale;
 
 
     public TextElementNoBounds() {
@@ -74,6 +75,10 @@ public class TextElementNoBounds implements SceneGraph, HandleMouseEvent {
     }
     
     public TextElementNoBounds(double originX, double originY, Alignment horizontalAlignment, double borderWidth, double paddingX, double paddingY, boolean editable) {
+       this(originX, originY, horizontalAlignment, borderWidth, paddingX, paddingY, editable, DEFAULT_SCALE);
+    }
+    
+    public TextElementNoBounds(double originX, double originY, Alignment horizontalAlignment, double borderWidth, double paddingX, double paddingY, boolean editable, double scale) {
         if (horizontalAlignment == null)
             throw new NullPointerException("null horizontal alignment");
 
@@ -85,9 +90,9 @@ public class TextElementNoBounds implements SceneGraph, HandleMouseEvent {
         this.editable = editable;
         this.paddingX = paddingX;
         this.paddingY = paddingY;
+        this.scale = scale;
     }
     
-
     @Override
     public void init(final IElement e, G2DParentNode parent) {
         TextNode node = getOrCreateTextNode(e, parent);
@@ -102,7 +107,7 @@ public class TextElementNoBounds implements SceneGraph, HandleMouseEvent {
         Alignment vAlign = ElementUtils.getHintOrDefault(e, ElementHints.KEY_VERTICAL_ALIGN, verticalAlignment);
         Double borderWidth = ElementUtils.getHintOrDefault(e, MonitorClass.KEY_BORDER_WIDTH, this.borderWidth);
 
-        node.init(text, font, color, originX, originY, SCALE);
+        node.init(text, font, color, originX, originY, scale);
         node.setBackgroundColor(fillColor);
         node.setBorderColor(borderColor);
         node.setHorizontalAlignment((byte) hAlign.ordinal());