Search in sources :

Example 1 with TableColumnController

use of delta.common.ui.swing.tables.TableColumnController in project lotro-companion by dmorcellet.

the class ItemChoiceTableController method buildStatColumn.

private TableColumnController<Item, FixedDecimalsInteger> buildStatColumn(final STAT stat) {
    CellDataProvider<Item, FixedDecimalsInteger> statCell = new CellDataProvider<Item, FixedDecimalsInteger>() {

        @Override
        public FixedDecimalsInteger getData(Item item) {
            BasicStatsSet stats = item.getStats();
            FixedDecimalsInteger value = stats.getStat(stat);
            return value;
        }
    };
    TableColumnController<Item, FixedDecimalsInteger> statColumn = new TableColumnController<Item, FixedDecimalsInteger>(stat.name(), stat.getName(), FixedDecimalsInteger.class, statCell);
    statColumn.setWidthSpecs(55, 55, 50);
    return statColumn;
}
Also used : Item(delta.games.lotro.lore.items.Item) FixedDecimalsInteger(delta.games.lotro.utils.FixedDecimalsInteger) TableColumnController(delta.common.ui.swing.tables.TableColumnController) CellDataProvider(delta.common.ui.swing.tables.CellDataProvider) BasicStatsSet(delta.games.lotro.character.stats.BasicStatsSet)

Example 2 with TableColumnController

use of delta.common.ui.swing.tables.TableColumnController in project lotro-companion by dmorcellet.

the class CharacterLogTableController method buildTable.

private GenericTableController<CharacterLogItem> buildTable() {
    DataProvider<CharacterLogItem> provider = new DataProvider<CharacterLogItem>() {

        @Override
        public CharacterLogItem getAt(int index) {
            return _log.getLogItem(index);
        }

        @Override
        public int getCount() {
            return _log.getNbItems();
        }
    };
    GenericTableController<CharacterLogItem> table = new GenericTableController<CharacterLogItem>(provider);
    // Date column
    {
        CellDataProvider<CharacterLogItem, Date> dateCell = new CellDataProvider<CharacterLogItem, Date>() {

            @Override
            public Date getData(CharacterLogItem item) {
                long timestamp = item.getDate();
                return new Date(timestamp);
            }
        };
        TableColumnController<CharacterLogItem, Date> dateColumn = new TableColumnController<CharacterLogItem, Date>("Date", Date.class, dateCell);
        dateColumn.setWidthSpecs(100, 100, 50);
        dateColumn.setCellRenderer(new DateRenderer(Formats.DATE_PATTERN));
        table.addColumnController(dateColumn);
    }
    // Type column
    {
        CellDataProvider<CharacterLogItem, LogItemType> typeCell = new CellDataProvider<CharacterLogItem, LogItemType>() {

            @Override
            public LogItemType getData(CharacterLogItem item) {
                return item.getLogItemType();
            }
        };
        TableColumnController<CharacterLogItem, LogItemType> typeColumn = new TableColumnController<CharacterLogItem, LogItemType>("Type", LogItemType.class, typeCell);
        typeColumn.setWidthSpecs(100, 100, 50);
        typeColumn.setCellRenderer(new LogItemTypeRenderer());
        typeColumn.setUseToString(Boolean.TRUE);
        table.addColumnController(typeColumn);
    }
    // Label column
    {
        CellDataProvider<CharacterLogItem, String> labelCell = new CellDataProvider<CharacterLogItem, String>() {

            @Override
            public String getData(CharacterLogItem item) {
                return item.getLabel();
            }
        };
        TableColumnController<CharacterLogItem, String> labelColumn = new TableColumnController<CharacterLogItem, String>("Label", String.class, labelCell);
        labelColumn.setWidthSpecs(150, -1, 150);
        table.addColumnController(labelColumn);
    }
    return table;
}
Also used : TableColumnController(delta.common.ui.swing.tables.TableColumnController) DateRenderer(delta.common.ui.swing.tables.GenericTableController.DateRenderer) Date(java.util.Date) CellDataProvider(delta.common.ui.swing.tables.CellDataProvider) DataProvider(delta.common.ui.swing.tables.DataProvider) GenericTableController(delta.common.ui.swing.tables.GenericTableController) CharacterLogItem(delta.games.lotro.character.log.CharacterLogItem) CellDataProvider(delta.common.ui.swing.tables.CellDataProvider) LogItemType(delta.games.lotro.character.log.CharacterLogItem.LogItemType)

Example 3 with TableColumnController

use of delta.common.ui.swing.tables.TableColumnController 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 4 with TableColumnController

use of delta.common.ui.swing.tables.TableColumnController in project lotro-companion by dmorcellet.

the class CraftingSynopsisTableController method buildProfessionColumn.

