public class Text extends scribble3
1:
2: package draw3;
3:
4: import java.awt.*;
5:
6: public class Text extends scribble3.Shape {
7:
8: public Text() {}
9:
10: public Text(Color color) {
11: super(color);
12: }
13:
14: public void setLocation(int x, int y) {
15: this.x = x;
16: this.y = y;
17: }
18:
19: public int getX() {
20: return x;
21: }
22:
23: public int getY() {
24: return y;
25: }
26:
27: public void setText(String text) {
28: this.text = text;
29: }
30:
31: public String getText() {
32: return text;
33: }
34:
35: public Font getFont() {
36: return font;
37: }
38:
39: public void setFont(Font font) {
40: this.font = font;
41: }
42:
43: public void draw(Graphics g) {
44: if (text != null) {
45: if (color != null) {
46: g.setColor(color);
47: }
48: if (font != null) {
49: g.setFont(font);
50: } else {
51: g.setFont(defaultFont);
52: }
53: g.drawString(text, x, y);
54: }
55: }
56:
57: protected int x;
58: protected int y;
59: protected String text;
60: protected Font font;
61:
62: protected static Font defaultFont = new Font("Serif", Font.BOLD, 24);
63:
64: }