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