2 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
6 changed files with 65 additions and 5 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

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

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);