-
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.
Merge branch 'dev' into ui-portfolio-logic
- Loading branch information
Showing
10 changed files
with
175 additions
and
6 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
33 changes: 33 additions & 0 deletions
33
src/main/java/edu/ntnu/idi/idatt/view/components/elements/NewspaperComponent.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,33 @@ | ||
| package edu.ntnu.idi.idatt.view.components.elements; | ||
|
|
||
| import edu.ntnu.idi.idatt.model.portfolio.Share; | ||
| 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.VBox; | ||
|
|
||
| public class NewspaperComponent extends HBox { | ||
| private final Label newsTitle; | ||
| private final Label newsText; | ||
|
|
||
| public NewspaperComponent(Share share) { | ||
| this.setPadding(new Insets(30)); | ||
| this.getStyleClass().add("newspaper-article"); | ||
|
|
||
| newsTitle = new Label("Earthquake in Norway"); | ||
| newsText = new Label("Intel are crashing"); | ||
| newsTitle.getStyleClass().add("newspaper-title"); | ||
| newsText.getStyleClass().add("newspaper-med-text"); | ||
|
|
||
| UICompositor shareComponent = new UICompositor.Builder() | ||
| .parent(new VBox()) | ||
| .growWithAlignment(Pos.TOP_CENTER) | ||
| .addAllContent(newsTitle, newsText) | ||
| .build(); | ||
|
|
||
| this.getChildren().add(shareComponent.makeUI()); | ||
| } | ||
|
|
||
| } |
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
24 changes: 24 additions & 0 deletions
24
src/main/java/edu/ntnu/idi/idatt/view/primary/newspaper/NewspaperController.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,24 @@ | ||
| package edu.ntnu.idi.idatt.view.primary.newspaper; | ||
|
|
||
| import edu.ntnu.idi.idatt.model.portfolio.Share; | ||
| import edu.ntnu.idi.idatt.session.UserSession; | ||
| import edu.ntnu.idi.idatt.view.components.AbstractController; | ||
| import edu.ntnu.idi.idatt.view.components.elements.NewspaperComponent; | ||
|
|
||
| import java.util.ArrayList; | ||
|
|
||
| public class NewspaperController extends AbstractController<NewspaperModel> { | ||
|
|
||
| private final ArrayList<NewspaperComponent> loadedNewspaperComponents = new ArrayList<>(); | ||
| private UserSession session = UserSession.getInstance(); | ||
|
|
||
| public NewspaperController(NewspaperModel model) { | ||
| super(model); | ||
| for (Share share : session.getPlayer().getPortfolio().getShares()) { | ||
| NewspaperComponent newspaperComponent = new NewspaperComponent(share); | ||
| loadedNewspaperComponents.add(newspaperComponent); | ||
| } | ||
| model.getNewspaperComponentsList().setAll(loadedNewspaperComponents); | ||
| } | ||
|
|
||
| } |
14 changes: 14 additions & 0 deletions
14
src/main/java/edu/ntnu/idi/idatt/view/primary/newspaper/NewspaperModel.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,14 @@ | ||
| package edu.ntnu.idi.idatt.view.primary.newspaper; | ||
|
|
||
| import edu.ntnu.idi.idatt.view.components.Model; | ||
| import edu.ntnu.idi.idatt.view.components.elements.NewspaperComponent; | ||
| import javafx.collections.FXCollections; | ||
| import javafx.collections.ObservableList; | ||
|
|
||
| public class NewspaperModel implements Model { | ||
| private final ObservableList<NewspaperComponent> newspaperComponentsList = FXCollections.observableArrayList(); | ||
|
|
||
| public ObservableList<NewspaperComponent> getNewspaperComponentsList() { | ||
| return newspaperComponentsList; | ||
| } | ||
| } |
61 changes: 61 additions & 0 deletions
61
src/main/java/edu/ntnu/idi/idatt/view/primary/newspaper/NewspaperView.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,61 @@ | ||
| package edu.ntnu.idi.idatt.view.primary.newspaper; | ||
|
|
||
| import edu.ntnu.idi.idatt.view.SceneFactory; | ||
| import edu.ntnu.idi.idatt.view.SceneManager; | ||
| import edu.ntnu.idi.idatt.view.components.AbstractViewUI; | ||
| import edu.ntnu.idi.idatt.view.components.ui.UIFactory; | ||
| import javafx.beans.binding.Bindings; | ||
| import javafx.geometry.Pos; | ||
| import javafx.scene.Parent; | ||
| import javafx.scene.layout.BorderPane; | ||
| import javafx.scene.layout.VBox; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| public class NewspaperView extends AbstractViewUI { | ||
| private VBox article; | ||
| @Override | ||
| public Parent createContent() { | ||
| BorderPane root = new BorderPane(); | ||
| root.getStyleClass().add("primary"); | ||
| article = new VBox(); | ||
| article.setFillWidth(false); | ||
| article.setAlignment(Pos.TOP_CENTER); | ||
| root.setCenter(article); | ||
| return root; | ||
| } | ||
|
|
||
| @Override | ||
| public Parent createNavigation() { | ||
| return UIFactory.createNavigation(" Newspaper", | ||
| List.of(" • Newspaper"), | ||
| () -> SceneManager.switchTo(SceneFactory.createNewspaperView())); | ||
| } | ||
|
|
||
| @Override | ||
| public Parent createHeader() { | ||
| return UIFactory.createHeader("Search", | ||
| query -> System.out.println()); | ||
| } | ||
|
|
||
| @Override | ||
| public Parent createToolbar() { | ||
| return UIFactory.createToolbar(() -> this.toggleMenu(), | ||
| () -> SceneManager.switchTo(SceneFactory.createStartView())); | ||
| } | ||
|
|
||
| @Override | ||
| public Parent createMenu() { | ||
| return UIFactory.createMenu("Account", | ||
| List.of(" • Portfolio", " • Transactions"), | ||
| () -> SceneManager.switchTo(SceneFactory.createPortfolioView()), | ||
| () -> SceneManager.switchTo(SceneFactory.createTransactionView())); | ||
| } | ||
|
|
||
| public void setModel(NewspaperModel model){ | ||
| Bindings.bindContent(article.getChildren(), model.getNewspaperComponentsList()); | ||
| } | ||
| public void setController(NewspaperController controller){ | ||
|
|
||
| } | ||
| } |
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
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