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;
}
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;
}
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;
}
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);
}
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>
*/
}
Aggregations