4 Commits

Author SHA1 Message Date
Sem van der Hoeven
3960efaad8 ADD::added button to display/hide explaination
EDIT::moved explaination to the center
2019-04-10 22:07:31 +02:00
Merel Steenbergen
867eae66f4 ADD::Explanation in first calculator screen 2019-04-09 16:28:17 +02:00
Mika Wauben
37d43c8247 Merge branch 'Update/activitiesPane' into 'master'
UPDATE:: activities pane (added all extra activities)

See merge request cse1105/2018-2019/oopp-group-43/template!82
2019-04-09 13:37:28 +00:00
Mika Wauben
a704522a63 UPDATE:: activities pane (added all extra activities) 2019-04-09 13:37:28 +00:00
8 changed files with 106 additions and 28 deletions

View File

@@ -144,6 +144,7 @@ public class CalculatorController {
@FXML
private Label servicesLabel;
//extra pane
@FXML
private AnchorPane extraPane;
@@ -400,7 +401,7 @@ public class CalculatorController {
}
try {
extraActivityController.updateExtras();
} catch (Exception ex) {
} catch (NullPointerException ex) {
System.out.println("continue");
}
Float footprint = userService.saveFootprint(userService.currentUser.getName());

View File

@@ -185,14 +185,18 @@ public class DashBoardController {
@FXML
private Label hintText;
@FXML
private Label solarPanels;
private Label veganMeal;
@FXML
private Label localProduce;
@FXML
private Label bike;
@FXML
private Label publicTrans;
@FXML
private Label loweringTemp;
@FXML
private Label solarPanels;
@FXML
private Button achiev1Tip;
@FXML
private Button achiev2Tip;
@@ -417,10 +421,12 @@ public class DashBoardController {
snacks.setText(inputMap.get("input_footprint_shopping_food_otherfood"));
Map<String, String> extraMap = userService
.getExtraInputs(userService.currentUser.getName());
veganMeal.setText(extraMap.get("vegan"));
localProduce.setText(extraMap.get("local_produce"));
bike.setText(extraMap.get("bike"));
solarPanels.setText(extraMap.get("solar_panels"));
publicTrans.setText(extraMap.get("public_transport"));
loweringTemp.setText(extraMap.get("temperature"));
solarPanels.setText(extraMap.get("solar_panels"));
}
/**

View File

@@ -24,6 +24,7 @@ import javafx.scene.control.ScrollPane;
import javafx.scene.control.Slider;
import javafx.scene.control.TextField;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.HBox;
import javafx.scene.text.Text;
import javafx.stage.Stage;
import javafx.stage.Window;
@@ -47,6 +48,10 @@ public class RegisterWindowController {
@Autowired
ExtraActivityController extraActivityController;
@FXML
private Text explainText;
//navigation panes
@FXML
private AnchorPane getStartedPane;
@@ -160,6 +165,9 @@ public class RegisterWindowController {
private PasswordField passwordField2;
@FXML
private Button signUpButton;
//@FXML
//private Line uNamePathLine;
@@ -187,6 +195,18 @@ public class RegisterWindowController {
slideIn.play();
}
public void showExplanation(ActionEvent event) throws InterruptedException {
System.out.println(explainText.isVisible());
if (explainText.isVisible()) {
System.out.println("set to false");
explainText.setVisible(false);
} else {
System.out.println("set to true");
explainText.setVisible(true);
}
}
/**
* Signs up the user.
* @param event the click of the sign up button
@@ -230,7 +250,7 @@ public class RegisterWindowController {
//close the register window after the user has entered all the credentials
Stage current = (Stage) owner;
current.close();
Parent calc = Application.load(this.getClass().getClassLoader()
.getResource("fxml/FirstCalculator.fxml"));
Scene scene = new Scene(calc);

View File

@@ -1,11 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.shape.*?>
<?import java.lang.*?>
<?import javafx.geometry.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.image.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.shape.*?>
<?import javafx.scene.text.*?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.CheckBox?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.ScrollPane?>
<?import javafx.scene.control.Slider?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.image.Image?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.shape.Line?>
<?import javafx.scene.text.Font?>
<?import javafx.scene.text.Text?>
<AnchorPane prefHeight="703.0" prefWidth="820.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="greenify.client.controller.RegisterWindowController">
<children>
@@ -146,6 +161,25 @@
</Label>
<Button fx:id="getStartedNextButton" layoutX="383.0" layoutY="406.0" mnemonicParsing="false" onAction="#displayTravel" styleClass="nextButton" text="Next" />
<Line endX="79.0" layoutX="147.0" layoutY="14.0" stroke="#545b54" />
<Text layoutX="296.0" layoutY="51.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Welcome to Greenify!">
<font>
<Font name="System Bold" size="22.0" />
</font>
</Text>
<Text fx:id="explainText" layoutX="53.0" layoutY="487.0" strokeType="OUTSIDE" strokeWidth="0.0" text="This application will help you decrease your CO2-footprint. In the next screen, you will be asked to fill in certain things, like your yearly energy costs. These values will help us calculate your CO2-footprint. Warning: If you don't fill anything in, the calculator will use a default value based on averages, so if you want a value to be zero, please fill in zero. After that, you'll be able to see your score and compare your footprint to those of your friends. Let's go green and save the planet!" textAlignment="CENTER" visible="false" wrappingWidth="714.0">
<font>
<Font size="16.0" />
</font>
</Text>
<Button layoutX="14.0" layoutY="532.0" mnemonicParsing="false" onAction="#showExplanation" style="-fx-background-color: transparent; -fx-padding: 0 0 0 0;">
<graphic>
<ImageView fitHeight="73.0" fitWidth="72.0" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="@../icons/questionmark.png" />
</image>
</ImageView>
</graphic>
</Button>
</children></AnchorPane>
<AnchorPane fx:id="travelPane" layoutY="85.0" prefHeight="618.0" prefWidth="820.0" visible="false">
<children>

View File

@@ -241,71 +241,83 @@
<Font name="System Bold Italic" size="18.0" />
</font>
</Label>
<Pane layoutX="545.0" layoutY="130.0" prefHeight="342.0" prefWidth="255.0" style="-fx-background-color: #f4fff4;">
<Pane layoutX="545.0" layoutY="130.0" prefHeight="255.0" prefWidth="255.0" style="-fx-background-color: #f4fff4;">
<children>
<Label alignment="CENTER" contentDisplay="CENTER" layoutX="18.0" layoutY="26.0" prefHeight="46.0" prefWidth="115.0" text="Meat fish eggs">
<Label alignment="CENTER" contentDisplay="CENTER" layoutX="18.0" layoutY="14.0" prefHeight="46.0" prefWidth="115.0" text="Meat fish eggs">
<font>
<Font size="14.0" />
</font>
</Label>
<Label alignment="CENTER" contentDisplay="CENTER" layoutX="18.0" layoutY="90.0" prefHeight="46.0" prefWidth="115.0" text="Grains/baked &#10;foods" textAlignment="CENTER">
<Label alignment="CENTER" contentDisplay="CENTER" layoutX="18.0" layoutY="60.0" prefHeight="46.0" prefWidth="115.0" text="Grains/baked &#10;foods" textAlignment="CENTER">
<font>
<Font size="14.0" />
</font>
</Label>
<Label alignment="CENTER" contentDisplay="CENTER" layoutX="18.0" layoutY="154.0" prefHeight="46.0" prefWidth="115.0" text="Dairy">
<Label alignment="CENTER" contentDisplay="CENTER" layoutX="18.0" layoutY="106.0" prefHeight="46.0" prefWidth="115.0" text="Dairy">
<font>
<Font size="14.0" />
</font>
</Label>
<Label alignment="CENTER" contentDisplay="CENTER" layoutX="18.0" layoutY="218.0" prefHeight="46.0" prefWidth="115.0" text="Fruits vegetables">
<Label alignment="CENTER" contentDisplay="CENTER" layoutX="18.0" layoutY="152.0" prefHeight="46.0" prefWidth="115.0" text="Fruits vegetables">
<font>
<Font size="14.0" />
</font>
</Label>
<Label alignment="CENTER" contentDisplay="CENTER" layoutX="18.0" layoutY="282.0" prefHeight="46.0" prefWidth="115.0" text="Snacks drinks">
<Label alignment="CENTER" contentDisplay="CENTER" layoutX="18.0" layoutY="198.0" prefHeight="46.0" prefWidth="115.0" text="Snacks drinks">
<font>
<Font size="14.0" />
</font>
</Label>
<Label fx:id="meat" layoutX="171.0" layoutY="41.0" styleClass="activityField" text="Label" />
<Label fx:id="grains" layoutX="171.0" layoutY="105.0" styleClass="activityField" text="Label" />
<Label fx:id="dairy" layoutX="171.0" layoutY="169.0" styleClass="activityField" text="Label" />
<Label fx:id="fruits" layoutX="171.0" layoutY="233.0" styleClass="activityField" text="Label" />
<Label fx:id="snacks" layoutX="171.0" layoutY="297.0" styleClass="activityField" text="Label" />
<Label fx:id="meat" layoutX="171.0" layoutY="29.0" styleClass="activityField" text="Label" />
<Label fx:id="grains" layoutX="171.0" layoutY="75.0" styleClass="activityField" text="Label" />
<Label fx:id="dairy" layoutX="171.0" layoutY="121.0" styleClass="activityField" text="Label" />
<Label fx:id="fruits" layoutX="171.0" layoutY="167.0" styleClass="activityField" text="Label" />
<Label fx:id="snacks" layoutX="171.0" layoutY="213.0" styleClass="activityField" text="Label" />
</children>
</Pane>
<Label alignment="CENTER" layoutX="545.0" layoutY="488.0" prefHeight="32.0" prefWidth="255.0" text="Extras!" textAlignment="CENTER" textFill="#107222">
<Label alignment="CENTER" layoutX="545.0" layoutY="385.0" prefHeight="32.0" prefWidth="255.0" text="Extras!" textAlignment="CENTER" textFill="#107222">
<font>
<Font name="System Bold Italic" size="18.0" />
</font>
</Label>
<Pane layoutX="545.0" layoutY="520.0" prefHeight="129.0" prefWidth="255.0" style="-fx-background-color: #f4fff4;">
<Pane layoutX="545.0" layoutY="412.0" prefHeight="238.0" prefWidth="255.0" style="-fx-background-color: #f4fff4;">
<children>
<Label alignment="CENTER" contentDisplay="CENTER" layoutX="18.0" layoutY="7.0" prefHeight="27.0" prefWidth="183.0" text="Buying local produce">
<Label alignment="CENTER" contentDisplay="CENTER" layoutX="12.0" layoutY="56.0" prefHeight="27.0" prefWidth="183.0" text="Buying local produce">
<font>
<Font size="14.0" />
</font>
</Label>
<Label fx:id="localProduce" layoutX="195.0" layoutY="7.0" mnemonicParsing="false" prefHeight="27.0" prefWidth="55.0" />
<Label alignment="CENTER" contentDisplay="CENTER" layoutX="18.0" layoutY="39.0" prefHeight="27.0" prefWidth="183.0" text="Using bike">
<Label fx:id="localProduce" layoutX="189.0" layoutY="56.0" mnemonicParsing="false" prefHeight="27.0" prefWidth="55.0" />
<Label alignment="CENTER" contentDisplay="CENTER" layoutX="12.0" layoutY="92.0" prefHeight="27.0" prefWidth="183.0" text="Using bike">
<font>
<Font size="14.0" />
</font>
</Label>
<Label fx:id="bike" layoutX="195.0" layoutY="39.0" mnemonicParsing="false" prefHeight="27.0" prefWidth="55.0" />
<Label alignment="CENTER" contentDisplay="CENTER" layoutX="20.0" layoutY="71.0" prefHeight="27.0" prefWidth="183.0" text="Lowering the temperature">
<Label fx:id="bike" layoutX="189.0" layoutY="92.0" mnemonicParsing="false" prefHeight="27.0" prefWidth="55.0" />
<Label alignment="CENTER" contentDisplay="CENTER" layoutX="13.0" layoutY="164.0" prefHeight="27.0" prefWidth="183.0" text="Lowering the temperature">
<font>
<Font size="14.0" />
</font>
</Label>
<Label fx:id="loweringTemp" layoutX="195.0" layoutY="71.0" mnemonicParsing="false" prefHeight="27.0" prefWidth="55.0" />
<Label alignment="CENTER" contentDisplay="CENTER" layoutX="20.0" layoutY="103.0" prefHeight="27.0" prefWidth="183.0" text="Installing solar panels">
<Label fx:id="loweringTemp" layoutX="188.0" layoutY="164.0" mnemonicParsing="false" prefHeight="27.0" prefWidth="55.0" />
<Label alignment="CENTER" contentDisplay="CENTER" layoutX="13.0" layoutY="200.0" prefHeight="27.0" prefWidth="183.0" text="Installing solar panels">
<font>
<Font size="14.0" />
</font>
</Label>
<Label fx:id="solarPanels" layoutX="195.0" layoutY="103.0" mnemonicParsing="false" prefHeight="27.0" prefWidth="55.0" />
<Label fx:id="solarPanels" layoutX="188.0" layoutY="200.0" mnemonicParsing="false" prefHeight="27.0" prefWidth="55.0" />
<Label alignment="CENTER" contentDisplay="CENTER" layoutX="13.0" layoutY="128.0" prefHeight="27.0" prefWidth="183.0" text="Using public transport">
<font>
<Font size="14.0" />
</font>
</Label>
<Label fx:id="publicTrans" layoutX="188.0" layoutY="128.0" mnemonicParsing="false" prefHeight="27.0" prefWidth="55.0" />
<Label alignment="CENTER" contentDisplay="CENTER" layoutX="11.0" layoutY="20.0" prefHeight="27.0" prefWidth="183.0" text="Eating vegetarian meal">
<font>
<Font size="14.0" />
</font>
</Label>
<Label fx:id="veganMeal" layoutX="188.0" layoutY="20.0" mnemonicParsing="false" prefHeight="27.0" prefWidth="55.0" />
</children>
</Pane>
<Button fx:id="addExtraActivityButton2" contentDisplay="RIGHT" layoutX="545.0" layoutY="14.0" mnemonicParsing="false" onAction="#openExtraActivities" style="-fx-background-color: transparent;" text="Add extra activity!" textFill="#147219">

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

View File

@@ -78,8 +78,8 @@ public class AchievementService {
* @param user user for whom achiev6 changes
*/
public void achieveLetItShine(User user) {
int solar_panels = Integer.parseInt(user.getExtraInputs().get("solar_panels"));
if (solar_panels >= 2) {
int solarPanels = Integer.parseInt(user.getExtraInputs().get("solar_panels"));
if (solarPanels >= 2) {
userService.setAchievement(user.getName(), "Let it shine", true);
}
}

View File

@@ -110,6 +110,11 @@ public class CalculatorService {
user.setFootPrintInputs(inputs);
}
/**
* Gets the result of the CO2-calculation from the CoolClimate website
* @param map results that the user filled in
* @return the results from the website.
*/
public Map<String, String> getResults(Map<String, String> map) {
HttpHeaders headers = new HttpHeaders();
headers.set("accept", MediaType.APPLICATION_JSON_VALUE);