Search in sources :

Example 16 with Faction

use of delta.games.lotro.lore.reputation.Faction 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 17 with Faction

use of delta.games.lotro.lore.reputation.Faction 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 18 with Faction

use of delta.games.lotro.lore.reputation.Faction in project lotro-companion by dmorcellet.

the class FactionEditionDialogController method build.

@Override
protected JDialog build() {
    JDialog dialog = super.build();
    Faction faction = _data.getFaction();
    String name = faction.getName();
    dialog.setTitle("Edit faction history: " + name);
    dialog.setResizable(false);
    return dialog;
}
Also used : JDialog(javax.swing.JDialog) Faction(delta.games.lotro.lore.reputation.Faction)

Example 19 with Faction

use of delta.games.lotro.lore.reputation.Faction in project lotro-companion by dmorcellet.

the class FactionHistoryChartController method updateData.

/**
 * Update graph data.
 */
public void updateData() {
    _data.removeAllSeries();
    XYSeries series = new XYSeries("History");
    Faction faction = _stats.getFaction();
    FactionLevel[] levels = faction.getLevels();
    for (FactionLevel level : levels) {
        FactionLevelStatus levelStatus = _stats.getStatusForLevel(level);
        if (levelStatus != null) {
            boolean isCompleted = levelStatus.isCompleted();
            if (isCompleted) {
                long date = levelStatus.getCompletionDate();
                if (date != 0) {
                    series.add(date, level.getValue());
                }
            }
        }
    }
    _data.addSeries(series);
}
Also used : XYSeries(org.jfree.data.xy.XYSeries) FactionLevelStatus(delta.games.lotro.character.reputation.FactionLevelStatus) FactionLevel(delta.games.lotro.lore.reputation.FactionLevel) Faction(delta.games.lotro.lore.reputation.Faction)

Example 20 with Faction

use of delta.games.lotro.lore.reputation.Faction in project lotro-tools by dmorcellet.

the class RewardsHTMLParser method parseReputationReward.

private Reputation parseReputationReward(Element rewardDiv) {
    // System.out.println("Reputation reward!");
    Reputation r = new Reputation();
    List<Element> elements = rewardDiv.getChildElements();
    if ((elements != null) && (elements.size() == 2)) {
        Element reputationNode = elements.get(1);
        List<Segment> nodes = JerichoHtmlUtils.getChildNodes(reputationNode);
        int nbNodes = nodes.size();
        int nbItems = nbNodes / 4;
        for (int i = 0; i < nbItems; i++) {
            Segment valueNode = nodes.get(i * 4 + 1);
            Segment factionNode = nodes.get(i * 4 + 3);
            if ((valueNode.getClass() == Segment.class) && (factionNode.getClass() == Segment.class)) {
                String valueStr = valueNode.toString();
                valueStr = valueStr.replace("with", "").trim();
                valueStr = valueStr.replace("+", "").trim();
                int reputation = NumericTools.parseInt(valueStr, 0);
                String factionName = factionNode.toString().trim();
                Faction faction = FactionsRegistry.getInstance().getByName(factionName);
                if (faction != null) {
                    ReputationItem item = new ReputationItem(faction);
                    item.setAmount(reputation);
                    r.add(item);
                } else {
                    _logger.error("Cannot get faction [" + factionName + "]!");
                }
            }
        }
    }
    return r;
/*
<div class="questReward">
<div>
<strong>Reputation:</strong>
</div>
<div>
<img class="icon" src="http://content.turbine.com/sites/lorebook.lotro.com/images/icons/reputation_increase.gif">
+700 with
<a href="/wiki/Faction:Malledhrim">Malledhrim</a>
</div>
</div>
     */
}
Also used : Element(net.htmlparser.jericho.Element) Reputation(delta.games.lotro.common.Reputation) ReputationItem(delta.games.lotro.common.ReputationItem) Segment(net.htmlparser.jericho.Segment) Faction(delta.games.lotro.lore.reputation.Faction)

Aggregations

Faction (delta.games.lotro.lore.reputation.Faction)20 FactionLevel (delta.games.lotro.lore.reputation.FactionLevel)6 JPanel (javax.swing.JPanel)5 FactionLevelStatus (delta.games.lotro.character.reputation.FactionLevelStatus)3 FactionStatus (delta.games.lotro.character.reputation.FactionStatus)3 ReputationItem (delta.games.lotro.common.ReputationItem)3 FactionsRegistry (delta.games.lotro.lore.reputation.FactionsRegistry)3 GridBagLayout (java.awt.GridBagLayout)3 CellDataProvider (delta.common.ui.swing.tables.CellDataProvider)2 TableColumnController (delta.common.ui.swing.tables.TableColumnController)2 Reputation (delta.games.lotro.common.Reputation)2 VirtueId (delta.games.lotro.common.VirtueId)2 ReputationRewardFilter (delta.games.lotro.common.rewards.filters.ReputationRewardFilter)2 BorderLayout (java.awt.BorderLayout)2 GridBagConstraints (java.awt.GridBagConstraints)2 Insets (java.awt.Insets)2 TableCellRenderer (javax.swing.table.TableCellRenderer)2 CheckboxController (delta.common.ui.swing.checkbox.CheckboxController)1 ComboBoxController (delta.common.ui.swing.combobox.ComboBoxController)1 ItemSelectionListener (delta.common.ui.swing.combobox.ItemSelectionListener)1