Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package nl.avans.view.dashboard;
- import java.awt.event.KeyEvent;
- import java.util.ArrayList;
- import java.util.function.Predicate;
- import java.util.logging.Filter;
- import javafx.beans.property.SimpleStringProperty;
- import javafx.collections.FXCollections;
- import javafx.collections.ObservableList;
- import javafx.collections.transformation.FilteredList;
- import javafx.collections.transformation.SortedList;
- import javafx.geometry.Insets;
- import javafx.geometry.Pos;
- import javafx.scene.control.TableColumn;
- import javafx.scene.control.TableView;
- import javafx.scene.control.TextField;
- import javafx.scene.control.cell.PropertyValueFactory;
- import javafx.scene.layout.Background;
- import javafx.scene.layout.BackgroundFill;
- import javafx.scene.layout.FlowPane;
- import javafx.scene.layout.VBox;
- import javafx.scene.paint.Color;
- import nl.avans.controller.dashboard.CreateNewGameController;
- import nl.avans.controller.dashboard.StatisticsController;
- import nl.avans.database.dashboard.StatisticsDB;
- import nl.avans.helpers.Styling;
- import nl.avans.model.Statistics;
- public class StatisticsPane extends FlowPane {
- private TableView<Statistics> tableView;
- private StatisticsController statisticsController;
- private TextField filter;
- private ObservableList<Statistics> masterData = FXCollections.observableArrayList();
- private ObservableList<String> allPlayers;
- @SuppressWarnings("unchecked")
- public StatisticsPane(StatisticsController controller) {
- this.statisticsController = controller;
- ArrayList<Statistics> totalStatistics = new ArrayList<Statistics>();
- for(String user: StatisticsDB.getAllPlayers() ) {
- totalStatistics.add(new Statistics(user));
- System.out.println(user);
- }
- tableView = new TableView();
- TableColumn<Statistics, String> userName = new TableColumn<Statistics, String>("Spelers");
- userName.setCellValueFactory(new PropertyValueFactory("username"));
- TableColumn<Statistics, Integer> totalScore = new TableColumn<Statistics, Integer>("Totale score");
- totalScore.setCellValueFactory(new PropertyValueFactory("totalScore"));
- TableColumn<Statistics, String> mostPlacedColor = new TableColumn<Statistics, String>("Meest geplaatste kleur");
- mostPlacedColor.setCellValueFactory(new PropertyValueFactory("mostPlacedColor"));
- TableColumn<Statistics, Integer> mostPlacedEye = new TableColumn<Statistics, Integer>("Meest geplaatste waarde");
- mostPlacedEye.setCellValueFactory(new PropertyValueFactory("mostPlacedEye"));
- TableColumn<Statistics, Integer> amountOfOpponentsPlayed = new TableColumn<Statistics, Integer>("Aantal verschillende tegenstanders");
- amountOfOpponentsPlayed.setCellValueFactory(new PropertyValueFactory("amountOfOpponentsPlayed"));
- TableColumn<Statistics, Integer> amountOfWins = new TableColumn<Statistics, Integer>("Gewonnen");
- amountOfWins.setCellValueFactory(new PropertyValueFactory("amountOfWins"));
- TableColumn<Statistics, Integer> amountOfLosses = new TableColumn<Statistics, Integer>("Verloren");
- amountOfLosses.setCellValueFactory(new PropertyValueFactory("amountOfLosses"));
- tableView.getColumns().addAll(userName, totalScore, amountOfWins, amountOfLosses, mostPlacedColor, mostPlacedEye, amountOfOpponentsPlayed);
- filter = new TextField();
- filter.setPadding(Styling.PADDING);
- filter.setPromptText("Speler zoeken...");
- tableView.setItems(FXCollections.observableArrayList(totalStatistics));
- VBox search = new VBox();
- search.setSpacing(10);
- search.getChildren().addAll(filter);
- VBox rootnode = new VBox(search, tableView);
- rootnode.setPadding(new Insets(30, 30, 30, 30));
- rootnode.setSpacing(20);
- rootnode.setBackground(new Background(new BackgroundFill(Color.WHITE, Styling.BORDER_RADIUS, null)));
- getChildren().add(rootnode);
- setAlignment(Pos.CENTER);
- setPadding(new Insets(20));
- rootnode.setStyle("-fx-border-radius:10 10 10 10");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement