-
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.
feat: Portfolio-view related classes refactored.
- Loading branch information
Showing
6 changed files
with
266 additions
and
109 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
23 changes: 13 additions & 10 deletions
23
src/main/java/edu/ntnu/idi/idatt/view/primary/portfolio/PortfolioModel.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,19 +1,22 @@ | ||
| package edu.ntnu.idi.idatt.view.primary.portfolio; | ||
|
|
||
| import edu.ntnu.idi.idatt.model.portfolio.Portfolio; | ||
| import edu.ntnu.idi.idatt.view.components.Model; | ||
| import edu.ntnu.idi.idatt.view.components.elements.ShareComponent; | ||
| import edu.ntnu.idi.idatt.view.primary.portfolio.viewmodel.PlayerInfoModel; | ||
| import javafx.collections.FXCollections; | ||
| import javafx.collections.ObservableList; | ||
|
|
||
| public class PortfolioModel implements Model { | ||
| private final ObservableList<ShareComponent> sharesList = FXCollections.observableArrayList(); | ||
| private final Portfolio portfolio = new Portfolio(); | ||
|
|
||
| public Portfolio getPortfolio() { | ||
| return portfolio; | ||
| } | ||
| public ObservableList<ShareComponent> getSharesList(){ | ||
| return sharesList; | ||
| } | ||
| } | ||
| private final ObservableList<ShareComponent> shareList = FXCollections.observableArrayList(); | ||
| private final PlayerInfoModel playerInfoModel = new PlayerInfoModel(); | ||
|
|
||
| public ObservableList<ShareComponent> getShareList() { | ||
| return shareList; | ||
| } | ||
|
|
||
| public PlayerInfoModel playerInfoModel() { | ||
| return playerInfoModel; | ||
| } | ||
|
|
||
| } |
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
75 changes: 75 additions & 0 deletions
75
src/main/java/edu/ntnu/idi/idatt/view/primary/portfolio/sections/PlayerInfoSection.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 |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| package edu.ntnu.idi.idatt.view.primary.portfolio.sections; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| import edu.ntnu.idi.idatt.view.components.elements.TextValueComponent; | ||
| import edu.ntnu.idi.idatt.view.components.ui.UICompositor; | ||
| import javafx.geometry.Insets; | ||
| import javafx.geometry.Pos; | ||
| import javafx.scene.control.Label; | ||
| import javafx.scene.layout.HBox; | ||
| import javafx.scene.layout.Priority; | ||
| import javafx.scene.layout.VBox; | ||
|
|
||
| public class PlayerInfoSection extends VBox { | ||
|
|
||
| Label title = new Label(); | ||
| Label netWorth = new Label(); | ||
| TextValueComponent netWorthTotalChange = new TextValueComponent("Total Net Worth change: "); | ||
| Label playerStatus = new Label(); | ||
| Label totalSharesOwned = new Label(); | ||
|
|
||
| public PlayerInfoSection() { | ||
|
|
||
| title.getStyleClass().add("portfolio-box-title"); | ||
|
|
||
| List<Label> labels = List.of(netWorth, playerStatus, totalSharesOwned); | ||
| labels.forEach(l -> l.getStyleClass().add("portfolio-box-text")); | ||
|
|
||
| new UICompositor.Builder() | ||
| .parent(this) | ||
| .properties((parent) -> { | ||
| VBox.setVgrow(parent, Priority.ALWAYS); | ||
| parent.setPadding(new Insets(20)); | ||
| }) | ||
| .wrap(new HBox()) | ||
| .properties((parent) -> { | ||
| parent.setMaxSize(Double.MAX_VALUE, 500); | ||
| parent.getStyleClass().add("light"); | ||
| parent.setPadding(new Insets(20)); | ||
| }) | ||
| .growWithAlignment(Pos.CENTER) | ||
| .wrap(new VBox()) | ||
| .addAllContent(title, netWorth, netWorthTotalChange) | ||
| .unwrap() | ||
| .filler() | ||
| .wrap(new VBox()) | ||
| .growWithAlignment(Pos.BOTTOM_CENTER) | ||
| .addAllContent(playerStatus, totalSharesOwned) | ||
| .unwrap() | ||
| .unwrap() | ||
| .build(); | ||
|
|
||
| } | ||
|
|
||
| public Label getTitle() { | ||
| return title; | ||
| } | ||
|
|
||
| public Label getNetWorth() { | ||
| return netWorth; | ||
| } | ||
|
|
||
| public TextValueComponent getNetWorthTotalChange() { | ||
| return netWorthTotalChange; | ||
| } | ||
|
|
||
| public Label getPlayerStatus() { | ||
| return playerStatus; | ||
| } | ||
|
|
||
| public Label getTotalSharesOwned() { | ||
| return totalSharesOwned; | ||
| } | ||
|
|
||
| } |
Oops, something went wrong.