-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathText.java
42 lines (37 loc) · 1004 Bytes
/
Text.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package conwaygame;
/*
* Class used to create label text for various aspects of the driver.
*/
import java.awt.Color;
public class Text {
public int x;
public int y;
public String text;
public Color color;
public String orientation;
public Text(int x, int y, String text, String orientation) {
this.x = x;
this.y = y;
this.text = text;
this.orientation = orientation;
}
public Text(int x, int y, String text) {
this(x, y, text, null);
}
public void draw() {
color = StdDraw.getPenColor();
if ("LEFT".equals(orientation)) {
StdDraw.textLeft(x, y, text);
} else if ("RIGHT".equals(orientation)) {
StdDraw.textRight(x, y, text);
} else {
StdDraw.text(x, y, text);
}
}
public void changeColor(Color c) {
Color tmp = StdDraw.getPenColor();
StdDraw.setPenColor(c);
draw();
StdDraw.setPenColor(tmp);
}
}