Search in sources :

Example 6 with WarbandDefinition

use of delta.games.lotro.lore.warbands.WarbandDefinition in project lotro-companion by dmorcellet.

the class WarbandsStats method dump.

/**
 * Dump the contents of this object to the given stream.
 * @param ps Output stream to use.
 */
public void dump(PrintStream ps) {
    ps.println("Warbands statistics for [" + _name + "]:");
    List<String> warbandNames = new ArrayList<String>(_stats.keySet());
    Collections.sort(warbandNames);
    WarbandsRegistry registry = WarbandsRegistry.getWarbandsRegistry();
    for (String warbandName : warbandNames) {
        WarbandDefinition warband = registry.getByName(warbandName);
        WarbandStats stat = getWarbandStats(warband);
        stat.dump(ps);
    }
}
Also used : WarbandDefinition(delta.games.lotro.lore.warbands.WarbandDefinition) ArrayList(java.util.ArrayList) WarbandsRegistry(delta.games.lotro.lore.warbands.WarbandsRegistry)

Example 7 with WarbandDefinition

use of delta.games.lotro.lore.warbands.WarbandDefinition in project lotro-companion by dmorcellet.

the class WarbandsFilterController method getRegions.

private String[] getRegions() {
    WarbandDefinition[] warbands = WarbandsRegistry.getWarbandsRegistry().getAllWarbands();
    Set<String> regionsSets = new HashSet<String>();
    for (WarbandDefinition warband : warbands) {
        String region = warband.getRegion();
        regionsSets.add(region);
    }
    List<String> regions = new ArrayList<String>(regionsSets);
    Collections.sort(regions);
    String[] ret = regions.toArray(new String[regions.size()]);
    return ret;
}
Also used : WarbandDefinition(delta.games.lotro.lore.warbands.WarbandDefinition) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet)

Example 8 with WarbandDefinition

use of delta.games.lotro.lore.warbands.WarbandDefinition 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)

Example 9 with WarbandDefinition

use of delta.games.lotro.lore.warbands.WarbandDefinition in project lotro-companion by dmorcellet.

the class WarbandsTableController method buildDataProvider.

private DataProvider<WarbandDefinition> buildDataProvider() {
    WarbandsRegistry registry = WarbandsRegistry.getWarbandsRegistry();
    WarbandDefinition[] warbands = registry.getAllWarbands();
    List<WarbandDefinition> warbandsList = Arrays.asList(warbands);
    DataProvider<WarbandDefinition> ret = new ListDataProvider<WarbandDefinition>(warbandsList);
    return ret;
}
Also used : ListDataProvider(delta.common.ui.swing.tables.ListDataProvider) WarbandDefinition(delta.games.lotro.lore.warbands.WarbandDefinition) WarbandsRegistry(delta.games.lotro.lore.warbands.WarbandsRegistry)

Aggregations

WarbandDefinition (delta.games.lotro.lore.warbands.WarbandDefinition)9 WarbandsRegistry (delta.games.lotro.lore.warbands.WarbandsRegistry)4 JPanel (javax.swing.JPanel)4 TableCellRenderer (javax.swing.table.TableCellRenderer)4 ArrayList (java.util.ArrayList)3 CellDataProvider (delta.common.ui.swing.tables.CellDataProvider)2 TableColumnController (delta.common.ui.swing.tables.TableColumnController)2 WarbandStats (delta.games.lotro.stats.warbands.WarbandStats)2 Comparator (java.util.Comparator)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 JTable (javax.swing.JTable)2 ListDataProvider (delta.common.ui.swing.tables.ListDataProvider)1 WarbandsStats (delta.games.lotro.stats.warbands.WarbandsStats)1 BorderLayout (java.awt.BorderLayout)1 GridBagLayout (java.awt.GridBagLayout)1