X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=net.mograsim.logic.model%2Fsrc%2Fnet%2Fmograsim%2Flogic%2Fmodel%2Fmodel%2Fcomponents%2Fatomic%2FTextComponent.java;h=e00dbb924110a763c304fec50ae00dec80268133;hb=3c3b223ffd0d54242a8cda1920a562ab01efba60;hp=4161406aafc8c1bfc9e589142081cdcd717e4c10;hpb=3cecdc2252876e22d41aeae31c214bb436e4972e;p=Mograsim.git diff --git a/net.mograsim.logic.model/src/net/mograsim/logic/model/model/components/atomic/TextComponent.java b/net.mograsim.logic.model/src/net/mograsim/logic/model/model/components/atomic/TextComponent.java index 4161406a..e00dbb92 100644 --- a/net.mograsim.logic.model/src/net/mograsim/logic/model/model/components/atomic/TextComponent.java +++ b/net.mograsim.logic.model/src/net/mograsim/logic/model/model/components/atomic/TextComponent.java @@ -20,6 +20,7 @@ import net.mograsim.preferences.Preferences; public class TextComponent extends GUIComponent { private final String text; + private boolean calculatedSize; public TextComponent(ViewModelModifiable model, String text) { @@ -38,9 +39,12 @@ public class TextComponent extends GUIComponent @Override public void render(GeneralGC gc, Rectangle visibleRegion) { - Point textExtent = gc.textExtent(text); - if (getWidth() != textExtent.x || getHeight() != textExtent.y) + if (!calculatedSize) + { + calculatedSize = true; + Point textExtent = gc.textExtent(text); setSize(textExtent.x, textExtent.y); + } Color textColor = Preferences.current().getColor("net.mograsim.logic.model.color.text"); if (textColor != null)