diff --git a/README.md b/README.md index d53b0be..67ff96a 100644 --- a/README.md +++ b/README.md @@ -42,3 +42,11 @@ TBMS is a Java-based application that provides functionalities for managing bank ## Commands Type `help` to see the list of commands and their usages. + +## Running the GUI + +To run the GUI application, use the `--gui` argument: + +``` +java -jar target/currency-exchange-system-1.0-SNAPSHOT.jar --gui +``` diff --git a/pom.xml b/pom.xml index 0df0969..21b14a9 100644 --- a/pom.xml +++ b/pom.xml @@ -1,5 +1,5 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://www.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 com.currencyconverter @@ -45,6 +45,16 @@ 5.8.1 test + + org.openjfx + javafx-graphics + 20.0.1 + + + org.openjfx + javafx-base + 20.0.1 + diff --git a/src/main/java/com/tbms/Main.java b/src/main/java/com/tbms/Main.java index 36aa836..e5907b3 100644 --- a/src/main/java/com/tbms/Main.java +++ b/src/main/java/com/tbms/Main.java @@ -1,6 +1,7 @@ package com.tbms; import com.tbms.cli.TbmsCLI; +import com.tbms.gui.GuiApp; import java.util.Scanner; @@ -9,6 +10,10 @@ public static void main(String[] args) { TbmsCLI tbmsCLI = new TbmsCLI(); if (args.length > 0) { + if (args[0].equals("--gui")) { + GuiApp.main(args); + return; + } // Command-line mode int exitCode = tbmsCLI.executeCommand(args); System.exit(exitCode); @@ -31,4 +36,4 @@ public static void main(String[] args) { } scanner.close(); } -} \ No newline at end of file +} diff --git a/src/main/java/com/tbms/gui/CurrencyGraph.java b/src/main/java/com/tbms/gui/CurrencyGraph.java new file mode 100644 index 0000000..0fb6f3f --- /dev/null +++ b/src/main/java/com/tbms/gui/CurrencyGraph.java @@ -0,0 +1,52 @@ +package com.tbms.gui; + +import javafx.scene.layout.Pane; +import javafx.scene.shape.Circle; +import javafx.scene.shape.Line; +import javafx.scene.paint.Color; + +import java.util.HashMap; +import java.util.Map; + +public class CurrencyGraph { + + private Pane graphPane; + private Map currencyNodes; + + public CurrencyGraph() { + this.graphPane = new Pane(); + this.currencyNodes = new HashMap<>(); + } + + public Pane generateGraph(Map> exchangeRates) { + graphPane.getChildren().clear(); + currencyNodes.clear(); + + // Create nodes for each currency + int index = 0; + for (String currency : exchangeRates.keySet()) { + Circle node = new Circle(20, Color.BLUE); + node.setCenterX(100 + index * 100); + node.setCenterY(100); + currencyNodes.put(currency, node); + graphPane.getChildren().add(node); + index++; + } + + // Create edges for each exchange rate + for (Map.Entry> entry : exchangeRates.entrySet()) { + String fromCurrency = entry.getKey(); + for (Map.Entry rateEntry : entry.getValue().entrySet()) { + String toCurrency = rateEntry.getKey(); + Line edge = new Line(); + edge.setStartX(currencyNodes.get(fromCurrency).getCenterX()); + edge.setStartY(currencyNodes.get(fromCurrency).getCenterY()); + edge.setEndX(currencyNodes.get(toCurrency).getCenterX()); + edge.setEndY(currencyNodes.get(toCurrency).getCenterY()); + graphPane.getChildren().add(edge); + } + } + + return graphPane; + } +} diff --git a/src/main/java/com/tbms/gui/GuiApp.java b/src/main/java/com/tbms/gui/GuiApp.java new file mode 100644 index 0000000..c672cf5 --- /dev/null +++ b/src/main/java/com/tbms/gui/GuiApp.java @@ -0,0 +1,30 @@ +package com.tbms.gui; + +import javafx.application.Application; +import javafx.scene.Scene; +import javafx.scene.layout.BorderPane; +import javafx.stage.Stage; + +public class GuiApp extends Application { + + @Override + public void start(Stage primaryStage) { + primaryStage.setTitle("Currency Exchange System"); + + BorderPane mainLayout = createMainLayout(); + + Scene scene = new Scene(mainLayout, 800, 600); + primaryStage.setScene(scene); + primaryStage.show(); + } + + private BorderPane createMainLayout() { + BorderPane borderPane = new BorderPane(); + // Add components to the layout + return borderPane; + } + + public static void main(String[] args) { + launch(args); + } +} diff --git a/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst new file mode 100644 index 0000000..eb01e4c --- /dev/null +++ b/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst @@ -0,0 +1,9 @@ +com/tbms/service/ExchangeService.class +com/tbms/util/CurrencyTablePrinter.class +com/tbms/service/BestConversion.class +com/tbms/model/Bank.class +com/tbms/cli/TbmsCLI.class +com/tbms/util/ExchangeEdge.class +com/tbms/service/BankService.class +com/tbms/util/CurrencyUtils.class +com/tbms/Main.class diff --git a/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst new file mode 100644 index 0000000..a0d5430 --- /dev/null +++ b/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -0,0 +1,9 @@ +/workspaces/java-tbms/src/main/java/com/tbms/util/CurrencyUtils.java +/workspaces/java-tbms/src/main/java/com/tbms/service/BankService.java +/workspaces/java-tbms/src/main/java/com/tbms/Main.java +/workspaces/java-tbms/src/main/java/com/tbms/service/ExchangeService.java +/workspaces/java-tbms/src/main/java/com/tbms/service/BestConversion.java +/workspaces/java-tbms/src/main/java/com/tbms/cli/TbmsCLI.java +/workspaces/java-tbms/src/main/java/com/tbms/util/ExchangeEdge.java +/workspaces/java-tbms/src/main/java/com/tbms/util/CurrencyTablePrinter.java +/workspaces/java-tbms/src/main/java/com/tbms/model/Bank.java