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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations