Commit 5d1bc590 authored by Peining's avatar Peining
Browse files

Add pie chart examples in player profile.

parent 0006b9e1
......@@ -14,6 +14,8 @@ import java.time.ZoneId;
import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.concurrent.Task;
import javafx.concurrent.WorkerStateEvent;
import javafx.event.ActionEvent;
......@@ -24,6 +26,7 @@ import javafx.scene.Cursor;
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.DatePicker;
import javafx.scene.control.Label;
......@@ -33,6 +36,7 @@ import javafx.scene.image.ImageView;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
import javafx.scene.layout.Pane;
import javafx.scene.paint.Color;
import javafx.stage.FileChooser;
import javafx.stage.Stage;
......@@ -57,6 +61,12 @@ public class PlayerProfileController extends AbstractController{
private TextField description;
@FXML
private ImageView image;
@FXML
private PieChart allMode;
@FXML
private PieChart classical;
@FXML
private PieChart belge;
private PublicUser me;
private PublicUser other;
......@@ -293,6 +303,15 @@ public class PlayerProfileController extends AbstractController{
}
}
public void drawPieChart(PieChart chart){
//to do: get data from interface Data
ObservableList<PieChart.Data> pieChartData = FXCollections.observableArrayList(
new PieChart.Data("Win", 15),
new PieChart.Data("Loss", 5),
new PieChart.Data("Abandonned", 0)
);
chart.setData(pieChartData);
}
@Override
/**
* Initializes all the info of profile.
......@@ -307,6 +326,9 @@ public class PlayerProfileController extends AbstractController{
firstName.setText(me.getFirstName());
lastName.setText(me.getLastName());
birthday.setText(me.getBirthDate().toString());
drawPieChart(allMode);
drawPieChart(classical);
drawPieChart(belge);
}
catch(NullPointerException e){
Logger.getLogger(
......
......@@ -77,20 +77,29 @@
</VBox>
<VBox prefHeight="261.0" prefWidth="291.0">
<children>
<HBox alignment="CENTER_RIGHT" prefHeight="51.0" prefWidth="268.0">
<HBox alignment="CENTER_LEFT" prefHeight="51.0" prefWidth="268.0">
<children>
<Label alignment="CENTER" text="Description" />
<Label alignment="CENTER" contentDisplay="CENTER" text="Description">
<HBox.margin>
<Insets left="80.0" />
</HBox.margin></Label>
</children>
<VBox.margin>
<Insets />
</VBox.margin>
</HBox>
<HBox alignment="CENTER_RIGHT" prefHeight="165.0" prefWidth="268.0">
<children>
<TextField fx:id="description" editable="false" onKeyPressed="#closeEdit" prefHeight="144.0" prefWidth="219.0" text="Hello!" />
</children>
</HBox>
<HBox alignment="CENTER_RIGHT" prefHeight="29.0" prefWidth="268.0">
<HBox alignment="CENTER_LEFT" prefHeight="29.0" prefWidth="268.0">
<children>
<Button mnemonicParsing="false" onAction="#editDescription" text="edit" />
</children>
<padding>
<Insets left="70.0" />
</padding>
</HBox>
</children></VBox>
</children>
......@@ -101,8 +110,8 @@
</columnConstraints>
<rowConstraints>
<RowConstraints maxHeight="143.0" minHeight="10.0" prefHeight="29.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="143.0" minHeight="6.0" prefHeight="14.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="280.0" minHeight="10.0" prefHeight="263.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="143.0" minHeight="0.0" prefHeight="0.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="280.0" minHeight="10.0" prefHeight="273.0" vgrow="SOMETIMES" />
</rowConstraints>
</GridPane>
<GridPane alignment="CENTER" GridPane.halignment="CENTER" GridPane.rowIndex="1" GridPane.valignment="CENTER">
......@@ -198,9 +207,9 @@
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<PieChart minHeight="-Infinity" minWidth="-Infinity" prefHeight="120.0" prefWidth="120.0" title="All Mode" titleSide="BOTTOM" />
<PieChart minHeight="-Infinity" minWidth="-Infinity" prefHeight="120.0" prefWidth="120.0" title="Classical" titleSide="BOTTOM" GridPane.columnIndex="1" />
<PieChart minHeight="-Infinity" minWidth="-Infinity" prefHeight="120.0" prefWidth="120.0" title="Belge" titleSide="BOTTOM" GridPane.columnIndex="2" />
<PieChart fx:id="allMode" minHeight="-Infinity" minWidth="-Infinity" prefHeight="120.0" prefWidth="120.0" title="All Mode" titleSide="BOTTOM" />
<PieChart fx:id="classical" minHeight="-Infinity" minWidth="-Infinity" prefHeight="120.0" prefWidth="120.0" title="Classical" titleSide="BOTTOM" GridPane.columnIndex="1" />
<PieChart fx:id="belge" minHeight="-Infinity" minWidth="-Infinity" prefHeight="120.0" prefWidth="120.0" title="Belge" titleSide="BOTTOM" GridPane.columnIndex="2" />
</children>
</GridPane>
</children>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment