diff options
author | Sven Gothel <[email protected]> | 2023-03-28 02:54:36 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2023-03-28 02:54:36 +0200 |
commit | fd66215f7e1e766d906234b978b0ad50cafc4716 (patch) | |
tree | 645006ebe5673229cf8d1e934164712fd7ac608d /src/graphui/classes/com/jogamp/graph/ui | |
parent | 6104bbdce6029d1e3c39aaa5b0f86d9f5ac5965d (diff) |
GraphUI Label: Add getScaledLineHeight() and refine setFontScale(), i.e. only act and markDirty() on change
Diffstat (limited to 'src/graphui/classes/com/jogamp/graph/ui')
-rw-r--r-- | src/graphui/classes/com/jogamp/graph/ui/gl/shapes/Label.java | 24 |
1 files changed, 21 insertions, 3 deletions
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. + * <p> + * This will lead to a recreate the shape's region in case fontScale differs. + * </p> + * <p> + * Use {@link #scale(float, float, float)} for non-expensive shape scaling. + * </p> + * @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 |