-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLabel.java
49 lines (37 loc) · 887 Bytes
/
Label.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
43
44
45
46
47
48
49
import java.awt.*;
public class Label extends Item {
private Point startingPoint;
private String text = "";
public Point point;
public Label(Point point) {
startingPoint = point;
}
public void addCharacter(char character) {
text += character;
}
public void removeCharacter() {
if (text.length() > 0) {
text = text.substring(0, text.length() - 1);
}
}
public boolean includes(Point point) {
this.point = point;
return distance(point, startingPoint) < 10.0;
}
public void render(UIContext uiContext) {
uiContext.draw(this);
}
public String getText() {
return text;
}
public Point getStartingPoint() {
return startingPoint;
}
public void translate(Point point) {
startingPoint.x += point.x;
startingPoint.y += point.y;
}
public boolean containsPoint(int x, int y) {
return true;
}
}