Skip to content

Commit

Permalink
Updated depencencies, version and added new logger
Browse files Browse the repository at this point in the history
  • Loading branch information
Felix Pechtl committed May 21, 2024
1 parent ccbb07c commit b6d848f
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 229 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ A library to create graphical menus for java projects.
<dependency>
<groupId>io.github.Fi0x</groupId>
<artifactId>JavaGUIMenu</artifactId>
<version>1.1.3</version>
<version>1.2.0</version>
</dependency>
```
22 changes: 11 additions & 11 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>io.github.Fi0x</groupId>
<artifactId>JavaGUIMenu</artifactId>
<version>1.1.3</version>
<version>1.2.0</version>
<name>Java GUI Menu</name>
<description>This is a library to quickly create a menu in java</description>
<url>http://github.com/Fi0x/JavaGUIMenu</url>
Expand Down Expand Up @@ -49,7 +49,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.12.1</version>
<version>3.13.0</version>
<configuration>
<source>19</source>
<target>19</target>
Expand All @@ -69,7 +69,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.3.0</version>
<version>3.3.1</version>
<executions>
<execution>
<id>attach-sources</id>
Expand All @@ -95,7 +95,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>3.1.0</version>
<version>3.2.4</version>
<executions>
<execution>
<id>sign-artifacts</id>
Expand All @@ -110,20 +110,20 @@
</build>

<dependencies>
<dependency>
<groupId>io.github.Fi0x</groupId>
<artifactId>JavaLogger</artifactId>
<version>1.3.5</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>21.0.2</version>
<version>22.0.1</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>21.0.2</version>
<version>22.0.1</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.32</version>
</dependency>
</dependencies>
</project>
94 changes: 11 additions & 83 deletions src/main/java/io/fi0x/javaguimenu/GUIWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.*;
Expand All @@ -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<AbstractElement> 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;

/**
Expand Down Expand Up @@ -82,10 +91,6 @@ public void stop()
*/
public static void start(String[] args)
{
List<String> arguments = Arrays.stream(args).toList();
Logger.getInstance().setDebug(arguments.contains("-d"));
Logger.getInstance().setVerbose(arguments.contains("-v"));

Application.launch(args);
}

Expand All @@ -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.
Expand All @@ -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<String, Object> generateUserOptions()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -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
{
/**
Expand Down Expand Up @@ -40,7 +41,7 @@ public void setUserOptions(Map<String, Object> 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;
}

Expand Down Expand Up @@ -70,7 +71,7 @@ private void setLayout(LayoutTypes type, Map<String, Object> 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");
}
}
}
117 changes: 4 additions & 113 deletions src/main/java/io/fi0x/javaguimenu/elements/AbstractElement.java
Original file line number Diff line number Diff line change
@@ -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
{
/**
Expand Down Expand Up @@ -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;
}
}
Loading

0 comments on commit b6d848f

Please sign in to comment.