package com.r0r5chach.controllers; import java.util.ArrayList; import com.r0r5chach.competitor.Competitor; import com.r0r5chach.competitor.Rank; import com.r0r5chach.competitor.r6.R6Player; import com.r0r5chach.competitor.valorant.ValorantPlayer; import com.r0r5chach.pages.CompetitorRow; import javafx.collections.FXCollections; import javafx.collections.ObservableList; import javafx.scene.control.TableColumn; import javafx.scene.control.TableView; import javafx.scene.control.cell.PropertyValueFactory; public class ViewController { public static void generateTable(TableView table) { TableColumn playerNumCol = new TableColumn("Player Number"); TableColumn playerNameCol = new TableColumn("Player Name"); TableColumn playerLevelCol = new TableColumn("Player Level"); TableColumn scoresCol = new TableColumn("Player Scores"); TableColumn favoriteCharsCol = new TableColumn("Favorite Characters"); TableColumn favoriteAgentCol = new TableColumn("Agent"); TableColumn favoriteAttackerCol = new TableColumn("Attacker"); TableColumn favoriteDefenderCol = new TableColumn("Defender"); playerNumCol.setCellValueFactory(new PropertyValueFactory("playerNumber")); playerNameCol.setCellValueFactory(new PropertyValueFactory("playerName")); playerLevelCol.setCellValueFactory(new PropertyValueFactory("playerLevel")); scoresCol.setCellValueFactory(new PropertyValueFactory("scores")); favoriteAgentCol.setCellValueFactory(new PropertyValueFactory("favoriteAgent")); favoriteAttackerCol.setCellValueFactory(new PropertyValueFactory("favoriteAttacker")); favoriteDefenderCol.setCellValueFactory(new PropertyValueFactory("favoriteDefender")); table.getColumns().add(playerNumCol); table.getColumns().add(playerNameCol); table.getColumns().add(playerLevelCol); table.getColumns().add(scoresCol); favoriteCharsCol.getColumns().add(favoriteAgentCol); favoriteCharsCol.getColumns().add(favoriteAttackerCol); favoriteCharsCol.getColumns().add(favoriteDefenderCol); table.getColumns().add(favoriteCharsCol); } public static ObservableList loadTable(ArrayList list) { ArrayList outputList = new ArrayList<>(); for(Competitor player: list) { if (player instanceof ValorantPlayer) { outputList.add(new CompetitorRow(player.getPlayerNumber(), player.getPlayerName(), player.getPlayerLevel(), player.getScores(), ((ValorantPlayer) player).getFavoriteAgent())); } if (player instanceof R6Player) { outputList.add(new CompetitorRow(player.getPlayerNumber(), player.getPlayerName(), player.getPlayerLevel(), player.getScores(), ((R6Player) player).getFavoriteAttacker(), ((R6Player) player).getFavoriteDefender())); } } return FXCollections.observableArrayList(outputList); } }