aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/dev/isxander/yacl/impl/utils/DimensionIntegerImpl.java
diff options
context:
space:
mode:
authorxander <xander@isxander.dev>2022-09-01 08:57:59 +0100
committerxander <xander@isxander.dev>2022-09-01 08:57:59 +0100
commit6f8ef7daaafd71090b2c334c10eadc8dedc738d9 (patch)
treed4054a65d99070c944132be83d25e109750dc5f9 /src/main/java/dev/isxander/yacl/impl/utils/DimensionIntegerImpl.java
parent9d0a5e937f97c1c17d034393e01636d5241f376a (diff)
downloadYetAnotherConfigLib-6f8ef7daaafd71090b2c334c10eadc8dedc738d9.tar.gz
YetAnotherConfigLib-6f8ef7daaafd71090b2c334c10eadc8dedc738d9.tar.bz2
YetAnotherConfigLib-6f8ef7daaafd71090b2c334c10eadc8dedc738d9.zip
GUI Implementation
Added groups Added button "option" Added test mod
Diffstat (limited to 'src/main/java/dev/isxander/yacl/impl/utils/DimensionIntegerImpl.java')
-rw-r--r--src/main/java/dev/isxander/yacl/impl/utils/DimensionIntegerImpl.java96
1 files changed, 95 insertions, 1 deletions
diff --git a/src/main/java/dev/isxander/yacl/impl/utils/DimensionIntegerImpl.java b/src/main/java/dev/isxander/yacl/impl/utils/DimensionIntegerImpl.java
index 908157d..4cb1c0e 100644
--- a/src/main/java/dev/isxander/yacl/impl/utils/DimensionIntegerImpl.java
+++ b/src/main/java/dev/isxander/yacl/impl/utils/DimensionIntegerImpl.java
@@ -4,7 +4,37 @@ import dev.isxander.yacl.api.utils.Dimension;
import org.jetbrains.annotations.ApiStatus;
@ApiStatus.Internal
-public record DimensionIntegerImpl(Integer x, Integer y, Integer width, Integer height) implements Dimension<Integer> {
+public class DimensionIntegerImpl implements Dimension<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;
@@ -16,7 +46,71 @@ public record DimensionIntegerImpl(Integer x, Integer y, Integer width, Integer
}
@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 Dimension<Integer> clone() {
+ return new DimensionIntegerImpl(x, y, width, height);
+ }
+
+ @Override public Dimension<Integer> setX(Integer x) { this.x = x; return this; }
+ @Override public Dimension<Integer> setY(Integer y) { this.y = y; return this; }
+ @Override public Dimension<Integer> setWidth(Integer width) { this.width = width; return this; }
+ @Override public Dimension<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().withWidth(width);
+ }
+
+ @Override
+ public Dimension<Integer> withHeight(Integer height) {
+ return clone().withHeight(height);
+ }
+
+ @Override
+ public Dimension<Integer> move(Integer x, Integer y) {
+ this.x += x;
+ this.y += y;
+ return this;
+ }
+
+ @Override
+ public Dimension<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);
+ }
}