Search in sources :

Example 6 with TableColumnController

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

the class CraftingSynopsisTableController method buildRowHeaderColumn.

private TableColumnController<CraftingSynopsisItem, String> buildRowHeaderColumn() {
    CellDataProvider<CraftingSynopsisItem, String> cell = new CellDataProvider<CraftingSynopsisItem, String>() {

        @Override
        public String getData(CraftingSynopsisItem item) {
            CharacterFile character = item.getCharacter();
            String name = character.getName();
            return name;
        }
    };
    TableColumnController<CraftingSynopsisItem, String> column = new TableColumnController<CraftingSynopsisItem, String>("Name", String.class, cell);
    // Init widths
    column.setMinWidth(100);
    column.setPreferredWidth(150);
    column.setMaxWidth(300);
    // Header renderer
    JPanel emptyHeaderPanel = GuiFactory.buildBackgroundPanel(new GridBagLayout());
    TableCellRenderer headerRenderer = buildSimpleCellRenderer(emptyHeaderPanel);
    column.setHeaderCellRenderer(headerRenderer);
    // Cell renderer
    TableCellRenderer renderer = buildCharacterNameCellRenderer();
    column.setCellRenderer(renderer);
    return column;
}
Also used : JPanel(javax.swing.JPanel) TableCellRenderer(javax.swing.table.TableCellRenderer) DefaultTableCellRenderer(javax.swing.table.DefaultTableCellRenderer) GridBagLayout(java.awt.GridBagLayout) TableColumnController(delta.common.ui.swing.tables.TableColumnController) CellDataProvider(delta.common.ui.swing.tables.CellDataProvider) CharacterFile(delta.games.lotro.character.CharacterFile)

Example 7 with TableColumnController

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

the class CraftingSynopsisTableController method buildCraftingTierColumn.

private TableColumnController<CraftingSynopsisItem, CraftingLevel> buildCraftingTierColumn(final boolean mastery) {
    CellDataProvider<CraftingSynopsisItem, CraftingLevel> cell = new CellDataProvider<CraftingSynopsisItem, CraftingLevel>() {

        @Override
        public CraftingLevel getData(CraftingSynopsisItem item) {
            return item.getLevel(mastery);
        }
    };
    String columnName = mastery ? "Mastery" : "Proficiency";
    String id = columnName;
    TableColumnController<CraftingSynopsisItem, CraftingLevel> column = new TableColumnController<CraftingSynopsisItem, CraftingLevel>(id, columnName, CraftingLevel.class, cell);
    // Header cell renderer
    JPanel panel = buildCraftingTierPanel(mastery);
    TableCellRenderer headerRenderer = buildSimpleCellRenderer(panel);
    column.setHeaderCellRenderer(headerRenderer);
    // Cell renderer
    TableCellRenderer renderer = buildCraftingLevelCellRenderer(mastery);
    column.setCellRenderer(renderer);
    // Init widths
    column.setMinWidth(150);
    column.setPreferredWidth(200);
    column.setMaxWidth(300);
    // Comparator
    Comparator<CraftingLevel> statsComparator = new Comparator<CraftingLevel>() {

        @Override
        public int compare(CraftingLevel data1, CraftingLevel data2) {
            return Integer.compare(data1.getTier(), data2.getTier());
        }
    };
    column.setComparator(statsComparator);
    return column;
}
Also used : JPanel(javax.swing.JPanel) TableCellRenderer(javax.swing.table.TableCellRenderer) DefaultTableCellRenderer(javax.swing.table.DefaultTableCellRenderer) TableColumnController(delta.common.ui.swing.tables.TableColumnController) CraftingLevel(delta.games.lotro.lore.crafting.CraftingLevel) CellDataProvider(delta.common.ui.swing.tables.CellDataProvider) FactionLevelComparator(delta.games.lotro.lore.reputation.FactionLevelComparator) ProfessionComparator(delta.games.lotro.lore.crafting.ProfessionComparator) Comparator(java.util.Comparator)

Example 8 with TableColumnController

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

