From fd66215f7e1e766d906234b978b0ad50cafc4716 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 28 Mar 2023 02:54:36 +0200 Subject: GraphUI Label: Add getScaledLineHeight() and refine setFontScale(), i.e. only act and markDirty() on change --- .../com/jogamp/graph/ui/gl/shapes/Label.java | 24 +++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'src/graphui') diff --git a/src/graphui/classes/com/jogamp/graph/ui/gl/shapes/Label.java b/src/graphui/classes/com/jogamp/graph/ui/gl/shapes/Label.java index 83309b04c..65371875d 100644 --- a/src/graphui/classes/com/jogamp/graph/ui/gl/shapes/Label.java +++ b/src/graphui/classes/com/jogamp/graph/ui/gl/shapes/Label.java @@ -147,12 +147,30 @@ public class Label extends Shape { return fontScale * font.getLineHeight(); } + /** Returns {@link Font#getLineHeight()} * {@link #getFontScale()} * {@link #getScaleY()}. */ + public float getScaledLineHeight() { + return getScaleY() * fontScale * font.getLineHeight(); + } + /** * Sets the font-scale factor, by which the em-sized type glyphs shall be scaled. + *

+ * This will lead to a recreate the shape's region in case fontScale differs. + *

+ *

+ * Use {@link #scale(float, float, float)} for non-expensive shape scaling. + *

+ * @param fontScale font-scale factor, by which the em-sized type glyphs shall be scaled + * @return true if font-scale has been updated, false if unchanged. */ - public void setFontScale(final float fontScale) { - this.fontScale = fontScale; - markShapeDirty(); + public boolean setFontScale(final float fontScale) { + if( this.fontScale != fontScale ) { + this.fontScale = fontScale; + markShapeDirty(); + return true; + } else { + return false; + } } @Override -- cgit v1.2.3