SHARE
TWEET

Untitled

a guest May 25th, 2019 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package nl.avans.view.dashboard;
  2.  
  3. import java.awt.event.KeyEvent;
  4. import java.util.ArrayList;
  5. import java.util.function.Predicate;
  6. import java.util.logging.Filter;
  7.  
  8. import javafx.beans.property.SimpleStringProperty;
  9. import javafx.collections.FXCollections;
  10. import javafx.collections.ObservableList;
  11. import javafx.collections.transformation.FilteredList;
  12. import javafx.collections.transformation.SortedList;
  13. import javafx.geometry.Insets;
  14. import javafx.geometry.Pos;
  15. import javafx.scene.control.TableColumn;
  16. import javafx.scene.control.TableView;
  17. import javafx.scene.control.TextField;
  18. import javafx.scene.control.cell.PropertyValueFactory;
  19. import javafx.scene.layout.Background;
  20. import javafx.scene.layout.BackgroundFill;
  21. import javafx.scene.layout.FlowPane;
  22. import javafx.scene.layout.VBox;
  23. import javafx.scene.paint.Color;
  24. import nl.avans.controller.dashboard.CreateNewGameController;
  25. import nl.avans.controller.dashboard.StatisticsController;
  26. import nl.avans.database.dashboard.StatisticsDB;
  27. import nl.avans.helpers.Styling;
  28. import nl.avans.model.Statistics;
  29.  
  30. public class StatisticsPane extends FlowPane {
  31.  
  32.  
  33.     private TableView<Statistics> tableView;
  34.     private StatisticsController statisticsController;
  35.     private TextField filter;
  36.     private ObservableList<Statistics> masterData = FXCollections.observableArrayList();
  37.     private ObservableList<String> allPlayers;
  38.     @SuppressWarnings("unchecked")
  39.  
  40.     public StatisticsPane(StatisticsController controller) {
  41.  
  42.         this.statisticsController = controller;
  43.  
  44.  
  45.         ArrayList<Statistics> totalStatistics = new ArrayList<Statistics>();
  46.  
  47.         for(String user: StatisticsDB.getAllPlayers() ) {
  48.             totalStatistics.add(new Statistics(user));
  49.             System.out.println(user);
  50.         }
  51.  
  52.  
  53.         tableView = new TableView();
  54.  
  55.  
  56.         TableColumn<Statistics, String> userName = new TableColumn<Statistics, String>("Spelers");
  57.         userName.setCellValueFactory(new PropertyValueFactory("username"));
  58.  
  59.         TableColumn<Statistics, Integer> totalScore = new TableColumn<Statistics, Integer>("Totale score");
  60.         totalScore.setCellValueFactory(new PropertyValueFactory("totalScore"));
  61.  
  62.         TableColumn<Statistics, String> mostPlacedColor = new TableColumn<Statistics, String>("Meest geplaatste kleur");
  63.         mostPlacedColor.setCellValueFactory(new PropertyValueFactory("mostPlacedColor"));
  64.  
  65.         TableColumn<Statistics, Integer> mostPlacedEye = new TableColumn<Statistics, Integer>("Meest geplaatste waarde");
  66.         mostPlacedEye.setCellValueFactory(new PropertyValueFactory("mostPlacedEye"));
  67.  
  68.         TableColumn<Statistics, Integer> amountOfOpponentsPlayed = new TableColumn<Statistics, Integer>("Aantal verschillende tegenstanders");
  69.         amountOfOpponentsPlayed.setCellValueFactory(new PropertyValueFactory("amountOfOpponentsPlayed"));
  70.  
  71.         TableColumn<Statistics, Integer> amountOfWins = new TableColumn<Statistics, Integer>("Gewonnen");
  72.         amountOfWins.setCellValueFactory(new PropertyValueFactory("amountOfWins"));
  73.  
  74.         TableColumn<Statistics, Integer> amountOfLosses = new TableColumn<Statistics, Integer>("Verloren");
  75.         amountOfLosses.setCellValueFactory(new PropertyValueFactory("amountOfLosses"));
  76.  
  77.  
  78.         tableView.getColumns().addAll(userName, totalScore, amountOfWins, amountOfLosses, mostPlacedColor, mostPlacedEye, amountOfOpponentsPlayed);
  79.         filter = new TextField();
  80.         filter.setPadding(Styling.PADDING);
  81.         filter.setPromptText("Speler zoeken...");
  82.  
  83.  
  84.         tableView.setItems(FXCollections.observableArrayList(totalStatistics));
  85.  
  86.         VBox search = new VBox();
  87.         search.setSpacing(10);
  88.         search.getChildren().addAll(filter);
  89.  
  90.         VBox rootnode = new VBox(search, tableView);
  91.         rootnode.setPadding(new Insets(30, 30, 30, 30));
  92.         rootnode.setSpacing(20);
  93.         rootnode.setBackground(new Background(new BackgroundFill(Color.WHITE, Styling.BORDER_RADIUS, null)));
  94.         getChildren().add(rootnode);
  95.         setAlignment(Pos.CENTER);
  96.         setPadding(new Insets(20));
  97.         rootnode.setStyle("-fx-border-radius:10 10 10 10");
  98.     }
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top