-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into dependabot/maven/io.github.Fi0x-JavaLogger…
…-1.3.1
- Loading branch information
Showing
13 changed files
with
221 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 31 additions & 20 deletions
51
src/main/java/io/fi0x/javaguimenu/controller/MainController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.