Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package nl.avans.view.dashboard;
- import javafx.collections.FXCollections;
- import javafx.collections.ObservableList;
- 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.helpers.Styling;
- import nl.avans.model.Statistics;
- public class StatisticsPane extends FlowPane {
- private TableView<Statistics> tableView;
- private StatisticsController statisticsController;
- private TextField filter;
- @SuppressWarnings("unchecked")
- public StatisticsPane(StatisticsController controller) {
- ObservableList<Statistics> statistics = FXCollections.observableArrayList();
- filter = new TextField();
- filter.setPadding(Styling.PADDING);
- filter.setPromptText("Speler zoeken...");
- TableColumn nameColumn = new TableColumn<Statistics, String>("Naam");
- nameColumn.setCellValueFactory(new PropertyValueFactory<>("name"));
- nameColumn.setMinWidth(100);
- nameColumn.setStyle("-fx-fill: white; -fx-background-color: grey; -fx-border-radius: 10 0 0 0;");
- TableColumn winColumn = new TableColumn<Statistics, Integer>("Win");
- winColumn.setCellValueFactory(new PropertyValueFactory<>("win"));
- winColumn.setMinWidth(100);
- winColumn.setStyle("-fx-fill: white; -fx-background-color: grey; -fx-border-radius: 0 0 0 0;");
- TableColumn lossColumn = new TableColumn<Statistics, Integer>("Loss");
- lossColumn.setCellValueFactory(new PropertyValueFactory<>("loss"));
- lossColumn.setMinWidth(100);
- lossColumn.setStyle("-fx-text-fill: white; -fx-background-color: grey");
- TableColumn worthColumn = new TableColumn<Statistics, Integer>("Waarde");
- worthColumn.setCellValueFactory(new PropertyValueFactory<>("diceworth"));
- worthColumn.setMinWidth(100);
- worthColumn.setStyle("-fx-text-fill: white; -fx-background-color: grey");
- TableColumn colorColumn = new TableColumn<Statistics, String>("Meest geplaatste kleur");
- colorColumn.setCellValueFactory(new PropertyValueFactory<>("dicecolor"));
- colorColumn.setMinWidth(100);
- colorColumn.setStyle("-fx-fill: white; -fx-background-color: grey");
- TableColumn opponentColumn = new TableColumn<Statistics, Integer>("tegenstanders");
- opponentColumn.setCellValueFactory(new PropertyValueFactory<>("opponents"));
- opponentColumn.setMinWidth(120);
- opponentColumn.setStyle("-fx-fill: white; -fx-background-color: grey");
- opponentColumn.setUserData(new StatisticsController().getAmountOfOpponentsPlayed());
- tableView = new TableView<>();
- tableView.setStyle("-fx-border-radius: 10 10 0 0; -fx-background-radius: 10 10 10 10;");
- tableView.getColumns().addAll(nameColumn, winColumn, lossColumn, worthColumn, colorColumn, opponentColumn);
- 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