From b6d848f748630f6f167e7eacec7e017564ea0c42 Mon Sep 17 00:00:00 2001 From: Felix Pechtl Date: Tue, 21 May 2024 08:59:42 +0200 Subject: [PATCH] Updated depencencies, version and added new logger --- README.md | 2 +- pom.xml | 22 ++-- .../java/io/fi0x/javaguimenu/GUIWindow.java | 94 ++------------ .../controller/MainController.java | 7 +- .../javaguimenu/elements/AbstractElement.java | 117 +----------------- .../javaguimenu/elements/RegularButton.java | 12 +- .../javaguimenu/layouts/AbsoluteLayout.java | 5 +- .../fi0x/javaguimenu/layouts/GridLayout.java | 5 +- .../fi0x/javaguimenu/layouts/HBoxLayout.java | 5 +- .../fi0x/javaguimenu/layouts/VBoxLayout.java | 5 +- 10 files changed, 45 insertions(+), 229 deletions(-) diff --git a/README.md b/README.md index a0da376..e8f0e98 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,6 @@ A library to create graphical menus for java projects. io.github.Fi0x JavaGUIMenu - 1.1.3 + 1.2.0 ``` diff --git a/pom.xml b/pom.xml index 161dd65..b21276d 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ io.github.Fi0x JavaGUIMenu - 1.1.3 + 1.2.0 Java GUI Menu This is a library to quickly create a menu in java http://github.com/Fi0x/JavaGUIMenu @@ -49,7 +49,7 @@ org.apache.maven.plugins maven-compiler-plugin - 3.12.1 + 3.13.0 19 19 @@ -69,7 +69,7 @@ org.apache.maven.plugins maven-source-plugin - 3.3.0 + 3.3.1 attach-sources @@ -95,7 +95,7 @@ org.apache.maven.plugins maven-gpg-plugin - 3.1.0 + 3.2.4 sign-artifacts @@ -110,20 +110,20 @@ - - io.github.Fi0x - JavaLogger - 1.3.5 - org.openjfx javafx-controls - 21.0.2 + 22.0.1 org.openjfx javafx-fxml - 21.0.2 + 22.0.1 + + + org.projectlombok + lombok + 1.18.32 \ No newline at end of file diff --git a/src/main/java/io/fi0x/javaguimenu/GUIWindow.java b/src/main/java/io/fi0x/javaguimenu/GUIWindow.java index e71bc35..93734f4 100644 --- a/src/main/java/io/fi0x/javaguimenu/GUIWindow.java +++ b/src/main/java/io/fi0x/javaguimenu/GUIWindow.java @@ -3,13 +3,13 @@ import io.fi0x.javaguimenu.controller.MainController; import io.fi0x.javaguimenu.elements.AbstractElement; import io.fi0x.javaguimenu.layouts.LayoutTypes; -import io.fi0x.javalogger.logging.Logger; import javafx.application.Application; import javafx.fxml.FXMLLoader; import javafx.scene.Parent; import javafx.scene.Scene; import javafx.scene.image.Image; import javafx.stage.Stage; +import lombok.Setter; import java.io.IOException; import java.util.*; @@ -23,15 +23,24 @@ public class GUIWindow extends Application private static String windowTitle = "Unnamed"; private static double width = 800; private static double height = 450; + @Setter private static String windowIcon = "images/logo.png"; + @Setter private static String cssFile = "css/main.css"; + @Setter private static boolean resizable = true; + @Setter private static boolean closeAllOnStop = false; + @Setter private static LayoutTypes layout = LayoutTypes.Grid; private static final ArrayList elements = new ArrayList<>(); + @Setter private static boolean spaceElementsEvenly; + @Setter private static int columns = 1; + @Setter private static int rows = 1; + @Setter private static boolean gridLaneVisibility = false; /** @@ -82,10 +91,6 @@ public void stop() */ public static void start(String[] args) { - List arguments = Arrays.stream(args).toList(); - Logger.getInstance().setDebug(arguments.contains("-d")); - Logger.getInstance().setVerbose(arguments.contains("-v")); - Application.launch(args); } @@ -107,50 +112,7 @@ public static void setSize(double w, double h) width = w; height = h; } - /** - * Changes the icon of the window. - * @param icon The path to the image that should be used. - */ - public static void setWindowIcon(String icon) - { - windowIcon = icon; - } - /** - * Replaces the default css-file with a custom one. - * @param cssFilePath The path to the css-file that should be used. - */ - public static void setCssFile(String cssFilePath) - { - cssFile = cssFilePath; - } - /** - * Sets the resizable-boolean of the javafx-window. - * @param isResizable Weather or not the menu-window should be resizable. - * Default is true. - */ - public static void setResizable(boolean isResizable) - { - resizable = isResizable; - } - /** - * Sets a boolean that determines if all other windows of this program should close - * when this fx-window is closed. - * @param stopAllOtherWindows Weather or not the window should force all other windows to close. - * Default is false. - */ - public static void setStopAllOnExit(boolean stopAllOtherWindows) - { - closeAllOnStop = stopAllOtherWindows; - } - /** - * This method changes the layout inside the menu-window. - * @param type Which type of layout should be used. - * Default is a Grid-layout. - */ - public static void setLayout(LayoutTypes type) - { - layout = type; - } + /** * You can add menu-elements with this method. * All added elements will be displayed in the menu at their specified position. @@ -172,40 +134,6 @@ public static void addElement(AbstractElement node) } } } - /** - * This method changes the behaviour of the element placement inside the layout. - * @param spaceEvenly If true, element column and row-indices are ignored, - * and they get placed one after another. - */ - public static void setElementSpacing(boolean spaceEvenly) - { - spaceElementsEvenly = spaceEvenly; - } - /** - * This method determines how many columns should be created in a grid. - * @param columnCount The number of columns to create. - */ - public static void setColumns(int columnCount) - { - columns = columnCount; - } - /** - * This method determines how many rows should be created in a grid. - * @param rowCount The number of rows to create. - */ - public static void setRows(int rowCount) - { - rows = rowCount; - } - /** - * This method provides the option to display the lines of a grid layout. - * Only works on grid-layouts. - * @param gridLanesVisible Weather or not the grid lanes should be visible. - */ - public static void showGridLanes(boolean gridLanesVisible) - { - gridLaneVisibility = gridLanesVisible; - } private Map generateUserOptions() { diff --git a/src/main/java/io/fi0x/javaguimenu/controller/MainController.java b/src/main/java/io/fi0x/javaguimenu/controller/MainController.java index d68e961..93983ca 100644 --- a/src/main/java/io/fi0x/javaguimenu/controller/MainController.java +++ b/src/main/java/io/fi0x/javaguimenu/controller/MainController.java @@ -1,15 +1,16 @@ package io.fi0x.javaguimenu.controller; import io.fi0x.javaguimenu.layouts.*; -import io.fi0x.javalogger.logging.LOG; import javafx.fxml.FXML; import javafx.scene.layout.AnchorPane; +import lombok.extern.java.Log; import java.util.Map; /** * This class controls the GUI. */ +@Log public class MainController { /** @@ -40,7 +41,7 @@ public void setUserOptions(Map settings) LayoutTypes layout = (LayoutTypes) settings.get("layout"); if(layout == null) { - LOG.WARN("No layout type found", "JavaGUIMenu", 611); + log.warning("No layout type found"); return; } @@ -70,7 +71,7 @@ private void setLayout(LayoutTypes type, Map settings) settings.remove("columns"); apMain.getChildren().add(new AbsoluteLayout(settings)); } - default -> LOG.WARN("The selected layout is not valid", "JavaGUIMenu", 611); + default -> log.warning("The selected layout is not valid"); } } } diff --git a/src/main/java/io/fi0x/javaguimenu/elements/AbstractElement.java b/src/main/java/io/fi0x/javaguimenu/elements/AbstractElement.java index 7e47de1..67339af 100644 --- a/src/main/java/io/fi0x/javaguimenu/elements/AbstractElement.java +++ b/src/main/java/io/fi0x/javaguimenu/elements/AbstractElement.java @@ -1,10 +1,14 @@ package io.fi0x.javaguimenu.elements; import javafx.scene.Node; +import lombok.Getter; +import lombok.Setter; /** * This class is used for all elements that should be placed inside the selected layout. */ +@Setter +@Getter public abstract class AbstractElement { /** @@ -45,117 +49,4 @@ public AbstractElement() * @return The Node. */ public abstract Node getNodeVersion(); - - /** - * Sets the index for the column that should be used. Index starts at 0. - * Should only be changed when using grid-layouts. - * - * @param columnIndex The index that should be used for this element. - * Must not be greater or equal to the column count. - */ - public void setColIdx(int columnIndex) - { - colIdx = columnIndex; - } - /** - * This method returns the index of the column this element is in. - * - * @return The index. - */ - public int getColIdx() - { - return colIdx; - } - /** - * Sets the index for the row that should be used. Index starts at 0. - * Should only be changed when using grid-layouts. - * - * @param rowIndex The index that should be used for this element. - * Must not be greater or equal to the row count. - */ - public void setRowIdx(int rowIndex) - { - rowIdx = rowIndex; - } - /** - * This method returns the index of the row this element is in. - * - * @return The index. - */ - public int getRowIdx() - { - return rowIdx; - } - /** - * Determines how many columns this element should occupy. Default is 1. - * - * @param columnSpan The amount of columns this element should be in. - */ - public void setColSpan(int columnSpan) - { - colSpan = columnSpan; - } - /** - * This method returns the amount of cells this element spans in its column. - * - * @return The column span. - */ - public int getColSpan() - { - return colSpan; - } - /** - * Determines how many rows this element should occupy. Default is 1. - * - * @param rowSpan The amount of rows this element should be in. - */ - public void setRowSpan(int rowSpan) - { - this.rowSpan = rowSpan; - } - /** - * This method returns the amount of cells this element spans in its row. - * - * @return The row span. - */ - public int getRowSpan() - { - return rowSpan; - } - /** - * Sets the x-offset for this element from its default position. - * - * @param xPosition The offset from the default position. - */ - public void setXPos(double xPosition) - { - xPos = xPosition; - } - /** - * This method returns the position of this element in an absolute layout. - * - * @return The x-position. - */ - public double getXPos() - { - return xPos; - } - /** - * Sets the y-offset for this element from its default position. - * - * @param yPosition The offset from the default position. - */ - public void setYPos(double yPosition) - { - yPos = yPosition; - } - /** - * This method returns the position of this element in an absolute layout. - * - * @return The y-position. - */ - public double getYPos() - { - return yPos; - } } diff --git a/src/main/java/io/fi0x/javaguimenu/elements/RegularButton.java b/src/main/java/io/fi0x/javaguimenu/elements/RegularButton.java index 5974f76..4a78933 100644 --- a/src/main/java/io/fi0x/javaguimenu/elements/RegularButton.java +++ b/src/main/java/io/fi0x/javaguimenu/elements/RegularButton.java @@ -2,6 +2,7 @@ import javafx.scene.Node; import javafx.scene.control.Button; +import lombok.Setter; import java.util.ArrayList; @@ -13,6 +14,7 @@ public class RegularButton extends AbstractElement /** * The text that should be displayed on the button. */ + @Setter protected String buttonText; /** * The listeners that will react to this button press. @@ -129,14 +131,4 @@ public Node getNodeVersion() return btn; } - - /** - * Set the text this button should display. - * - * @param text The text to display. - */ - public void setText(String text) - { - buttonText = text; - } } diff --git a/src/main/java/io/fi0x/javaguimenu/layouts/AbsoluteLayout.java b/src/main/java/io/fi0x/javaguimenu/layouts/AbsoluteLayout.java index b419b66..b9fe3b3 100644 --- a/src/main/java/io/fi0x/javaguimenu/layouts/AbsoluteLayout.java +++ b/src/main/java/io/fi0x/javaguimenu/layouts/AbsoluteLayout.java @@ -1,9 +1,9 @@ package io.fi0x.javaguimenu.layouts; import io.fi0x.javaguimenu.elements.AbstractElement; -import io.fi0x.javalogger.logging.LOG; import javafx.scene.Node; import javafx.scene.layout.*; +import lombok.extern.java.Log; import java.util.ArrayList; import java.util.Map; @@ -13,6 +13,7 @@ * Columns and rows are ignored and only the x and y positions of elements * are used to set the location. */ +@Log public class AbsoluteLayout extends Pane { private ArrayList elements; @@ -39,7 +40,7 @@ private void setUserOptions(Map settings) if("elements".equals(entry.getKey())) elements = (ArrayList) entry.getValue(); else - LOG.WARN("Invalid user-settings-entry in absolute layout detected", "JavaGUIMenu", 610); + log.warning("Invalid user-settings-entry in absolute layout detected"); } addAllElements(); } diff --git a/src/main/java/io/fi0x/javaguimenu/layouts/GridLayout.java b/src/main/java/io/fi0x/javaguimenu/layouts/GridLayout.java index db9de46..525e747 100644 --- a/src/main/java/io/fi0x/javaguimenu/layouts/GridLayout.java +++ b/src/main/java/io/fi0x/javaguimenu/layouts/GridLayout.java @@ -1,10 +1,10 @@ package io.fi0x.javaguimenu.layouts; import io.fi0x.javaguimenu.elements.AbstractElement; -import io.fi0x.javalogger.logging.LOG; import javafx.geometry.HPos; import javafx.geometry.VPos; import javafx.scene.layout.*; +import lombok.extern.java.Log; import java.util.ArrayList; import java.util.Map; @@ -14,6 +14,7 @@ * Columns and rows are used to position elements * and the x and y positions of elements set an offset from the default positions. */ +@Log public class GridLayout extends GridPane { private boolean spaceElementsEvenly = true; @@ -53,7 +54,7 @@ private void setUserOptions(Map settings) case "columns" -> colCount = (int) entry.getValue(); case "rows" -> rowCount = (int) entry.getValue(); case "gridLanes" -> gridLaneVisibility = (boolean) entry.getValue(); - default -> LOG.WARN("Invalid user-settings-entry in grid layout detected", "JavaGUIMenu", 610); + default -> log.warning("Invalid user-settings-entry in grid layout detected"); } } setConstraints(); diff --git a/src/main/java/io/fi0x/javaguimenu/layouts/HBoxLayout.java b/src/main/java/io/fi0x/javaguimenu/layouts/HBoxLayout.java index c815edf..efb4ec3 100644 --- a/src/main/java/io/fi0x/javaguimenu/layouts/HBoxLayout.java +++ b/src/main/java/io/fi0x/javaguimenu/layouts/HBoxLayout.java @@ -1,8 +1,8 @@ package io.fi0x.javaguimenu.layouts; import io.fi0x.javaguimenu.elements.AbstractElement; -import io.fi0x.javalogger.logging.LOG; import javafx.scene.layout.*; +import lombok.extern.java.Log; import java.util.ArrayList; import java.util.Map; @@ -12,6 +12,7 @@ * Columns are used to position elements, rows are ignored. * The x and y positions of elements set an offset from the default positions. */ +@Log public class HBoxLayout extends HBox { private boolean spaceElementsEvenly = true; @@ -44,7 +45,7 @@ private void setUserOptions(Map settings) case "elementSpacing" -> spaceElementsEvenly = (boolean) entry.getValue(); case "elements" -> elements = (ArrayList) entry.getValue(); case "columns" -> colCount = (int) entry.getValue(); - default -> LOG.WARN("Invalid user-settings-entry in h-box layout detected", "JavaGUIMenu", 610); + default -> log.warning("Invalid user-settings-entry in h-box layout detected"); } } addAllElements(); diff --git a/src/main/java/io/fi0x/javaguimenu/layouts/VBoxLayout.java b/src/main/java/io/fi0x/javaguimenu/layouts/VBoxLayout.java index 7033c31..f4b9a23 100644 --- a/src/main/java/io/fi0x/javaguimenu/layouts/VBoxLayout.java +++ b/src/main/java/io/fi0x/javaguimenu/layouts/VBoxLayout.java @@ -1,8 +1,8 @@ package io.fi0x.javaguimenu.layouts; import io.fi0x.javaguimenu.elements.AbstractElement; -import io.fi0x.javalogger.logging.LOG; import javafx.scene.layout.*; +import lombok.extern.java.Log; import java.util.ArrayList; import java.util.Map; @@ -12,6 +12,7 @@ * Rows are used to position elements, columns are ignored. * The x and y positions of elements set an offset from the default positions. */ +@Log public class VBoxLayout extends VBox { private boolean spaceElementsEvenly = true; @@ -43,7 +44,7 @@ private void setUserOptions(Map settings) case "elementSpacing" -> spaceElementsEvenly = (boolean) entry.getValue(); case "elements" -> elements = (ArrayList) entry.getValue(); case "rows" -> rowCount = (int) entry.getValue(); - default -> LOG.WARN("Invalid user-settings-entry in v-box layout detected", "JavaGUIMenu", 610); + default -> log.warning("Invalid user-settings-entry in v-box layout detected"); } } addAllElements();