Skip to content

Commit

Permalink
Merge branch 'master' into dependabot/maven/io.github.Fi0x-JavaLogger…
Browse files Browse the repository at this point in the history
…-1.3.1
  • Loading branch information
Fi0x committed Dec 30, 2023
2 parents 22431d0 + 1165180 commit 7b9d95f
Show file tree
Hide file tree
Showing 13 changed files with 221 additions and 104 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.0</version>
<version>1.1.3</version>
</dependency>
```
8 changes: 4 additions & 4 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.2</version>
<version>1.1.3</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.11.0</version>
<version>3.12.1</version>
<configuration>
<source>19</source>
<target>19</target>
Expand Down Expand Up @@ -82,7 +82,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.6.2</version>
<version>3.6.3</version>
<executions>
<execution>
<id>attach-javadocs</id>
Expand Down Expand Up @@ -113,7 +113,7 @@
<dependency>
<groupId>io.github.Fi0x</groupId>
<artifactId>JavaLogger</artifactId>
<version>1.3.1</version>
<version>1.3.3</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
Expand Down
8 changes: 7 additions & 1 deletion src/main/java/io/fi0x/javaguimenu/GUIWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ public class GUIWindow extends Application
private static int rows = 1;
private static boolean gridLaneVisibility = false;

/**
* Default constructor of this class.
*/
public GUIWindow()
{
}

@Override
public void start(Stage primaryStage)
{
Expand Down Expand Up @@ -164,7 +171,6 @@ public static void addElement(AbstractElement node)
break;
}
}
Logger.log("Added new element to window", Logger.TEMPLATE.VERBOSE);
}
/**
* This method changes the behaviour of the element placement inside the layout.
Expand Down
51 changes: 31 additions & 20 deletions src/main/java/io/fi0x/javaguimenu/controller/MainController.java
Original file line number Diff line number Diff line change
@@ -1,65 +1,76 @@
package io.fi0x.javaguimenu.controller;

import io.fi0x.javaguimenu.layouts.*;
import io.fi0x.javalogger.logging.Logger;
import io.fi0x.javalogger.logging.LOG;
import javafx.fxml.FXML;
import javafx.scene.layout.AnchorPane;

import java.util.Map;

/**
* This class controls the GUI.
*/
public class MainController
{
/**
* This pane is the anchor-pane of the GUI where all other elements get added.
*/
@FXML
public AnchorPane apMain;

/**
* Default constructor of this class.
*/
public MainController()
{
}

@FXML
private void initialize()
{
}

/**
* This method lets the user add individual options for the layout.
*
* @param settings The settings that should be integrated into the layout.
*/
public void setUserOptions(Map<String, Object> settings)
{
LayoutTypes layout = (LayoutTypes) settings.get("layout");
if(layout == null)
{
Logger.log("No layout type found", Logger.TEMPLATE.WARNING);
LOG.WARN("No layout type found", "JavaGUIMenu", 611);
return;
}

settings.remove("layout");
setLayout(layout, settings);

Logger.log("Main controller initialized", Logger.TEMPLATE.VERBOSE);
}

private void setLayout(LayoutTypes type, Map<String, Object> settings)
{
switch(type)
{
case Grid:
Logger.log("Using Grid layout", Logger.TEMPLATE.VERBOSE);
apMain.getChildren().add(new GridLayout(settings));
break;
case VBox:
Logger.log("Using VBox layout", Logger.TEMPLATE.VERBOSE);
case Grid -> apMain.getChildren().add(new GridLayout(settings));
case VBox ->
{
settings.remove("columns");
apMain.getChildren().add(new VBoxLayout(settings));
break;
case HBox:
Logger.log("Using HBox layout", Logger.TEMPLATE.VERBOSE);
}
case HBox ->
{
settings.remove("rows");
apMain.getChildren().add(new HBoxLayout(settings));
break;
case Absolute:
Logger.log("Using Absolute layout", Logger.TEMPLATE.VERBOSE);
}
case Absolute ->
{
settings.remove("elementSpacing");
settings.remove("rows");
settings.remove("columns");
apMain.getChildren().add(new AbsoluteLayout(settings));
break;
default:
Logger.log("The selected layout is not valid", Logger.TEMPLATE.WARNING);
break;
}
default -> LOG.WARN("The selected layout is not valid", "JavaGUIMenu", 611);
}
}
}
66 changes: 66 additions & 0 deletions src/main/java/io/fi0x/javaguimenu/elements/AbstractElement.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,87 +7,153 @@
*/
public abstract class AbstractElement
{
/**
* The index of the column this element should be in.
*/
protected int colIdx = -1;
/**
* The index of the row this element should be in.
*/
protected int rowIdx = -1;
/**
* The amount of cells in a column this element should occupy.
*/
protected int colSpan = 1;
/**
* The amount of cells in a row this element should occupy.
*/
protected int rowSpan = 1;
/**
* The x-position of this element in an absolute layout.
*/
protected double xPos;
/**
* The y-position of this element in an absolute layout.
*/
protected double yPos;

/**
* Default constructor of this class.
*/
public AbstractElement()
{
}

/**
* This method returns the node that this element represents.
*
* @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;
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/io/fi0x/javaguimenu/elements/Listener.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
package io.fi0x.javaguimenu.elements;

/**
* This interface allows a class to listen for trigger events.
*/
public interface Listener
{
/**
* This method gets triggered, when the sender-element is triggered.
*
* @param sender The element that got triggered.
*/
void trigger(AbstractElement sender);
}
13 changes: 13 additions & 0 deletions src/main/java/io/fi0x/javaguimenu/elements/PriorityButton.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,19 @@
*/
public class PriorityButton extends RegularButton
{
/**
* Default constructor of this class.
*/
public PriorityButton()
{
super();
}

/**
* This method returns the node that this element represents.
*
* @return The Node.
*/
@Override
public Node getNodeVersion()
{
Expand Down
Loading

0 comments on commit 7b9d95f

Please sign in to comment.