Skip to content

Commit

Permalink
feat(PlayerPortfolioComponent): Change labels to show the right info
Browse files Browse the repository at this point in the history
  • Loading branch information
danieskj committed May 14, 2026
1 parent 98b3f06 commit 9336f0d
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
3 changes: 3 additions & 0 deletions src/main/java/edu/ntnu/idi/idatt/view/SceneFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ public static Parent createStartView() {

}
public static Parent createPortfolioView(){

mark(() -> createPortfolioView());

PortfolioModel model = new PortfolioModel();
PortfolioView view = new PortfolioView();
PortfolioController controller = new PortfolioController(model);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.Collections;

Expand All @@ -17,32 +19,28 @@ public PlayerPortfolioComponent(Portfolio portfolio){
this.setMaxSize(Double.MAX_VALUE, 500);
this.getStyleClass().add("light");

Label userTitle = new Label("Name Title");
Label invisibleTitle = new Label(" ");
Label userTitle = new Label(String.format("%s's Portfolio", UserSession.getInstance().getPlayer().getName()));
Label netWorth = new Label();
netWorth.textProperty().bind(
UserSession.getInstance().netWorthProperty().asString("Net Worth: %.2f $"));
Label percentageChange = new Label("Percentage change: ");
Label percentageChange = new Label("Percentage change: "+ UserSession.getInstance().netWorthProperty().doubleValue());
Label playerStatus = new Label("Player status: "+ UserSession.getInstance().getPlayer().getStatus());
Label portfolioWorth = new Label("Portfolio net worth: ");
Label totalShares = new Label("Total shares owned: ");

Label totalShares = new Label("Total shares owned: "+ UserSession.getInstance().getPlayer().getPortfolio().getShares().size());
ArrayList<Label> labels = new ArrayList<>();
Collections.addAll(labels, netWorth, percentageChange, playerStatus, portfolioWorth, totalShares);
Collections.addAll(labels, netWorth, percentageChange, playerStatus, totalShares);
labels.forEach(e -> e.getStyleClass().add("portfolio-box-text"));
userTitle.getStyleClass().add("portfolio-box-title");
invisibleTitle.getStyleClass().add("portfolio-box-title");

UICompositor playerPortfolioComponent = new UICompositor.Builder()
.parent(new HBox())
.growWithAlignment(Pos.CENTER)
.wrap(new VBox())
.addAllContent(userTitle, netWorth, percentageChange, playerStatus)
.addAllContent(userTitle, netWorth, percentageChange)
.unwrap()
.filler()
.wrap(new VBox())
.growWithAlignment(Pos.CENTER)
.addAllContent(portfolioWorth, totalShares)
.growWithAlignment(Pos.BOTTOM_CENTER)
.addAllContent(playerStatus, totalShares)
.unwrap()
.build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,7 @@ public static Parent createMenu(String title, List<String> buttonLables, ActionE

UICompositor.Builder menuBuilder = new UICompositor.Builder()
.parent(new VBox())
.growWithAlignment(Pos.TOP_CENTER)
.properties((menu) -> menu.setPrefSize(300, Double.MAX_VALUE))
.growWithAlignment(Pos.CENTER)
.addContent(menuIcon);

buttons.forEach(b -> menuBuilder.addContent(b));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public Parent createContent() {
VBox.setVgrow(userBox, Priority.ALWAYS);
userBox.setPadding(new Insets(20));
ScrollPane stockBox = new ScrollPane();
stockBox.setPadding(new Insets(10, 10, 20, 20));
stockBox.setPadding(new Insets(0, 10, 0, 20));
shareBox = new VBox(20);

stockBox.setFitToWidth(true);
Expand Down

0 comments on commit 9336f0d

Please sign in to comment.