diff --git a/src/main/java/edu/ntnu/idi/idatt/model/enums/NewspaperEnum.java b/src/main/java/edu/ntnu/idi/idatt/model/enums/NewspaperEnum.java index 11b8c22..1c09db1 100644 --- a/src/main/java/edu/ntnu/idi/idatt/model/enums/NewspaperEnum.java +++ b/src/main/java/edu/ntnu/idi/idatt/model/enums/NewspaperEnum.java @@ -7,7 +7,7 @@ * Creates static events that can occur within Newspaper. *

* - * @see Newspaper + * {@link Newspaper} */ public enum NewspaperEnum { NEW_PRODUCT( diff --git a/src/main/java/edu/ntnu/idi/idatt/model/portfolio/Share.java b/src/main/java/edu/ntnu/idi/idatt/model/portfolio/Share.java index c828dd6..4be3d3a 100644 --- a/src/main/java/edu/ntnu/idi/idatt/model/portfolio/Share.java +++ b/src/main/java/edu/ntnu/idi/idatt/model/portfolio/Share.java @@ -77,7 +77,8 @@ public BigDecimal getTotalPurchasePrice() { * SaleCalculator.calculateGross() - getTotalPurchasePrice() *

* - * @see Player (Net worth calculation) + * {@link Player} + * * @return BigDecimal current profit. */ public BigDecimal getProfit() { diff --git a/src/main/java/edu/ntnu/idi/idatt/model/transaction/TransactionArchive.java b/src/main/java/edu/ntnu/idi/idatt/model/transaction/TransactionArchive.java index a861539..b766616 100644 --- a/src/main/java/edu/ntnu/idi/idatt/model/transaction/TransactionArchive.java +++ b/src/main/java/edu/ntnu/idi/idatt/model/transaction/TransactionArchive.java @@ -106,7 +106,8 @@ public List getSales() { * Used to calculate player statuses. *

* - * @see Player + * {@link Player} + * * @return int amount of distinct weeks. */ public int countDistinctWeeks() { diff --git a/src/main/java/edu/ntnu/idi/idatt/service/transaction/SaleCalculator.java b/src/main/java/edu/ntnu/idi/idatt/service/transaction/SaleCalculator.java index bcbc17d..aba30e7 100644 --- a/src/main/java/edu/ntnu/idi/idatt/service/transaction/SaleCalculator.java +++ b/src/main/java/edu/ntnu/idi/idatt/service/transaction/SaleCalculator.java @@ -84,7 +84,7 @@ public BigDecimal calculateTotal() { * to the net worth calculation method. *

* - * @see Player + * {@link Player} */ public BigDecimal calculateProfit() { return calculateGross().subtract(purchasePrice.multiply(quantity)); diff --git a/src/main/java/edu/ntnu/idi/idatt/session/UserSession.java b/src/main/java/edu/ntnu/idi/idatt/session/UserSession.java index 05bacf6..d68ebde 100644 --- a/src/main/java/edu/ntnu/idi/idatt/session/UserSession.java +++ b/src/main/java/edu/ntnu/idi/idatt/session/UserSession.java @@ -89,7 +89,7 @@ public void setExchange(Exchange exchange) { /** * Getter for moneyProperty. * - * @return SimpleObjectProperty; + * @return {@code SimpleObjectProperty} */ public SimpleObjectProperty moneyProperty() { return moneyProperty; @@ -98,7 +98,7 @@ public SimpleObjectProperty moneyProperty() { /** * Getter for netWorthProperty. * - * @return SimpleObjectProperty + * @return {@code SimpleObjectProperty} */ public SimpleObjectProperty netWorthProperty() { return netWorthProperty; @@ -126,7 +126,7 @@ public SimpleStringProperty statusProperty() { * Method used for updating the game state. *

* Updates the user interface model from diverse - * places through the code to synchronize model <-> UI. + * places through the code to synchronize model with UI. * Saves current session. *

*/ diff --git a/src/main/java/edu/ntnu/idi/idatt/view/SceneFactory.java b/src/main/java/edu/ntnu/idi/idatt/view/SceneFactory.java index 154e11b..e04ded5 100644 --- a/src/main/java/edu/ntnu/idi/idatt/view/SceneFactory.java +++ b/src/main/java/edu/ntnu/idi/idatt/view/SceneFactory.java @@ -220,7 +220,7 @@ public static Parent createExchangeView() { *

* * @param clean - should it reset the page stack. - * @rteturn View's root + * @return View's root */ public static Parent createExchangeView(boolean clean) { return createDefaultExchangeView(clean); diff --git a/src/main/java/edu/ntnu/idi/idatt/view/components/AbstractViewUI.java b/src/main/java/edu/ntnu/idi/idatt/view/components/AbstractViewUI.java index 93a9574..028b77c 100644 --- a/src/main/java/edu/ntnu/idi/idatt/view/components/AbstractViewUI.java +++ b/src/main/java/edu/ntnu/idi/idatt/view/components/AbstractViewUI.java @@ -1,5 +1,8 @@ package edu.ntnu.idi.idatt.view.components; +import javafx.animation.KeyFrame; +import javafx.animation.KeyValue; +import javafx.animation.Timeline; import javafx.beans.property.SimpleBooleanProperty; import javafx.geometry.Pos; import javafx.scene.Parent; @@ -9,6 +12,7 @@ import javafx.scene.layout.Region; import javafx.scene.layout.StackPane; import javafx.scene.layout.VBox; +import javafx.util.Duration; /** * Abstract View UI class. @@ -59,12 +63,12 @@ public AbstractViewUI() { disableMenu.setVisible(false); disableMenu.setOnMouseClicked(e -> { - menu.setVisible(false); + animationMenu(false); disableMenu.setVisible(false); }); isMenuVisible.addListener((observer, oldVal, newVal) -> { - menu.setVisible(true); + animationMenu(true); disableMenu.setVisible(true); }); @@ -165,4 +169,25 @@ public void toggleMenu() { isMenuVisible.set(!isMenuVisible.get()); } + /** + * Method for animating the menu. + * + * @param val - in = true, out = false + */ + private void animationMenu(boolean val) { + Timeline animation; + if (val) { + menu.setVisible(true); + menu.setTranslateX(menu.getWidth()); // Fix issue from menu initialization + // (hide before starting to appear no matter what) + animation = new Timeline(new KeyFrame(Duration.millis(200), + new KeyValue(menu.translateXProperty(), 0))); + } else { + animation = new Timeline(new KeyFrame(Duration.millis(200), + new KeyValue(menu.translateXProperty(), menu.getWidth()))); + animation.setOnFinished((e) -> menu.setVisible(false)); + } + animation.play(); + } + } diff --git a/src/main/java/edu/ntnu/idi/idatt/view/components/elements/StockComponent.java b/src/main/java/edu/ntnu/idi/idatt/view/components/elements/StockComponent.java index 4bc55a9..6e956f1 100644 --- a/src/main/java/edu/ntnu/idi/idatt/view/components/elements/StockComponent.java +++ b/src/main/java/edu/ntnu/idi/idatt/view/components/elements/StockComponent.java @@ -8,6 +8,7 @@ import edu.ntnu.idi.idatt.view.util.CssUtils; import javafx.geometry.Insets; import javafx.geometry.Pos; +import javafx.scene.Cursor; import javafx.scene.control.Label; import javafx.scene.layout.HBox; import javafx.scene.layout.VBox; @@ -74,6 +75,9 @@ public StockComponent(Stock stock) { .unwrap() .build(); + // Add click cursor + this.setCursor(Cursor.HAND); + this.getChildren().addAll(stockComponent.makeUI()); } diff --git a/src/main/java/edu/ntnu/idi/idatt/view/components/ui/UIAlert.java b/src/main/java/edu/ntnu/idi/idatt/view/components/ui/UIAlert.java index a6d9556..f96b490 100644 --- a/src/main/java/edu/ntnu/idi/idatt/view/components/ui/UIAlert.java +++ b/src/main/java/edu/ntnu/idi/idatt/view/components/ui/UIAlert.java @@ -16,9 +16,9 @@ public class UIAlert { /** * Constructor for UIAlert. * - * @param title - Window name - * @param header - context - * @content - description of context + * @param title - Window name + * @param header - context + * @param content - description of context */ public UIAlert(String title, String header, String content) { alert.setTitle(title); diff --git a/src/main/java/edu/ntnu/idi/idatt/view/components/ui/UIFactory.java b/src/main/java/edu/ntnu/idi/idatt/view/components/ui/UIFactory.java index 06ba4c8..25ed060 100644 --- a/src/main/java/edu/ntnu/idi/idatt/view/components/ui/UIFactory.java +++ b/src/main/java/edu/ntnu/idi/idatt/view/components/ui/UIFactory.java @@ -7,6 +7,7 @@ import edu.ntnu.idi.idatt.session.UserSession; import edu.ntnu.idi.idatt.view.SceneFactory; +import edu.ntnu.idi.idatt.view.components.AbstractViewUI; import edu.ntnu.idi.idatt.view.components.elements.IconComponent; import edu.ntnu.idi.idatt.view.components.elements.SearchBarComponent; import edu.ntnu.idi.idatt.view.components.primitives.ActionEventHandler; @@ -33,7 +34,7 @@ * equal layouts across multiple views. *

* - * @see AbstractViewUI + * {@link AbstractViewUI} */ public class UIFactory { @@ -191,7 +192,10 @@ private static Parent createDefaultNavigation(Label titleLabel, List but .properties(nav -> nav.setPadding(new Insets(40))) .addContent(titleLabel); - buttons.forEach(b -> navigationBuilder.addContent(b)); + buttons.forEach(b -> { + navigationBuilder.addContent(b); + CssUtils.fadeInAnimation(b); + }); navigationBuilder .filler(); diff --git a/src/main/java/edu/ntnu/idi/idatt/view/entry/StartView.java b/src/main/java/edu/ntnu/idi/idatt/view/entry/StartView.java index ece4e5a..7b51f10 100644 --- a/src/main/java/edu/ntnu/idi/idatt/view/entry/StartView.java +++ b/src/main/java/edu/ntnu/idi/idatt/view/entry/StartView.java @@ -3,6 +3,7 @@ import java.util.List; import edu.ntnu.idi.idatt.view.components.AbstractView; +import edu.ntnu.idi.idatt.view.util.CssUtils; import javafx.geometry.Insets; import javafx.geometry.Pos; import javafx.scene.Parent; @@ -45,7 +46,7 @@ public StartView() { /** * Overriden method for createContent() * - * @see AbstractView; + * @see AbstractView * @return root node. */ @Override @@ -145,6 +146,8 @@ public void setModel(StartModel model) { this.errorLabel.textProperty().bind(model.getError()); this.fileLabel.textProperty().bind(model.getFileName()); this.newGameWrapper.visibleProperty().bind(model.isNewGame()); + this.newGameWrapper.visibleProperty() + .addListener((obs) -> this.newGameWrapper.getChildren().forEach(c -> CssUtils.fadeInAnimation(c))); this.csvPredefinedCheckBox.selectedProperty().bindBidirectional(model.isPredefinedCSV()); // Binding importCsvWrapper visibleProperty here for convenience diff --git a/src/main/java/edu/ntnu/idi/idatt/view/primary/exchange/ExchangeController.java b/src/main/java/edu/ntnu/idi/idatt/view/primary/exchange/ExchangeController.java index cd317d1..af9df1b 100644 --- a/src/main/java/edu/ntnu/idi/idatt/view/primary/exchange/ExchangeController.java +++ b/src/main/java/edu/ntnu/idi/idatt/view/primary/exchange/ExchangeController.java @@ -9,6 +9,7 @@ import edu.ntnu.idi.idatt.view.SceneManager; import edu.ntnu.idi.idatt.view.components.AbstractController; import edu.ntnu.idi.idatt.view.components.elements.StockComponent; +import edu.ntnu.idi.idatt.view.util.CssUtils; import javafx.animation.Animation; import javafx.animation.KeyFrame; import javafx.animation.KeyValue; @@ -80,7 +81,7 @@ public void setStocksModel(List stockList) { StockComponent stockComponent = new StockComponent(stock); if (stock.getNewspaper().hasNewNews()) { - applyNewspaperGlow(stockComponent); + CssUtils.applyNewspaperGlow(stockComponent); } stockComponent.onStockClick((symbol) -> redirectView(symbol)); @@ -88,27 +89,6 @@ public void setStocksModel(List stockList) { } } - /** - * Method that applies glow effect to StockComponent with new news. - * - * @param component - The chosen StockComponent. - */ - public void applyNewspaperGlow(StockComponent component) { - DropShadow glow = new DropShadow(7, Color.WHITE); - - Timeline timeline = new Timeline( - new KeyFrame(Duration.ZERO, - new KeyValue(glow.radiusProperty(), 10)), - new KeyFrame(Duration.seconds(0.5), - new KeyValue(glow.radiusProperty(), 50))); - - timeline.setAutoReverse(true); - timeline.setCycleCount(Animation.INDEFINITE); - - component.setEffect(glow); - timeline.play(); - } - /** * Method to handle searchbar query. * diff --git a/src/main/java/edu/ntnu/idi/idatt/view/primary/exchange/ExchangeModel.java b/src/main/java/edu/ntnu/idi/idatt/view/primary/exchange/ExchangeModel.java index f7bf431..ac4d1c4 100644 --- a/src/main/java/edu/ntnu/idi/idatt/view/primary/exchange/ExchangeModel.java +++ b/src/main/java/edu/ntnu/idi/idatt/view/primary/exchange/ExchangeModel.java @@ -17,7 +17,7 @@ public class ExchangeModel implements Model { /** * Getter for the stock list. * - * @return ObservableList; + * @return {@code ObservableList} */ public ObservableList getStockList() { return stockList; diff --git a/src/main/java/edu/ntnu/idi/idatt/view/primary/finish/FinishController.java b/src/main/java/edu/ntnu/idi/idatt/view/primary/finish/FinishController.java index 4ad3014..eec90c9 100644 --- a/src/main/java/edu/ntnu/idi/idatt/view/primary/finish/FinishController.java +++ b/src/main/java/edu/ntnu/idi/idatt/view/primary/finish/FinishController.java @@ -116,9 +116,9 @@ private BigDecimal calculateProfits() { private BigDecimal calculateROI() { BigDecimal profit = session.getPlayer().getMoney().subtract( session.getPlayer().getStartingMoney()); - BigDecimal profitPercent = profit.divide(session.getPlayer().getStartingMoney()).setScale(2, RoundingMode.HALF_UP); + BigDecimal profitPercent = profit.divide(session.getPlayer().getStartingMoney()); - BigDecimal returnOfInvestement = profitPercent.multiply(new BigDecimal("100")); + BigDecimal returnOfInvestement = profitPercent.multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP); return returnOfInvestement; } diff --git a/src/main/java/edu/ntnu/idi/idatt/view/primary/newspaper/NewspaperModel.java b/src/main/java/edu/ntnu/idi/idatt/view/primary/newspaper/NewspaperModel.java index e5499be..0df8b7d 100644 --- a/src/main/java/edu/ntnu/idi/idatt/view/primary/newspaper/NewspaperModel.java +++ b/src/main/java/edu/ntnu/idi/idatt/view/primary/newspaper/NewspaperModel.java @@ -14,7 +14,7 @@ public class NewspaperModel implements Model { /** * Getter for newsList. * - * @return ObservableList