6 Commits

Author SHA1 Message Date
Sem van der Hoeven
377db10f13 EDIT::changed color of register window button 2019-04-10 12:24:11 +02:00
Sem van der Hoeven
50fb2078b0 EDIT::fixed checkstyle import 2019-04-10 12:22:23 +02:00
Sem van der Hoeven
123a767a75 ADD::added style to button in register window 2019-04-10 12:19:31 +02:00
Sem van der Hoeven
e0e6744c95 EDIT::removed lines from background of vegetarian meals achievement picture 2019-04-10 12:07:07 +02:00
Sem van der Hoeven
cfc238af73 ADD::Added animations to switching panes in extra activities 2019-04-10 12:04:17 +02:00
Sem van der Hoeven
78e050751f ADD::added animations to buttons in login and register screen 2019-04-10 11:49:31 +02:00
13 changed files with 180 additions and 127 deletions

View File

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

View File

@@ -2,12 +2,15 @@ package greenify.client.controller;
import com.sun.javafx.scene.control.skin.ButtonSkin;
import greenify.client.rest.UserService;
import javafx.animation.FadeTransition;
import javafx.animation.ParallelTransition;
import javafx.animation.ScaleTransition;
import javafx.animation.TranslateTransition;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.Node;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.Slider;
@@ -129,12 +132,26 @@ public class ExtraActivityController {
});
}
public void addFadeTransAnimation(Node node) {
FadeTransition fade = new FadeTransition(Duration.millis(350), node);
fade.setFromValue(0);
fade.setToValue(1.0);
TranslateTransition trans = new TranslateTransition(Duration.millis(350), node);
trans.setFromX(-800);
trans.setToX(0);
ParallelTransition par = new ParallelTransition();
par.setNode(node);
par.getChildren().addAll(fade, trans);
par.play();
}
/**
* displays the vegetarian meal section.
* @param event the click of the designated button
*/
public void displayVeganMeal(ActionEvent event) {
// System.out.println("display vm");
addFadeTransAnimation(veganMealPane);
veganMealPane.setVisible(true);
bikePane.setVisible(false);
temperaturePane.setVisible(false);
@@ -149,6 +166,7 @@ public class ExtraActivityController {
*/
public void displayBike(ActionEvent event) {
// System.out.println("display b");
addFadeTransAnimation(bikePane);
veganMealPane.setVisible(false);
bikePane.setVisible(true);
temperaturePane.setVisible(false);
@@ -163,6 +181,7 @@ public class ExtraActivityController {
*/
public void displayTemperature(ActionEvent event) {
// System.out.println("display t");
addFadeTransAnimation(temperaturePane);
veganMealPane.setVisible(false);
bikePane.setVisible(false);
temperaturePane.setVisible(true);
@@ -177,6 +196,7 @@ public class ExtraActivityController {
*/
public void displaySolarPanel(ActionEvent event) {
// System.out.println("display sp");
addFadeTransAnimation(solarPanelPane);
veganMealPane.setVisible(false);
bikePane.setVisible(false);
temperaturePane.setVisible(false);
@@ -190,6 +210,7 @@ public class ExtraActivityController {
* @param event the click of the designated button
*/
public void displayLocalProduce(ActionEvent event) {
addFadeTransAnimation(localProducePane);
veganMealPane.setVisible(false);
bikePane.setVisible(false);
temperaturePane.setVisible(false);
@@ -203,6 +224,7 @@ public class ExtraActivityController {
* @param event the click of the designated button
*/
public void displayPublicTransport(ActionEvent event) {
addFadeTransAnimation(publicTransportPane);
veganMealPane.setVisible(false);
bikePane.setVisible(false);
temperaturePane.setVisible(false);

View File

@@ -1,5 +1,6 @@
package greenify.client.controller;
import com.sun.javafx.scene.control.skin.ButtonSkin;
import greenify.client.Application;
import greenify.client.rest.UserService;
import javafx.animation.FadeTransition;
@@ -7,8 +8,10 @@ import javafx.animation.Interpolator;
import javafx.animation.KeyFrame;
import javafx.animation.KeyValue;
import javafx.animation.ParallelTransition;
import javafx.animation.ScaleTransition;
import javafx.animation.Timeline;
import javafx.animation.TranslateTransition;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.event.ActionEvent;
@@ -24,7 +27,6 @@ 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;
@@ -48,10 +50,6 @@ public class RegisterWindowController {
@Autowired
ExtraActivityController extraActivityController;
@FXML
private Text explainText;
//navigation panes
@FXML
private AnchorPane getStartedPane;
@@ -165,9 +163,6 @@ public class RegisterWindowController {
private PasswordField passwordField2;
@FXML
private Button signUpButton;
//@FXML
//private Line uNamePathLine;
@@ -180,6 +175,8 @@ public class RegisterWindowController {
addSlideAnimation(1100, passwordField, 300);
TimeUnit.MILLISECONDS.sleep(300);
addSlideAnimation(1100, passwordField2, -420);
signUpButton.setSkin(new registerButtonSkin(signUpButton));
}
/**
@@ -195,18 +192,6 @@ 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
@@ -250,7 +235,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);
@@ -633,4 +618,37 @@ public class RegisterWindowController {
carTravelElectricLabel.getText().replace(" km/Le", ""));
}
}
@SuppressWarnings("Duplicates")
public class registerButtonSkin extends ButtonSkin {
public registerButtonSkin(Button button) {
super(button);
ScaleTransition scaleUp = new ScaleTransition(Duration.millis(140));
scaleUp.setToX(1.2);
scaleUp.setToY(1.2);
scaleUp.setNode(button);
button.setOnMouseEntered(e -> scaleUp.playFromStart());
ScaleTransition scaleMiddleDown = new ScaleTransition(Duration.millis(50));
scaleMiddleDown.setToX(1.1);
scaleMiddleDown.setToY(1.1);
scaleMiddleDown.setNode(button);
button.setOnMousePressed(e -> scaleMiddleDown.playFromStart());
ScaleTransition scaleMiddleUp = new ScaleTransition(Duration.millis(50));
scaleMiddleUp.setToX(1.2);
scaleMiddleUp.setToY(1.2);
scaleMiddleUp.setNode(button);
button.setOnMouseReleased(e -> scaleMiddleUp.playFromStart());
ScaleTransition scaleDown = new ScaleTransition(Duration.millis(200));
scaleDown.setToX(1.0);
scaleDown.setToY(1.0);
scaleDown.setNode(button);
button.setOnMouseExited(e -> scaleDown.playFromStart());
}
}
}

View File

@@ -1,7 +1,9 @@
package greenify.client.controller;
import com.sun.javafx.scene.control.skin.ButtonSkin;
import greenify.client.Application;
import greenify.client.rest.UserService;
import javafx.animation.ScaleTransition;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.Parent;
@@ -12,6 +14,7 @@ import javafx.scene.control.PasswordField;
import javafx.scene.control.TextField;
import javafx.stage.Stage;
import javafx.stage.Window;
import javafx.util.Duration;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.client.HttpClientErrorException;
@@ -36,6 +39,10 @@ public class UserController {
@FXML
private Button signUpButton;
public void initialize() {
loginButton.setSkin(new LoginButtonSkin(loginButton));
signUpButton.setSkin(new LoginButtonSkin(signUpButton));
}
/**
* Handles when the user clicks on the login button.
* it checks if the username and password fields are filled
@@ -136,11 +143,47 @@ public class UserController {
Parent registerWindow = Application.load(this.getClass().getClassLoader()
.getResource("fxml/RegisterWindow.fxml"));
Scene registerScene = new Scene(registerWindow);
registerScene.getStylesheets().add(this.getClass().getClassLoader()
.getResource("stylesheets/registerWindowStyle.css").toExternalForm());
Stage registerStage = new Stage();
registerStage.setScene(registerScene);
registerStage.setTitle("Enter register credentials");
registerStage.show();
}
@SuppressWarnings("Duplicates")
public class LoginButtonSkin extends ButtonSkin {
public LoginButtonSkin(Button button) {
super(button);
ScaleTransition scaleUp = new ScaleTransition(Duration.millis(140));
scaleUp.setToX(1.1);
scaleUp.setToY(1.1);
scaleUp.setNode(button);
button.setOnMouseEntered(e -> scaleUp.playFromStart());
ScaleTransition scaleMiddleDown = new ScaleTransition(Duration.millis(50));
scaleMiddleDown.setFromX(1.1);
scaleMiddleDown.setFromY(1.1);
scaleMiddleDown.setToX(1.05);
scaleMiddleDown.setToY(1.05);
scaleMiddleDown.setNode(button);
button.setOnMousePressed(e -> scaleMiddleDown.playFromStart());
ScaleTransition scaleMiddleUp = new ScaleTransition(Duration.millis(50));
scaleMiddleUp.setFromX(1.05);
scaleMiddleUp.setFromY(1.05);
scaleMiddleUp.setToX(1.1);
scaleMiddleUp.setToY(1.1);
scaleMiddleUp.setNode(button);
button.setOnMouseReleased(e -> scaleMiddleUp.playFromStart());
ScaleTransition scaleDown = new ScaleTransition(Duration.millis(200));
scaleDown.setToX(1.0);
scaleDown.setToY(1.0);
scaleDown.setNode(button);
button.setOnMouseExited(e -> scaleDown.playFromStart());
}
}
}

View File

@@ -1,26 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import java.lang.*?>
<?import javafx.scene.shape.*?>
<?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>
@@ -161,25 +146,6 @@
</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

@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import java.lang.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.image.*?>
<?import javafx.scene.layout.*?>
@@ -24,7 +25,7 @@
<Font size="13.0" />
</font>
</TextField>
<Button fx:id="signUpButton" layoutX="115.0" layoutY="229.0" mnemonicParsing="false" onAction="#handleSignUpButton" style="-fx-background-color: #005e07;" text="Sign up!" textFill="#c4eec9">
<Button fx:id="signUpButton" layoutX="115.0" layoutY="229.0" mnemonicParsing="false" onAction="#handleSignUpButton" text="Sign up!" textFill="#c4eec9">
<font>
<Font name="Corbel Bold" size="14.0" />
</font>

View File

@@ -461,14 +461,14 @@
</Button>
<TableView fx:id="globalLeaderboard" layoutX="56.0" layoutY="220.0" prefHeight="333.0" prefWidth="200.0">
<columns>
<TableColumn fx:id="globalUser" prefWidth="75.0" text="User" />
<TableColumn fx:id="globalScore" prefWidth="124.0" text="Score" />
<TableColumn fx:id="globalUser" prefWidth="121.0" text="User" />
<TableColumn fx:id="globalScore" prefWidth="78.0" text="Score" />
</columns>
</TableView>
<TableView fx:id="developmentLeaderboard" layoutX="302.0" layoutY="220.0" prefHeight="333.0" prefWidth="200.0">
<columns>
<TableColumn fx:id="developmentUser" prefWidth="75.0" text="User" />
<TableColumn fx:id="developmentScore" prefWidth="124.0" text="Score" />
<TableColumn fx:id="developmentUser" prefWidth="126.0" text="User" />
<TableColumn fx:id="developmentScore" prefWidth="73.0" text="Score" />
</columns>
</TableView>
<Label layoutX="69.0" layoutY="177.0" prefHeight="46.0" prefWidth="187.0" text="Global Leaderboard" textAlignment="CENTER" textFill="#5f1616">

View File

@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import java.lang.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.image.*?>
<?import javafx.scene.layout.*?>
@@ -8,63 +9,6 @@
<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="62.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="displayLocalProduceButton" contentDisplay="TOP" layoutX="14.0" layoutY="143.0" mnemonicParsing="false" onAction="#displayLocalProduce" 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/localProduce.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="displaySolarPanelButton" contentDisplay="TOP" layoutX="14.0" layoutY="467.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>
<Button fx:id="displayTemperatureButton" contentDisplay="TOP" layoutX="14.0" layoutY="386.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="displayPublicTransportButton" contentDisplay="TOP" layoutX="14.0" layoutY="305.0" mnemonicParsing="false" onAction="#displayPublicTransport" 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/publicTransport.png" />
</image>
</ImageView>
</graphic>
</Button>
</children>
</AnchorPane>
<AnchorPane fx:id="veganMealPane" layoutX="107.0" prefHeight="611.0" prefWidth="713.0">
<children>
<Line fx:id="line1" endX="79.0" layoutX="465.0" layoutY="7.0" stroke="#545b54" />
@@ -257,5 +201,62 @@
</HBox>
</children>
</AnchorPane>
<AnchorPane prefHeight="611.0" prefWidth="107.0">
<children>
<Button fx:id="displayVeganMealButton" contentDisplay="TOP" layoutX="14.0" layoutY="62.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="displayLocalProduceButton" contentDisplay="TOP" layoutX="14.0" layoutY="143.0" mnemonicParsing="false" onAction="#displayLocalProduce" 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/localProduce.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="displaySolarPanelButton" contentDisplay="TOP" layoutX="14.0" layoutY="467.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>
<Button fx:id="displayTemperatureButton" contentDisplay="TOP" layoutX="14.0" layoutY="386.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="displayPublicTransportButton" contentDisplay="TOP" layoutX="14.0" layoutY="305.0" mnemonicParsing="false" onAction="#displayPublicTransport" 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/publicTransport.png" />
</image>
</ImageView>
</graphic>
</Button>
</children>
</AnchorPane>
</children>
</AnchorPane>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.4 KiB

View File

@@ -2,4 +2,12 @@
-fx-background-color: #005e07;
-fx-text-fill: #c4eec9;
-fx-font-weight: bold;
}
.button:hover {
-fx-background-color: #027009;
}
.button:pressed {
-fx-background-color: #1ba023;
}

View File

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

View File

@@ -110,11 +110,6 @@ 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);