Fix the number of decimal points of footprints
This commit is contained in:
@@ -1,16 +1,17 @@
|
|||||||
package greenify.client;
|
package greenify.client;
|
||||||
|
|
||||||
|
import javafx.beans.property.SimpleDoubleProperty;
|
||||||
import javafx.beans.property.SimpleFloatProperty;
|
import javafx.beans.property.SimpleFloatProperty;
|
||||||
import javafx.beans.property.SimpleStringProperty;
|
import javafx.beans.property.SimpleStringProperty;
|
||||||
|
|
||||||
public class Friend {
|
public class Friend {
|
||||||
|
|
||||||
private SimpleStringProperty friend;
|
private SimpleStringProperty friend;
|
||||||
private SimpleFloatProperty score;
|
private SimpleDoubleProperty score;
|
||||||
|
|
||||||
public Friend(String friend, Float friendScore) {
|
public Friend(String friend, Double friendScore) {
|
||||||
this.friend = new SimpleStringProperty(friend);
|
this.friend = new SimpleStringProperty(friend);
|
||||||
this.score = new SimpleFloatProperty(friendScore);
|
this.score = new SimpleDoubleProperty(friendScore);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -22,11 +23,11 @@ public class Friend {
|
|||||||
this.friend = new SimpleStringProperty(name);
|
this.friend = new SimpleStringProperty(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Float getScore() {
|
public Double getScore() {
|
||||||
return score.get();
|
return score.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setScore(Float score) {
|
public void setScore(Double score) {
|
||||||
this.score = new SimpleFloatProperty(score);
|
this.score = new SimpleDoubleProperty(score);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ import javafx.scene.Parent;
|
|||||||
import javafx.scene.Scene;
|
import javafx.scene.Scene;
|
||||||
import javafx.scene.chart.PieChart;
|
import javafx.scene.chart.PieChart;
|
||||||
import javafx.scene.control.Button;
|
import javafx.scene.control.Button;
|
||||||
import javafx.scene.control.CheckBox;
|
|
||||||
import javafx.scene.control.Label;
|
import javafx.scene.control.Label;
|
||||||
import javafx.scene.control.TableColumn;
|
import javafx.scene.control.TableColumn;
|
||||||
import javafx.scene.control.TableView;
|
import javafx.scene.control.TableView;
|
||||||
@@ -168,16 +167,16 @@ public class DashBoardController {
|
|||||||
@FXML
|
@FXML
|
||||||
private ImageView achiev1image;
|
private ImageView achiev1image;
|
||||||
@FXML
|
@FXML
|
||||||
private CheckBox localProduce;
|
|
||||||
@FXML
|
|
||||||
private CheckBox loweringTemp;
|
|
||||||
@FXML
|
|
||||||
private CheckBox bike;
|
|
||||||
@FXML
|
|
||||||
private CheckBox solarPanels;
|
|
||||||
@FXML
|
|
||||||
private Label hintText;
|
private Label hintText;
|
||||||
@FXML
|
@FXML
|
||||||
|
private Label solarPanels;
|
||||||
|
@FXML
|
||||||
|
private Label localProduce;
|
||||||
|
@FXML
|
||||||
|
private Label bike;
|
||||||
|
@FXML
|
||||||
|
private Label loweringTemp;
|
||||||
|
@FXML
|
||||||
private Button refreshHintsButton;
|
private Button refreshHintsButton;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -249,8 +248,8 @@ public class DashBoardController {
|
|||||||
public void sortScores(List<String> users) throws InterruptedException {
|
public void sortScores(List<String> users) throws InterruptedException {
|
||||||
for (int i = 0; i < users.size(); i++) {
|
for (int i = 0; i < users.size(); i++) {
|
||||||
for (int j = 0; j < users.size(); j++) {
|
for (int j = 0; j < users.size(); j++) {
|
||||||
Float firstScore = userService.getFootprint(users.get(i));
|
Double firstScore = userService.getFootprint(users.get(i));
|
||||||
Float secondScore = userService.getFootprint(users.get(j));
|
Double secondScore = userService.getFootprint(users.get(j));
|
||||||
if (i > j && firstScore < secondScore) {
|
if (i > j && firstScore < secondScore) {
|
||||||
String temp = users.get(i);
|
String temp = users.get(i);
|
||||||
users.set(i, users.get(j));
|
users.set(i, users.get(j));
|
||||||
@@ -272,9 +271,9 @@ public class DashBoardController {
|
|||||||
public void sortDiffScores(List<String> users) throws InterruptedException {
|
public void sortDiffScores(List<String> users) throws InterruptedException {
|
||||||
for (int i = 0; i < users.size(); i++) {
|
for (int i = 0; i < users.size(); i++) {
|
||||||
for (int j = 0; j < users.size(); j++) {
|
for (int j = 0; j < users.size(); j++) {
|
||||||
Float firstDiff = userService.getFirstFootprint(users.get(i)) - userService
|
Double firstDiff = userService.getFirstFootprint(users.get(i)) - userService
|
||||||
.getFootprint(users.get(i));
|
.getFootprint(users.get(i));
|
||||||
Float secondDiff = userService.getFirstFootprint(users.get(j)) - userService
|
Double secondDiff = userService.getFirstFootprint(users.get(j)) - userService
|
||||||
.getFootprint(users.get(j));
|
.getFootprint(users.get(j));
|
||||||
if (i < j && firstDiff < secondDiff) {
|
if (i < j && firstDiff < secondDiff) {
|
||||||
String temp = users.get(i);
|
String temp = users.get(i);
|
||||||
@@ -356,18 +355,11 @@ public class DashBoardController {
|
|||||||
dairy.setText(inputMap.get("input_footprint_shopping_food_dairy"));
|
dairy.setText(inputMap.get("input_footprint_shopping_food_dairy"));
|
||||||
fruits.setText(inputMap.get("input_footprint_shopping_food_fruitvegetables"));
|
fruits.setText(inputMap.get("input_footprint_shopping_food_fruitvegetables"));
|
||||||
snacks.setText(inputMap.get("input_footprint_shopping_food_otherfood"));
|
snacks.setText(inputMap.get("input_footprint_shopping_food_otherfood"));
|
||||||
if (userService.getExtraInputs(userService.currentUser.getName()).get("local_produce")) {
|
Map<String, String> extraMap = userService.getExtraInputs(userService.currentUser.getName());
|
||||||
localProduce.setSelected(true);
|
localProduce.setText(extraMap.get("local_produce"));
|
||||||
}
|
bike.setText(extraMap.get("bike"));
|
||||||
if (userService.getExtraInputs(userService.currentUser.getName()).get("bike")) {
|
solarPanels.setText(extraMap.get("solar_panels"));
|
||||||
bike.setSelected(true);
|
loweringTemp.setText(extraMap.get("temperature"));
|
||||||
}
|
|
||||||
if (userService.getExtraInputs(userService.currentUser.getName()).get("temperature")) {
|
|
||||||
loweringTemp.setSelected(true);
|
|
||||||
}
|
|
||||||
if (userService.getExtraInputs(userService.currentUser.getName()).get("solar_panels")) {
|
|
||||||
solarPanels.setSelected(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -380,9 +372,9 @@ public class DashBoardController {
|
|||||||
footprintLabel.setText("" + userService.getFootprint(userService.currentUser.getName()));
|
footprintLabel.setText("" + userService.getFootprint(userService.currentUser.getName()));
|
||||||
firstFootprintLabel.setText("" + userService
|
firstFootprintLabel.setText("" + userService
|
||||||
.getFirstFootprint(userService.currentUser.getName()));
|
.getFirstFootprint(userService.currentUser.getName()));
|
||||||
Float diff = userService.getFirstFootprint(userService.currentUser.getName()) - userService
|
Double diff = userService.getFirstFootprint(userService.currentUser.getName()) - userService
|
||||||
.getFootprint(userService.currentUser.getName());
|
.getFootprint(userService.currentUser.getName());
|
||||||
differenceLabel.setText( "" + diff);
|
differenceLabel.setText( "" + Math.round(diff * 10) / 10.0);
|
||||||
usernameLabel.setText("" + userService.currentUser.getName());
|
usernameLabel.setText("" + userService.currentUser.getName());
|
||||||
addFadeTransition(userPane);
|
addFadeTransition(userPane);
|
||||||
System.out.println("display user");
|
System.out.println("display user");
|
||||||
@@ -390,7 +382,6 @@ public class DashBoardController {
|
|||||||
userPane.setVisible(true);
|
userPane.setVisible(true);
|
||||||
activitiesPane.setVisible(false);
|
activitiesPane.setVisible(false);
|
||||||
friendsPane.setVisible(false);
|
friendsPane.setVisible(false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -526,9 +517,9 @@ public class DashBoardController {
|
|||||||
sortDiffScores(userList);
|
sortDiffScores(userList);
|
||||||
for (int j = 0; j < userList.size(); j++) {
|
for (int j = 0; j < userList.size(); j++) {
|
||||||
Friend user = new Friend(userList.get(j), userService.getFootprint(userList.get(j)));
|
Friend user = new Friend(userList.get(j), userService.getFootprint(userList.get(j)));
|
||||||
Friend diffUser = new Friend(userList.get(j), userService
|
double diff = Math.round((userService.getFirstFootprint(userList.get(j))
|
||||||
.getFirstFootprint(userList.get(j))
|
- userService.getFootprint(userList.get(j))) * 10) / 10.0;
|
||||||
- userService.getFootprint(userList.get(j)));
|
Friend diffUser = new Friend(userList.get(j), diff);
|
||||||
globalLeaderData.add(user);
|
globalLeaderData.add(user);
|
||||||
developmentData.add(diffUser);
|
developmentData.add(diffUser);
|
||||||
}
|
}
|
||||||
@@ -558,9 +549,9 @@ public class DashBoardController {
|
|||||||
data.add(user);
|
data.add(user);
|
||||||
}
|
}
|
||||||
for (int j = 0; j < wholeList.size(); j++) {
|
for (int j = 0; j < wholeList.size(); j++) {
|
||||||
Friend diffUser = new Friend(wholeList.get(j),
|
double diff = Math.round((userService.getFirstFootprint(wholeList.get(j))
|
||||||
userService.getFirstFootprint(wholeList.get(j))
|
- userService.getFootprint(wholeList.get(j))) * 10) / 10.0;
|
||||||
- userService.getFootprint(wholeList.get(j)));
|
Friend diffUser = new Friend(wholeList.get(j), diff);
|
||||||
friendLeaderData.add(diffUser);
|
friendLeaderData.add(diffUser);
|
||||||
}
|
}
|
||||||
friendsTable.setItems(data);
|
friendsTable.setItems(data);
|
||||||
@@ -642,6 +633,4 @@ public class DashBoardController {
|
|||||||
button.setOnMouseExited(e -> scaleDown.playFromStart());
|
button.setOnMouseExited(e -> scaleDown.playFromStart());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user