Example 9 with TableColumnController

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

the class ReputationSynopsisTableController method buildFactionsColumn.

private TableColumnController<Faction, String> buildFactionsColumn() {
    CellDataProvider<Faction, String> cell = new CellDataProvider<Faction, String>() {

        @Override
        public String getData(Faction item) {
            return item.getName();
        }
    };
    TableColumnController<Faction, String> column = new TableColumnController<Faction, String>("Factions", String.class, cell);
    // Init panels
    column.setMinWidth(200);
    column.setPreferredWidth(200);
    // Header renderer
    JPanel emptyHeaderPanel = GuiFactory.buildBackgroundPanel(new GridBagLayout());
    TableCellRenderer headerRenderer = buildSimpleCellRenderer(emptyHeaderPanel);
    column.setHeaderCellRenderer(headerRenderer);
    return column;
}
Also used : JPanel(javax.swing.JPanel) TableCellRenderer(javax.swing.table.TableCellRenderer) GridBagLayout(java.awt.GridBagLayout) TableColumnController(delta.common.ui.swing.tables.TableColumnController) CellDataProvider(delta.common.ui.swing.tables.CellDataProvider) Faction(delta.games.lotro.lore.reputation.Faction)

Example 10 with TableColumnController

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

the class WarbandsTableController method buildWarbandColumn.

private TableColumnController<WarbandDefinition, WarbandDefinition> buildWarbandColumn() {
    CellDataProvider<WarbandDefinition, WarbandDefinition> cell = new CellDataProvider<WarbandDefinition, WarbandDefinition>() {

        @Override
        public WarbandDefinition getData(WarbandDefinition item) {
            return item;
        }
    };
    TableColumnController<WarbandDefinition, WarbandDefinition> column = new TableColumnController<WarbandDefinition, WarbandDefinition>("Warbands", WarbandDefinition.class, cell);
    // Init panels
    int warbandColumnWidth = 0;
    final HashMap<String, JPanel> warbandPanels = new HashMap<String, JPanel>();
    WarbandsRegistry registry = WarbandsRegistry.getWarbandsRegistry();
    WarbandDefinition[] warbands = registry.getAllWarbands();
    for (WarbandDefinition warband : warbands) {
        JPanel warbandPanel = buildWarbandPanel(warband);
        warbandPanels.put(warband.getName(), warbandPanel);
        // Column size
        int width = warbandPanel.getPreferredSize().width;
        warbandColumnWidth = Math.max(warbandColumnWidth, width);
    }
    column.setMinWidth(warbandColumnWidth + 10);
    column.setPreferredWidth(warbandColumnWidth + 10);
    // Cell renderer
    TableCellRenderer renderer = buildWarbandCellRenderer(warbandPanels);
    column.setCellRenderer(renderer);
    // Header renderer
    JPanel emptyHeaderPanel = GuiFactory.buildBackgroundPanel(new GridBagLayout());
    TableCellRenderer headerRenderer = buildSimpleCellRenderer(emptyHeaderPanel);
    column.setHeaderCellRenderer(headerRenderer);
    // Comparator
    Comparator<WarbandDefinition> warbandComparator = new Comparator<WarbandDefinition>() {

        @Override
        public int compare(WarbandDefinition w1, WarbandDefinition w2) {
            String n1 = w1.getSafeShortName();
            String n2 = w2.getSafeShortName();
            return n1.compareTo(n2);
        }
    };
    column.setComparator(warbandComparator);
    return column;
}
Also used : JPanel(javax.swing.JPanel) TableCellRenderer(javax.swing.table.TableCellRenderer) GridBagLayout(java.awt.GridBagLayout) HashMap(java.util.HashMap) TableColumnController(delta.common.ui.swing.tables.TableColumnController) WarbandsRegistry(delta.games.lotro.lore.warbands.WarbandsRegistry) Comparator(java.util.Comparator) WarbandDefinition(delta.games.lotro.lore.warbands.WarbandDefinition) CellDataProvider(delta.common.ui.swing.tables.CellDataProvider)

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