ADD:added section indicators to calculator

Merge branch 'master' of gitlab.ewi.tudelft.nl:cse1105/2018-2019/oopp-group-43/template

# Conflicts:
#	src/Client/src/main/resources/fxml/calculator.fxml
This commit is contained in:
Sem van der Hoeven
2019-03-30 11:18:50 +01:00

View File

@@ -12,10 +12,12 @@ import javafx.fxml.FXML;
import javafx.scene.Node;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.ScrollPane;
import javafx.scene.control.Slider;
import javafx.scene.control.TextField;
import javafx.scene.control.ScrollPane;
import javafx.scene.layout.AnchorPane;
import javafx.stage.Stage;
import javafx.stage.Window;
import javafx.util.Duration;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
@@ -77,10 +79,18 @@ public class CalculatorController {
//home pane
@FXML
private TextField electricityField;
@FXML
private Slider cleanEnergyPurchasedSlider;
@FXML
private Label cleanEnergyPurchasedLabel;
@FXML
private TextField naturalGasField;
@FXML
private TextField heatingOilField;
@FXML
private TextField livingSpaceField;
@FXML
private Slider waterUsageSlider;
@FXML
private Label waterUsageLabel;
@@ -293,24 +303,127 @@ public class CalculatorController {
* The method saves the calculation.
* @param event user clicks to button
*/
public void saveCalculation(ActionEvent event) {
public void saveCalc(ActionEvent event) {
Window owner = saveButton.getScene().getWindow();
getStartedPane.setVisible(false);
travelPane.setVisible(false);
homePane.setVisible(false);
foodPane.setVisible(false);
shoppingPane.setVisible(false);
if (!annualIncomeLabel.getText().equals(null)) {
if (!annualIncomeLabel.getText().equals("0")) {
userService.updateInput(userService.currentUser.getName(), "input_income",
annualIncomeLabel.getText());
}
if (!peopleInHouseHoldLabel.getText().equals(null)) {
userService.updateInput(userService.currentUser.getName(), "input_population",
if (!peopleInHouseHoldLabel.getText().equals("0")) {
userService.updateInput(userService.currentUser.getName(), "input_size",
peopleInHouseHoldLabel.getText());
}
userService.updateInput(userService.currentUser.getName(),
"input_footprint_housing_naturalgas_cuft", "0");
userService.updateInput(userService.currentUser.getName(),
"input_footprint_transportation_miles1", "0");
if (!publicTransitField.getText().equals("0")) {
userService.updateInput(userService.currentUser.getName(),
"input_footprint_transportation_publictrans",
publicTransitField.getText());
}
if (!airplaneTravelField.getText().equals("0")) {
userService.updateInput(userService.currentUser.getName(),
"input_footprint_transportation_airtotal",
airplaneTravelField.getText());
}
if (!carTravelGasolineField.getText().equals("0")) {
userService.updateInput(userService.currentUser.getName(),
"input_footprint_transportation_miles1",
carTravelGasolineField.getText());
}
if (!carTravelGasolineLabel.getText().replace(" km/L", "").equals("0")) {
userService.updateInput(userService.currentUser.getName(),
"input_footprint_transportation_mpg1",
carTravelGasolineLabel.getText());
}
if (!carTravelDieselField.getText().equals("0")) {
userService.updateInput(userService.currentUser.getName(),
"input_footprint_transportation_miles2",
carTravelDieselField.getText());
}
if (!carTravelDieselLabel.getText().replace(" km/L", "").equals("0")) {
userService.updateInput(userService.currentUser.getName(),
"input_footprint_transportation_mpg2",
carTravelDieselLabel.getText());
}
if (!carTravelElectricField.getText().equals("0")) {
userService.updateInput(userService.currentUser.getName(),
"input_footprint_transportation_miles3",
peopleInHouseHoldLabel.getText());
}
if (!carTravelElectricLabel.getText().replace(" km/Le", "").equals("0")) {
userService.updateInput(userService.currentUser.getName(),
"input_footprint_transportation_mpg3",
carTravelElectricLabel.getText());
}
if (!electricityField.getText().equals("0")) {
userService.updateInput(userService.currentUser.getName(),
"input_footprint_electricity_dollars",
electricityField.getText());
}
if (!cleanEnergyPurchasedLabel.getText().replace(" %", "").equals("0")) {
userService.updateInput(userService.currentUser.getName(),
"input_footprint_housing_gco2_per_kwh",
cleanEnergyPurchasedLabel.getText());
}
if (!naturalGasField.getText().equals("0")) {
userService.updateInput(userService.currentUser.getName(),
"input_footprint_naturalgas_dollars",
naturalGasField.getText());
}
if (!heatingOilField.getText().equals("0")) {
userService.updateInput(userService.currentUser.getName(),
"input_footprint_heatingoil_dollars",
heatingOilField.getText());
}
if (!livingSpaceField.getText().equals("0")) {
userService.updateInput(userService.currentUser.getName(),
"input_footprint_housing_squarefeet",
livingSpaceField.getText());
}
if (!waterUsageLabel.getText().replace("% of similar households", "").equals("0")) {
userService.updateInput(userService.currentUser.getName(),
"input_footprint_housing_watersewage",
waterUsageLabel.getText());
}
if (!meatFishEggsLabel.getText().replace(" daily servings per person", "").equals("2.6")) {
userService.updateInput(userService.currentUser.getName(),
"input_footprint_shopping_food_meatfisheggs",
meatFishEggsLabel.getText());
}
if (!grainsBakedGoodsLabel.getText().replace(" daily servings per person", "").equals("4.4")) {
userService.updateInput(userService.currentUser.getName(),
"input_footprint_shopping_food_cereals",
grainsBakedGoodsLabel.getText());
}
if (!dairyLabel.getText().replace(" daily servings per person", "").equals("2.4")) {
userService.updateInput(userService.currentUser.getName(),
"input_footprint_shopping_food_dairy",
dairyLabel.getText());
}
if (!fruitsVegetablesLabel.getText().replace(" daily servings per person", "").equals("3.9")) {
userService.updateInput(userService.currentUser.getName(),
"input_footprint_shopping_food_fruitvegetables",
fruitsVegetablesLabel.getText());
}
if (!snacksDrinksLabel.getText().replace(" daily servings per person", "").equals("3.7")) {
userService.updateInput(userService.currentUser.getName(),
"input_footprint_shopping_food_otherfood",
snacksDrinksLabel.getText());
}
if (!goodsLabel.getText().replace(" € / month", "").equals("1520")) {
userService.updateInput(userService.currentUser.getName(),
"input_footprint_shopping_goods_total",
snacksDrinksLabel.getText());
}
if (!servicesLabel.getText().replace(" € / month", "").equals("3428")) {
userService.updateInput(userService.currentUser.getName(),
"input_footprint_shopping_services_total",
snacksDrinksLabel.getText());
}
Stage current = (Stage) owner;
current.close();
}
}
}