projects
/
Mograsim.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
TextComponent now only calculates its size once => speedup
[Mograsim.git]
/
net.mograsim.logic.model
/
src
/
net
/
mograsim
/
logic
/
model
/
model
/
components
/
atomic
/
TextComponent.java
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
ec91151
..
e00dbb9
100644
(file)
--- 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;
public class TextComponent extends GUIComponent
{
private final String text;
+ private boolean calculatedSize;
public TextComponent(ViewModelModifiable model, String text)
{
public TextComponent(ViewModelModifiable model, String text)
{
@@
-38,8
+39,12
@@
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);
- 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)
Color textColor = Preferences.current().getColor("net.mograsim.logic.model.color.text");
if (textColor != null)