Skip to content

Commit fa6e44c

Browse files
author
Edward Nutting
committed
Enable SSText to be a dynamically drawable component.
1 parent 03c80a0 commit fa6e44c

1 file changed

Lines changed: 34 additions & 3 deletions

File tree

src/com/modsim/modules/parts/SSText.java

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ public class SSText extends VisiblePart {
1111
private String text;
1212
private Font font;
1313
private Color color;
14+
private RefreshMode refreshMode = RefreshMode.Static;
1415

1516
/**
1617
* Create a label
@@ -45,7 +46,18 @@ public SSText(int x, int y, String txt, int fontSize, Color col) {
4546
fontSize);
4647
color = col;
4748
}
48-
49+
50+
public SSText(int x, int y, String txt, int fontSize, Color col, RefreshMode refreshMode) {
51+
this.x = x;
52+
this.y = y;
53+
text = txt;
54+
font = new Font(Fonts.moduleLabel.getFamily(),
55+
Fonts.moduleLabel.getStyle(),
56+
fontSize);
57+
color = col;
58+
this.refreshMode = refreshMode;
59+
}
60+
4961
public SSText(int x, int y, String txt, int fontSize, Color col, String font_name) {
5062
this.x = x;
5163
this.y = y;
@@ -55,7 +67,26 @@ public SSText(int x, int y, String txt, int fontSize, Color col, String font_nam
5567
fontSize);
5668
color = col;
5769
}
58-
70+
71+
public SSText(int x, int y, String txt, int fontSize, Color col, String font_name, RefreshMode refreshMode) {
72+
this.x = x;
73+
this.y = y;
74+
text = txt;
75+
font = new Font(font_name,
76+
Fonts.moduleLabel.getStyle(),
77+
fontSize);
78+
color = col;
79+
this.refreshMode = refreshMode;
80+
}
81+
82+
public void setText(String value) {
83+
text = value;
84+
}
85+
86+
public void setRefreshMode(RefreshMode value) {
87+
refreshMode = value;
88+
}
89+
5990
@Override
6091
public void paint(Graphics2D g) {
6192
// Draw the text
@@ -71,6 +102,6 @@ public void povTick() {
71102

72103
@Override
73104
public RefreshMode getRefreshMode() {
74-
return RefreshMode.Static;
105+
return refreshMode;
75106
}
76107
}

0 commit comments

Comments
 (0)