import org.eclipse.swt.graphics.Color;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonPrimitive;
-
import net.haspamelodica.swt.helper.gcs.GeneralGC;
import net.haspamelodica.swt.helper.swtobjectwrappers.Point;
import net.haspamelodica.swt.helper.swtobjectwrappers.Rectangle;
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(IdentifierGetter idGetter)
+ public String getParamsForSerializing(IdentifierGetter idGetter)
{
- return new JsonPrimitive(text);
+ return text;
}
static