Search in sources :

Example 1 with WarbandsStats

use of delta.games.lotro.stats.warbands.WarbandsStats in project lotro-companion by dmorcellet.

the class WarbandsTableController method buildCharacterColumn.

private TableColumnController<WarbandDefinition, WarbandStats> buildCharacterColumn(CharacterFile character) {
    final WarbandsStats warbandsStats = loadToonStats(character);
    CellDataProvider<WarbandDefinition, WarbandStats> cell = new CellDataProvider<WarbandDefinition, WarbandStats>() {

        @Override
        public WarbandStats getData(WarbandDefinition item) {
            return warbandsStats.getWarbandStats(item, true);
        }
    };
    String id = character.getIdentifier();
    TableColumnController<WarbandDefinition, WarbandStats> column = new TableColumnController<WarbandDefinition, WarbandStats>(id, "Stats", WarbandStats.class, cell);
    // Cell renderer
    TableCellRenderer renderer = buildStatCellRenderer(warbandsStats);
    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
    Comparator<WarbandStats> statsComparator = new Comparator<WarbandStats>() {

        @Override
        public int compare(WarbandStats w1, WarbandStats w2) {
            Long d1 = w1.getMostRecentDate();
            Long d2 = w2.getMostRecentDate();
            if (d1 == null) {
                if (d2 == null)
                    return 0;
                return -1;
            }
            if (d2 == null)
                return 1;
            return d1.compareTo(d2);
        }
    };
    column.setComparator(statsComparator);
    return column;
}
Also used : TableCellRenderer(javax.swing.table.TableCellRenderer) JPanel(javax.swing.JPanel) WarbandsStats(delta.games.lotro.stats.warbands.WarbandsStats) TableColumnController(delta.common.ui.swing.tables.TableColumnController) Comparator(java.util.Comparator) WarbandDefinition(delta.games.lotro.lore.warbands.WarbandDefinition) WarbandStats(delta.games.lotro.stats.warbands.WarbandStats) CellDataProvider(delta.common.ui.swing.tables.CellDataProvider)

Example 2 with WarbandsStats

use of delta.games.lotro.stats.warbands.WarbandsStats in project lotro-companion by dmorcellet.

the class WarbandsTableController method loadToonStats.

private WarbandsStats loadToonStats(CharacterFile toon) {
    CharacterLog log = toon.getLastCharacterLog();
    WarbandsStats stats = new WarbandsStats(log);
    return stats;
}
Also used : WarbandsStats(delta.games.lotro.stats.warbands.WarbandsStats) CharacterLog(delta.games.lotro.character.log.CharacterLog)

Aggregations

WarbandsStats (delta.games.lotro.stats.warbands.WarbandsStats)2 CellDataProvider (delta.common.ui.swing.tables.CellDataProvider)1 TableColumnController (delta.common.ui.swing.tables.TableColumnController)1 CharacterLog (delta.games.lotro.character.log.CharacterLog)1 WarbandDefinition (delta.games.lotro.lore.warbands.WarbandDefinition)1 WarbandStats (delta.games.lotro.stats.warbands.WarbandStats)1 Comparator (java.util.Comparator)1 JPanel (javax.swing.JPanel)1 TableCellRenderer (javax.swing.table.TableCellRenderer)1