From 2349d0ac3ae59109099bba02fc491284d566e024 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Wed, 18 Dec 2019 13:01:23 +0100 Subject: ui.Label : code factorisation --- core/src/ch/asynk/gdx/boardgame/ui/Label.java | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/core/src/ch/asynk/gdx/boardgame/ui/Label.java b/core/src/ch/asynk/gdx/boardgame/ui/Label.java index 10b7c50..4d89ffa 100644 --- a/core/src/ch/asynk/gdx/boardgame/ui/Label.java +++ b/core/src/ch/asynk/gdx/boardgame/ui/Label.java @@ -31,26 +31,25 @@ public class Label extends Element this.layout = new GlyphLayout(); } - public void setFont(BitmapFont font) + public String getText() { - this.font = font; - this.layout.setText(font, (text == null) ? "" : text); - taint(); + return text; } - public String getText() + public void setFont(BitmapFont font) { - return text; + this.font = font; + write(); } public void write(String text) { - write(text, getX(), getY()); + this.text = text; + write(); } - public void write(String text, float x, float y) + public void write() { - this.text = text; this.layout.setText(font, (text == null) ? "" : text); taint(); } -- cgit v1.1-2-g2b99