-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTriangle.java
84 lines (68 loc) · 1.77 KB
/
Triangle.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
80
81
82
83
84
import java.awt.*;
public class Triangle extends Item {
private Point point1;
private Point point2;
private Point point3;
public Point point;
public Triangle(Point point1, Point point2, Point point3) {
this.point1 = point1;
this.point2 = point2;
this.point3 = point3;
}
public Triangle(Point point1, Point point2) {
this.point1 = point1;
this.point2 = point2;
}
public Triangle(Point point1) {
this.point1 = point1;
}
public Triangle() {
}
public boolean includes(Point point) {
this.point = point;
return ((distance(point, point1) < 2.0) || (distance(point, point2) < 2.0)
|| (distance(point, point3) < 2.0));
}
public void render(UIContext uiContext) {
uiContext.draw(this);
}
public void setPoint1(Point point) {
point1 = point;
}
public void setPoint2(Point point) {
point2 = point;
}
public void setPoint3(Point point) {
point3 = point;
}
public Point getPoint1() {
return point1;
}
public Point getPoint2() {
return point2;
}
public Point getPoint3() {
return point3;
}
public String toString() {
return "Line from " + point1 + " to " + point2 + "to " + point3;
}
@Override
public void translate(Point point) {
if (point1 != null) {
point1.x += point.x;
point1.y += point.y;
}
if (point2 != null) {
point2.x += point.x;
point2.y += point.y;
}
if (point3 != null) {
point3.x += point.x;
point3.y += point.y;
}
}
public boolean containsPoint(int x, int y) {
return true;
}
}