-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dot.java
79 lines (63 loc) · 1.41 KB
/
Dot.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/**
* Yuki Tetsuka
* <p>
* Project: DrawJava
* Description: A simple drawing application in Java.
* <p>
* Copyright (c) 2023 Yuki Tetsuka. All rights reserved.
* See the project repository at: https://github.com/ponstream24/DrawJava
*/
package enshuReport2_2023;
import java.awt.Color;
import java.awt.Graphics;
public class Dot extends Figure {
boolean isEraser = false;
public Dot(boolean isEraser) {
// 初期値を白。10にする。
this.color = Color.BLACK;
this.isFill = false;
this.isEraser = isEraser;
}
public Dot() {
this.isFill = true;
}
@Override
public void paint(Graphics g) {
if (isEraser) {
g.setColor(Color.WHITE);
} else {
g.setColor(this.color);
}
if (this.isFill) {
g.fillOval(x - w / 2, y - h / 2, w, h);
} else {
g.drawOval(x - w / 2, y - h / 2, w, h);
}
}
@Override
public void paintLine(Graphics g, int x, int y) {
g.setColor(this.color);
if (this.isFill) {
g.fillOval(x - w / 2, y - h / 2, w, h);
} else {
g.drawOval(x - w / 2, y - h / 2, w, h);
}
}
@Override
public void move(int dx, int dy) {
x += dx;
y += dy;
}
@Override
public Dot clone() {
Dot box = new Dot();
box.color = this.color;
box.isEraser = this.isEraser;
box.isFill = this.isFill;
box.x = this.x;
box.y = this.y;
box.w = this.w;
box.h = this.h;
return box;
}
}