From: Marko Luukkainen Date: Fri, 21 Feb 2020 09:12:37 +0000 (+0200) Subject: Allow customizing TextElement default vertical alignment X-Git-Tag: v1.43.0~91 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F50%2F3850%2F1;p=simantics%2Fplatform.git Allow customizing TextElement default vertical alignment gitlab #471 Change-Id: I05ead92b16fe172672231bbc9a2ac0f7da5b9da6 (cherry picked from commit e14a9fd13c79c0c3ca1d5af56727d80f8940f437) --- diff --git a/bundles/org.simantics.diagram/src/org/simantics/diagram/elements/TextElementHandler.java b/bundles/org.simantics.diagram/src/org/simantics/diagram/elements/TextElementHandler.java index 192b0ea5d..a50c190b9 100644 --- a/bundles/org.simantics.diagram/src/org/simantics/diagram/elements/TextElementHandler.java +++ b/bundles/org.simantics.diagram/src/org/simantics/diagram/elements/TextElementHandler.java @@ -56,6 +56,12 @@ public class TextElementHandler extends TextElementNoBounds implements InternalS double paddingX, double paddingY, boolean editable, double scale) { super(originX, originY, horizontalAlignment, borderWidth, paddingX, paddingY, editable, scale); } + + public TextElementHandler(double originX, double originY, Alignment horizontalAlignment, + Alignment verticalAlignment, double borderWidth, double paddingX, double paddingY, boolean editable, + double scale) { + super(originX, originY, horizontalAlignment, verticalAlignment, borderWidth, paddingX, paddingY, editable, scale); + } @Override public Rectangle2D getBounds(IElement e, Rectangle2D size) { diff --git a/bundles/org.simantics.diagram/src/org/simantics/diagram/elements/TextElementNoBounds.java b/bundles/org.simantics.diagram/src/org/simantics/diagram/elements/TextElementNoBounds.java index 376fadc06..14bc7c1f6 100644 --- a/bundles/org.simantics.diagram/src/org/simantics/diagram/elements/TextElementNoBounds.java +++ b/bundles/org.simantics.diagram/src/org/simantics/diagram/elements/TextElementNoBounds.java @@ -79,13 +79,17 @@ public class TextElementNoBounds implements SceneGraph, HandleMouseEvent { } public TextElementNoBounds(double originX, double originY, Alignment horizontalAlignment, double borderWidth, double paddingX, double paddingY, boolean editable, double scale) { + this(originX, originY, horizontalAlignment, Alignment.BASELINE, borderWidth, paddingX, paddingY, editable, scale); + } + + public TextElementNoBounds(double originX, double originY, Alignment horizontalAlignment, Alignment verticalAlignment, double borderWidth, double paddingX, double paddingY, boolean editable, double scale) { if (horizontalAlignment == null) throw new NullPointerException("null horizontal alignment"); this.originX = originX; this.originY = originY; this.horizontalAlignment = horizontalAlignment; - this.verticalAlignment = Alignment.BASELINE; + this.verticalAlignment = verticalAlignment; this.borderWidth = borderWidth; this.editable = editable; this.paddingX = paddingX;