Search in sources :

Example 1 with ReputationStatus

use of delta.games.lotro.character.reputation.ReputationStatus in project lotro-companion by dmorcellet.

the class ReputationSynopsisTableController method buildCharacterColumn.

private TableColumnController<Faction, FactionStatus> buildCharacterColumn(CharacterFile character) {
    final CharacterFile toon = character;
    CellDataProvider<Faction, FactionStatus> cell = new CellDataProvider<Faction, FactionStatus>() {

        @Override
        public FactionStatus getData(Faction item) {
            ReputationStatus status = toon.getReputation();
            return status.getOrCreateFactionStat(item);
        }
    };
    String id = character.getIdentifier();
    TableColumnController<Faction, FactionStatus> column = new TableColumnController<Faction, FactionStatus>(id, "Faction", FactionStatus.class, cell);
    // Cell renderer
    TableCellRenderer renderer = buildFactionStatusCellRenderer();
    column.setCellRenderer(renderer);
    // Header renderer
    JPanel headerPanel = buildToonHeaderPanel(character);
    TableCellRenderer headerRenderer = buildSimpleCellRenderer(headerPanel);
    column.setHeaderCellRenderer(headerRenderer);
    int minWidth = headerPanel.getPreferredSize().width;
    column.setMinWidth(minWidth);
    column.setPreferredWidth(minWidth);
    // Comparator
    final FactionLevelComparator factionLevelComparator = new FactionLevelComparator();
    Comparator<FactionStatus> statsComparator = new Comparator<FactionStatus>() {

        @Override
        public int compare(FactionStatus data1, FactionStatus data2) {
            return factionLevelComparator.compare(data1.getFactionLevel(), data2.getFactionLevel());
        }
    };
    column.setComparator(statsComparator);
    return column;
}
Also used : TableCellRenderer(javax.swing.table.TableCellRenderer) JPanel(javax.swing.JPanel) TableColumnController(delta.common.ui.swing.tables.TableColumnController) CharacterFile(delta.games.lotro.character.CharacterFile) FactionLevelComparator(delta.games.lotro.lore.reputation.FactionLevelComparator) Comparator(java.util.Comparator) FactionLevelComparator(delta.games.lotro.lore.reputation.FactionLevelComparator) CellDataProvider(delta.common.ui.swing.tables.CellDataProvider) ReputationStatus(delta.games.lotro.character.reputation.ReputationStatus) FactionStatus(delta.games.lotro.character.reputation.FactionStatus) Faction(delta.games.lotro.lore.reputation.Faction)

Aggregations

CellDataProvider (delta.common.ui.swing.tables.CellDataProvider)1 TableColumnController (delta.common.ui.swing.tables.TableColumnController)1 CharacterFile (delta.games.lotro.character.CharacterFile)1 FactionStatus (delta.games.lotro.character.reputation.FactionStatus)1 ReputationStatus (delta.games.lotro.character.reputation.ReputationStatus)1 Faction (delta.games.lotro.lore.reputation.Faction)1 FactionLevelComparator (delta.games.lotro.lore.reputation.FactionLevelComparator)1 Comparator (java.util.Comparator)1 JPanel (javax.swing.JPanel)1 TableCellRenderer (javax.swing.table.TableCellRenderer)1