-
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: Added new UI for the ingame view
- Loading branch information
Showing
11 changed files
with
332 additions
and
34 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
2 changes: 2 additions & 0 deletions
2
src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/view/ingame/InGameActions.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,4 +1,6 @@ | ||
| package edu.ntnu.idi.idatt2003.g40.mappe.view.ingame; | ||
|
|
||
| public enum InGameActions { | ||
| BUY_SHARES, | ||
| SELL_SHARES; | ||
| } |
21 changes: 21 additions & 0 deletions
21
src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/view/ingame/InGameController.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,21 @@ | ||
| package edu.ntnu.idi.idatt2003.g40.mappe.view.ingame; | ||
|
|
||
| import edu.ntnu.idi.idatt2003.g40.mappe.service.event.EventManager; | ||
| import edu.ntnu.idi.idatt2003.g40.mappe.view.ViewController; | ||
|
|
||
| public class InGameController extends ViewController<InGameView> { | ||
|
|
||
| /** | ||
| * {@inheritDoc}. | ||
| */ | ||
| protected InGameController(final InGameView viewElement, | ||
| final EventManager eventManager) | ||
| throws IllegalArgumentException { | ||
| super(viewElement, eventManager); | ||
| } | ||
|
|
||
| @Override | ||
| protected void initInteractions() { | ||
|
|
||
| } | ||
| } |
30 changes: 26 additions & 4 deletions
30
src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/view/ingame/InGameView.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,27 +1,49 @@ | ||
| package edu.ntnu.idi.idatt2003.g40.mappe.view.ingame; | ||
|
|
||
| import edu.ntnu.idi.idatt2003.g40.mappe.model.Stock; | ||
| import edu.ntnu.idi.idatt2003.g40.mappe.view.ViewElement; | ||
| import edu.ntnu.idi.idatt2003.g40.mappe.view.ViewEnum; | ||
| import edu.ntnu.idi.idatt2003.g40.mappe.view.widgets.topbar.TopBarView; | ||
| import javafx.geometry.Pos; | ||
| import javafx.scene.Node; | ||
| import javafx.scene.chart.LineChart; | ||
| import javafx.scene.chart.NumberAxis; | ||
| import javafx.scene.chart.XYChart; | ||
| import javafx.scene.control.Button; | ||
| import javafx.scene.control.Label; | ||
| import javafx.scene.control.Separator; | ||
| import javafx.scene.layout.HBox; | ||
| import javafx.scene.layout.Priority; | ||
| import javafx.scene.layout.VBox; | ||
|
|
||
| import java.util.ArrayList; | ||
|
|
||
| public class InGameView extends ViewElement<VBox, InGameActions> { | ||
|
|
||
| TopBarView topBarView; | ||
| private final TopBarView topBarView; | ||
| private Node centerView; | ||
|
|
||
| public InGameView(final TopBarView topBarView) { | ||
| public InGameView(final TopBarView topBarView, final Node centerView) { | ||
| this.topBarView = topBarView; | ||
| this.centerView = centerView; | ||
| super(new VBox(), ViewEnum.IN_GAME, InGameActions.class); | ||
|
|
||
| } | ||
|
|
||
| @Override | ||
| protected void initLayout() { | ||
| getRootPane().getChildren().add(topBarView.getRootPane()); | ||
| getRootPane().getChildren().addAll(topBarView.getRootPane(), centerView); | ||
| VBox.setVgrow(centerView, Priority.ALWAYS); | ||
| } | ||
|
|
||
| @Override | ||
| protected void initStyling() { | ||
|
|
||
| } | ||
|
|
||
| public void changeCenterView(final Node newCenterView) { | ||
| this.centerView = newCenterView; | ||
| getRootPane().getChildren().clear(); | ||
| getRootPane().getChildren().addAll(topBarView.getRootPane(), centerView); | ||
| VBox.setVgrow(centerView, Priority.ALWAYS); | ||
| } | ||
| } |
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
6 changes: 6 additions & 0 deletions
6
src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/view/widgets/stats/StatsActions.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,6 @@ | ||
| package edu.ntnu.idi.idatt2003.g40.mappe.view.widgets.stats; | ||
|
|
||
| public enum StatsActions { | ||
| BUY_SHARES, | ||
| SELL_SHARES; | ||
| } |
4 changes: 4 additions & 0 deletions
4
src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/view/widgets/stats/StatsController.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,4 @@ | ||
| package edu.ntnu.idi.idatt2003.g40.mappe.view.widgets.stats; | ||
|
|
||
| public class StatsController { | ||
| } |
145 changes: 145 additions & 0 deletions
145
src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/view/widgets/stats/StatsView.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,145 @@ | ||
| package edu.ntnu.idi.idatt2003.g40.mappe.view.widgets.stats; | ||
|
|
||
| import edu.ntnu.idi.idatt2003.g40.mappe.model.Stock; | ||
| import edu.ntnu.idi.idatt2003.g40.mappe.view.ViewElement; | ||
| import java.util.ArrayList; | ||
| import javafx.geometry.Pos; | ||
| import javafx.scene.chart.LineChart; | ||
| import javafx.scene.chart.NumberAxis; | ||
| import javafx.scene.chart.XYChart; | ||
| import javafx.scene.control.Button; | ||
| import javafx.scene.control.Label; | ||
| import javafx.scene.control.ScrollBar; | ||
| import javafx.scene.control.ScrollPane; | ||
| import javafx.scene.layout.HBox; | ||
| import javafx.scene.layout.Priority; | ||
| import javafx.scene.layout.VBox; | ||
|
|
||
| public class StatsView extends ViewElement<HBox, StatsActions> { | ||
| private LineChart<Number, Number> chart; | ||
| private XYChart.Series<Number, Number> dataSeries; | ||
| private VBox sidebar; | ||
| private ArrayList<Stock> stocks; | ||
| private ArrayList<String> stockStrings; | ||
| private ArrayList<Button> stockButtons; | ||
| private Label selectedStock; | ||
|
|
||
| public StatsView() { | ||
| super(new HBox(), StatsActions.class); | ||
| } | ||
|
|
||
| @Override | ||
| protected void initLayout() { | ||
| getRootPane().setAlignment(Pos.TOP_LEFT); | ||
| getRootPane().setFillHeight(true); | ||
|
|
||
| sidebar = new VBox(10); | ||
| sidebar.setPrefWidth(150); | ||
| sidebar.setMaxHeight(Double.MAX_VALUE); | ||
| VBox.setVgrow(sidebar, Priority.ALWAYS); | ||
|
|
||
| stocks = new ArrayList<>(); | ||
|
|
||
| stockStrings = new ArrayList<>(); | ||
| stockStrings.add("AAPL"); | ||
| stockStrings.add("AALL"); | ||
| stockStrings.add("NVID"); | ||
| stockStrings.add("NVID"); | ||
| stockStrings.add("NVID"); | ||
| stockStrings.add("NVID"); | ||
| stockStrings.add("NVID"); | ||
| stockStrings.add("NVID"); | ||
| stockStrings.add("NVID"); | ||
| stockStrings.add("NVID"); | ||
| stockStrings.add("NVID"); | ||
| stockStrings.add("NVID"); | ||
| stockStrings.add("NVID"); | ||
| stockStrings.add("NVID"); | ||
| stockStrings.add("NVID"); | ||
| stockStrings.add("NVID"); | ||
| stockStrings.add("NVID"); | ||
| stockStrings.add("NVID"); | ||
| stockStrings.add("NVID"); | ||
| stockStrings.add("NVID"); | ||
| stockStrings.add("NVID"); | ||
|
|
||
|
|
||
|
|
||
| stockButtons = new ArrayList<>(); | ||
| for (String t : stockStrings) { | ||
| Button btn = new Button(t); | ||
| stockButtons.add(btn); | ||
| sidebar.getChildren().add(btn); | ||
| } | ||
| ScrollPane scrollPane = new ScrollPane(sidebar); | ||
|
|
||
| scrollPane.setFitToWidth(true); | ||
| scrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER); | ||
| scrollPane.setVbarPolicy(ScrollPane.ScrollBarPolicy.AS_NEEDED); | ||
|
|
||
| VBox.setVgrow(scrollPane, Priority.ALWAYS); | ||
| scrollPane.setMaxHeight(Double.MAX_VALUE); | ||
|
|
||
| VBox mainContent = new VBox(20); | ||
| mainContent.setAlignment(Pos.CENTER); | ||
| HBox.setHgrow(mainContent, Priority.ALWAYS); | ||
| mainContent.setMaxHeight(Double.MAX_VALUE); | ||
| VBox.setVgrow(mainContent, Priority.ALWAYS); | ||
|
|
||
| selectedStock = new Label("APL"); | ||
|
|
||
| NumberAxis xAxis = new NumberAxis(1, 22, 1); | ||
| xAxis.setMinorTickVisible(false); | ||
| xAxis.setTickMarkVisible(true); | ||
| xAxis.setTickLabelsVisible(true); | ||
|
|
||
| NumberAxis yAxis = new NumberAxis(); | ||
| yAxis.setTickLabelsVisible(false); | ||
| yAxis.setTickMarkVisible(false); | ||
| yAxis.setMinorTickVisible(false); | ||
|
|
||
| chart = new LineChart<>(xAxis, yAxis); | ||
| chart.setCreateSymbols(false); | ||
| chart.setLegendVisible(false); | ||
| chart.setHorizontalGridLinesVisible(false); | ||
| chart.setVerticalGridLinesVisible(false); | ||
| chart.setAlternativeRowFillVisible(false); | ||
| chart.setAnimated(false); | ||
| chart.setPrefHeight(250); | ||
| chart.setMinHeight(200); | ||
| chart.setMaxHeight(300); | ||
| chart.setMaxWidth(Double.MAX_VALUE); | ||
| chart.setMinWidth(0); | ||
| dataSeries = new XYChart.Series<>(); | ||
| chart.prefHeightProperty().bind(getRootPane().heightProperty().divide(5)); | ||
| chart.minHeightProperty().set(50); | ||
| chart.getData().add(dataSeries); | ||
|
|
||
| // Trade Buttons Row | ||
| HBox tradeActions = new HBox(); | ||
| tradeActions.setAlignment(Pos.CENTER); | ||
| tradeActions.setSpacing(300); // Push buy/sell to opposite sides | ||
|
|
||
| Button buyBtn = new Button("buy"); | ||
| buyBtn.getStyleClass().add("buy-button"); | ||
| registerButton(StatsActions.BUY_SHARES, buyBtn); | ||
|
|
||
| Button sellBtn = new Button("sell"); | ||
| sellBtn.getStyleClass().add("sell-button"); | ||
| registerButton(StatsActions.SELL_SHARES, sellBtn); | ||
|
|
||
| tradeActions.getChildren().addAll(buyBtn, sellBtn); | ||
|
|
||
| mainContent.getChildren().addAll(selectedStock, chart, tradeActions); | ||
| getRootPane().getChildren().addAll(scrollPane, mainContent); | ||
| } | ||
|
|
||
| @Override | ||
| protected void initStyling() { | ||
| sidebar.getStyleClass().add("market-sidebar"); | ||
| for (Button b : stockButtons) { | ||
| b.getStyleClass().add("stock-button"); | ||
| } | ||
| selectedStock.getStyleClass().add("selected-stock-pill"); | ||
| } | ||
| } |
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.