1 package net.mograsim.logic.ui.model.components;
3 import org.eclipse.swt.graphics.Color;
5 import net.haspamelodica.swt.helper.gcs.GeneralGC;
6 import net.haspamelodica.swt.helper.swtobjectwrappers.Point;
7 import net.haspamelodica.swt.helper.swtobjectwrappers.Rectangle;
8 import net.mograsim.logic.ui.model.ViewModelModifiable;
9 import net.mograsim.logic.ui.modeladapter.ViewLogicModelAdapter;
10 import net.mograsim.logic.ui.modeladapter.componentadapters.NoLogicAdapter;
11 import net.mograsim.preferences.Preferences;
13 public class TextComponent extends GUIComponent
15 private final String text;
17 public TextComponent(ViewModelModifiable model, String text)
24 public void render(GeneralGC gc, Rectangle visibleRegion)
26 Point textExtent = gc.textExtent(text);
27 Color textColor = Preferences.current().getColor("net.mograsim.logic.ui.color.text");
28 if (textColor != null)
29 gc.setForeground(textColor);
30 gc.drawText(text, getPosX() - textExtent.x / 2, getPosY() - textExtent.y / 2, true);
35 ViewLogicModelAdapter.addComponentAdapter(NoLogicAdapter.forClass(TextComponent.class));