From 6f8ef7daaafd71090b2c334c10eadc8dedc738d9 Mon Sep 17 00:00:00 2001 From: xander Date: Thu, 1 Sep 2022 08:57:59 +0100 Subject: GUI Implementation Added groups Added button "option" Added test mod --- .../yacl/impl/utils/DimensionIntegerImpl.java | 96 +++++++++++++++++++++- 1 file changed, 95 insertions(+), 1 deletion(-) (limited to 'src/main/java/dev/isxander/yacl/impl/utils') 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 { +public class DimensionIntegerImpl implements Dimension { + 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; @@ -15,8 +45,72 @@ public record DimensionIntegerImpl(Integer x, Integer y, Integer width, Integer 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 Dimension clone() { + return new DimensionIntegerImpl(x, y, width, height); + } + + @Override public Dimension setX(Integer x) { this.x = x; return this; } + @Override public Dimension setY(Integer y) { this.y = y; return this; } + @Override public Dimension setWidth(Integer width) { this.width = width; return this; } + @Override public Dimension setHeight(Integer height) { this.height = height; return this; } + + @Override + public Dimension withX(Integer x) { + return clone().setX(x); + } + + @Override + public Dimension withY(Integer y) { + return clone().setY(y); + } + + @Override + public Dimension withWidth(Integer width) { + return clone().withWidth(width); + } + + @Override + public Dimension withHeight(Integer height) { + return clone().withHeight(height); + } + + @Override + public Dimension move(Integer x, Integer y) { + this.x += x; + this.y += y; + return this; + } + + @Override + public Dimension expand(Integer width, Integer height) { + this.width += width; + this.height += height; + return this; + } + + @Override + public Dimension moved(Integer x, Integer y) { + return clone().move(x, y); + } + + @Override + public Dimension expanded(Integer width, Integer height) { + return clone().expand(width, height); + } } -- cgit