ADD::almost completed travel pane of calculator

This commit is contained in:
Sem van der Hoeven
2019-03-27 09:44:34 +01:00
parent 1f03552d84
commit 1d10d1d54b
9 changed files with 84 additions and 26 deletions

View File

@@ -54,6 +54,7 @@ public class Application extends javafx.application.Application {
.getResource("fxml/LoginWindow.fxml"));
primaryStage.setTitle("Greenify");
Scene scene = new Scene(rootNode);
scene.getStylesheets().add(getClass().getClassLoader().getResource("stylesheets/LoginWindowStyle.css").toExternalForm());
primaryStage.setScene(scene);
primaryStage.show();
}

View File

@@ -7,8 +7,8 @@ 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.control.TextField;
import javafx.scene.layout.AnchorPane;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
@@ -31,7 +31,7 @@ public class CalculatorController {
@FXML
private AnchorPane getStartedPane;
@FXML
private ScrollPane travelPane;
private AnchorPane travelPane;
@FXML
private AnchorPane homePane;
@FXML
@@ -39,7 +39,7 @@ public class CalculatorController {
@FXML
private AnchorPane shoppingPane;
@FXML
private Slider peopleInHouseholdSLider;
private Slider peopleInHouseholdSlider;
@FXML
private Label peopleInHouseHoldLabel;
@FXML
@@ -48,8 +48,12 @@ public class CalculatorController {
private Label annualIncomeLabel;
@FXML
private Button saveButton;
// @FXML
// private Button getStartedNextButton;
@FXML
private Button getStartedNextButton;
private TextField publicTransitField;
@FXML
private TextField airplaneTravelField;
/**
* initializes the window, performs some actions before loading all other things.
@@ -57,10 +61,10 @@ public class CalculatorController {
* it adds listeners to all the sliders for updating the label next to them
*/
public void initialize() {
peopleInHouseholdSLider.setSnapToTicks(true);
peopleInHouseholdSlider.setSnapToTicks(true);
annualIncomeSlider.setSnapToTicks(true);
//add listener to slider for amount of people in household
peopleInHouseholdSLider.valueProperty().addListener(new ChangeListener<Number>() {
peopleInHouseholdSlider.valueProperty().addListener(new ChangeListener<Number>() {
public void changed(ObservableValue<? extends Number> observable,
Number oldValue, Number newValue) {

View File

@@ -61,6 +61,8 @@ public class DashBoardController {
private Button addNewActivityButton;
@FXML
private Button calculateFootPrintButton;
@FXML
private Label footPrintLabel;
/**
* Loads the the necessary things before anything else.

View File

@@ -1,10 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import java.lang.*?>
<?import javafx.scene.image.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.image.Image?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.text.*?>
<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="602.0" prefWidth="934.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="greenify.client.controller.UserController">
<children>
<ImageView fitHeight="600.0" fitWidth="943.0" layoutX="-1.0" pickOnBounds="true">
@@ -32,4 +36,3 @@
<TextField fx:id="usernameField" layoutX="319.0" layoutY="154.0" prefHeight="42.0" prefWidth="303.0" promptText="Username" />
</children>
</AnchorPane>

View File

@@ -12,7 +12,7 @@
<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.CalculatorController">
<children>
<AnchorPane fx:id="calculatorTabs" prefHeight="85.0" prefWidth="820.0" style="-fx-background-color: #677069;">
<AnchorPane fx:id="calculatorTabs" prefHeight="92.0" prefWidth="820.0" style="-fx-background-color: #677069;">
<children>
<Button fx:id="calculatorGetStartedButton" contentDisplay="TOP" layoutX="188.0" layoutY="5.0" mnemonicParsing="false" onAction="#displayGetStarted" style="-fx-padding: 0px 0px 0px 0px;" styleClass="navButton" text="Get started" textFill="#d4ddd6" AnchorPane.leftAnchor="188.0">
<font>
@@ -104,14 +104,14 @@
</font></Button>
</children>
</AnchorPane>
<AnchorPane fx:id="getStartedPane" layoutY="85.0" prefHeight="618.0" prefWidth="820.0" AnchorPane.leftAnchor="0.0">
<AnchorPane fx:id="getStartedPane" layoutY="85.0" prefHeight="618.0" prefWidth="820.0" visible="false" AnchorPane.leftAnchor="0.0">
<children>
<Text layoutX="224.0" layoutY="96.0" strokeType="OUTSIDE" strokeWidth="0.0" text="1. How many people live in your household?">
<font>
<Font size="19.0" />
</font>
</Text>
<Slider fx:id="peopleInHouseholdSLider" blockIncrement="1.0" layoutX="260.0" layoutY="147.0" majorTickUnit="1.0" max="6.0" min="1.0" minorTickCount="0" prefHeight="38.0" prefWidth="300.0" showTickLabels="true" showTickMarks="true" snapToTicks="true" />
<Slider fx:id="peopleInHouseholdSlider" blockIncrement="1.0" layoutX="260.0" layoutY="147.0" majorTickUnit="1.0" max="6.0" min="1.0" minorTickCount="0" prefHeight="38.0" prefWidth="300.0" showTickLabels="true" showTickMarks="true" snapToTicks="true" />
<Label fx:id="peopleInHouseHoldLabel" alignment="CENTER" contentDisplay="CENTER" layoutX="612.0" layoutY="70.0" prefHeight="38.0" prefWidth="44.0" text="0">
<font>
<Font size="20.0" />
@@ -137,7 +137,54 @@
</Label>
<Button fx:id="getStartedNextButton" layoutX="383.0" layoutY="406.0" mnemonicParsing="false" onAction="#displayTravel" styleClass="nextButton" text="Next" />
</children></AnchorPane>
<ScrollPane fx:id="travelPane" layoutY="85.0" prefHeight="618.0" prefWidth="820.0" visible="false" />
<AnchorPane fx:id="travelPane" layoutY="85.0" prefHeight="618.0" prefWidth="820.0">
<children>
<ScrollPane layoutX="158.0" layoutY="109.0" prefHeight="215.0" prefWidth="499.0">
<content>
<TextField prefHeight="33.0" prefWidth="497.0" />
</content></ScrollPane>
<Text layoutX="300.0" layoutY="36.0" strokeType="OUTSIDE" strokeWidth="0.0" text="How do you get around?">
<font>
<Font size="20.0" />
</font></Text>
<Text fill="#727272" layoutX="370.0" layoutY="103.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Car travel">
<font>
<Font size="18.0" />
</font>
</Text>
<Text fill="#727272" layoutX="355.0" layoutY="374.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Public Transit">
<font>
<Font size="18.0" />
</font>
</Text>
<TextField fx:id="publicTransitField" alignment="CENTER_RIGHT" layoutX="158.0" layoutY="394.0" prefHeight="31.0" prefWidth="499.0" promptText="0" />
<Text fill="#727272" layoutX="350.0" layoutY="476.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Airplane travel">
<font>
<Font size="18.0" />
</font>
</Text>
<TextField fx:id="airplaneTravelField" alignment="CENTER_RIGHT" layoutX="158.0" layoutY="495.0" prefHeight="31.0" prefWidth="499.0" promptText="0" />
<HBox alignment="CENTER_LEFT" layoutX="659.0" layoutY="394.0" prefHeight="31.0" prefWidth="62.0" styleClass="km-yearBox">
<children>
<Text layoutY="3.0" strokeType="OUTSIDE" strokeWidth="0.0" text="km/year" wrappingWidth="63.0">
<font>
<Font size="16.0" />
</font>
</Text>
</children>
</HBox>
<HBox alignment="CENTER_LEFT" layoutX="659.0" layoutY="495.0" prefHeight="31.0" prefWidth="62.0" styleClass="km-yearBox">
<children>
<Text layoutY="3.0" strokeType="OUTSIDE" strokeWidth="0.0" text="km/year" wrappingWidth="63.0">
<font>
<Font size="16.0" />
</font>
</Text>
</children>
</HBox>
<Button fx:id="travelNextButton" layoutX="383.0" layoutY="559.0" mnemonicParsing="false" onAction="#displayHome" styleClass="nextButton" text="Next" />
</children>
</AnchorPane>
<AnchorPane fx:id="homePane" layoutY="85.0" prefHeight="618.0" prefWidth="820.0" visible="false" />
<AnchorPane fx:id="foodPane" layoutY="85.0" prefHeight="618.0" prefWidth="820.0" visible="false" />
<AnchorPane fx:id="shoppingPane" layoutY="85.0" prefHeight="618.0" prefWidth="820.0" visible="false" />

View File

@@ -190,7 +190,7 @@
<Font size="24.0" />
</font>
</Text>
<Label fx:id="scoreField1" alignment="CENTER" contentDisplay="CENTER" prefHeight="27.0" prefWidth="134.0" text="co2 footprint" textAlignment="CENTER">
<Label fx:id="footPrintLabel" alignment="CENTER" contentDisplay="CENTER" prefHeight="27.0" prefWidth="134.0" text="co2 footprint" textAlignment="CENTER">
<font>
<Font size="18.0" />
</font>

View File

@@ -29,6 +29,13 @@
-fx-text-fill: red;
}
.km-yearBox {
-fx-background-color: #efefef;
-fx-border-radius: 5px;
-fx-background-radius: 5px;
-fx-padding: 0 0 0 3px;
}

View File

@@ -4,15 +4,9 @@ import greenify.common.ApplicationException;
import greenify.server.InputValidator;
import lombok.Data;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.util.*;
@Entity
@Data
@@ -147,8 +141,7 @@ public class User {
public void addFriend(User user) {
if (user.equals(this)) {
throw new ApplicationException("Cannot add yourself as a friend");
}
else {
} else {
friends.add(user);
System.out.print("Friend added!");
}
@@ -179,7 +172,8 @@ public class User {
return result + "]";
}
/** This method checks whether two users are equal or not.
/**
* This method checks whether two users are equal or not.
* @param other an other user
* @return users are (not) equal
*/

View File

@@ -1,9 +1,5 @@
package greenify.server.service;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.Mockito.when;
import greenify.common.ApplicationException;
import greenify.common.UserDto;
import greenify.server.data.model.User;
@@ -19,6 +15,10 @@ import org.springframework.test.context.junit4.SpringRunner;
import java.util.ArrayList;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.Mockito.when;
@RunWith(SpringRunner.class)
public class UserServiceTest {
@TestConfiguration