Edit dashboard for new properties
This commit is contained in:
@@ -1,18 +1,25 @@
|
||||
package greenify.client.controller;
|
||||
|
||||
import com.sun.javafx.scene.control.skin.ButtonSkin;
|
||||
import greenify.client.Application;
|
||||
import greenify.client.Friend;
|
||||
import greenify.client.rest.UserService;
|
||||
import javafx.animation.FadeTransition;
|
||||
import javafx.animation.PathTransition;
|
||||
import javafx.animation.ScaleTransition;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.Parent;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.chart.PieChart;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.TableColumn;
|
||||
import javafx.scene.control.TableView;
|
||||
import javafx.scene.control.cell.PropertyValueFactory;
|
||||
import javafx.scene.control.skin.ButtonSkin;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import javafx.scene.shape.Line;
|
||||
import javafx.stage.Stage;
|
||||
@@ -60,6 +67,18 @@ public class DashBoardController {
|
||||
private Button calculateFootPrintButton;
|
||||
@FXML
|
||||
private Label footprintLabel;
|
||||
@FXML
|
||||
private Button addFriendButton;
|
||||
@FXML
|
||||
private TableView<Friend> friendsTable;
|
||||
@FXML
|
||||
private TableColumn<Friend, String> friendsColumn;
|
||||
@FXML
|
||||
private TableColumn<Friend, Float> scoreColumn;
|
||||
@FXML
|
||||
private PieChart pieChart;
|
||||
@FXML
|
||||
private Label usernameLabel;
|
||||
|
||||
/**
|
||||
* Loads the the necessary things before anything else.
|
||||
@@ -74,8 +93,23 @@ public class DashBoardController {
|
||||
activitiesButton.setSkin(new MyButtonSkin(activitiesButton));
|
||||
userButton.setSkin(new MyButtonSkin(userButton));
|
||||
friendsButton.setSkin(new MyButtonSkin(friendsButton));
|
||||
|
||||
|
||||
friendsColumn.setCellValueFactory(new PropertyValueFactory<>("Friend"));
|
||||
scoreColumn.setCellValueFactory(new PropertyValueFactory<>("Score"));
|
||||
friendsTable.setItems(FriendController.getData());
|
||||
if(pieChart != null) {
|
||||
ObservableList<PieChart.Data> pieChartData =
|
||||
FXCollections.observableArrayList(
|
||||
new PieChart.Data("Vegan Meal", 100),
|
||||
new PieChart.Data("Public Transport", 200),
|
||||
new PieChart.Data("Home Temperature", 50),
|
||||
new PieChart.Data("Bike", 75),
|
||||
new PieChart.Data("Local Product", 110),
|
||||
new PieChart.Data("Solar Panel", 300)
|
||||
);
|
||||
pieChart.setTitle("FOOTPRINT DISTRIBUTION");
|
||||
pieChart.setMaxSize(1000, 1000);
|
||||
pieChart.setData(pieChartData);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -126,6 +160,7 @@ public class DashBoardController {
|
||||
System.out.println(userService.currentUser.getName());
|
||||
System.out.println(userService.getFootprint(userService.currentUser.getName()));
|
||||
footprintLabel.setText("" + userService.getFootprint(userService.currentUser.getName()));
|
||||
usernameLabel.setText("" + userService.currentUser.getName());
|
||||
addFadeTransition(userPane);
|
||||
System.out.println("display user");
|
||||
dashboardPane.setVisible(false);
|
||||
@@ -146,7 +181,6 @@ public class DashBoardController {
|
||||
userPane.setVisible(false);
|
||||
activitiesPane.setVisible(false);
|
||||
friendsPane.setVisible(true);
|
||||
|
||||
}
|
||||
|
||||
//sets the slide in transition for startup
|
||||
@@ -172,6 +206,16 @@ public class DashBoardController {
|
||||
calcStage.show();
|
||||
}
|
||||
|
||||
public void openAddFriend() throws IOException {
|
||||
Parent calc = Application.load(this.getClass().getClassLoader()
|
||||
.getResource("fxml/AddFriend.fxml"));
|
||||
Scene scene = new Scene(calc);
|
||||
Stage calcStage = new Stage();
|
||||
calcStage.setScene(scene);
|
||||
calcStage.setTitle("Add a new friend - " + userService.currentUser.getName());
|
||||
calcStage.show();
|
||||
}
|
||||
|
||||
//class for the animations on the navigation buttons
|
||||
public class MyButtonSkin extends ButtonSkin {
|
||||
/**
|
||||
@@ -198,4 +242,4 @@ public class DashBoardController {
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.geometry.*?>
|
||||
<?import java.lang.*?>
|
||||
<?import javafx.scene.chart.PieChart?>
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.image.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<?import javafx.scene.shape.*?>
|
||||
<?import javafx.scene.shape.Line?>
|
||||
<?import javafx.scene.text.*?>
|
||||
|
||||
<AnchorPane prefHeight="702.0" prefWidth="1032.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="greenify.client.controller.DashBoardController">
|
||||
<children>
|
||||
<AnchorPane fx:id="menuBar" prefHeight="703.0" prefWidth="216.0" style="-fx-background-color: #5a635c;">
|
||||
@@ -169,38 +167,43 @@
|
||||
<Font size="30.0" />
|
||||
</font>
|
||||
</Text>
|
||||
<VBox layoutX="517.0" layoutY="28.0" prefHeight="53.0" prefWidth="100.0" style="-fx-background-color: #daefdf; -fx-border-radius: 20%;">
|
||||
<VBox layoutX="80.0" layoutY="150.0" prefHeight="59.0" prefWidth="266.0" style="-fx-background-color: #daefdf; -fx-border-radius: 20%;">
|
||||
<children>
|
||||
<Text fill="#004d11" strokeType="OUTSIDE" strokeWidth="0.0" text="Score" textAlignment="CENTER" wrappingWidth="100.79296875">
|
||||
<Text fill="#004d11" strokeType="OUTSIDE" strokeWidth="0.0" text="Username" textAlignment="CENTER" wrappingWidth="267.1929016113281">
|
||||
<font>
|
||||
<Font size="24.0" />
|
||||
</font>
|
||||
</Text>
|
||||
<Label fx:id="scoreField" alignment="CENTER" contentDisplay="CENTER" prefHeight="17.0" prefWidth="101.0" text="score" textAlignment="CENTER">
|
||||
<Label fx:id="usernameLabel" alignment="CENTER" contentDisplay="CENTER" layoutX="50.0" prefHeight="27.0" prefWidth="267.0" text="username" textAlignment="CENTER">
|
||||
<font>
|
||||
<Font size="18.0" />
|
||||
</font>
|
||||
</Label>
|
||||
</children>
|
||||
</VBox>
|
||||
<VBox alignment="CENTER" layoutX="517.0" layoutY="121.0" prefHeight="53.0" prefWidth="100.0" style="-fx-background-color: #daefdf; -fx-border-radius: 20%;">
|
||||
<VBox alignment="CENTER" layoutX="80.0" layoutY="250.0" prefHeight="59.0" prefWidth="266.0" style="-fx-background-color: #daefdf; -fx-border-radius: 20%;">
|
||||
<children>
|
||||
<Text fill="#004d11" strokeType="OUTSIDE" strokeWidth="0.0" text="CO2 footprint" textAlignment="CENTER" wrappingWidth="161.79296875">
|
||||
<font>
|
||||
<Font size="24.0" />
|
||||
</font>
|
||||
</Text>
|
||||
<Label fx:id="footprintLabel" alignment="CENTER" contentDisplay="CENTER" prefHeight="27.0" prefWidth="134.0" text="co2 footprint" textAlignment="CENTER">
|
||||
<Label fx:id="footprintLabel" alignment="CENTER" contentDisplay="CENTER" prefHeight="27.0" prefWidth="162.0" text="co2 footprint" textAlignment="CENTER">
|
||||
<font>
|
||||
<Font size="18.0" />
|
||||
</font>
|
||||
</Label>
|
||||
</children>
|
||||
</VBox>
|
||||
<PieChart fx:id="pieChart" layoutX="441.0" layoutY="300.0" prefHeight="352.0" prefWidth="363.0" />
|
||||
<ImageView fitHeight="163.0" fitWidth="200.0" layoutX="550.0" layoutY="47.0" pickOnBounds="true" preserveRatio="true">
|
||||
<image>
|
||||
<Image url="@../icons/butterfly.png" />
|
||||
</image>
|
||||
</ImageView>
|
||||
</children></AnchorPane>
|
||||
<AnchorPane fx:id="dashboardPane" layoutX="215.0" prefHeight="703.0" prefWidth="820.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="214.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||
<children>
|
||||
<HBox layoutX="97.0" layoutY="124.0" prefHeight="100.0" prefWidth="200.0" />
|
||||
<Label fx:id="welcomebacktext" layoutX="69.0" layoutY="53.0" text="Welcome back user!" AnchorPane.leftAnchor="60.0" AnchorPane.topAnchor="40.0">
|
||||
<font>
|
||||
<Font size="30.0" />
|
||||
@@ -223,7 +226,7 @@
|
||||
<Font size="15.0" />
|
||||
</font>
|
||||
</Text>
|
||||
<Button fx:id="calculateFootPrintButton" contentDisplay="RIGHT" layoutX="572.0" layoutY="124.0" mnemonicParsing="false" onAction="#openCalculator" prefHeight="74.0" prefWidth="205.0" style="-fx-border-radius: 20px; -fx-padding: 0px 0px 0px 0px; -fx-background-color: transparent;" text="Calculate your CO2 footprint" textFill="#29721a">
|
||||
<Button fx:id="calculateFootPrintButton" contentDisplay="RIGHT" layoutX="577.0" layoutY="126.0" mnemonicParsing="false" onAction="#openCalculator" prefHeight="74.0" prefWidth="205.0" style="-fx-border-radius: 20px; -fx-padding: 0px 0px 0px 0px; -fx-background-color: transparent;" text="Calculate your CO2 footprint" textFill="#29721a">
|
||||
<font>
|
||||
<Font name="Corbel Bold" size="14.0" />
|
||||
</font>
|
||||
@@ -239,6 +242,18 @@
|
||||
</ImageView>
|
||||
</graphic>
|
||||
</Button>
|
||||
<Button fx:id="addFriendButton" contentDisplay="RIGHT" layoutX="596.0" layoutY="220.0" mnemonicParsing="false" onAction="#openAddFriend" prefHeight="74.0" prefWidth="200.0" style="-fx-border-radius: 20px; -fx-padding: 0px 0px 0px 0px; -fx-background-color: transparent;" text="Add friend" textFill="#29721a">
|
||||
<font>
|
||||
<Font name="Corbel Bold" size="14.0" />
|
||||
</font>
|
||||
<graphic>
|
||||
<ImageView fitHeight="74.0" fitWidth="64.0" pickOnBounds="true" preserveRatio="true">
|
||||
<image>
|
||||
<Image url="@../icons/friend.png" />
|
||||
</image>
|
||||
</ImageView>
|
||||
</graphic>
|
||||
</Button>
|
||||
</children>
|
||||
</AnchorPane>
|
||||
<AnchorPane fx:id="friendsPane" layoutX="216.0" prefHeight="703.0" prefWidth="820.0" visible="false" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="214.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||
@@ -253,8 +268,11 @@
|
||||
<TableColumn fx:id="friendsColumn" prefWidth="107.0" text="Friend" />
|
||||
<TableColumn fx:id="scoreColumn" prefWidth="108.0" text="Score" />
|
||||
</columns>
|
||||
<columnResizePolicy>
|
||||
<TableView fx:constant="CONSTRAINED_RESIZE_POLICY" />
|
||||
</columnResizePolicy>
|
||||
</TableView>
|
||||
</children>
|
||||
</AnchorPane>
|
||||
</children>
|
||||
</AnchorPane>
|
||||
</AnchorPane>
|
||||
Reference in New Issue
Block a user