use of delta.games.lotro.utils.FixedDecimalsInteger in project lotro-companion by dmorcellet.
the class StatValuesPanelController method buildContents.
private void buildContents() {
// Clear
_panel.removeAll();
GridBagConstraints c = new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2, 5, 2, 5), 0, 0);
// First line: Base stat
// - First cell blank
c.gridx++;
// - Stat name
STAT baseStat = _config.getBaseStat();
JLabel baseStatNameLabel = GuiFactory.buildLabel(baseStat.getName());
_panel.add(baseStatNameLabel, c);
// - Stat value
c.gridx++;
FixedDecimalsInteger baseStatValue = _values.getStat(baseStat);
JLabel baseStatValueLabel = GuiFactory.buildLabel(StatDisplayUtils.getStatDisplay(baseStatValue, baseStat.isPercentage()));
_panel.add(baseStatValueLabel, c);
c.gridy++;
boolean doComputeDelta = (_deltaValues.size() == 0);
// Stat lines
int level = _config.getLevel();
List<SingleStatCurveConfiguration> curveConfigs = _config.getCurveConfigurations();
int nbCurves = curveConfigs.size();
int index = 0;
for (int curveIndex = 0; curveIndex < nbCurves; curveIndex++) {
SingleStatCurveConfiguration curveConfig = curveConfigs.get(curveIndex);
Color color = StatCurveChartPanelController.LINE_COLORS[curveIndex];
List<STAT> stats = curveConfig.getStats();
for (STAT stat : stats) {
c.gridx = 0;
c.fill = GridBagConstraints.NONE;
c.weightx = 0.0;
// Add color
JLabel coloredLabel = buildColoredLabel(color);
_panel.add(coloredLabel, c);
c.gridx++;
// Stat name
JLabel statNameLabel = GuiFactory.buildLabel(stat.getName());
_panel.add(statNameLabel, c);
c.gridx++;
// Stat value
FixedDecimalsInteger statValueFromCurve = getStatValue(curveConfig, level, baseStatValue);
FixedDecimalsInteger statValue = _values.getStat(stat);
String statValueFromCurveStr = StatDisplayUtils.getStatDisplay(statValueFromCurve, stat.isPercentage());
JLabel statValueFromCurveLabel = GuiFactory.buildLabel(statValueFromCurveStr);
_panel.add(statValueFromCurveLabel, c);
c.gridx++;
// Bonus
FixedDecimalsInteger deltaValue = null;
if (doComputeDelta) {
deltaValue = getDeltaValue(statValueFromCurve, statValue);
_deltaValues.add(deltaValue);
} else {
deltaValue = _deltaValues.get(index);
}
if (deltaValue != null) {
String deltaValueStr = StatDisplayUtils.getStatDisplay(deltaValue, stat.isPercentage());
if (deltaValue.getInternalValue() > 0)
deltaValueStr = "+" + deltaValueStr;
FixedDecimalsInteger totalValue = new FixedDecimalsInteger(statValueFromCurve);
totalValue.add(deltaValue);
String totalValueStr = StatDisplayUtils.getStatDisplay(totalValue, stat.isPercentage());
String bonusStr = deltaValueStr + " = " + totalValueStr;
JLabel bonusLabel = GuiFactory.buildLabel(bonusStr);
_panel.add(bonusLabel, c);
c.gridx++;
}
// Add 'buffer' empty column
{
c.fill = GridBagConstraints.BOTH;
c.weightx = 1.0;
Component glue = Box.createGlue();
_panel.add(glue, c);
}
c.gridx++;
c.gridy++;
index++;
}
}
}
use of delta.games.lotro.utils.FixedDecimalsInteger in project lotro-companion by dmorcellet.
the class StatValuesPanelController method getDeltaValue.
private FixedDecimalsInteger getDeltaValue(FixedDecimalsInteger statValueFromCurve, FixedDecimalsInteger statValue) {
FixedDecimalsInteger deltaValue = null;
if ((statValueFromCurve != null) && (statValue != null)) {
int delta = statValue.getInternalValue() - statValueFromCurve.getInternalValue();
if (delta != 0) {
deltaValue = new FixedDecimalsInteger();
deltaValue.setRawValue(delta);
}
}
return deltaValue;
}
use of delta.games.lotro.utils.FixedDecimalsInteger in project lotro-companion by dmorcellet.
the class StatContribsPanelController method updateStat.
private void updateStat(STAT stat) {
if (stat == null) {
return;
}
ContribsByStat contribs = _contribs.getContribs(stat);
if (contribs == null) {
contribs = new ContribsByStat(stat);
}
_chartPanel.setContributions(contribs);
_table.setContributions(contribs);
FixedDecimalsInteger statValue = _toon.getStats().getStat(stat);
updateTotals(contribs, statValue);
}
use of delta.games.lotro.utils.FixedDecimalsInteger in project lotro-companion by dmorcellet.
the class MainTestSingleStatWidgetsController method doIt.
private void doIt() {
BasicStatsSet value = new BasicStatsSet();
value.addStat(STAT.MORALE, new FixedDecimalsInteger(100));
value.addStat(STAT.CRITICAL_MELEE_PERCENTAGE, new FixedDecimalsInteger(12.3f));
BasicStatsSet reference = new BasicStatsSet();
reference.addStat(STAT.MORALE, new FixedDecimalsInteger(67));
reference.addStat(STAT.CRITICAL_MELEE_PERCENTAGE, new FixedDecimalsInteger(13.3f));
JLabel morale = GuiFactory.buildLabel("Morale");
SingleStatWidgetsController moraleCtrl = new SingleStatWidgetsController(STAT.MORALE, false);
moraleCtrl.updateStats(reference, value);
showFrameForStat(morale, moraleCtrl);
JLabel critMelee = GuiFactory.buildLabel("Crit Melee %");
SingleStatWidgetsController critCtrl = new SingleStatWidgetsController(STAT.CRITICAL_MELEE_PERCENTAGE, true);
critCtrl.updateStats(reference, value);
showFrameForStat(critMelee, critCtrl);
}
use of delta.games.lotro.utils.FixedDecimalsInteger in project lotro-tools by dmorcellet.
the class StatValueParser method parseStatValue.
/**
* Parse a stat value.
* @param valueStr Input string.
* @return A value or <code>null</code>.
*/
public static FixedDecimalsInteger parseStatValue(String valueStr) {
FixedDecimalsInteger ret = null;
int factor = 1;
if (valueStr.startsWith("=")) {
valueStr = valueStr.substring(1);
factor = 100;
}
if (valueStr.endsWith("%")) {
valueStr = valueStr.substring(0, valueStr.length() - 1);
}
valueStr = valueStr.replace(',', '.').trim();
if (valueStr.contains(".")) {
Float statValue = NumericTools.parseFloat(valueStr);
if (statValue != null) {
float value = statValue.floatValue();
value *= factor;
ret = new FixedDecimalsInteger(value);
}
} else {
Integer statValue = NumericTools.parseInteger(valueStr);
if (statValue != null) {
int value = statValue.intValue();
ret = new FixedDecimalsInteger(value);
}
}
return ret;
}
Aggregations