use of delta.games.lotro.lore.reputation.FactionLevelComparator 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;
}
use of delta.games.lotro.lore.reputation.FactionLevelComparator 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;
}
Aggregations