EDIT::added style to tooltips and reduced delay between hovering over the achievement and the tooltip appearing
EDIT::fixed some checkstyle warnings
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
package greenify.client;
|
package greenify.client;
|
||||||
|
|
||||||
import javafx.beans.property.SimpleDoubleProperty;
|
import javafx.beans.property.SimpleDoubleProperty;
|
||||||
import javafx.beans.property.SimpleFloatProperty;
|
|
||||||
import javafx.beans.property.SimpleStringProperty;
|
import javafx.beans.property.SimpleStringProperty;
|
||||||
|
|
||||||
public class Friend {
|
public class Friend {
|
||||||
|
|||||||
@@ -397,11 +397,11 @@ public class CalculatorController {
|
|||||||
}
|
}
|
||||||
Float footprint = userService.saveFootprint(userService.currentUser.getName());
|
Float footprint = userService.saveFootprint(userService.currentUser.getName());
|
||||||
Window owner = saveButton.getScene().getWindow();
|
Window owner = saveButton.getScene().getWindow();
|
||||||
Stage current = (Stage) owner;
|
|
||||||
controller.updateLeaderboard();
|
controller.updateLeaderboard();
|
||||||
controller.updateAchievements();
|
controller.updateAchievements();
|
||||||
UserController.AlertHelper.showAlert(Alert.AlertType.CONFIRMATION,
|
UserController.AlertHelper.showAlert(Alert.AlertType.CONFIRMATION,
|
||||||
owner, "Footprint saved!", "Your footprint is saved!");
|
owner, "Footprint saved!", "Your footprint is saved!");
|
||||||
|
Stage current = (Stage) owner;
|
||||||
current.close();
|
current.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,8 +6,10 @@ import greenify.client.Friend;
|
|||||||
import greenify.client.Hints;
|
import greenify.client.Hints;
|
||||||
import greenify.client.rest.UserService;
|
import greenify.client.rest.UserService;
|
||||||
import javafx.animation.FadeTransition;
|
import javafx.animation.FadeTransition;
|
||||||
|
import javafx.animation.KeyFrame;
|
||||||
import javafx.animation.PathTransition;
|
import javafx.animation.PathTransition;
|
||||||
import javafx.animation.ScaleTransition;
|
import javafx.animation.ScaleTransition;
|
||||||
|
import javafx.animation.Timeline;
|
||||||
import javafx.collections.FXCollections;
|
import javafx.collections.FXCollections;
|
||||||
import javafx.collections.ObservableList;
|
import javafx.collections.ObservableList;
|
||||||
import javafx.event.ActionEvent;
|
import javafx.event.ActionEvent;
|
||||||
@@ -16,7 +18,12 @@ import javafx.scene.Node;
|
|||||||
import javafx.scene.Parent;
|
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.*;
|
|
||||||
|
import javafx.scene.control.Button;
|
||||||
|
import javafx.scene.control.Label;
|
||||||
|
import javafx.scene.control.TableColumn;
|
||||||
|
import javafx.scene.control.TableView;
|
||||||
|
import javafx.scene.control.Tooltip;
|
||||||
import javafx.scene.control.cell.PropertyValueFactory;
|
import javafx.scene.control.cell.PropertyValueFactory;
|
||||||
import javafx.scene.image.ImageView;
|
import javafx.scene.image.ImageView;
|
||||||
import javafx.scene.layout.AnchorPane;
|
import javafx.scene.layout.AnchorPane;
|
||||||
@@ -28,6 +35,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
@@ -258,6 +266,9 @@ public class DashBoardController {
|
|||||||
|
|
||||||
addRandomHints();
|
addRandomHints();
|
||||||
|
|
||||||
|
Tooltip tooltip = new Tooltip("tip");
|
||||||
|
hackTooltipStartTiming(tooltip);
|
||||||
|
|
||||||
addToolTip(achiev1Tip, "Starting off \n You did your first green activity!");
|
addToolTip(achiev1Tip, "Starting off \n You did your first green activity!");
|
||||||
addToolTip(achiev2Tip, "Social Butterfly \n You added three friends");
|
addToolTip(achiev2Tip, "Social Butterfly \n You added three friends");
|
||||||
addToolTip(achiev3Tip, "Green Saver \n You saved * of CO2");
|
addToolTip(achiev3Tip, "Green Saver \n You saved * of CO2");
|
||||||
@@ -271,10 +282,37 @@ public class DashBoardController {
|
|||||||
* @param button the button to add the tooltip to.
|
* @param button the button to add the tooltip to.
|
||||||
* @param message the message to be displayed in the tooltip.
|
* @param message the message to be displayed in the tooltip.
|
||||||
*/
|
*/
|
||||||
public void addToolTip(Button button, String message) {
|
private void addToolTip(Button button, String message) {
|
||||||
button.setTooltip(new Tooltip(message));
|
button.setTooltip(new Tooltip(message));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* changes the delay time between hovering over something with a tooltip and when the
|
||||||
|
* tooltip is displayed.
|
||||||
|
* @param tooltip the tooltip to change the delay of
|
||||||
|
*/
|
||||||
|
private static void hackTooltipStartTiming(Tooltip tooltip) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
Field fieldBehavior = tooltip.getClass().getDeclaredField("BEHAVIOR");
|
||||||
|
fieldBehavior.setAccessible(true);
|
||||||
|
Object objBehavior = fieldBehavior.get(tooltip);
|
||||||
|
|
||||||
|
Field fieldTimer = objBehavior.getClass().getDeclaredField("activationTimer");
|
||||||
|
fieldTimer.setAccessible(true);
|
||||||
|
Timeline objTimer = (Timeline) fieldTimer.get(objBehavior);
|
||||||
|
|
||||||
|
objTimer.getKeyFrames().clear();
|
||||||
|
objTimer.getKeyFrames().add(new KeyFrame(new Duration(150)));
|
||||||
|
} catch (NoSuchFieldException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
e.getMessage();
|
||||||
|
} catch (IllegalAccessException e) {
|
||||||
|
e.getMessage();
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sorts the scores of users.
|
* Sorts the scores of users.
|
||||||
* @param users the list of users
|
* @param users the list of users
|
||||||
@@ -389,7 +427,8 @@ 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"));
|
||||||
Map<String, String> extraMap = userService.getExtraInputs(userService.currentUser.getName());
|
Map<String, String> extraMap = userService.getExtraInputs(userService.currentUser
|
||||||
|
.getName());
|
||||||
localProduce.setText(extraMap.get("local_produce"));
|
localProduce.setText(extraMap.get("local_produce"));
|
||||||
bike.setText(extraMap.get("bike"));
|
bike.setText(extraMap.get("bike"));
|
||||||
solarPanels.setText(extraMap.get("solar_panels"));
|
solarPanels.setText(extraMap.get("solar_panels"));
|
||||||
@@ -433,7 +472,7 @@ public class DashBoardController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logs out the user
|
* Logs out the user.
|
||||||
* @param event the event (clicking the button)
|
* @param event the event (clicking the button)
|
||||||
* @throws IOException if the Application doesn't load.
|
* @throws IOException if the Application doesn't load.
|
||||||
*/
|
*/
|
||||||
@@ -597,32 +636,32 @@ public class DashBoardController {
|
|||||||
*/
|
*/
|
||||||
public void updateAchievements() {
|
public void updateAchievements() {
|
||||||
Map achievements = userService.getAchievements(userService.currentUser.getName());
|
Map achievements = userService.getAchievements(userService.currentUser.getName());
|
||||||
if((Boolean)achievements.get("Starting off")) {
|
if ((Boolean)achievements.get("Starting off")) {
|
||||||
achieve1.setOpacity(1);
|
achieve1.setOpacity(1);
|
||||||
} else {
|
} else {
|
||||||
achieve1.setOpacity(0.3);
|
achieve1.setOpacity(0.3);
|
||||||
}
|
}
|
||||||
if((Boolean)achievements.get("Social butterfly")) {
|
if ((Boolean)achievements.get("Social butterfly")) {
|
||||||
achieve2.setOpacity(1);
|
achieve2.setOpacity(1);
|
||||||
} else {
|
} else {
|
||||||
achieve2.setOpacity(0.3);
|
achieve2.setOpacity(0.3);
|
||||||
}
|
}
|
||||||
if((Boolean)achievements.get("Green saver")) {
|
if ((Boolean)achievements.get("Green saver")) {
|
||||||
achieve3.setOpacity(1);
|
achieve3.setOpacity(1);
|
||||||
} else {
|
} else {
|
||||||
achieve3.setOpacity(0.3);
|
achieve3.setOpacity(0.3);
|
||||||
}
|
}
|
||||||
if((Boolean)achievements.get("Animal friend")) {
|
if ((Boolean)achievements.get("Animal friend")) {
|
||||||
achieve4.setOpacity(1);
|
achieve4.setOpacity(1);
|
||||||
} else {
|
} else {
|
||||||
achieve4.setOpacity(0.3);
|
achieve4.setOpacity(0.3);
|
||||||
}
|
}
|
||||||
if((Boolean)achievements.get("Tom Dumoulin")) {
|
if ((Boolean)achievements.get("Tom Dumoulin")) {
|
||||||
achieve5.setOpacity(1);
|
achieve5.setOpacity(1);
|
||||||
} else {
|
} else {
|
||||||
achieve5.setOpacity(0.3);
|
achieve5.setOpacity(0.3);
|
||||||
}
|
}
|
||||||
if((Boolean)achievements.get("Let it shine")) {
|
if ((Boolean)achievements.get("Let it shine")) {
|
||||||
achieve6.setOpacity(1);
|
achieve6.setOpacity(1);
|
||||||
} else {
|
} else {
|
||||||
achieve6.setOpacity(0.3);
|
achieve6.setOpacity(0.3);
|
||||||
|
|||||||
@@ -229,7 +229,8 @@ public class ExtraActivityController {
|
|||||||
controller.updateAchievements();
|
controller.updateAchievements();
|
||||||
Stage current = (Stage) owner;
|
Stage current = (Stage) owner;
|
||||||
current.close();
|
current.close();
|
||||||
UserController.AlertHelper.showAlert(Alert.AlertType.CONFIRMATION, owner, "Activities are added!",
|
UserController.AlertHelper.showAlert(Alert.AlertType.CONFIRMATION, owner,
|
||||||
|
"Activities are added!",
|
||||||
"Your new activities are added!");
|
"Your new activities are added!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -86,5 +86,11 @@
|
|||||||
-fx-padding: 0 0 0 0;
|
-fx-padding: 0 0 0 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.tooltip {
|
||||||
|
-fx-background-color: #d0f2d3;
|
||||||
|
-fx-text-fill: #364c38;
|
||||||
|
-fx-font-size: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user