Search in sources :

Example 1 with WarbandsRegistry

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

the class WarbandsStats method parseItem.

private void parseItem(CharacterLogItem item) {
    String label = item.getLabel();
    String warbandName = label.substring(WARBAND_SEED.length()).trim();
    long date = item.getDate();
    WarbandsRegistry registry = WarbandsRegistry.getWarbandsRegistry();
    WarbandDefinition warband = registry.getByName(warbandName);
    if (warband == null) {
        _logger.warn("Unknown warband [" + warbandName + "]. Ignored.");
    } else {
        WarbandStats stat = getWarbandStats(warband, true);
        stat.add(date);
    }
}
Also used : WarbandDefinition(delta.games.lotro.lore.warbands.WarbandDefinition) WarbandsRegistry(delta.games.lotro.lore.warbands.WarbandsRegistry)

Example 2 with WarbandsRegistry

use of delta.games.lotro.lore.warbands.WarbandsRegistry 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 3 with WarbandsRegistry

use of delta.games.lotro.lore.warbands.WarbandsRegistry 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 4 with WarbandsRegistry

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

Example 5 with WarbandsRegistry

use of delta.games.lotro.lore.warbands.WarbandsRegistry in project lotro-tools by dmorcellet.

the class WarbandsGenerator method doIt.

private void doIt() {
    LotroCoreConfig cfg = LotroCoreConfig.getInstance();
    File loreDir = cfg.getLoreDir();
    File warbandsFile = new File(loreDir, "warbands.xml");
    WarbandsRegistry r = buildRegistry();
    WarbandsRegistryXMLWriter w = new WarbandsRegistryXMLWriter();
    w.write(warbandsFile, r, EncodingNames.UTF_8);
}
Also used : WarbandsRegistryXMLWriter(delta.games.lotro.lore.warbands.io.xml.WarbandsRegistryXMLWriter) WarbandsRegistry(delta.games.lotro.lore.warbands.WarbandsRegistry) LotroCoreConfig(delta.games.lotro.LotroCoreConfig) File(java.io.File)

Aggregations

WarbandsRegistry (delta.games.lotro.lore.warbands.WarbandsRegistry)5 WarbandDefinition (delta.games.lotro.lore.warbands.WarbandDefinition)4 CellDataProvider (delta.common.ui.swing.tables.CellDataProvider)1 ListDataProvider (delta.common.ui.swing.tables.ListDataProvider)1 TableColumnController (delta.common.ui.swing.tables.TableColumnController)1 LotroCoreConfig (delta.games.lotro.LotroCoreConfig)1 WarbandsRegistryXMLWriter (delta.games.lotro.lore.warbands.io.xml.WarbandsRegistryXMLWriter)1 GridBagLayout (java.awt.GridBagLayout)1 File (java.io.File)1 ArrayList (java.util.ArrayList)1 Comparator (java.util.Comparator)1 HashMap (java.util.HashMap)1 JPanel (javax.swing.JPanel)1 TableCellRenderer (javax.swing.table.TableCellRenderer)1