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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
package dev.isxander.yacl3.impl.utils;
import dev.isxander.yacl3.api.utils.Dimension;
import dev.isxander.yacl3.api.utils.MutableDimension;
public class DimensionIntegerImpl implements MutableDimension<Integer> {
private int x, y;
private int width, height;
public DimensionIntegerImpl(int x, int y, int width, int height) {
this.x = x;
this.y = y;
this.width = width;
this.height = height;
}
@Override
public Integer x() {
return x;
}
@Override
public Integer y() {
return y;
}
@Override
public Integer width() {
return width;
}
@Override
public Integer height() {
return height;
}
@Override
public Integer xLimit() {
return x + width;
}
@Override
public Integer yLimit() {
return y + height;
}
@Override
public Integer centerX() {
return x + width / 2;
}
@Override
public Integer centerY() {
return y + height / 2;
}
@Override
public boolean isPointInside(Integer x, Integer y) {
return x >= x() && x <= xLimit() && y >= y() && y <= yLimit();
}
@Override
public MutableDimension<Integer> clone() {
return new DimensionIntegerImpl(x, y, width, height);
}
@Override public MutableDimension<Integer> setX(Integer x) { this.x = x; return this; }
@Override public MutableDimension<Integer> setY(Integer y) { this.y = y; return this; }
@Override public MutableDimension<Integer> setWidth(Integer width) { this.width = width; return this; }
@Override public MutableDimension<Integer> setHeight(Integer height) { this.height = height; return this; }
@Override
public Dimension<Integer> withX(Integer x) {
return clone().setX(x);
}
@Override
public Dimension<Integer> withY(Integer y) {
return clone().setY(y);
}
@Override
public Dimension<Integer> withWidth(Integer width) {
return clone().setWidth(width);
}
@Override
public Dimension<Integer> withHeight(Integer height) {
return clone().setHeight(height);
}
@Override
public MutableDimension<Integer> move(Integer x, Integer y) {
this.x += x;
this.y += y;
return this;
}
@Override
public MutableDimension<Integer> expand(Integer width, Integer height) {
this.width += width;
this.height += height;
return this;
}
@Override
public Dimension<Integer> moved(Integer x, Integer y) {
return clone().move(x, y);
}
@Override
public Dimension<Integer> expanded(Integer width, Integer height) {
return clone().expand(width, height);
}
}
|