diff --git a/src/main/java/no/ntnu/idatt1002/demo/controller/BudgetController.java b/src/main/java/no/ntnu/idatt1002/demo/controller/BudgetController.java index 68c7d89c85f8648319884c5d99a2c388fd18cc22..6745be1c116c99277f1e7598fd0a0d55ca80961e 100644 --- a/src/main/java/no/ntnu/idatt1002/demo/controller/BudgetController.java +++ b/src/main/java/no/ntnu/idatt1002/demo/controller/BudgetController.java @@ -83,10 +83,12 @@ public class BudgetController extends FinanceController { private PieChart budgetPieChart; @FXML - private Label daysLeftLbl; + private Label disposableAmount; - BudgetRegister budgetRegister = new BudgetRegister(); + @FXML + private Label amountLeft; + BudgetRegister budgetRegister; /** * Initializes the budget register, the observable budget list and the tableview, along with the values of the dropbox used for filtering the tableview. @@ -115,7 +117,7 @@ public class BudgetController extends FinanceController { .readBudgetArchive("budgets/Archive"); } - //Refresh piecharts only if the budget is old + //Refresh pie charts only if the budget is old if (!FileHandlingBudget.isNewBudget( "budgets/" + FileHandlingSelectedBudget. readSelectedBudget("budgets/SelectedBudget") + "/Budget")) { @@ -125,7 +127,10 @@ public class BudgetController extends FinanceController { ioe.printStackTrace(); showErrorDialogBox(ioe.getMessage(), ioe.getMessage(), ioe.getMessage()); } + //Set calendar, disposable amount and amount left formatDatePicker(); + disposableAmount.setText(String.valueOf(general.getMaxAmount())); + amountLeft.setText(String.valueOf(general.getMaxAmount())); } /** @@ -243,6 +248,7 @@ public class BudgetController extends FinanceController { //Updates the tableview and pie chart using the register refreshTableView(); refreshPieChart(); + refreshAmountLeft(); } @@ -267,6 +273,7 @@ public class BudgetController extends FinanceController { general.deleteItemFromBudget(item.getBudgetCategory()); refreshTableView(); refreshPieChart(); + refreshAmountLeft(); } } @@ -279,6 +286,13 @@ public class BudgetController extends FinanceController { this.budgetList.setAll(general.getBudgetItems()); } + /** + * Method for synching the amount left to the sum of budget items in the table view. + */ + private void refreshAmountLeft() { + amountLeft.setText(String.valueOf(general.getMaxAmount() - general.totalSum())); + } + /** * Saves the changes made to the tableview by writing the information to a file. * diff --git a/src/main/java/no/ntnu/idatt1002/demo/data/Budget/FileHandlingBudgetArchive.java b/src/main/java/no/ntnu/idatt1002/demo/data/Budget/FileHandlingBudgetArchive.java index 5bef228d32a349d7ea8f7331a6906d005959054d..fe1cc796bf356f1b3c0ceb390161901db0d16359 100644 --- a/src/main/java/no/ntnu/idatt1002/demo/data/Budget/FileHandlingBudgetArchive.java +++ b/src/main/java/no/ntnu/idatt1002/demo/data/Budget/FileHandlingBudgetArchive.java @@ -13,7 +13,6 @@ import java.io.IOException; //close button i first menu //remove printstackstraces //HVIS CONTINUE I BUDGET PRESSES, SHOWCONFIRMATION -//VIKTIG_ BALANCE LABEL ER RØD PÅ GRØNN BAKGRUNN!!! //Binde label to total balance i budget window (newBUdgetBert) //En delete funksjon i select old budget //Endre pakkenavn @@ -21,7 +20,6 @@ import java.io.IOException; //Popup for edit og delete button //confirmation for når returnBtn som returner til start. "Are you sure you want to go back. Changes will not be saved" // FIKSE TRY CATCHES I ALLE METODENE!!!!!!!!!! -//tester for nye filklasser //set all windows unresizable //Bytte oversikt på dualList til Monthly .... diff --git a/src/main/resources/view/newBudgetBudgert.fxml b/src/main/resources/view/newBudgetBudgert.fxml index 227a1d3e1ee6a67e9818aee013a663e80e957ab8..2e883a20eba1bcdca5f45dd7a94d2827c79f799c 100644 --- a/src/main/resources/view/newBudgetBudgert.fxml +++ b/src/main/resources/view/newBudgetBudgert.fxml @@ -1,15 +1,29 @@ <?xml version="1.0" encoding="UTF-8"?> -<?import javafx.geometry.*?> -<?import javafx.scene.*?> -<?import javafx.scene.chart.*?> -<?import javafx.scene.control.*?> -<?import javafx.scene.image.*?> -<?import javafx.scene.layout.*?> -<?import javafx.scene.shape.*?> -<?import javafx.scene.text.*?> +<?import javafx.geometry.Insets?> +<?import javafx.scene.Cursor?> +<?import javafx.scene.chart.PieChart?> +<?import javafx.scene.control.Button?> +<?import javafx.scene.control.ComboBox?> +<?import javafx.scene.control.DatePicker?> +<?import javafx.scene.control.Label?> +<?import javafx.scene.control.TableColumn?> +<?import javafx.scene.control.TableView?> +<?import javafx.scene.image.Image?> +<?import javafx.scene.image.ImageView?> +<?import javafx.scene.layout.AnchorPane?> +<?import javafx.scene.layout.ColumnConstraints?> +<?import javafx.scene.layout.GridPane?> +<?import javafx.scene.layout.HBox?> +<?import javafx.scene.layout.Pane?> +<?import javafx.scene.layout.RowConstraints?> +<?import javafx.scene.layout.StackPane?> +<?import javafx.scene.layout.VBox?> +<?import javafx.scene.shape.Rectangle?> +<?import javafx.scene.text.Font?> +<?import javafx.scene.text.Text?> -<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="500.0" prefWidth="750.0" xmlns="http://javafx.com/javafx/17.0.2-ea" xmlns:fx="http://javafx.com/fxml/1" fx:controller="no.ntnu.idatt1002.demo.controller.BudgetController"> +<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="500.0" prefWidth="750.0" xmlns="http://javafx.com/javafx/19" xmlns:fx="http://javafx.com/fxml/1" fx:controller="no.ntnu.idatt1002.demo.controller.BudgetController"> <children> <ImageView fitHeight="500.0" fitWidth="750.0" pickOnBounds="true"> <image> @@ -48,22 +62,27 @@ <children> <HBox alignment="CENTER" spacing="10.0" GridPane.columnIndex="1" GridPane.rowIndex="1"> <children> - <PieChart fx:id="budgetPieChart" legendSide="RIGHT" maxHeight="444.0" maxWidth="512.0" prefHeight="302.0" prefWidth="354.0" /> + <PieChart fx:id="budgetPieChart" legendSide="RIGHT" maxHeight="444.0" maxWidth="512.0" prefHeight="297.0" prefWidth="330.0" /> </children> </HBox> <StackPane alignment="CENTER_LEFT" prefWidth="375.0" GridPane.rowIndex="2" GridPane.rowSpan="2147483647"> <children> <Rectangle arcHeight="5.0" arcWidth="5.0" fill="#f8f8f8" height="26.0" stroke="#d9cccc" strokeLineCap="ROUND" strokeType="INSIDE" width="350.0" /> - <HBox alignment="CENTER_LEFT" minHeight="15.0" prefHeight="36.0" prefWidth="345.0"> + <HBox alignment="CENTER_LEFT" minHeight="15.0" prefHeight="36.0" prefWidth="345.0" spacing="10.0"> <children> - <Text strokeType="OUTSIDE" strokeWidth="0.0" text="Overview: (used of disposal)"> + <Text strokeType="OUTSIDE" strokeWidth="0.0" text="Left:"> <HBox.margin> <Insets left="3.0" /> </HBox.margin> <font> - <Font size="14.0" /> + <Font name="Lucida Console" size="14.0" /> </font> </Text> + <Label fx:id="amountLeft" text="Label"> + <font> + <Font name="Lucida Console" size="14.0" /> + </font> + </Label> </children> </HBox> </children> @@ -137,15 +156,20 @@ </HBox> </children> </GridPane> - <HBox alignment="CENTER" GridPane.columnIndex="1"> + <VBox alignment="CENTER" GridPane.columnIndex="1"> <children> - <Label alignment="CENTER" prefHeight="20.0" prefWidth="533.0" styleClass="font" stylesheets="@../style.css" text="Amount at disposal: 1000"> + <Label alignment="CENTER" prefHeight="20.0" prefWidth="533.0" styleClass="font" stylesheets="@../style.css" text="Amount at disposal:"> + <font> + <Font size="24.0" /> + </font> + </Label> + <Label fx:id="disposableAmount" text="Label"> <font> - <Font size="18.0" /> + <Font name="Lucida Console" size="18.0" /> </font> </Label> </children> - </HBox> + </VBox> <TableView fx:id="budgetTableView" maxHeight="450.0" prefHeight="305.0" prefWidth="340.0" GridPane.rowIndex="1"> <columns> <TableColumn fx:id="categoryCol" prefWidth="75.0" text="Category" />