diff --git a/src/Client/src/main/java/greenify/client/controller/CalculatorController.java b/src/Client/src/main/java/greenify/client/controller/CalculatorController.java new file mode 100644 index 0000000..8c6c98f --- /dev/null +++ b/src/Client/src/main/java/greenify/client/controller/CalculatorController.java @@ -0,0 +1,154 @@ +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.ScrollPane; +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 CalculatorController { + @Autowired + UserService userService; + + @FXML + private Button calculatorGetStartedButton; + @FXML + private Button calculatorTravelButton; + @FXML + private Button calculatorHomeButton; + @FXML + private Button calculatorFoodButton; + @FXML + private Button calculatorShoppingButton; + @FXML + private AnchorPane getStartedPane; + @FXML + private ScrollPane travelPane; + @FXML + private AnchorPane homePane; + @FXML + private AnchorPane foodPane; + @FXML + private AnchorPane shoppingPane; + @FXML + private Slider peopleInHouseholdSLider; + @FXML + private Label peopleInHouseHoldLabel; + @FXML + private Slider annualIncomeSlider; + @FXML + private Label annualIncomeLabel; + @FXML + private Button saveButton; + @FXML + private Button getStartedNextButton; + + /** + * initializes the window, performs some actions before loading all other things. + * it sets the sliders to snap to the ticks + * it adds listeners to all the sliders for updating the label next to them + */ + public void initialize() { + peopleInHouseholdSLider.setSnapToTicks(true); + annualIncomeSlider.setSnapToTicks(true); + //add listener to slider for amount of people in household + peopleInHouseholdSLider.valueProperty().addListener(new ChangeListener() { + + public void changed(ObservableValue observable, + Number oldValue, Number newValue) { + peopleInHouseHoldLabel.setText("" + newValue.intValue()); + } + }); + + //add listener to slider for annual income + annualIncomeSlider.valueProperty().addListener(new ChangeListener() { + @Override + public void changed(ObservableValue observable, + Number oldValue, Number newValue) { + annualIncomeLabel.setText("" + (newValue.intValue() * 1000)); + } + }); + } + + /** + * displays the 'get started' section of the calculator. + * Activated when the designated button (navigation button) is clicked + * @param event the click of the button + */ + public void displayGetStarted(ActionEvent event) { + getStartedPane.setVisible(true); + travelPane.setVisible(false); + homePane.setVisible(false); + foodPane.setVisible(false); + shoppingPane.setVisible(false); + + } + + /** + * displays the 'travel' section of the calculator. + * Activated when the designated button (navigation button) is clicked + * @param event the click of the button + */ + public void displayTravel(ActionEvent event) { + getStartedPane.setVisible(false); + travelPane.setVisible(true); + homePane.setVisible(false); + foodPane.setVisible(false); + shoppingPane.setVisible(false); + } + + /** + * displays the 'home' section of the calculator. + * Activated when the designated button (navigation button) is clicked + * @param event the click of the button + */ + public void displayHome(ActionEvent event) { + getStartedPane.setVisible(false); + travelPane.setVisible(false); + homePane.setVisible(true); + foodPane.setVisible(false); + shoppingPane.setVisible(false); + } + + /** + * displays the 'food' section of the calculator. + * Activated when the designated button (navigation button) is clicked + * @param event the click of the button + */ + public void displayFood(ActionEvent event) { + getStartedPane.setVisible(false); + travelPane.setVisible(false); + homePane.setVisible(false); + foodPane.setVisible(true); + shoppingPane.setVisible(false); + } + + /** + * displays the 'shopping' section of the calculator. + * Activated when the designated button (navigation button) is clicked + * @param event the click of the button + */ + public void displayShopping(ActionEvent event) { + getStartedPane.setVisible(false); + travelPane.setVisible(false); + homePane.setVisible(false); + foodPane.setVisible(false); + shoppingPane.setVisible(true); + } + + + + + + + + +} 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 81e148a..80918bd 100644 --- a/src/Client/src/main/java/greenify/client/controller/DashBoardController.java +++ b/src/Client/src/main/java/greenify/client/controller/DashBoardController.java @@ -1,6 +1,7 @@ package greenify.client.controller; import com.sun.javafx.scene.control.skin.ButtonSkin; +import greenify.client.Application; import greenify.client.rest.UserService; import javafx.animation.FadeTransition; import javafx.animation.PathTransition; @@ -8,14 +9,19 @@ import javafx.animation.ScaleTransition; import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.scene.Node; +import javafx.scene.Parent; +import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.Label; import javafx.scene.layout.AnchorPane; import javafx.scene.shape.Line; +import javafx.stage.Stage; import javafx.util.Duration; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; +import java.io.IOException; + //Class that controls the dashboard fxml file (the GUI Screen) @@ -56,6 +62,9 @@ public class DashBoardController { private AnchorPane menuBar; @FXML private Button addNewActivityButton; + @FXML + private Button calculateFootPrintButton; + @@ -72,6 +81,12 @@ public class DashBoardController { activitiesButton.setSkin(new MyButtonSkin(activitiesButton)); userButton.setSkin(new MyButtonSkin(userButton)); friendsButton.setSkin(new MyButtonSkin(friendsButton)); + + + } + + public UserService getUserService() { + return userService; } /** @@ -136,7 +151,6 @@ public class DashBoardController { userPane.setVisible(false); activitiesPane.setVisible(false); friendsPane.setVisible(true); - } //sets the slide in transition for startup @@ -145,6 +159,18 @@ public class DashBoardController { pathTrans.play(); } + public void openCalculator() throws IOException { + Parent calc = Application.load(this.getClass().getClassLoader() + .getResource("fxml/calculator.fxml")); + Scene scene = new Scene(calc); + scene.getStylesheets().add(getClass().getClassLoader().getResource("stylesheets/calculatorStyle.css").toExternalForm()); + Stage calcStage = new Stage(); + + calcStage.setScene(scene); + calcStage.setTitle("Calculate CO2 footprint - " + userService.currentUser.getName()); + calcStage.show(); + } + //class for the animations on the navigation buttons public class MyButtonSkin extends ButtonSkin { /** @@ -169,5 +195,6 @@ public class DashBoardController { scaleDown.setToX(1.0); button.setOnMouseExited(e -> scaleDown.playFromStart()); } + } -} +} \ No newline at end of file diff --git a/src/Client/src/main/resources/fxml/calculator.fxml b/src/Client/src/main/resources/fxml/calculator.fxml new file mode 100644 index 0000000..e4b7627 --- /dev/null +++ b/src/Client/src/main/resources/fxml/calculator.fxml @@ -0,0 +1,145 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + @@ -160,7 +162,7 @@ - + @@ -181,8 +183,22 @@ + + + + + + + + + + - + - - + diff --git a/src/Client/src/main/resources/addActivity1.png b/src/Client/src/main/resources/icons/addActivity1.png similarity index 100% rename from src/Client/src/main/resources/addActivity1.png rename to src/Client/src/main/resources/icons/addActivity1.png diff --git a/src/Client/src/main/resources/addActivity2.png b/src/Client/src/main/resources/icons/addActivity2.png similarity index 100% rename from src/Client/src/main/resources/addActivity2.png rename to src/Client/src/main/resources/icons/addActivity2.png diff --git a/src/Client/src/main/resources/icons/cloud.png b/src/Client/src/main/resources/icons/cloud.png new file mode 100644 index 0000000..1cc8c2b Binary files /dev/null and b/src/Client/src/main/resources/icons/cloud.png differ diff --git a/src/Client/src/main/resources/icons/co2.png b/src/Client/src/main/resources/icons/co2.png new file mode 100644 index 0000000..bac53df Binary files /dev/null and b/src/Client/src/main/resources/icons/co2.png differ diff --git a/src/Client/src/main/resources/icons/co2_2.png b/src/Client/src/main/resources/icons/co2_2.png new file mode 100644 index 0000000..ef3516a Binary files /dev/null and b/src/Client/src/main/resources/icons/co2_2.png differ diff --git a/src/Client/src/main/resources/icons/coffee-cup.png b/src/Client/src/main/resources/icons/coffee-cup.png new file mode 100644 index 0000000..310c098 Binary files /dev/null and b/src/Client/src/main/resources/icons/coffee-cup.png differ diff --git a/src/Client/src/main/resources/icons/home.png b/src/Client/src/main/resources/icons/home.png new file mode 100644 index 0000000..9cecc79 Binary files /dev/null and b/src/Client/src/main/resources/icons/home.png differ diff --git a/src/Client/src/main/resources/icons/shopping-cart.png b/src/Client/src/main/resources/icons/shopping-cart.png new file mode 100644 index 0000000..7c76dcc Binary files /dev/null and b/src/Client/src/main/resources/icons/shopping-cart.png differ diff --git a/src/Client/src/main/resources/icons/world.png b/src/Client/src/main/resources/icons/world.png new file mode 100644 index 0000000..92643b8 Binary files /dev/null and b/src/Client/src/main/resources/icons/world.png differ diff --git a/src/Client/src/main/resources/stylesheets/calculatorStyle.css b/src/Client/src/main/resources/stylesheets/calculatorStyle.css new file mode 100644 index 0000000..af59819 --- /dev/null +++ b/src/Client/src/main/resources/stylesheets/calculatorStyle.css @@ -0,0 +1,35 @@ + +#calculatorTabs .navButton { + -fx-background-color: transparent; + -fx-font-size: 16px; +} +#calculatorTabs .navButton:pressed { + -fx-border-color: #677069; +} +#calculatorTabs .navButton:hover { + -fx-background-color: #707a72; +} +#calculatorTabs #saveButton { + -fx-background-color: #89a888; + -fx-font-size: 16px; + -fx-font-weight: regular; +} + +.nextButton { + -fx-background-color: #89a888; + -fx-font-size: 16px; + -fx-font-family: Corbel; +} +.nextButton:hover { + -fx-background-color: #9ec19c; +} + +.slider { + -show-value-on-interaction: true; + -fx-text-fill: red; +} + + + + + diff --git a/src/Client/src/main/resources/stylesheets/dashboardStyle.css b/src/Client/src/main/resources/stylesheets/dashboardStyle.css index 77bceaa..eb074d6 100644 --- a/src/Client/src/main/resources/stylesheets/dashboardStyle.css +++ b/src/Client/src/main/resources/stylesheets/dashboardStyle.css @@ -48,10 +48,15 @@ -fx-background-color: #b7e2c2; } + #addNewActivityButton:pressed { -fx-border-color: #497251; } +#calculateFootPrintButton:pressed { + -fx-border-color: #497251; +} + /*friends table*/ #friendsTable .column-header { /*-fx-background-color: linear-gradient(#4b7a3d, #588c58);*/