-
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: Updated Top bar and Stats page
Stats page and top bar now has graphs that change over weeks and value changes
- Loading branch information
Showing
8 changed files
with
198 additions
and
74 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
1 change: 1 addition & 0 deletions
1
src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/view/ViewElement.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
23 changes: 21 additions & 2 deletions
23
...ava/edu/ntnu/idi/idatt2003/g40/mappe/view/widgets/financialsummary/SummaryController.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,31 +1,50 @@ | ||
| package edu.ntnu.idi.idatt2003.g40.mappe.view.widgets.financialsummary; | ||
|
|
||
| import edu.ntnu.idi.idatt2003.g40.mappe.engine.Exchange; | ||
| import edu.ntnu.idi.idatt2003.g40.mappe.model.Player; | ||
| import edu.ntnu.idi.idatt2003.g40.mappe.service.event.EventManager; | ||
| import edu.ntnu.idi.idatt2003.g40.mappe.view.ViewController; | ||
| import java.math.BigDecimal; | ||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
|
|
||
| public class SummaryController extends ViewController<SummaryView> { | ||
|
|
||
| private Exchange exchange; | ||
| private Player player; | ||
| private List<Float> playerNetWorthHistory; | ||
|
|
||
| /** | ||
| * {@inheritDoc}. | ||
| */ | ||
| public SummaryController(final SummaryView viewElement, | ||
| final EventManager eventManager, | ||
| final Exchange exchange) | ||
| final Exchange exchange, | ||
| final Player player) | ||
| throws IllegalArgumentException { | ||
| this.exchange = exchange; | ||
| this.player = player; | ||
| this.playerNetWorthHistory = new ArrayList<>(); | ||
| super(viewElement, eventManager); | ||
| getViewElement().setBalance(player.getStartingMoney().floatValue(), player.getStartingMoney().floatValue()); | ||
| } | ||
|
|
||
| @Override | ||
| protected void initInteractions() { | ||
| playerNetWorthHistory.add(player.getNetWorth().floatValue()); | ||
| getViewElement().setOnAction(SummaryActions.NEXT_WEEK, () -> { | ||
| exchange.nextWeek(); | ||
| exchange.advance(); | ||
| }); | ||
|
|
||
| exchange.weekProperty().addListener((observable, o, n) -> { | ||
| getViewElement().setWeek((Integer) n); | ||
| playerNetWorthHistory.add(player.getNetWorth().floatValue()); | ||
| getViewElement().updateChart(playerNetWorthHistory); | ||
| getViewElement().setBalance(player.getMoney().floatValue(), player.getNetWorth().floatValue()); | ||
| }); | ||
|
|
||
| player.getNetWorthAsFloatProperty().addListener((observable, o, n) -> { | ||
| getViewElement().setBalance(player.getMoney().floatValue(), player.getNetWorth().floatValue()); | ||
| }); | ||
| } | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,5 +2,6 @@ | |
|
|
||
| public enum StatsActions { | ||
| BUY_SHARES, | ||
| SELL_SHARES; | ||
| SELL_SHARES, | ||
| SELECT_STOCK; | ||
| } | ||
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
Oops, something went wrong.