projects
/
Mograsim.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Added getBounds() to TextComponent
[Mograsim.git]
/
net.mograsim.logic.ui
/
src
/
net
/
mograsim
/
logic
/
ui
/
model
/
components
/
TextComponent.java
diff --git
a/net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/components/TextComponent.java
b/net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/components/TextComponent.java
index
871d4f9
..
18f4384
100644
(file)
--- a/
net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/components/TextComponent.java
+++ b/
net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/components/TextComponent.java
@@
-13,6
+13,7
@@
import net.mograsim.preferences.Preferences;
public class TextComponent extends GUIComponent
{
private final String text;
public class TextComponent extends GUIComponent
{
private final String text;
+ private Point textExtent;
public TextComponent(ViewModelModifiable model, String text)
{
public TextComponent(ViewModelModifiable model, String text)
{
@@
-23,13
+24,21
@@
public class TextComponent extends GUIComponent
@Override
public void render(GeneralGC gc, Rectangle visibleRegion)
{
@Override
public void render(GeneralGC gc, Rectangle visibleRegion)
{
-
Point
textExtent = gc.textExtent(text);
+ textExtent = gc.textExtent(text);
Color textColor = Preferences.current().getColor("net.mograsim.logic.ui.color.text");
if (textColor != null)
gc.setForeground(textColor);
gc.drawText(text, getPosX() - textExtent.x / 2, getPosY() - textExtent.y / 2, true);
}
Color textColor = Preferences.current().getColor("net.mograsim.logic.ui.color.text");
if (textColor != null)
gc.setForeground(textColor);
gc.drawText(text, getPosX() - textExtent.x / 2, getPosY() - textExtent.y / 2, true);
}
+ @Override
+ public Rectangle getBounds()
+ {
+ if (textExtent == null)
+ return super.getBounds();
+ return new Rectangle(getPosX() - textExtent.x / 2, getPosY() - textExtent.y / 2, textExtent.x, textExtent.y);
+ }
+
static
{
ViewLogicModelAdapter.addComponentAdapter(NoLogicAdapter.forClass(TextComponent.class));
static
{
ViewLogicModelAdapter.addComponentAdapter(NoLogicAdapter.forClass(TextComponent.class));