diff --git a/src/main/java/no/ntnu/idatt1002/SpendWise/budgeting/FutureBudgeting.java b/src/main/java/no/ntnu/idatt1002/SpendWise/budgeting/Budgeting.java similarity index 84% rename from src/main/java/no/ntnu/idatt1002/SpendWise/budgeting/FutureBudgeting.java rename to src/main/java/no/ntnu/idatt1002/SpendWise/budgeting/Budgeting.java index 0efcb27cef6d4fcb2f55e5e0a910575e5d6fd68b..79d1ab53aaf7d358482e28a421c61041a581c8b0 100644 --- a/src/main/java/no/ntnu/idatt1002/SpendWise/budgeting/FutureBudgeting.java +++ b/src/main/java/no/ntnu/idatt1002/SpendWise/budgeting/Budgeting.java @@ -11,12 +11,12 @@ import javafx.stage.Stage; /** * Creates the stage for future budgeting. */ -public class FutureBudgeting extends Application { +public class Budgeting extends Application { @Override public void start(Stage stage) throws IOException { Parent root = FXMLLoader.load(Objects.requireNonNull( - getClass().getResource("/FutureBudgeting.fxml"))); + getClass().getResource("/Budgeting.fxml"))); Scene scene = new Scene(root); stage.setScene(scene); stage.show(); diff --git a/src/main/java/no/ntnu/idatt1002/SpendWise/budgeting/BudgetingCell.java b/src/main/java/no/ntnu/idatt1002/SpendWise/budgeting/BudgetingCell.java new file mode 100644 index 0000000000000000000000000000000000000000..beeaa474dcd1692ec48af95e98d9d63c6018bd94 --- /dev/null +++ b/src/main/java/no/ntnu/idatt1002/SpendWise/budgeting/BudgetingCell.java @@ -0,0 +1,51 @@ +package no.ntnu.idatt1002.SpendWise.budgeting; + +import javafx.beans.property.SimpleDoubleProperty; +import no.ntnu.idatt1002.SpendWise.data.Category; + +public class BudgetingCell { + private Category category; + private SimpleDoubleProperty expected; + private SimpleDoubleProperty actual; + private SimpleDoubleProperty difference; + + public BudgetingCell(double expected, double actual, Category category) { + this.expected = new SimpleDoubleProperty(expected); + this.actual = new SimpleDoubleProperty(actual); + this.difference = new SimpleDoubleProperty(expected-actual); + this.category = category; + } + + public BudgetingCell(double actual, Category category) { + this.expected = new SimpleDoubleProperty(0); + this.actual = new SimpleDoubleProperty(actual); + this.difference = new SimpleDoubleProperty(expected.get()-actual); + this.category = category; + } + + public double getExpected() { + return expected.get(); + } + + public void setExpected(double newExpected) { + this.difference.set(newExpected-actual.get()); + this.expected.set(newExpected); + } + + public double getActual() { + return actual.get(); + } + + public void setActual(double newActual) { + this.difference.set(this.expected.get() - newActual); + this.actual.set(newActual); + } + + public String getCategoryName() { + return category.getName(); + } + + public double getDifference() { + return difference.get(); + } +} diff --git a/src/main/java/no/ntnu/idatt1002/SpendWise/budgeting/BudgetingController.java b/src/main/java/no/ntnu/idatt1002/SpendWise/budgeting/BudgetingController.java new file mode 100644 index 0000000000000000000000000000000000000000..2082ff0ac811f6e9955ecf45e2650a135e54d3e1 --- /dev/null +++ b/src/main/java/no/ntnu/idatt1002/SpendWise/budgeting/BudgetingController.java @@ -0,0 +1,267 @@ +package no.ntnu.idatt1002.SpendWise.budgeting; + +import javafx.collections.FXCollections; +import javafx.collections.ObservableList; +import javafx.fxml.FXML; +import javafx.fxml.FXMLLoader; +import javafx.fxml.Initializable; +import javafx.scene.Node; +import javafx.scene.Scene; +import javafx.scene.chart.BarChart; +import javafx.scene.chart.PieChart; +import javafx.scene.control.*; +import javafx.scene.control.cell.PropertyValueFactory; +import javafx.scene.layout.BorderPane; +import javafx.stage.Stage; +import javafx.util.converter.LocalDateStringConverter; +import no.ntnu.idatt1002.SpendWise.data.Category; +import no.ntnu.idatt1002.SpendWise.data.Register; +import no.ntnu.idatt1002.SpendWise.data.RegisterController; +import no.ntnu.idatt1002.SpendWise.exceptions.ConformityException; +import no.ntnu.idatt1002.SpendWise.exceptions.DuplicateNameException; +import org.w3c.dom.Text; + +import java.awt.event.ActionEvent; +import java.io.IOException; +import java.net.URISyntaxException; +import java.net.URL; +import java.time.LocalDate; +import java.time.Month; +import java.time.Year; +import java.time.YearMonth; +import java.time.format.DateTimeFormatter; +import java.util.*; + +import static java.lang.Double.parseDouble; + +public class BudgetingController implements Initializable { + @FXML + private TextField expectedAmountExpenseField; + @FXML + private TextField expectedAmountIncomeField; + @FXML + private TextField totalActual; + private double totalActualDoub; + private double expectedIncome; + private double expectedExpense; + private double actualIncome; + private double actualExpense; + @FXML + private TextField totalExpected; + private double totalExpectedDoub; + @FXML + private TextField totalDifference; + private double totalDifferenceDoub; + @FXML + private DatePicker datePicker; + @FXML + private TableView<BudgetingCell> tableViewIncomeCat; + @FXML + private TableColumn<BudgetingCell, String> categoryColumnIn; + @FXML + private TableColumn<BudgetingCell, Double> actualAmountColumnIn; + @FXML + private TableView<BudgetingCell> tableViewIncomeDoub; + @FXML + private TableColumn<BudgetingCell, Double> expectedAmountColumnIn; + @FXML + private TableColumn<BudgetingCell, Double> differenceColumnIn; + @FXML + private TableView<BudgetingCell> tableViewExpenseCat; + @FXML + private TableColumn<BudgetingCell, String> categoryColumnEx; + @FXML + private TableColumn<BudgetingCell, Double> actualAmountColumnEx; + @FXML + private TableView<BudgetingCell> tableViewExpenseDoub; + @FXML + private TableColumn<BudgetingCell, Double> expectedAmountColumnEx; + @FXML + private TableColumn<BudgetingCell, Double> differenceColumnEx; + @FXML + private PieChart expectedPie; + @FXML + private PieChart actualPie; + private LocalDate dateChosen; + private Register categoryRegister; + + public BudgetingController() throws DuplicateNameException, IOException, URISyntaxException, ConformityException { + categoryRegister = RegisterController.readData(getClass().getClassLoader().getResource("database/register.json")); + } + + @Override + public void initialize(URL url, ResourceBundle resourceBundle) { + + } + + private void fillTableIncome() { + List<String> incomeString = categoryRegister.getCategoriesByTransactionType(false); + List<LocalDate> dates = getDates(); + ArrayList<BudgetingCell> incomeDouble = new ArrayList<>(); + for (String string : incomeString) { + Category category = categoryRegister.getCategoryByName(string); + BudgetingCell budgetingCell = new BudgetingCell(category.getTotalAmountWithinTimeFrame(dates.get(0), dates.get(1)), category); + incomeDouble.add(budgetingCell); + } + ObservableList<BudgetingCell> transactionObservableList = FXCollections.observableArrayList(incomeDouble); + categoryColumnIn.setCellValueFactory(new PropertyValueFactory<>("CategoryName")); + actualAmountColumnIn.setCellValueFactory(new PropertyValueFactory<>("Actual")); + + ObservableList<BudgetingCell> transactionObservableList2 = FXCollections.observableArrayList(incomeDouble); + expectedAmountColumnIn.setCellValueFactory(new PropertyValueFactory<>("Expected")); + differenceColumnIn.setCellValueFactory(new PropertyValueFactory<>("Difference")); + + tableViewIncomeCat.setItems(transactionObservableList); + tableViewIncomeDoub.setItems(transactionObservableList2); + } + + private void fillTableExpense() { + List<String> expenseString = categoryRegister.getCategoriesByTransactionType(true); + List<LocalDate> dates = getDates(); + ArrayList<BudgetingCell> expenseDouble = new ArrayList<>(); + for (String string : expenseString) { + Category category = categoryRegister.getCategoryByName(string); + BudgetingCell budgetingCell = new BudgetingCell(category.getTotalAmountWithinTimeFrame(dates.get(0), dates.get(1)), category); + expenseDouble.add(budgetingCell); + } + ObservableList<BudgetingCell> transactionObservableList = FXCollections.observableArrayList(expenseDouble); + categoryColumnEx.setCellValueFactory(new PropertyValueFactory<>("CategoryName")); + actualAmountColumnEx.setCellValueFactory(new PropertyValueFactory<>("Actual")); + + ObservableList<BudgetingCell> transactionsObservableList2 = FXCollections.observableArrayList(expenseDouble); + expectedAmountColumnEx.setCellValueFactory(new PropertyValueFactory<>("Expected")); + differenceColumnEx.setCellValueFactory(new PropertyValueFactory<>("Difference")); + + tableViewExpenseCat.setItems(transactionObservableList); + tableViewExpenseDoub.setItems(transactionsObservableList2); + } + + public void dateChosen() { + dateChosen = datePicker.getValue(); + fillTableExpense(); + fillTableIncome(); + updateTotal(); + fillCharts(); + tableViewExpenseDoub.refresh(); + tableViewIncomeDoub.refresh(); + tableViewExpenseCat.refresh(); + tableViewIncomeCat.refresh(); + + } + + public void addExpenseAmountPressed() { + BudgetingCell selectedItem = tableViewExpenseDoub.getSelectionModel().getSelectedItem(); + try { + Double.parseDouble(expectedAmountExpenseField.getText()); + } catch (Exception e) { + expectedAmountExpenseField.clear(); + expectedAmountExpenseField.setPromptText("Please enter a number."); + return; + } + if (expectedAmountExpenseField.getText().isEmpty()) { + expectedAmountExpenseField.setPromptText("Please enter amount."); + return; + } + if (selectedItem == null) { + System.out.println("Not selected expense"); + expectedAmountExpenseField.clear(); + expectedAmountExpenseField.setPromptText("Please choose a row to update."); + return; + } + double expected = Double.parseDouble(expectedAmountExpenseField.getText()); + selectedItem.setExpected(expected); + expectedAmountExpenseField.clear(); + System.out.println("Added: " + expected); + tableViewExpenseDoub.refresh(); + updateTotal(); + fillCharts(); + } + public void addIncomeAmountPressed() { + BudgetingCell selectedItem = tableViewIncomeDoub.getSelectionModel().getSelectedItem(); + try { + Double.parseDouble(expectedAmountIncomeField.getText()); + } catch (Exception e) { + expectedAmountIncomeField.clear(); + expectedAmountIncomeField.setPromptText("Please enter a number."); + return; + } + if (expectedAmountIncomeField.getText().isEmpty()) { + expectedAmountIncomeField.setPromptText("Please enter amount."); + return; + } + if (selectedItem == null) { + expectedAmountIncomeField.clear(); + expectedAmountIncomeField.setPromptText("Please choose a row to update."); + return; + } + double expected = Double.parseDouble(expectedAmountIncomeField.getText()); + selectedItem.setExpected(expected); + expectedAmountIncomeField.clear(); + tableViewIncomeDoub.refresh(); + updateTotal(); + fillCharts(); + } + + public void fillCharts() { + ObservableList<PieChart.Data> piechartExpectedData = FXCollections.observableArrayList(); + piechartExpectedData.add(new PieChart.Data("Expected expenses", expectedExpense)); + piechartExpectedData.add(new PieChart.Data("Expected income", expectedIncome)); + expectedPie.setData(piechartExpectedData); + + ObservableList<PieChart.Data> piechartActualData = FXCollections.observableArrayList(); + piechartActualData.add(new PieChart.Data("Actual expenses", actualExpense)); + piechartActualData.add(new PieChart.Data("Actual income", actualIncome)); + actualPie.setData(piechartActualData); + } + + private void updateTotal() { + for (BudgetingCell item : tableViewIncomeCat.getItems()) { + actualIncome += item.getActual(); + expectedIncome += item.getExpected(); + totalActualDoub += item.getActual(); + totalDifferenceDoub += item.getDifference(); + totalExpectedDoub += item.getExpected(); + } + for (BudgetingCell item : tableViewExpenseCat.getItems()) { + actualExpense += item.getActual(); + expectedExpense += item.getExpected(); + totalActualDoub -= item.getActual(); + totalDifferenceDoub += item.getDifference(); + totalExpectedDoub -= item.getExpected(); + } + totalActual.setText(Double.toString(totalActualDoub)); + totalDifference.setText(Double.toString(totalDifferenceDoub)); + totalExpected.setText(Double.toString(totalExpectedDoub)); + } + + private List<LocalDate> getDates() { + Calendar c = Calendar.getInstance(); + ArrayList<LocalDate> dates = new ArrayList<>(); + Month month = dateChosen.getMonth(); + int year = dateChosen.getYear(); + int res = c.getActualMaximum(Calendar.DAY_OF_MONTH); + + LocalDate startDate = LocalDate.of(year, month.getValue(), 1); + dates.add(startDate); + LocalDate endDate = LocalDate.of(year, month.getValue(), res); + dates.add(endDate); + return dates; + } + + /** + * Home button. + + * @param event mouse click on button. + * @throws IOException if wrong input is detected. + */ + @FXML + public void goHome(ActionEvent event) throws IOException { + BorderPane rootGoHome = (FXMLLoader.load(Objects.requireNonNull( + getClass().getResource("/SpendWiseHomePage.fxml")))); + + Stage stage = (Stage) ((Node) event.getSource()).getScene().getWindow(); + Scene scene = new Scene(rootGoHome); + stage.setScene(scene); + stage.show(); + } +} diff --git a/src/main/java/no/ntnu/idatt1002/SpendWise/budgeting/FutureBudgetingController.java b/src/main/java/no/ntnu/idatt1002/SpendWise/budgeting/FutureBudgetingController.java deleted file mode 100644 index d5eddb8b20941a35461134735ab1a857a3766390..0000000000000000000000000000000000000000 --- a/src/main/java/no/ntnu/idatt1002/SpendWise/budgeting/FutureBudgetingController.java +++ /dev/null @@ -1,274 +0,0 @@ -package no.ntnu.idatt1002.SpendWise.budgeting; - -import java.io.IOException; -import java.net.URL; -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; -import java.util.ResourceBundle; - -import javafx.collections.FXCollections; -import javafx.event.ActionEvent; -import javafx.fxml.FXML; -import javafx.fxml.FXMLLoader; -import javafx.fxml.Initializable; -import javafx.scene.Node; -import javafx.scene.Parent; -import javafx.scene.Scene; -import javafx.scene.control.ChoiceBox; -import javafx.scene.control.TextField; -import javafx.scene.layout.BorderPane; -import javafx.scene.text.Text; -import javafx.stage.Stage; - -/** - * Controller for future budgeting GUI. - */ -public class FutureBudgetingController implements Initializable { - private Stage stage; - private Scene scene; - @FXML - public TextField firstExpected; - - @FXML - public TextField secondExpected; - - @FXML - public TextField thirdExpected; - - @FXML - public TextField fourthExpected; - - @FXML - public TextField fifthExpected; - - @FXML - public TextField sixthExpected; - - @FXML - public TextField firstActual; - - @FXML - public TextField secondActual; - - @FXML - public TextField thirdActual; - - @FXML - public TextField fourthActual; - - @FXML - public TextField fifthActual; - - @FXML - public TextField sixthActual; - - @FXML - private Text firstDiff; - - @FXML - private Text secondDiff; - - @FXML - private Text thirdDiff; - - @FXML - private Text fourthDiff; - - @FXML - private Text fifthDiff; - - @FXML - private Text sixthDiff; - - /** - * Calculates difference between given expected output and actual output. - */ - public void setFirstDiff() { - String difference; - difference = String.valueOf((Integer.parseInt(firstExpected.getText()) - - Integer.parseInt(firstActual.getText()))); - firstDiff.setText(difference); - } - - /** - * Calculates difference between given expected output and actual output. - */ - public void setSecondDiff() { - String difference; - difference = String.valueOf((Integer.parseInt(secondExpected.getText()) - - Integer.parseInt(secondActual.getText()))); - secondDiff.setText(difference); - } - - /** - * Calculates difference between given expected output and actual output. - */ - public void setThirdDiff() { - String difference; - difference = String.valueOf((Integer.parseInt(thirdExpected.getText()) - - Integer.parseInt(thirdActual.getText()))); - thirdDiff.setText(difference); - } - - /** - * Calculates difference between given expected output and actual output. - */ - public void setFourthDiff() { - String difference; - difference = String.valueOf((Integer.parseInt(fourthExpected.getText()) - - Integer.parseInt(fourthActual.getText()))); - fourthDiff.setText(difference); - } - - /** - * Calculates difference between given expected output and actual output. - */ - public void setFifthDiff() { - String difference; - difference = String.valueOf((Integer.parseInt(fifthExpected.getText()) - - Integer.parseInt(fifthActual.getText()))); - fifthDiff.setText(difference); - } - - /** - * Calculates difference between given expected output and actual output. - */ - public void setSixthDiff() { - String difference; - difference = String.valueOf((Integer.parseInt(sixthExpected.getText()) - - Integer.parseInt(sixthActual.getText()))); - sixthDiff.setText(difference); - } - - @FXML - private ChoiceBox<Object> firstCategory; - - @FXML - private ChoiceBox<Object> secondCategory; - - @FXML - private ChoiceBox<Object> thirdCategory; - - @FXML - private ChoiceBox<Object> fourthCategory; - - @FXML - private ChoiceBox<Object> fifthCategory; - - @FXML - private ChoiceBox<Object> sixthCategory; - - /** - * Initializes the categories used in future budgeting dropdowns. - */ - public void categoryInitiator() { - if (firstCategory.isVisible()) { - List<ChoiceBox<Object>> dropdowns = new ArrayList<>(); - dropdowns.add(firstCategory); - dropdowns.add(secondCategory); - dropdowns.add(thirdCategory); - dropdowns.add(fourthCategory); - dropdowns.add(fifthCategory); - dropdowns.add(sixthCategory); - - List<String> categories = new ArrayList<>(); - categories.add("Housing"); - categories.add("Groceries"); - categories.add("Travel"); - categories.add("Entertainment"); - categories.add("Fixed expenses"); - categories.add("Other..."); - - for (ChoiceBox<Object> cb : dropdowns) { //TODO add this to button that leads to page. - cb.setItems(FXCollections.observableArrayList(categories)); - } - } - } - - @Override - public void initialize (URL url, ResourceBundle resourceBundle){ - categoryInitiator(); - } - - /** - * Button to go to home page of application. - - * @param event when button is pressed with mouse. - * @throws IOException if input is invalid. - */ - public void goHome(ActionEvent event) throws IOException { - BorderPane rootGoHome = (FXMLLoader.load(Objects.requireNonNull(getClass().getResource( - "/SpendWiseHomePage.fxml")))); - Stage stage = (Stage) ((Node) event.getSource()).getScene().getWindow(); - Scene scene = new Scene(rootGoHome); - stage.setScene(scene); - stage.show(); - } - - /** - * Button that takes user to income. - - * @param event mouse click. - * @throws IOException if wrong input detected. - */ - public void switchToIncome(ActionEvent event) throws IOException { - BorderPane rootSwitchToIncome = (FXMLLoader.load(Objects.requireNonNull( - getClass().getResource("/NewIncome.fxml")))); - - stage = (Stage) ((Node) event.getSource()).getScene().getWindow(); - scene = new Scene(rootSwitchToIncome); - stage.setScene(scene); - stage.show(); - } - - /** - * Button that takes user to recurring transactions. - - * @param event mouse click. - * @throws IOException if wrong input detected. - */ - public void switchToRecurringTransactions(ActionEvent event) throws IOException { - BorderPane rootSwitchToRecurringTrans = (FXMLLoader.load(Objects.requireNonNull( - getClass().getResource("/RecurringTransactions.fxml")))); - - stage = (Stage) ((Node) event.getSource()).getScene().getWindow(); - scene = new Scene(rootSwitchToRecurringTrans); - stage.setScene(scene); - stage.show(); - } - - - /** - * Button that takes user to edit income. - - * @param event mouse click. - * @throws IOException if wrong input detected. - */ - public void switchToEditIncome(ActionEvent event) throws IOException { - BorderPane rootSwitchToEditIncome = (FXMLLoader.load(Objects.requireNonNull( - getClass().getResource("/EditIncome.fxml")))); - - stage = (Stage) ((Node) event.getSource()).getScene().getWindow(); - scene = new Scene(rootSwitchToEditIncome); - stage.setScene(scene); - stage.show(); - } - - /** - * A button that opens the help option menu. - * @param event - mouse click - * @throws IOException - if wrong input detected - */ - public void openHelpOption(ActionEvent event) throws IOException { - FXMLLoader rootSwitchToHelpOption = new FXMLLoader(getClass().getResource("/HelpScenes/HelpBudgeting.fxml")); - Parent rootHelp = (Parent) rootSwitchToHelpOption.load(); - Stage stage = new Stage(); - stage.setScene(new Scene(rootHelp)); - stage.show(); - } - - } - - - diff --git a/src/main/java/no/ntnu/idatt1002/SpendWise/home/HomePageController.java b/src/main/java/no/ntnu/idatt1002/SpendWise/home/HomePageController.java index 5d19562bebc4428ea3a857e64ae5dfc3d103f496..1cfce3377e20cdd99dbc3ee14bb030c074f89251 100644 --- a/src/main/java/no/ntnu/idatt1002/SpendWise/home/HomePageController.java +++ b/src/main/java/no/ntnu/idatt1002/SpendWise/home/HomePageController.java @@ -86,12 +86,12 @@ public class HomePageController implements Initializable { * @param event mouse click. * @throws IOException if wrong input detected. */ - public void switchToFutureBudgeting(ActionEvent event) throws IOException { - BorderPane rootSwitchToFutureBudgeting = (FXMLLoader.load(Objects.requireNonNull( - getClass().getResource("/FutureBudgeting.fxml")))); + public void switchToBudgeting(ActionEvent event) throws IOException { + BorderPane rootSwitchToBudgeting = (FXMLLoader.load(Objects.requireNonNull( + getClass().getResource("/Budgeting.fxml")))); stage = (Stage) ((Node) event.getSource()).getScene().getWindow(); - scene = new Scene(rootSwitchToFutureBudgeting); + scene = new Scene(rootSwitchToBudgeting); stage.setScene(scene); stage.show(); } diff --git a/src/main/resources/Budgeting.fxml b/src/main/resources/Budgeting.fxml new file mode 100644 index 0000000000000000000000000000000000000000..596cdb2ecdb07bb92f005cb62a1f896f683efb07 --- /dev/null +++ b/src/main/resources/Budgeting.fxml @@ -0,0 +1,260 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<?import javafx.geometry.*?> +<?import javafx.scene.chart.*?> +<?import javafx.scene.control.*?> +<?import javafx.scene.image.*?> +<?import javafx.scene.layout.*?> +<?import javafx.scene.text.*?> + +<BorderPane prefHeight="800.0" prefWidth="1400.0" xmlns="http://javafx.com/javafx/17.0.2-ea" xmlns:fx="http://javafx.com/fxml/1" fx:controller="no.ntnu.idatt1002.SpendWise.budgeting.BudgetingController"> + <center> + <BorderPane> + <top> + <ToolBar prefHeight="40.0" prefWidth="200.0" style="-fx-background-color: EC84E2; -fx-border-color: #382119;" BorderPane.alignment="CENTER"> + <items> + <Button mnemonicParsing="false" style="-fx-background-color: translucent;" text="Overview" textFill="#382119"> + <font> + <Font name="Arial Bold" size="15.0" /> + </font></Button> + <Button mnemonicParsing="false" style="-fx-background-color: translucent;" text="Recurring Transactions" textFill="#382119"> + <font> + <Font name="Arial Bold" size="15.0" /> + </font></Button> + <Button mnemonicParsing="false" style="-fx-background-color: translucent;" text="Budgeting" textFill="#382119"> + <font> + <Font name="Arial" size="15.0" /> + </font></Button> + <Button mnemonicParsing="false" style="-fx-background-color: translucent;" text="Edit" textFill="#382119"> + <font> + <Font name="Arial Bold" size="15.0" /> + </font></Button> + </items> + <padding> + <Insets bottom="10.0" left="10.0" right="10.0" top="10.0" /> + </padding> + </ToolBar> + </top> + <center> + <HBox alignment="CENTER" prefHeight="493.0" prefWidth="1400.0" spacing="30.0" BorderPane.alignment="CENTER"> + <BorderPane.margin> + <Insets /> + </BorderPane.margin> + <children> + <VBox prefHeight="532.0" prefWidth="646.0" spacing="50.0"> + <children> + <HBox prefHeight="154.0" prefWidth="646.0"> + <children> + <TableView fx:id="tableViewIncomeCat" prefHeight="154.0" prefWidth="349.0"> + <columns> + <TableColumn fx:id="categoryColumnIn" prefWidth="161.5" text="Category" /> + <TableColumn fx:id="actualAmountColumnIn" minWidth="0.0" prefWidth="169.0" text="Actual amount" /> + </columns> + <opaqueInsets> + <Insets /> + </opaqueInsets> + <HBox.margin> + <Insets right="-1.0" /> + </HBox.margin> + <columnResizePolicy> + <TableView fx:constant="CONSTRAINED_RESIZE_POLICY" /> + </columnResizePolicy> + </TableView> + <TableView fx:id="tableViewIncomeDoub" editable="true" prefHeight="154.0" prefWidth="334.0"> + <columns> + <TableColumn fx:id="expectedAmountColumnIn" prefWidth="160.0" text="Expected amount" /> + <TableColumn fx:id="differenceColumnIn" minWidth="0.0" prefWidth="155.5" text="Difference" /> + </columns> + <opaqueInsets> + <Insets /> + </opaqueInsets> + <HBox.margin> + <Insets left="-1.0" /> + </HBox.margin> + <columnResizePolicy> + <TableView fx:constant="CONSTRAINED_RESIZE_POLICY" /> + </columnResizePolicy> + </TableView> + </children> + </HBox> + <HBox prefHeight="100.0" prefWidth="423.0"> + <children> + <TableView fx:id="tableViewExpenseCat" prefHeight="100.0" prefWidth="346.0"> + <columns> + <TableColumn fx:id="categoryColumnEx" prefWidth="163.0" text="Category" /> + <TableColumn fx:id="actualAmountColumnEx" prefWidth="167.5" text="Actual amount" /> + </columns> + <HBox.margin> + <Insets right="-1.0" /> + </HBox.margin> + <columnResizePolicy> + <TableView fx:constant="CONSTRAINED_RESIZE_POLICY" /> + </columnResizePolicy> + </TableView> + <TableView fx:id="tableViewExpenseDoub" editable="true" prefHeight="100.0" prefWidth="331.0"> + <columns> + <TableColumn fx:id="expectedAmountColumnEx" prefWidth="161.0" text="Expected amount" /> + <TableColumn fx:id="differenceColumnEx" minWidth="0.0" prefWidth="0.0" text="Difference" /> + </columns> + <HBox.margin> + <Insets left="-1.0" /> + </HBox.margin> + <columnResizePolicy> + <TableView fx:constant="CONSTRAINED_RESIZE_POLICY" /> + </columnResizePolicy> + </TableView> + </children> + <padding> + <Insets top="-50.0" /> + </padding> + </HBox> + <VBox prefHeight="200.0" prefWidth="100.0"> + <children> + <HBox prefHeight="51.0" prefWidth="646.0"> + <children> + <Text strokeType="OUTSIDE" strokeWidth="0.0" text="Total amount:" wrappingWidth="157.13671875"> + <font> + <Font name="Arial" size="18.0" /> + </font> + </Text> + <TextField fx:id="totalActual" editable="false" prefHeight="25.0" prefWidth="205.0" /> + <TextField fx:id="totalExpected" editable="false" prefHeight="25.0" prefWidth="147.0" /> + <TextField fx:id="totalDifference" editable="false" prefHeight="25.0" prefWidth="160.0" /> + </children> + </HBox> + <HBox prefHeight="144.0" prefWidth="646.0"> + <children> + <VBox prefHeight="100.0" prefWidth="187.0"> + <children> + <Label prefHeight="50.0" prefWidth="155.0" text="Expected income amount:"> + <font> + <Font name="Arial" size="13.0" /> + </font> + </Label> + <Label prefHeight="52.0" prefWidth="176.0" text="Expected expense amount:"> + <font> + <Font name="Arial" size="13.0" /> + </font> + </Label> + </children> + </VBox> + <VBox prefHeight="143.0" prefWidth="195.0"> + <children> + <TextField fx:id="expectedAmountIncomeField" prefHeight="25.0" prefWidth="146.0" promptText="Write income here"> + <font> + <Font name="Arial" size="13.0" /> + </font> + </TextField> + <TextField fx:id="expectedAmountExpenseField" prefHeight="10.0" prefWidth="195.0" promptText="Write expense here"> + <font> + <Font name="Arial" size="13.0" /> + </font> + </TextField> + </children> + </VBox> + <VBox prefHeight="143.0" prefWidth="264.0"> + <children> + <Button fx:id="addIncomeAmount" mnemonicParsing="false" onAction="#addIncomeAmountPressed" text="Add income amount"> + <font> + <Font name="Arial" size="13.0" /> + </font> + </Button> + <Button fx:id="addExpenseAmount" mnemonicParsing="false" onAction="#addExpenseAmountPressed" text="Add expense amount"> + <font> + <Font name="Arial" size="13.0" /> + </font> + </Button> + </children> + </VBox> + </children> + </HBox> + </children> + </VBox> + </children> + </VBox> + <VBox prefHeight="503.0" prefWidth="602.0"> + <children> + <DatePicker fx:id="datePicker" onAction="#dateChosen" /> + <HBox prefHeight="100.0" prefWidth="200.0"> + <children> + <Label prefHeight="61.0" prefWidth="344.0" text="Expected PieChart:"> + <font> + <Font name="Arial" size="18.0" /> + </font> + </Label> + <Label prefHeight="74.0" prefWidth="322.0" text="Actual PieChart:"> + <font> + <Font name="Arial" size="18.0" /> + </font> + </Label> + </children> + </HBox> + <HBox prefHeight="485.0" prefWidth="602.0"> + <children> + <PieChart fx:id="expectedPie" prefHeight="485.0" prefWidth="316.0" /> + <PieChart fx:id="actualPie" prefHeight="485.0" prefWidth="317.0" /> + </children> + </HBox> + </children> + </VBox> + </children> + </HBox> + </center> + </BorderPane> + </center> + <top> + <BorderPane prefHeight="100.0" prefWidth="1400.0" style="-fx-background-color: EC84E2;" BorderPane.alignment="CENTER"> + <right> + <VBox alignment="CENTER" prefHeight="50.0" prefWidth="50.0" spacing="20.0" BorderPane.alignment="CENTER"> + <children> + <Button mnemonicParsing="false" style="-fx-background-color: translucent;"> + <graphic> + <ImageView fitHeight="30.0" fitWidth="30.0" pickOnBounds="true" preserveRatio="true"> + <image> + <Image url="@Icons/Settings.png" /> + </image> + </ImageView> + </graphic> + </Button> + <Button mnemonicParsing="false" style="-fx-background-color: translucent;"> + <graphic> + <ImageView fitHeight="30.0" fitWidth="30.0" pickOnBounds="true" preserveRatio="true"> + <image> + <Image url="@Icons/HelpIcon.png" /> + </image> + </ImageView> + </graphic> + </Button> + </children> + </VBox> + </right> + <left> + <Button mnemonicParsing="false" style="-fx-background-color: translucent;" BorderPane.alignment="CENTER"> + <graphic> + <ImageView fitHeight="100.0" fitWidth="100.0" pickOnBounds="true" preserveRatio="true"> + <image> + <Image url="@Icons/SpendwiseIcon.png" /> + </image> + </ImageView> + </graphic> + </Button> + </left> + <center> + <Label text="Budgeting" textFill="#382119" BorderPane.alignment="CENTER"> + <font> + <Font name="Arial Bold" size="45.0" /> + </font> + </Label> + </center> + <padding> + <Insets bottom="20.0" left="20.0" right="20.0" top="20.0" /> + </padding> + <BorderPane.margin> + <Insets /> + </BorderPane.margin> + </BorderPane> + </top> + <bottom> + <HBox alignment="CENTER" prefHeight="71.0" prefWidth="1400.0" spacing="10.0" BorderPane.alignment="CENTER" /> + </bottom> +</BorderPane> diff --git a/src/main/resources/FutureBudgeting.fxml b/src/main/resources/FutureBudgeting.fxml deleted file mode 100644 index 618a945aba37d3e98b1391bb7df40affe5e77787..0000000000000000000000000000000000000000 --- a/src/main/resources/FutureBudgeting.fxml +++ /dev/null @@ -1,251 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> - -<?import javafx.geometry.Insets?> -<?import javafx.scene.control.Button?> -<?import javafx.scene.control.ChoiceBox?> -<?import javafx.scene.control.Label?> -<?import javafx.scene.control.TextField?> -<?import javafx.scene.control.ToolBar?> -<?import javafx.scene.image.Image?> -<?import javafx.scene.image.ImageView?> -<?import javafx.scene.layout.BorderPane?> -<?import javafx.scene.layout.HBox?> -<?import javafx.scene.layout.VBox?> -<?import javafx.scene.text.Font?> -<?import javafx.scene.text.Text?> - -<BorderPane prefHeight="800.0" prefWidth="1400.0" xmlns="http://javafx.com/javafx/19" xmlns:fx="http://javafx.com/fxml/1" fx:controller="no.ntnu.idatt1002.SpendWise.budgeting.FutureBudgetingController"> - <center> - <BorderPane> - <top> - <ToolBar prefHeight="40.0" prefWidth="200.0" style="-fx-background-color: EC84E2; -fx-border-color: #382119;" BorderPane.alignment="CENTER"> - <items> - <Button mnemonicParsing="false" onAction="#switchToIncome" style="-fx-background-color: translucent;" text="Overview" textFill="#382119"> - <font> - <Font name="Arial Bold" size="15.0" /> - </font></Button> - <Button mnemonicParsing="false" onAction="#switchToRecurringTransactions" style="-fx-background-color: translucent;" text="Recurring Transactions" textFill="#382119"> - <font> - <Font name="Arial Bold" size="15.0" /> - </font></Button> - <Button mnemonicParsing="false" style="-fx-background-color: translucent;" text="Budgeting" textFill="#382119"> - <font> - <Font name="Arial" size="15.0" /> - </font></Button> - <Button mnemonicParsing="false" onAction="#switchToEditIncome" style="-fx-background-color: translucent;" text="Edit" textFill="#382119"> - <font> - <Font name="Arial Bold" size="15.0" /> - </font></Button> - </items> - <padding> - <Insets bottom="10.0" left="10.0" right="10.0" top="10.0" /> - </padding> - </ToolBar> - </top> - <center> - <HBox alignment="CENTER" prefHeight="493.0" prefWidth="1400.0" spacing="40.0" BorderPane.alignment="CENTER"> - <BorderPane.margin> - <Insets /> - </BorderPane.margin> - <children> - <VBox alignment="CENTER" prefHeight="509.0" prefWidth="171.0" spacing="10.0"> - <children> - <Text fill="#382119" strokeType="OUTSIDE" strokeWidth="0.0" text="Category"> - <font> - <Font name="Arial" size="25.0" /> - </font> - </Text> - <ChoiceBox fx:id="firstCategory" prefWidth="150.0" /> - <ChoiceBox fx:id="secondCategory" prefWidth="150.0" /> - <ChoiceBox fx:id="thirdCategory" prefWidth="150.0" /> - <ChoiceBox fx:id="fourthCategory" prefWidth="150.0" /> - <ChoiceBox fx:id="fifthCategory" prefWidth="150.0" /> - <ChoiceBox fx:id="sixthCategory" prefWidth="150.0" /> - </children> - </VBox> - <VBox alignment="CENTER" prefHeight="200.0" prefWidth="139.0" spacing="10.0"> - <children> - <Text fill="#382119" strokeType="OUTSIDE" strokeWidth="0.0" text="Expected cost"> - <font> - <Font name="Arial" size="25.0" /> - </font> - </Text> - <TextField fx:id="firstExpected" onAction="#setFirstDiff" prefHeight="25.0" prefWidth="100.0"> - <font> - <Font name="Arial" size="15.0" /> - </font> - </TextField> - <TextField fx:id="secondExpected" onAction="#setSecondDiff" prefHeight="25.0" prefWidth="117.0"> - <font> - <Font name="Arial" size="15.0" /> - </font> - </TextField> - <TextField fx:id="thirdExpected" onAction="#setThirdDiff" prefHeight="25.0" prefWidth="117.0"> - <font> - <Font name="Arial" size="15.0" /> - </font> - </TextField> - <TextField fx:id="fourthExpected" onAction="#setFourthDiff" prefHeight="25.0" prefWidth="117.0"> - <font> - <Font name="Arial" size="15.0" /> - </font> - </TextField> - <TextField fx:id="fifthExpected" onAction="#setFifthDiff" prefHeight="25.0" prefWidth="117.0"> - <font> - <Font name="Arial" size="15.0" /> - </font> - </TextField> - <TextField fx:id="sixthExpected" onAction="#setSixthDiff" prefHeight="25.0" prefWidth="117.0"> - <font> - <Font name="Arial" size="15.0" /> - </font> - </TextField> - </children> - </VBox> - <VBox alignment="CENTER" prefHeight="200.0" prefWidth="100.0" spacing="10.0"> - <children> - <Text fill="#382119" strokeType="OUTSIDE" strokeWidth="0.0" text="Actual cost"> - <font> - <Font name="Arial" size="25.0" /> - </font> - </Text> - <TextField fx:id="firstActual" onAction="#setFirstDiff" prefHeight="25.0" prefWidth="117.0" text="0"> - <font> - <Font name="Arial" size="15.0" /> - </font> - </TextField> - <TextField fx:id="secondActual" onAction="#setSecondDiff" prefHeight="25.0" prefWidth="117.0" text="0"> - <font> - <Font name="Arial" size="15.0" /> - </font> - </TextField> - <TextField fx:id="thirdActual" onAction="#setThirdDiff" prefHeight="25.0" prefWidth="117.0" text="0"> - <font> - <Font name="Arial" size="15.0" /> - </font> - </TextField> - <TextField fx:id="fourthActual" onAction="#setFourthDiff" prefHeight="25.0" prefWidth="117.0" text="0"> - <font> - <Font name="Arial" size="15.0" /> - </font> - </TextField> - <TextField fx:id="fifthActual" onAction="#setFifthDiff" prefHeight="25.0" prefWidth="117.0" text="0"> - <font> - <Font name="Arial" size="15.0" /> - </font> - </TextField> - <TextField fx:id="sixthActual" onAction="#setSixthDiff" prefHeight="25.0" prefWidth="117.0" text="0"> - <font> - <Font name="Arial" size="15.0" /> - </font> - </TextField> - </children> - </VBox> - <VBox alignment="CENTER" prefHeight="200.0" prefWidth="100.0" spacing="18.0"> - <children> - <Text fill="#382119" strokeType="OUTSIDE" strokeWidth="0.0" text="Difference"> - <font> - <Font name="Arial" size="25.0" /> - </font> - </Text> - <Text fx:id="firstDiff" fill="#495635" strokeType="OUTSIDE" strokeWidth="0.0" text="0" textAlignment="RIGHT"> - <font> - <Font name="Arial" size="17.0" /> - </font> - </Text> - <Text fx:id="secondDiff" fill="#495635" strokeType="OUTSIDE" strokeWidth="0.0" text="0" textAlignment="RIGHT"> - <font> - <Font name="Arial" size="17.0" /> - </font> - </Text> - <Text fx:id="thirdDiff" fill="#495635" strokeType="OUTSIDE" strokeWidth="0.0" text="0" textAlignment="RIGHT"> - <font> - <Font name="Arial" size="17.0" /> - </font> - </Text> - <Text fx:id="fourthDiff" fill="#495635" strokeType="OUTSIDE" strokeWidth="0.0" text="0" textAlignment="RIGHT"> - <font> - <Font name="Arial" size="17.0" /> - </font> - </Text> - <Text fx:id="fifthDiff" fill="#495635" strokeType="OUTSIDE" strokeWidth="0.0" text="0" textAlignment="RIGHT"> - <font> - <Font name="Arial" size="17.0" /> - </font> - </Text> - <Text fx:id="sixthDiff" fill="#495635" strokeType="OUTSIDE" strokeWidth="0.0" text="0" textAlignment="RIGHT"> - <font> - <Font name="Arial" size="17.0" /> - </font> - </Text> - </children> - </VBox> - </children> - </HBox> - </center> - </BorderPane> - </center> - <top> - <BorderPane prefHeight="100.0" prefWidth="1400.0" style="-fx-background-color: EC84E2;" BorderPane.alignment="CENTER"> - <right> - <VBox alignment="CENTER" prefHeight="50.0" prefWidth="50.0" spacing="20.0" BorderPane.alignment="CENTER"> - <children> - <Button mnemonicParsing="false" style="-fx-background-color: translucent;"> - <graphic> - <ImageView fitHeight="30.0" fitWidth="30.0" pickOnBounds="true" preserveRatio="true"> - <image> - <Image url="@Icons/Settings.png" /> - </image> - </ImageView> - </graphic> - </Button> - <Button mnemonicParsing="false" onAction="#openHelpOption" style="-fx-background-color: translucent;"> - <graphic> - <ImageView fitHeight="30.0" fitWidth="30.0" pickOnBounds="true" preserveRatio="true"> - <image> - <Image url="@Icons/HelpIcon.png" /> - </image> - </ImageView> - </graphic> - </Button> - </children> - </VBox> - </right> - <left> - <Button mnemonicParsing="false" onAction="#goHome" style="-fx-background-color: translucent;" BorderPane.alignment="CENTER"> - <graphic> - <ImageView fitHeight="100.0" fitWidth="100.0" pickOnBounds="true" preserveRatio="true"> - <image> - <Image url="@Icons/SpendwiseIcon.png" /> - </image> - </ImageView> - </graphic> - </Button> - </left> - <center> - <Label text="Future Budgeting" textFill="#382119" BorderPane.alignment="CENTER"> - <font> - <Font name="Arial Bold" size="45.0" /> - </font> - </Label> - </center> - <padding> - <Insets bottom="20.0" left="20.0" right="20.0" top="20.0" /> - </padding> - </BorderPane> - </top> - <bottom> - <HBox alignment="CENTER" prefHeight="81.0" prefWidth="1400.0" BorderPane.alignment="CENTER"> - <BorderPane.margin> - <Insets /> - </BorderPane.margin> - <children> - <Label prefHeight="36.0" prefWidth="350.0" text="Only use numbers in text fields!" textFill="#ff4530"> - <font> - <Font name="Arial" size="25.0" /> - </font> - </Label> - </children> - </HBox> - </bottom> -</BorderPane> diff --git a/src/main/resources/SpendWiseHomePage.fxml b/src/main/resources/SpendWiseHomePage.fxml index 35ca3523ee191a5510544e016e4a95a0ae90e67c..2edb9ac9734bfae8cb7f14e4a037b8d7bd37a2f7 100644 --- a/src/main/resources/SpendWiseHomePage.fxml +++ b/src/main/resources/SpendWiseHomePage.fxml @@ -137,7 +137,7 @@ </ImageView> </graphic> </Button> - <Button alignment="CENTER" contentDisplay="RIGHT" mnemonicParsing="false" onAction="#switchToFutureBudgeting" prefHeight="100.0" prefWidth="360.0" style="-fx-background-color: F5793A;" text="Budgeting " textFill="#382119" GridPane.columnIndex="1" GridPane.rowIndex="1"> + <Button alignment="CENTER" contentDisplay="RIGHT" mnemonicParsing="false" onAction="#switchToBudgeting" prefHeight="100.0" prefWidth="360.0" style="-fx-background-color: F5793A;" text="Budgeting " textFill="#382119" GridPane.columnIndex="1" GridPane.rowIndex="1"> <font> <Font name="Arial" size="22.0" /> </font> @@ -171,7 +171,7 @@ <Font name="Arial Bold" size="15.0" /> </font> </Button> - <Button mnemonicParsing="false" onAction="#switchToFutureBudgeting" prefHeight="36.0" style="-fx-background-color: translucent;" text="Budgeting" textFill="#382119"> + <Button mnemonicParsing="false" onAction="#switchToBudgeting" prefHeight="36.0" style="-fx-background-color: translucent;" text="Budgeting" textFill="#382119"> <font> <Font name="Arial Bold" size="15.0" /> </font>