-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathNumberRectangle.java
More file actions
64 lines (50 loc) · 1.23 KB
/
NumberRectangle.java
File metadata and controls
64 lines (50 loc) · 1.23 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package src.classSrc;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.geom.Rectangle2D;
public class NumberRectangle {
private int x;
private int y;
private int value;
private Color color;
public NumberRectangle(int x, int y, int value, Color color) {
this.x = x;
this.y = y;
this.color = color;
this.value = value;
}
public void draw(Graphics2D g2) {
int clientX = 85 + x * 30;
int clientY = 150 + y * 10;
Rectangle2D.Double rect = new Rectangle2D.Double(clientX, clientY, 20, value * 20);
g2.setPaint(color);
g2.fill(rect);
g2.setPaint(Color.BLACK);
g2.draw(rect);
g2.drawString(String.valueOf(value), clientX, clientY - 10);
}
public Color getColor() {
return color;
}
public void setColor(Color color) {
this.color = color;
}
public int getX() {
return x;
}
public void setX(int x) {
this.x = x;
}
public int getY() {
return y;
}
public void setY(int y) {
this.y = y;
}
public int getValue() {
return value;
}
public void setValue(int value) {
this.value = value;
}
}