private TableColumnController<CraftingSynopsisItem, Profession> buildProfessionColumn() {
    CellDataProvider<CraftingSynopsisItem, Profession> professionCell = new CellDataProvider<CraftingSynopsisItem, Profession>() {

        @Override
        public Profession getData(CraftingSynopsisItem item) {
            return item.getProfession();
        }
    };
    TableColumnController<CraftingSynopsisItem, Profession> professionColumn = new TableColumnController<CraftingSynopsisItem, Profession>("Profession", Profession.class, professionCell);
    professionColumn.setWidthSpecs(50, 50, 50);
    // Header renderer
    JPanel emptyHeaderPanel = GuiFactory.buildBackgroundPanel(new GridBagLayout());
    TableCellRenderer headerRenderer = buildSimpleCellRenderer(emptyHeaderPanel);
    professionColumn.setHeaderCellRenderer(headerRenderer);
    // Cell renderer
    TableCellRenderer cellRenderer = buildProfessionCellRenderer();
    professionColumn.setCellRenderer(cellRenderer);
    // Comparator
    ProfessionComparator comparator = new ProfessionComparator();
    professionColumn.setComparator(comparator);
    return professionColumn;
}
Also used : JPanel(javax.swing.JPanel) TableCellRenderer(javax.swing.table.TableCellRenderer) DefaultTableCellRenderer(javax.swing.table.DefaultTableCellRenderer) ProfessionComparator(delta.games.lotro.lore.crafting.ProfessionComparator) Profession(delta.games.lotro.lore.crafting.Profession) GridBagLayout(java.awt.GridBagLayout) TableColumnController(delta.common.ui.swing.tables.TableColumnController) CellDataProvider(delta.common.ui.swing.tables.CellDataProvider)

Example 5 with TableColumnController

use of delta.common.ui.swing.tables.TableColumnController in project lotro-companion by dmorcellet.

the class CraftingSynopsisTableController method buildGuildColumn.

private TableColumnController<CraftingSynopsisItem, FactionStatus> buildGuildColumn() {
    CellDataProvider<CraftingSynopsisItem, FactionStatus> cell = new CellDataProvider<CraftingSynopsisItem, FactionStatus>() {

        @Override
        public FactionStatus getData(CraftingSynopsisItem item) {
            return item.getGuildFaction();
        }
    };
    String columnName = "Guild";
    String id = columnName;
    TableColumnController<CraftingSynopsisItem, FactionStatus> column = new TableColumnController<CraftingSynopsisItem, FactionStatus>(id, columnName, FactionStatus.class, cell);
    // Header cell renderer
    JPanel panel = buildGuildPanel();
    TableCellRenderer headerRenderer = buildSimpleCellRenderer(panel);
    column.setHeaderCellRenderer(headerRenderer);
    // Cell renderer
    TableCellRenderer renderer = ReputationSynopsisTableController.buildFactionStatusCellRenderer();
    column.setCellRenderer(renderer);
    // Init widths
    column.setMinWidth(150);
    column.setPreferredWidth(200);
    column.setMaxWidth(300);
    // 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 : FactionLevelComparator(delta.games.lotro.lore.reputation.FactionLevelComparator) JPanel(javax.swing.JPanel) TableCellRenderer(javax.swing.table.TableCellRenderer) DefaultTableCellRenderer(javax.swing.table.DefaultTableCellRenderer) TableColumnController(delta.common.ui.swing.tables.TableColumnController) CellDataProvider(delta.common.ui.swing.tables.CellDataProvider) FactionStatus(delta.games.lotro.character.reputation.FactionStatus) FactionLevelComparator(delta.games.lotro.lore.reputation.FactionLevelComparator) ProfessionComparator(delta.games.lotro.lore.crafting.ProfessionComparator) Comparator(java.util.Comparator)

Aggregations

CellDataProvider (delta.common.ui.swing.tables.CellDataProvider)10 TableColumnController (delta.common.ui.swing.tables.TableColumnController)10 JPanel (javax.swing.JPanel)8 TableCellRenderer (javax.swing.table.TableCellRenderer)8 Comparator (java.util.Comparator)5 GridBagLayout (java.awt.GridBagLayout)4 DefaultTableCellRenderer (javax.swing.table.DefaultTableCellRenderer)4 ProfessionComparator (delta.games.lotro.lore.crafting.ProfessionComparator)3 FactionLevelComparator (delta.games.lotro.lore.reputation.FactionLevelComparator)3 CharacterFile (delta.games.lotro.character.CharacterFile)2 FactionStatus (delta.games.lotro.character.reputation.FactionStatus)2 Faction (delta.games.lotro.lore.reputation.Faction)2 WarbandDefinition (delta.games.lotro.lore.warbands.WarbandDefinition)2 DataProvider (delta.common.ui.swing.tables.DataProvider)1 GenericTableController (delta.common.ui.swing.tables.GenericTableController)1 DateRenderer (delta.common.ui.swing.tables.GenericTableController.DateRenderer)1 CharacterLogItem (delta.games.lotro.character.log.CharacterLogItem)1 LogItemType (delta.games.lotro.character.log.CharacterLogItem.LogItemType)1 ReputationStatus (delta.games.lotro.character.reputation.ReputationStatus)1 BasicStatsSet (delta.games.lotro.character.stats.BasicStatsSet)1