-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLine.java
More file actions
78 lines (59 loc) · 1.49 KB
/
Copy pathLine.java
File metadata and controls
78 lines (59 loc) · 1.49 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/**
* 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.*;
public class Line extends Figure {
public Line(int width) {
this.width = width;
this.color = Color.BLACK;
this.isFill = false;
}
public Line() {
// 初期値を白。10にする。
this.color = Color.BLACK;
this.isFill = false;
}
@Override
public void paint(Graphics g) {
g.setColor(this.color);
int[] xp = new int[2];
int[] yp = new int[2];
xp[0] = x;
yp[0] = y;
xp[1] = x + w;
yp[1] = y + h;
Graphics2D g2 = (Graphics2D) g;
BasicStroke bs = new BasicStroke(this.width);
g2.setStroke(bs);
g2.drawPolyline(xp, yp, 2);
}
@Override
public void paintLine(Graphics g, int x, int y) {
g.setColor(this.color);
g.drawLine(x, y, x + w, y + h);
}
@Override
public void move(int dx, int dy) {
x += dx;
y += dy;
}
@Override
public Line clone() {
Line line = new Line();
line.width = this.width;
line.color = this.color;
line.isFill = this.isFill;
line.x = this.x;
line.y = this.y;
line.w = this.w;
line.h = this.h;
return line;
}
}