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;
|
||||
|
||||
import javafx.beans.property.SimpleDoubleProperty;
|
||||
import javafx.beans.property.SimpleFloatProperty;
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
|
||||
public class Friend {
|
||||
|
||||
@@ -397,11 +397,11 @@ public class CalculatorController {
|
||||
}
|
||||
Float footprint = userService.saveFootprint(userService.currentUser.getName());
|
||||
Window owner = saveButton.getScene().getWindow();
|
||||
Stage current = (Stage) owner;
|
||||
controller.updateLeaderboard();
|
||||
controller.updateAchievements();
|
||||
UserController.AlertHelper.showAlert(Alert.AlertType.CONFIRMATION,
|
||||
owner, "Footprint saved!", "Your footprint is saved!");
|
||||
Stage current = (Stage) owner;
|
||||
current.close();
|
||||
}
|
||||
|
||||
|
||||
@@ -6,8 +6,10 @@ import greenify.client.Friend;
|
||||
import greenify.client.Hints;
|
||||
import greenify.client.rest.UserService;
|
||||
import javafx.animation.FadeTransition;
|
||||
import javafx.animation.KeyFrame;
|
||||
import javafx.animation.PathTransition;
|
||||
import javafx.animation.ScaleTransition;
|
||||
import javafx.animation.Timeline;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.event.ActionEvent;
|
||||
@@ -16,7 +18,12 @@ import javafx.scene.Node;
|
||||
import javafx.scene.Parent;
|
||||
import javafx.scene.Scene;
|
||||
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.image.ImageView;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
@@ -28,6 +35,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
@@ -258,6 +266,9 @@ public class DashBoardController {
|
||||
|
||||
addRandomHints();
|
||||
|
||||
Tooltip tooltip = new Tooltip("tip");
|
||||
hackTooltipStartTiming(tooltip);
|
||||
|
||||
addToolTip(achiev1Tip, "Starting off \n You did your first green activity!");
|
||||
addToolTip(achiev2Tip, "Social Butterfly \n You added three friends");
|
||||
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 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));
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* @param users the list of users
|
||||
@@ -389,7 +427,8 @@ 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"));
|
||||
Map<String, String> extraMap = userService.getExtraInputs(userService.currentUser.getName());
|
||||
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"));
|
||||
@@ -433,7 +472,7 @@ public class DashBoardController {
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs out the user
|
||||
* Logs out the user.
|
||||
* @param event the event (clicking the button)
|
||||
* @throws IOException if the Application doesn't load.
|
||||
*/
|
||||
|
||||
@@ -229,7 +229,8 @@ public class ExtraActivityController {
|
||||
controller.updateAchievements();
|
||||
Stage current = (Stage) owner;
|
||||
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!");
|
||||
}
|
||||
|
||||
|
||||
@@ -86,5 +86,11 @@
|
||||
-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