import net.mograsim.logic.model.model.components.GUIComponent;
import net.mograsim.logic.model.modeladapter.ViewLogicModelAdapter;
import net.mograsim.logic.model.modeladapter.componentadapters.NoLogicAdapter;
+import net.mograsim.logic.model.serializing.IdentifierGetter;
import net.mograsim.logic.model.serializing.IndirectGUIComponentCreator;
import net.mograsim.preferences.Preferences;
public class TextComponent extends GUIComponent
{
private final String text;
+ private boolean calculatedSize;
public TextComponent(ViewModelModifiable model, String text)
{
@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)
// serializing
@Override
- public JsonElement getParamsForSerializing()
+ public JsonElement getParamsForSerializing(IdentifierGetter idGetter)
{
return new JsonPrimitive(text);
}