diff --git a/src/Client/src/main/java/greenify/client/controller/CalculatorController.java b/src/Client/src/main/java/greenify/client/controller/CalculatorController.java index 5098636..d2ab3d3 100644 --- a/src/Client/src/main/java/greenify/client/controller/CalculatorController.java +++ b/src/Client/src/main/java/greenify/client/controller/CalculatorController.java @@ -1,5 +1,6 @@ package greenify.client.controller; +import greenify.client.Application; import greenify.client.rest.UserService; import javafx.animation.Interpolator; import javafx.animation.KeyFrame; @@ -9,9 +10,7 @@ import javafx.beans.value.ChangeListener; import javafx.beans.value.ObservableValue; import javafx.event.ActionEvent; import javafx.fxml.FXML; -import javafx.fxml.FXMLLoader; import javafx.scene.Node; -import javafx.scene.Parent; import javafx.scene.control.Button; import javafx.scene.control.CheckBox; import javafx.scene.control.Label; @@ -151,6 +150,7 @@ public class CalculatorController { @FXML private CheckBox solarPanelsCheckbox; + /** * initializes the window, performs some actions before loading all other things. * it sets the sliders to snap to the ticks. @@ -259,6 +259,7 @@ public class CalculatorController { */ @SuppressWarnings("Duplicates") public void displayGetStarted(ActionEvent event) { + getStartedPane.setVisible(true); travelPane.setVisible(false); homePane.setVisible(false); @@ -275,7 +276,7 @@ public class CalculatorController { */ @SuppressWarnings("Duplicates") public void displayTravel(ActionEvent event) { - addSlideInAnimation(travelPane); + getStartedPane.setVisible(false); travelPane.setVisible(true); homePane.setVisible(false); @@ -292,6 +293,7 @@ public class CalculatorController { */ @SuppressWarnings("Duplicates") public void displayHome(ActionEvent event) { + getStartedPane.setVisible(false); travelPane.setVisible(false); homePane.setVisible(true); @@ -307,6 +309,7 @@ public class CalculatorController { */ @SuppressWarnings("Duplicates") public void displayFood(ActionEvent event) { + getStartedPane.setVisible(false); travelPane.setVisible(false); homePane.setVisible(false); @@ -322,6 +325,7 @@ public class CalculatorController { */ @SuppressWarnings("Duplicates") public void displayShopping(ActionEvent event) { + getStartedPane.setVisible(false); travelPane.setVisible(false); homePane.setVisible(false); @@ -338,8 +342,8 @@ public class CalculatorController { @SuppressWarnings("Duplicates") public void displayExtra(ActionEvent event) throws IOException { - // Parent extra = FXMLLoader.load(getClass().getClassLoader().getResource("fxml/extraActivities.fxml")); - // extraPane.getChildren().setAll(extra); + extraPane.getChildren().setAll((Node) Application.load(this.getClass() + .getClassLoader().getResource("fxml/extraActivities.fxml"))); getStartedPane.setVisible(false); travelPane.setVisible(false); homePane.setVisible(false); diff --git a/src/Client/src/main/java/greenify/client/controller/DashBoardController.java b/src/Client/src/main/java/greenify/client/controller/DashBoardController.java index 259ed42..ea61adc 100644 --- a/src/Client/src/main/java/greenify/client/controller/DashBoardController.java +++ b/src/Client/src/main/java/greenify/client/controller/DashBoardController.java @@ -155,20 +155,23 @@ public class DashBoardController { private Label snacks; @FXML private CheckBox localProduce; - @SuppressWarnings("CheckStyle") @FXML private CheckBox loweringTemp; - @SuppressWarnings("CheckStyle") @FXML private CheckBox bike; - @SuppressWarnings("CheckStyle") @FXML private CheckBox solarPanels; /** * Loads the the necessary things before anything else. + * @throws InterruptedException exception if interrupted */ public void initialize() throws InterruptedException { + //set the dashboardPane to visible + dashboardPane.setVisible(true); + userPane.setVisible(false); + activitiesPane.setVisible(false); + friendsPane.setVisible(false); //sets the text of the 'welcome back' text to include the username welcomebacktext.setText("Welcome back, " + userService.currentUser.getName() + "!"); //adds the slide transition to the menu bar @@ -314,8 +317,8 @@ public class DashBoardController { electricMiles.setText(inputMap.get("input_footprint_transportation_miles3")); electricMpg.setText(inputMap.get("input_footprint_transportation_mpg3")); publicTransportation.setText(inputMap.get("input_footprint_transportation_publictrans") - + " mi/yr"); - airPlane.setText(inputMap.get("input_footprint_transportation_airtotal") + " mi/yr"); + + " km/yr"); + airPlane.setText(inputMap.get("input_footprint_transportation_airtotal") + " km/yr"); goodShopping.setText(inputMap.get("input_footprint_shopping_goods_total") + " €/mo"); serviceShopping.setText(inputMap.get("input_footprint_shopping_services_total") + " €/mo"); meat.setText(inputMap.get("input_footprint_shopping_food_meatfisheggs")); @@ -397,6 +400,17 @@ public class DashBoardController { calcStage.show(); } + public void openExtraActivities(ActionEvent event) throws IOException { + Parent extra = Application.load(this.getClass().getClassLoader() + .getResource("fxml/extraActivities.fxml")); + Scene scene = new Scene(extra); + Stage extraStage = new Stage(); + extraStage.setScene(scene); + extraStage.setTitle("Add extra activity - " + userService.currentUser.getName()); + extraStage.show(); + + } + /** * method opend addFriend scene. * @throws IOException when file is not found diff --git a/src/Client/src/main/java/greenify/client/controller/ExtraActivityController.java b/src/Client/src/main/java/greenify/client/controller/ExtraActivityController.java new file mode 100644 index 0000000..ecb9ba3 --- /dev/null +++ b/src/Client/src/main/java/greenify/client/controller/ExtraActivityController.java @@ -0,0 +1,138 @@ +package greenify.client.controller; + +import greenify.client.rest.UserService; +import javafx.beans.value.ChangeListener; +import javafx.beans.value.ObservableValue; +import javafx.event.ActionEvent; +import javafx.fxml.FXML; +import javafx.scene.control.Button; +import javafx.scene.control.Label; +import javafx.scene.control.Slider; +import javafx.scene.layout.AnchorPane; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; + +@Controller +public class ExtraActivityController { + + @Autowired + UserService userService; + + @FXML + private AnchorPane veganMealPane; + @FXML + private AnchorPane bikePane; + @FXML + private AnchorPane temperaturePane; + @FXML + private AnchorPane solarPanelPane; + @FXML + private Button displayVeganMealButton; + @FXML + private Button displayBikeButton; + @FXML + private Button displayTemperatureButton; + @FXML + private Button displaySolarPanelButton; + + @FXML + private Button addVeganMealButton; + @FXML + private Button addBikeButton; + @FXML + private Button addTemperatureButton; + @FXML + private Button addSolarPanelsButton; + @FXML + private Slider bikeSlider; + @FXML + private Label bikeLabel; + @FXML + private Slider temperatureSlider; + @FXML + private Label temperatureLabel; + @FXML + private Slider solarPanelsSlider; + @FXML + private Label solarPanelsLabel; + + /** + * initializes the sliders and labels before loading. + * sets the labels to display the outputs of the designated sliders. + */ + public void initialize() { + coupleSliderToLabel(bikeSlider, bikeLabel, " km", false); + coupleSliderToLabel(temperatureSlider, temperatureLabel, " Degrees", true); + coupleSliderToLabel(solarPanelsSlider, solarPanelsLabel, "", true); + + } + + /** + * Sets the label to display the value of the designated slider. + * sets the text to be displayed after the value of the slider. + * sets whether the slider should snap to ticks + * @param slider the slider to read the value from + * @param label the label to display the value of the slider + * @param string the string to be placed after the outputted value of the slider + * @param snapToTicks whether the slider should snap to ticks or not + */ + public void coupleSliderToLabel(Slider slider, Label label, String string, + boolean snapToTicks) { + slider.setSnapToTicks(snapToTicks); + slider.valueProperty().addListener(new ChangeListener() { + @Override + public void changed(ObservableValue observable, + Number oldValue, Number newValue) { + label.setText(newValue.intValue() + string); + } + }); + } + + /** + * displays the vegetarian meal section. + * @param event the click of the designated button + */ + public void displayVeganMeal(ActionEvent event) { + // System.out.println("display vm"); + veganMealPane.setVisible(true); + bikePane.setVisible(false); + temperaturePane.setVisible(false); + solarPanelPane.setVisible(false); + } + + /** + * displays the bike section. + * @param event the click of the designated button + */ + public void displayBike(ActionEvent event) { + // System.out.println("display b"); + veganMealPane.setVisible(false); + bikePane.setVisible(true); + temperaturePane.setVisible(false); + solarPanelPane.setVisible(false); + } + + /** + * displays the temperature section. + * @param event the click of the designated button + */ + public void displayTemperature(ActionEvent event) { + // System.out.println("display t"); + veganMealPane.setVisible(false); + bikePane.setVisible(false); + temperaturePane.setVisible(true); + solarPanelPane.setVisible(false); + } + + /** + * displays the solar panels section. + * @param event the click of the designated button + */ + public void displaySolarPanel(ActionEvent event) { + // System.out.println("display sp"); + veganMealPane.setVisible(false); + bikePane.setVisible(false); + temperaturePane.setVisible(false); + solarPanelPane.setVisible(true); + } +} diff --git a/src/Client/src/main/resources/fxml/dashboard.fxml b/src/Client/src/main/resources/fxml/dashboard.fxml index 36948f8..d14738f 100644 --- a/src/Client/src/main/resources/fxml/dashboard.fxml +++ b/src/Client/src/main/resources/fxml/dashboard.fxml @@ -1,5 +1,12 @@ + + + + + + + @@ -15,7 +22,7 @@ - + @@ -272,6 +279,18 @@ + @@ -420,6 +439,18 @@ + diff --git a/src/Client/src/main/resources/fxml/extraActivities.fxml b/src/Client/src/main/resources/fxml/extraActivities.fxml index f3e46b9..d1ab289 100644 --- a/src/Client/src/main/resources/fxml/extraActivities.fxml +++ b/src/Client/src/main/resources/fxml/extraActivities.fxml @@ -1,20 +1,188 @@ + + + + - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Client/src/main/resources/icons/icons8-bicycle-filled-100.png b/src/Client/src/main/resources/icons/icons8-bicycle-filled-100.png new file mode 100644 index 0000000..8fd71e4 Binary files /dev/null and b/src/Client/src/main/resources/icons/icons8-bicycle-filled-100.png differ diff --git a/src/Client/src/main/resources/icons/icons8-solar-panel-filled-100.png b/src/Client/src/main/resources/icons/icons8-solar-panel-filled-100.png new file mode 100644 index 0000000..58fb479 Binary files /dev/null and b/src/Client/src/main/resources/icons/icons8-solar-panel-filled-100.png differ diff --git a/src/Client/src/main/resources/icons/icons8-temperature-inside-64.png b/src/Client/src/main/resources/icons/icons8-temperature-inside-64.png new file mode 100644 index 0000000..d548a77 Binary files /dev/null and b/src/Client/src/main/resources/icons/icons8-temperature-inside-64.png differ diff --git a/src/Client/src/main/resources/icons/icons8-vegan-food-100.png b/src/Client/src/main/resources/icons/icons8-vegan-food-100.png new file mode 100644 index 0000000..83f766b Binary files /dev/null and b/src/Client/src/main/resources/icons/icons8-vegan-food-100.png differ diff --git a/src/Client/src/main/resources/stylesheets/calculatorStyle.css b/src/Client/src/main/resources/stylesheets/calculatorStyle.css index c3c3665..1877abb 100644 --- a/src/Client/src/main/resources/stylesheets/calculatorStyle.css +++ b/src/Client/src/main/resources/stylesheets/calculatorStyle.css @@ -29,7 +29,6 @@ .slider { -show-value-on-interaction: true; - -fx-text-fill: red; } .km-yearBox { diff --git a/src/Client/src/main/resources/stylesheets/extraActivitiesStyle.css b/src/Client/src/main/resources/stylesheets/extraActivitiesStyle.css new file mode 100644 index 0000000..e30c77a --- /dev/null +++ b/src/Client/src/main/resources/stylesheets/extraActivitiesStyle.css @@ -0,0 +1,19 @@ +.navButton { + -fx-background-color: #6a7a6d; +} + +.slider .track { + -fx-background-color: #d3d3d3; +} + +.slider .thumb { + -fx-background-color: transparent; + -fx-background-image: url('../icons/leaficon.png'); + -fx-padding: 12; +} + +.textHolder { + -fx-background-color: #89a888; + -fx-background-radius: 5px; + -fx-border-radius: 5px; +} \ No newline at end of file