Advertisement
Guest User

Untitled

a guest
May 24th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.65 KB | None | 0 0
  1. package nl.avans.view.dashboard;
  2.  
  3. import javafx.collections.FXCollections;
  4. import javafx.collections.ObservableList;
  5. import javafx.geometry.Insets;
  6. import javafx.geometry.Pos;
  7. import javafx.scene.control.TableColumn;
  8. import javafx.scene.control.TableView;
  9. import javafx.scene.control.TextField;
  10. import javafx.scene.control.cell.PropertyValueFactory;
  11. import javafx.scene.layout.Background;
  12. import javafx.scene.layout.BackgroundFill;
  13. import javafx.scene.layout.FlowPane;
  14. import javafx.scene.layout.VBox;
  15. import javafx.scene.paint.Color;
  16. import nl.avans.controller.dashboard.CreateNewGameController;
  17. import nl.avans.controller.dashboard.StatisticsController;
  18. import nl.avans.helpers.Styling;
  19. import nl.avans.model.Statistics;
  20.  
  21. public class StatisticsPane extends FlowPane {
  22.  
  23.  
  24. private TableView<Statistics> tableView;
  25. private StatisticsController statisticsController;
  26. private TextField filter;
  27.  
  28.  
  29. @SuppressWarnings("unchecked")
  30.  
  31. public StatisticsPane(StatisticsController controller) {
  32. ObservableList<Statistics> statistics = FXCollections.observableArrayList();
  33.  
  34. filter = new TextField();
  35. filter.setPadding(Styling.PADDING);
  36. filter.setPromptText("Speler zoeken...");
  37.  
  38. TableColumn nameColumn = new TableColumn<Statistics, String>("Naam");
  39. nameColumn.setCellValueFactory(new PropertyValueFactory<>("name"));
  40. nameColumn.setMinWidth(100);
  41. nameColumn.setStyle("-fx-fill: white; -fx-background-color: grey; -fx-border-radius: 10 0 0 0;");
  42.  
  43.  
  44. TableColumn winColumn = new TableColumn<Statistics, Integer>("Win");
  45. winColumn.setCellValueFactory(new PropertyValueFactory<>("win"));
  46. winColumn.setMinWidth(100);
  47. winColumn.setStyle("-fx-fill: white; -fx-background-color: grey; -fx-border-radius: 0 0 0 0;");
  48.  
  49.  
  50. TableColumn lossColumn = new TableColumn<Statistics, Integer>("Loss");
  51. lossColumn.setCellValueFactory(new PropertyValueFactory<>("loss"));
  52. lossColumn.setMinWidth(100);
  53. lossColumn.setStyle("-fx-text-fill: white; -fx-background-color: grey");
  54.  
  55. TableColumn worthColumn = new TableColumn<Statistics, Integer>("Waarde");
  56. worthColumn.setCellValueFactory(new PropertyValueFactory<>("diceworth"));
  57. worthColumn.setMinWidth(100);
  58.  
  59. worthColumn.setStyle("-fx-text-fill: white; -fx-background-color: grey");
  60.  
  61.  
  62. TableColumn colorColumn = new TableColumn<Statistics, String>("Meest geplaatste kleur");
  63. colorColumn.setCellValueFactory(new PropertyValueFactory<>("dicecolor"));
  64. colorColumn.setMinWidth(100);
  65. colorColumn.setStyle("-fx-fill: white; -fx-background-color: grey");
  66.  
  67.  
  68. TableColumn opponentColumn = new TableColumn<Statistics, Integer>("tegenstanders");
  69. opponentColumn.setCellValueFactory(new PropertyValueFactory<>("opponents"));
  70. opponentColumn.setMinWidth(120);
  71. opponentColumn.setStyle("-fx-fill: white; -fx-background-color: grey");
  72. opponentColumn.setUserData(new StatisticsController().getAmountOfOpponentsPlayed());
  73.  
  74. tableView = new TableView<>();
  75.  
  76. tableView.setStyle("-fx-border-radius: 10 10 0 0; -fx-background-radius: 10 10 10 10;");
  77.  
  78. tableView.getColumns().addAll(nameColumn, winColumn, lossColumn, worthColumn, colorColumn, opponentColumn);
  79.  
  80.  
  81.  
  82.  
  83.  
  84. VBox search = new VBox();
  85. search.setSpacing(10);
  86. search.getChildren().addAll(filter);
  87.  
  88. VBox rootnode = new VBox(search, tableView);
  89. rootnode.setPadding(new Insets(30, 30, 30, 30));
  90. rootnode.setSpacing(20);
  91. rootnode.setBackground(new Background(new BackgroundFill(Color.WHITE, Styling.BORDER_RADIUS, null)));
  92. getChildren().add(rootnode);
  93. setAlignment(Pos.CENTER);
  94. setPadding(new Insets(20));
  95. rootnode.setStyle("-fx-border-radius:10 10 10 10");
  96. }
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement