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=ec91151d40971f5f2b5f1a16e950df83d7e1be09;hpb=a47c9b1f38bbb6d2f5a3c482f3b09d1f42270401;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 ec91151d..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,8 +39,12 @@ public class TextComponent extends GUIComponent @Override public void render(GeneralGC gc, Rectangle visibleRegion) { - Point textExtent = gc.textExtent(text); - setSize(textExtent.x, 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)