Merge branch 'add_details_extra_activities' into 'master'

add/added extra activities GUI

See merge request cse1105/2018-2019/oopp-group-43/template!62
This commit is contained in:
Sem van der Hoeven
2019-04-03 19:15:46 +00:00
11 changed files with 396 additions and 22 deletions

View File

@@ -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;
@@ -149,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.
@@ -257,6 +259,7 @@ public class CalculatorController {
*/
@SuppressWarnings("Duplicates")
public void displayGetStarted(ActionEvent event) {
getStartedPane.setVisible(true);
travelPane.setVisible(false);
homePane.setVisible(false);
@@ -273,7 +276,7 @@ public class CalculatorController {
*/
@SuppressWarnings("Duplicates")
public void displayTravel(ActionEvent event) {
addSlideInAnimation(travelPane);
getStartedPane.setVisible(false);
travelPane.setVisible(true);
homePane.setVisible(false);
@@ -290,6 +293,7 @@ public class CalculatorController {
*/
@SuppressWarnings("Duplicates")
public void displayHome(ActionEvent event) {
getStartedPane.setVisible(false);
travelPane.setVisible(false);
homePane.setVisible(true);
@@ -305,6 +309,7 @@ public class CalculatorController {
*/
@SuppressWarnings("Duplicates")
public void displayFood(ActionEvent event) {
getStartedPane.setVisible(false);
travelPane.setVisible(false);
homePane.setVisible(false);
@@ -320,6 +325,7 @@ public class CalculatorController {
*/
@SuppressWarnings("Duplicates")
public void displayShopping(ActionEvent event) {
getStartedPane.setVisible(false);
travelPane.setVisible(false);
homePane.setVisible(false);
@@ -336,9 +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);

View File

@@ -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

View File

@@ -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<Number>() {
@Override
public void changed(ObservableValue<? extends Number> 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);
}
}

View File

@@ -1,5 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import java.lang.*?>
<?import javafx.scene.chart.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.image.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.shape.*?>
<?import javafx.scene.text.*?>
<?import javafx.scene.chart.PieChart?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.CheckBox?>
@@ -15,7 +22,7 @@
<?import javafx.scene.text.Font?>
<?import javafx.scene.text.Text?>
<AnchorPane prefHeight="702.0" prefWidth="1032.0" xmlns="http://javafx.com/javafx/10.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="greenify.client.controller.DashBoardController">
<AnchorPane prefHeight="702.0" prefWidth="1032.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="greenify.client.controller.DashBoardController">
<children>
<AnchorPane fx:id="menuBar" prefHeight="703.0" prefWidth="216.0" style="-fx-background-color: #5a635c;">
<children>
@@ -272,6 +279,18 @@
<CheckBox fx:id="solarPanels" layoutX="195.0" layoutY="103.0" mnemonicParsing="false" prefHeight="27.0" prefWidth="55.0" />
</children>
</Pane>
<Button contentDisplay="RIGHT" layoutX="545.0" layoutY="14.0" mnemonicParsing="false" onAction="#openExtraActivities" style="-fx-background-color: transparent;" text="Add extra activity!" textFill="#147219">
<graphic>
<ImageView fitHeight="69.0" fitWidth="61.0" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="@../icons/addActivity1.png" />
</image>
</ImageView>
</graphic>
<font>
<Font name="System Bold Italic" size="14.0" />
</font>
</Button>
</children></AnchorPane>
<AnchorPane fx:id="userPane" layoutX="215.0" layoutY="-1.0" prefHeight="703.0" prefWidth="820.0" visible="false" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="214.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<children>
@@ -420,6 +439,18 @@
<Font size="20.0" />
</font>
</Label>
<Button contentDisplay="RIGHT" layoutX="568.0" layoutY="223.0" mnemonicParsing="false" onAction="#openExtraActivities" style="-fx-background-color: transparent;" text="Add extra activity" textFill="#147219">
<font>
<Font name="Corbel Bold" size="14.0" />
</font>
<graphic>
<ImageView fitHeight="80.0" fitWidth="79.0" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="@../icons/addActivity1.png" />
</image>
</ImageView>
</graphic>
</Button>
</children>
</AnchorPane>
<AnchorPane fx:id="friendsPane" layoutX="216.0" prefHeight="703.0" prefWidth="820.0" visible="false" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="214.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">

View File

@@ -1,20 +1,188 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.shape.*?>
<?import javafx.scene.text.*?>
<?import javafx.scene.image.*?>
<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.shape.Line?>
<AnchorPane xmlns="http://javafx.com/javafx"
xmlns:fx="http://javafx.com/fxml"
fx:controller="greenify.client.controller.CalculatorController"
prefHeight="611.0" prefWidth="820.0">
<children>
<Button text="click">
</Button>
</children>
<AnchorPane prefHeight="611.0" prefWidth="820.0" stylesheets="@../stylesheets/extraActivitiesStyle.css" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="greenify.client.controller.ExtraActivityController">
<children>
<AnchorPane prefHeight="611.0" prefWidth="107.0">
<children>
<Button fx:id="displayVeganMealButton" contentDisplay="TOP" layoutX="14.0" layoutY="143.0" mnemonicParsing="false" onAction="#displayVeganMeal" prefHeight="70.0" prefWidth="82.0" styleClass="navButton">
<graphic>
<ImageView fitHeight="45.0" fitWidth="45.0" pickOnBounds="true" preserveRatio="true" styleClass="navButton">
<image>
<Image url="@../icons/icons8-vegan-food-100.png" />
</image>
</ImageView>
</graphic>
</Button>
<Button fx:id="displayBikeButton" contentDisplay="TOP" layoutX="14.0" layoutY="224.0" mnemonicParsing="false" onAction="#displayBike" prefHeight="70.0" prefWidth="82.0" styleClass="navButton">
<graphic>
<ImageView fitHeight="45.0" fitWidth="48.0" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="@../icons/icons8-bicycle-filled-100.png" />
</image>
</ImageView>
</graphic></Button>
<Button fx:id="displayTemperatureButton" contentDisplay="TOP" layoutX="14.0" layoutY="305.0" mnemonicParsing="false" onAction="#displayTemperature" prefHeight="70.0" prefWidth="82.0" styleClass="navButton">
<graphic>
<ImageView fitHeight="45.0" fitWidth="48.0" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="@../icons/icons8-temperature-inside-64.png" />
</image>
</ImageView>
</graphic>
</Button>
<Button fx:id="displaySolarPanelButton" contentDisplay="TOP" layoutX="14.0" layoutY="386.0" mnemonicParsing="false" onAction="#displaySolarPanel" prefHeight="70.0" prefWidth="82.0" styleClass="navButton">
<graphic>
<ImageView fitHeight="45.0" fitWidth="48.0" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="@../icons/icons8-solar-panel-filled-100.png" />
</image>
</ImageView>
</graphic>
</Button>
</children>
</AnchorPane>
<AnchorPane fx:id="veganMealPane" layoutX="107.0" prefHeight="611.0" prefWidth="713.0" visible="false">
<children>
<Line fx:id="line1" endX="79.0" layoutX="465.0" layoutY="7.0" stroke="#545b54" />
<Text layoutX="248.0" layoutY="56.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Eating a vegetarian meal">
<font>
<Font size="20.0" />
</font>
</Text>
<Button fx:id="addVeganMealButton" contentDisplay="TOP" layoutX="267.0" layoutY="226.0" mnemonicParsing="false" prefHeight="150.0" prefWidth="180.0" style="-fx-background-color: transparent;" text="Add activity!" textFill="#23652b">
<graphic>
<ImageView fitHeight="116.0" fitWidth="156.0" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="@../icons/addActivity1.png" />
</image>
</ImageView>
</graphic>
<font>
<Font name="System Bold Italic" size="18.0" />
</font>
</Button>
</children>
</AnchorPane>
<AnchorPane fx:id="bikePane" layoutX="107.0" prefHeight="611.0" prefWidth="713.0" visible="false">
<children>
<Line fx:id="line2" endX="79.0" layoutX="465.0" layoutY="7.0" stroke="#545b54" />
<Text layoutX="203.0" layoutY="56.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Using your bike instead of your car">
<font>
<Font size="20.0" />
</font>
</Text>
<Slider fx:id="bikeSlider" layoutX="144.0" layoutY="271.0" majorTickUnit="20.0" max="200.0" minorTickCount="0" prefHeight="24.0" prefWidth="427.0" showTickLabels="true" showTickMarks="true" />
<Text fill="#727272" layoutX="179.0" layoutY="144.0" strokeType="OUTSIDE" strokeWidth="0.0" text="How many km did you travel using your bike &#10;that you would have traveled with your car?" textAlignment="CENTER">
<font>
<Font size="18.0" />
</font>
</Text>
<Button fx:id="addBikeButton" contentDisplay="TOP" layoutX="267.0" layoutY="351.0" mnemonicParsing="false" prefHeight="150.0" prefWidth="180.0" style="-fx-background-color: transparent;" text="Add activity!" textFill="#23652b">
<font>
<Font name="System Bold Italic" size="18.0" />
</font>
<graphic>
<ImageView fitHeight="116.0" fitWidth="156.0" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="@../icons/addActivity1.png" />
</image>
</ImageView>
</graphic>
</Button>
<HBox alignment="CENTER" layoutX="305.0" layoutY="204.0" prefHeight="36.0" prefWidth="107.0" styleClass="textHolder">
<children>
<Label fx:id="bikeLabel" text="0 km">
<font>
<Font size="17.0" />
</font>
</Label>
</children>
</HBox>
</children>
</AnchorPane>
<AnchorPane fx:id="temperaturePane" layoutX="107.0" prefHeight="611.0" prefWidth="713.0" visible="false">
<children>
<Line fx:id="line3" endX="79.0" layoutX="465.0" layoutY="7.0" stroke="#545b54" />
<Text layoutX="179.0" layoutY="56.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Lowering the temperature of your home">
<font>
<Font size="20.0" />
</font>
</Text>
<Text fill="#727272" layoutX="187.0" layoutY="133.0" strokeType="OUTSIDE" strokeWidth="0.0" text="How many degrees (Celcius) did you lower&#10;your home temperature?" textAlignment="CENTER">
<font>
<Font size="18.0" />
</font>
</Text>
<Slider fx:id="temperatureSlider" blockIncrement="1.0" layoutX="176.0" layoutY="266.0" majorTickUnit="1.0" max="15.0" minorTickCount="0" prefHeight="24.0" prefWidth="360.0" showTickLabels="true" showTickMarks="true" />
<HBox alignment="CENTER" layoutX="316.0" layoutY="194.0" prefHeight="36.0" prefWidth="107.0" styleClass="textHolder">
<children>
<Label fx:id="temperatureLabel" text="0 Degrees">
<font>
<Font size="17.0" />
</font>
</Label>
</children>
</HBox>
<Button fx:id="addTemperatureButton" contentDisplay="TOP" layoutX="267.0" layoutY="353.0" mnemonicParsing="false" prefHeight="150.0" prefWidth="180.0" style="-fx-background-color: transparent;" text="Add activity!" textFill="#23652b">
<font>
<Font name="System Bold Italic" size="18.0" />
</font>
<graphic>
<ImageView fitHeight="116.0" fitWidth="156.0" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="@../icons/addActivity1.png" />
</image>
</ImageView>
</graphic>
</Button>
</children>
</AnchorPane>
<AnchorPane fx:id="solarPanelPane" layoutX="107.0" prefHeight="611.0" prefWidth="713.0">
<children>
<Line fx:id="line4" endX="79.0" layoutX="465.0" layoutY="7.0" stroke="#545b54" />
<Text layoutX="262.0" layoutY="56.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Installing solar panels">
<font>
<Font size="20.0" />
</font>
</Text>
<Text fill="#727272" layoutX="202.0" layoutY="150.0" strokeType="OUTSIDE" strokeWidth="0.0" text="How many solar panels did you install?" textAlignment="CENTER">
<font>
<Font size="18.0" />
</font>
</Text>
<HBox alignment="CENTER" layoutX="329.0" layoutY="201.0" prefHeight="36.0" prefWidth="56.0" styleClass="textHolder">
<children>
<Label fx:id="solarPanelsLabel" text="0">
<font>
<Font size="17.0" />
</font>
</Label>
</children>
</HBox>
<Slider fx:id="solarPanelsSlider" blockIncrement="1.0" layoutX="187.0" layoutY="274.0" majorTickUnit="1.0" max="10.0" min="1.0" minorTickCount="0" prefHeight="24.0" prefWidth="338.0" showTickLabels="true" showTickMarks="true" />
<Button fx:id="addSolarPanelsButton" contentDisplay="TOP" layoutX="267.0" layoutY="378.0" mnemonicParsing="false" prefHeight="150.0" prefWidth="180.0" style="-fx-background-color: transparent;" text="Add activity!" textFill="#23652b">
<font>
<Font name="System Bold Italic" size="18.0" />
</font>
<graphic>
<ImageView fitHeight="116.0" fitWidth="156.0" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="@../icons/addActivity1.png" />
</image>
</ImageView>
</graphic>
</Button>
</children>
</AnchorPane>
</children>
</AnchorPane>

Binary file not shown.

After

Width:  |  Height:  |  Size: 825 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View File

@@ -29,7 +29,6 @@
.slider {
-show-value-on-interaction: true;
-fx-text-fill: red;
}
.km-yearBox {

View File

@@ -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;
}