Search in sources :

Example 1 with FixedDecimalsInteger

use of delta.games.lotro.utils.FixedDecimalsInteger in project lotro-companion by dmorcellet.

the class ItemChoiceTableController method buildStatColumn.

private TableColumnController<Item, FixedDecimalsInteger> buildStatColumn(final STAT stat) {
    CellDataProvider<Item, FixedDecimalsInteger> statCell = new CellDataProvider<Item, FixedDecimalsInteger>() {

        @Override
        public FixedDecimalsInteger getData(Item item) {
            BasicStatsSet stats = item.getStats();
            FixedDecimalsInteger value = stats.getStat(stat);
            return value;
        }
    };
    TableColumnController<Item, FixedDecimalsInteger> statColumn = new TableColumnController<Item, FixedDecimalsInteger>(stat.name(), stat.getName(), FixedDecimalsInteger.class, statCell);
    statColumn.setWidthSpecs(55, 55, 50);
    return statColumn;
}
Also used : Item(delta.games.lotro.lore.items.Item) FixedDecimalsInteger(delta.games.lotro.utils.FixedDecimalsInteger) TableColumnController(delta.common.ui.swing.tables.TableColumnController) CellDataProvider(delta.common.ui.swing.tables.CellDataProvider) BasicStatsSet(delta.games.lotro.character.stats.BasicStatsSet)

Example 2 with FixedDecimalsInteger

use of delta.games.lotro.utils.FixedDecimalsInteger in project lotro-companion by dmorcellet.

the class CharacterStatsSummaryPanelController method update.

/**
 * Update contents.
 */
public void update() {
    STAT[] stats = STAT.values();
    int nbStats = stats.length;
    for (int i = 0; i < nbStats; i++) {
        String statValue = "";
        if (_toon != null) {
            BasicStatsSet characterStats = _toon.getStats();
            FixedDecimalsInteger value = characterStats.getStat(stats[i]);
            if (value != null) {
                statValue = String.valueOf(value.intValue());
            } else {
                statValue = "-";
            }
        }
        if (_statValues[i] != null) {
            _statValues[i].setText(statValue);
        }
    }
    DetailedCharacterStatsWindowController detailsStatsController = getDetailsController();
    if (detailsStatsController != null) {
        detailsStatsController.update();
    }
    StatContribsWindowController contribsController = getContribsController();
    if (contribsController != null) {
        contribsController.update();
    }
}
Also used : STAT(delta.games.lotro.character.stats.STAT) StatContribsWindowController(delta.games.lotro.gui.character.stats.contribs.StatContribsWindowController) FixedDecimalsInteger(delta.games.lotro.utils.FixedDecimalsInteger) DetailedCharacterStatsWindowController(delta.games.lotro.gui.character.stats.details.DetailedCharacterStatsWindowController) BasicStatsSet(delta.games.lotro.character.stats.BasicStatsSet)

Example 3 with FixedDecimalsInteger

use of delta.games.lotro.utils.FixedDecimalsInteger in project lotro-companion by dmorcellet.

the class StatsEditionPanelController method initFromStats.

/**
 * Initialize the managed panel with the given stats.
 * @param stats Stats to set.
 */
public void initFromStats(BasicStatsSet stats) {
    _statControllers.clear();
    for (STAT stat : STAT.values()) {
        FixedDecimalsInteger value = stats.getStat(stat);
        if (value != null) {
            SingleStatController ctrl = new SingleStatController();
            ctrl.setStat(stat, value);
            _statControllers.add(ctrl);
        }
    }
    if (_statControllers.size() == 0) {
        addNewStatController();
    }
    updateUi();
}
Also used : STAT(delta.games.lotro.character.stats.STAT) FixedDecimalsInteger(delta.games.lotro.utils.FixedDecimalsInteger)

Example 4 with FixedDecimalsInteger

use of delta.games.lotro.utils.FixedDecimalsInteger in project lotro-companion by dmorcellet.

the class StatContribsChartPanelController method setContributions.

/**
 * Set the contributions to display.
 * @param contribs Contributions to display.
 */
public void setContributions(ContribsByStat contribs) {
    // Update data
    _data.clear();
    for (StatContribution contrib : contribs.getContribs()) {
        String source = contrib.getSource().getLabel();
        FixedDecimalsInteger value = contrib.getValue();
        _data.setValue(source, value.doubleValue());
    }
}
Also used : FixedDecimalsInteger(delta.games.lotro.utils.FixedDecimalsInteger) StatContribution(delta.games.lotro.character.stats.contribs.StatContribution)

Example 5 with FixedDecimalsInteger

use of delta.games.lotro.utils.FixedDecimalsInteger in project lotro-companion by dmorcellet.

the class StatContribsPanelController method updateTotals.

private void updateTotals(ContribsByStat contribs, FixedDecimalsInteger expectedTotal) {
    FixedDecimalsInteger total = new FixedDecimalsInteger();
    List<StatContribution> statContribs = contribs.getContribs();
    for (StatContribution statContrib : statContribs) {
        total.add(statContrib.getValue());
    }
    int expected = (expectedTotal != null) ? expectedTotal.getInternalValue() : 0;
    boolean positive = (expected >= 0);
    int actual = total.getInternalValue();
    boolean same = (actual == Math.abs(expected));
    boolean isPercentage = _statChooser.getSelectedItem().isPercentage();
    String totalStr = StatDisplayUtils.getStatDisplay(total, isPercentage);
    if (!positive)
        totalStr = "-" + totalStr;
    String expectedTotalStr = StatDisplayUtils.getStatDisplay(expectedTotal, isPercentage);
    String label = "Total: " + (same ? totalStr : totalStr + " / " + expectedTotalStr);
    _totals.setText(label);
}
Also used : FixedDecimalsInteger(delta.games.lotro.utils.FixedDecimalsInteger) StatContribution(delta.games.lotro.character.stats.contribs.StatContribution)

Aggregations

FixedDecimalsInteger (delta.games.lotro.utils.FixedDecimalsInteger)25 BasicStatsSet (delta.games.lotro.character.stats.BasicStatsSet)11 STAT (delta.games.lotro.character.stats.STAT)11 Armour (delta.games.lotro.lore.items.Armour)7 Item (delta.games.lotro.lore.items.Item)7 EquipmentLocation (delta.games.lotro.lore.items.EquipmentLocation)6 CharacterClass (delta.games.lotro.common.CharacterClass)4 ArmourType (delta.games.lotro.lore.items.ArmourType)3 ItemQuality (delta.games.lotro.lore.items.ItemQuality)3 SlicesBasedItemStatsProvider (delta.games.lotro.lore.items.stats.SlicesBasedItemStatsProvider)3 JLabel (javax.swing.JLabel)3 StatContribution (delta.games.lotro.character.stats.contribs.StatContribution)2 DamageType (delta.games.lotro.lore.items.DamageType)2 Weapon (delta.games.lotro.lore.items.Weapon)2 WeaponType (delta.games.lotro.lore.items.WeaponType)2 ItemStatSliceData (delta.games.lotro.lore.items.stats.ItemStatSliceData)2 Color (java.awt.Color)2 GridBagConstraints (java.awt.GridBagConstraints)2 Insets (java.awt.Insets)2 HashMap (java.util.HashMap)2