-
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 top bar with graph and navigation row
- Loading branch information
Showing
10 changed files
with
333 additions
and
7 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
4 changes: 4 additions & 0 deletions
4
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 |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| package edu.ntnu.idi.idatt2003.g40.mappe.view.ingame; | ||
|
|
||
| public enum InGameActions { | ||
| } |
15 changes: 10 additions & 5 deletions
15
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
5 changes: 5 additions & 0 deletions
5
...n/java/edu/ntnu/idi/idatt2003/g40/mappe/view/widgets/financialsummary/SummaryActions.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,5 @@ | ||
| package edu.ntnu.idi.idatt2003.g40.mappe.view.widgets.financialsummary; | ||
|
|
||
| public enum SummaryActions { | ||
| NEXT_WEEK; | ||
| } |
23 changes: 23 additions & 0 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 |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| package edu.ntnu.idi.idatt2003.g40.mappe.view.widgets.financialsummary; | ||
|
|
||
| import edu.ntnu.idi.idatt2003.g40.mappe.service.event.EventManager; | ||
| import edu.ntnu.idi.idatt2003.g40.mappe.view.ViewController; | ||
|
|
||
| public class SummaryController extends ViewController<SummaryView> { | ||
|
|
||
| /** | ||
| * {@inheritDoc}. | ||
| */ | ||
| public SummaryController(final SummaryView viewElement, | ||
| final EventManager eventManager) | ||
| throws IllegalArgumentException { | ||
| super(viewElement, eventManager); | ||
| } | ||
|
|
||
| @Override | ||
| protected void initInteractions() { | ||
| getViewElement().setOnAction(SummaryActions.NEXT_WEEK, () -> { | ||
| System.out.println("Next week!"); | ||
| }); | ||
| } | ||
| } |
106 changes: 106 additions & 0 deletions
106
...main/java/edu/ntnu/idi/idatt2003/g40/mappe/view/widgets/financialsummary/SummaryView.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,106 @@ | ||
| package edu.ntnu.idi.idatt2003.g40.mappe.view.widgets.financialsummary; | ||
|
|
||
| import edu.ntnu.idi.idatt2003.g40.mappe.view.ViewElement; | ||
| 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.layout.HBox; | ||
| import javafx.scene.layout.Priority; | ||
| import javafx.scene.layout.Region; | ||
| import javafx.scene.layout.VBox; | ||
|
|
||
| public class SummaryView extends ViewElement<HBox, SummaryActions> { | ||
| private Label balanceLabel; | ||
| private Label weekLabel; | ||
| private Label titleLabel; | ||
| private LineChart<Number, Number> chart; | ||
| private XYChart.Series<Number, Number> dataSeries; | ||
| private Button nextBtn; | ||
|
|
||
| public SummaryView() { | ||
| super(new HBox(), SummaryActions.class); | ||
| } | ||
|
|
||
| @Override | ||
| protected void initLayout() { | ||
| getRootPane().setSpacing(20); | ||
| getRootPane().setAlignment(Pos.BOTTOM_CENTER); | ||
| getRootPane().setFillHeight(false); | ||
|
|
||
| VBox balanceInfo = new VBox(); | ||
|
|
||
| titleLabel = new Label("balance/investments"); | ||
| balanceLabel = new Label("200$/2394$"); | ||
|
|
||
| balanceInfo.getChildren().addAll(titleLabel, balanceLabel); | ||
|
|
||
| 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(100); | ||
| chart.setMinHeight(100); | ||
| chart.setMaxHeight(100); | ||
|
|
||
| Region spacer = new Region(); | ||
| HBox.setHgrow(spacer, Priority.ALWAYS); | ||
| HBox.setHgrow(chart, Priority.ALWAYS); | ||
|
|
||
| Region leftSpacer = new Region(); | ||
| HBox.setHgrow(leftSpacer, Priority.SOMETIMES); | ||
|
|
||
| dataSeries = new XYChart.Series<>(); | ||
| chart.prefHeightProperty().bind(getRootPane().heightProperty().divide(5)); | ||
| chart.minHeightProperty().set(50); | ||
| chart.getData().add(dataSeries); | ||
|
|
||
| VBox navInfo = new VBox(); | ||
| navInfo.setAlignment(Pos.BOTTOM_RIGHT); | ||
|
|
||
| nextBtn = new Button("next"); | ||
|
|
||
| weekLabel = new Label("week: 0"); | ||
| weekLabel.getStyleClass().add("week-label"); | ||
|
|
||
| navInfo.getChildren().addAll(nextBtn, weekLabel); | ||
|
|
||
| getRootPane().getChildren().addAll(balanceInfo, chart, navInfo); | ||
| registerButton(SummaryActions.NEXT_WEEK, nextBtn); | ||
| } | ||
|
|
||
| @Override | ||
| protected void initStyling() { | ||
| getRootPane().getStyleClass().add("summary-container"); | ||
| titleLabel.getStyleClass().add("balance-title"); | ||
| balanceLabel.getStyleClass().add("balance-value"); | ||
| nextBtn.getStyleClass().add("next-button"); | ||
| } | ||
|
|
||
| public void setBalance(final String text) { | ||
| balanceLabel.setText(text); | ||
| } | ||
|
|
||
| public void setWeek(int week) { | ||
| weekLabel.setText("week: " + week); | ||
| } | ||
|
|
||
| public void updateChart(double x, double y) { | ||
| dataSeries.getData().add(new XYChart.Data<>(x, y)); | ||
| } | ||
| } |
8 changes: 8 additions & 0 deletions
8
src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/view/widgets/topbar/TopBarActions.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,8 @@ | ||
| package edu.ntnu.idi.idatt2003.g40.mappe.view.widgets.topbar; | ||
|
|
||
| public enum TopBarActions { | ||
| EXIT, | ||
| STATS, | ||
| MARKET, | ||
| SETTINGS; | ||
| } |
21 changes: 21 additions & 0 deletions
21
src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/view/widgets/topbar/TopBarController.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.widgets.topbar; | ||
|
|
||
| import edu.ntnu.idi.idatt2003.g40.mappe.service.event.EventManager; | ||
| import edu.ntnu.idi.idatt2003.g40.mappe.view.ViewController; | ||
| import edu.ntnu.idi.idatt2003.g40.mappe.view.ViewEnum; | ||
|
|
||
| public class TopBarController extends ViewController<TopBarView> { | ||
|
|
||
| /** | ||
| * {@inheritDoc}. | ||
| */ | ||
| public TopBarController(final TopBarView viewElement, final EventManager eventManager) | ||
| throws IllegalArgumentException { | ||
| super(viewElement, eventManager); | ||
| } | ||
|
|
||
| @Override | ||
| protected void initInteractions() { | ||
| getViewElement().setOnAction(TopBarActions.EXIT, () -> changeScene(ViewEnum.MAIN_MENU)); | ||
| } | ||
| } |
56 changes: 56 additions & 0 deletions
56
src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/view/widgets/topbar/TopBarView.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,56 @@ | ||
| package edu.ntnu.idi.idatt2003.g40.mappe.view.widgets.topbar; | ||
|
|
||
| import edu.ntnu.idi.idatt2003.g40.mappe.view.ViewElement; | ||
| import edu.ntnu.idi.idatt2003.g40.mappe.view.widgets.financialsummary.SummaryView; | ||
| import javafx.geometry.Pos; | ||
| import javafx.scene.control.Button; | ||
| import javafx.scene.layout.HBox; | ||
| import javafx.scene.layout.VBox; | ||
|
|
||
| import java.util.stream.Stream; | ||
|
|
||
| public class TopBarView extends ViewElement<VBox, TopBarActions> { | ||
| private Button quitBtn; | ||
| private Button statsBtn; | ||
| private Button marketBtn; | ||
| private Button settingsBtn; | ||
| private final SummaryView summaryView; | ||
|
|
||
| public TopBarView(final SummaryView summaryView) { | ||
| this.summaryView = summaryView; | ||
| super(new VBox(10), TopBarActions.class); | ||
| } | ||
|
|
||
| @Override | ||
| protected void initLayout() { | ||
| HBox navRow = new HBox(20); | ||
| navRow.setAlignment(Pos.CENTER); | ||
|
|
||
| quitBtn = new Button("Quit"); | ||
| statsBtn = new Button("Stats"); | ||
| marketBtn = new Button("Market"); | ||
| settingsBtn = new Button("Settings"); | ||
|
|
||
| navRow.getChildren().addAll( | ||
| quitBtn, | ||
| statsBtn, | ||
| marketBtn, | ||
| settingsBtn | ||
| ); | ||
|
|
||
| getRootPane().getChildren().addAll(navRow, summaryView.getRootPane()); | ||
|
|
||
| registerButton(TopBarActions.EXIT, quitBtn); | ||
| registerButton(TopBarActions.STATS, statsBtn); | ||
| registerButton(TopBarActions.MARKET, marketBtn); | ||
| registerButton(TopBarActions.SETTINGS, settingsBtn); | ||
|
|
||
| } | ||
|
|
||
| @Override | ||
| protected void initStyling() { | ||
| getRootPane().getStyleClass().add("top-bar"); // For your CSS file | ||
| Stream.of(quitBtn, statsBtn, marketBtn, settingsBtn) | ||
| .forEach(b -> b.getStyleClass().add("menu-button")); | ||
| } | ||
| } |
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