use of delta.games.lotro.lore.reputation.FactionLevel in project lotro-companion by dmorcellet.
the class CharacterReputationDialogController method updateFactionDisplay.
private void updateFactionDisplay(FactionEditionPanelController editor) {
Faction faction = editor.getFaction();
FactionLevel current;
FactionStatus factionStatus = _data.getFactionStatus(faction);
if (factionStatus != null) {
current = factionStatus.getFactionLevel();
} else {
current = faction.getInitialLevel();
}
editor.setFactionLevel(current);
}
use of delta.games.lotro.lore.reputation.FactionLevel in project lotro-companion by dmorcellet.
the class FactionHistoryChartPanelController method updateLevelLabel.
private void updateLevelLabel() {
FactionLevel level = _stats.getFactionLevel();
String name = (level != null) ? level.getName() : "";
_label.setText("Level: " + name);
}
use of delta.games.lotro.lore.reputation.FactionLevel in project lotro-companion by dmorcellet.
the class FactionStatusEditionPanelController method handleCompletionChange.
private void handleCompletionChange(Object source) {
int index = 0;
Faction faction = _status.getFaction();
for (FactionLevel level : faction.getLevels()) {
FactionLevelEditionGadgets gadgets = _gadgets.get(index);
if (source == gadgets.getCompleted().getCheckbox()) {
boolean completed = gadgets.getCompleted().isSelected();
_status.setCompletionStatus(level, completed);
_status.updateCurrentLevel();
triggerChartUpdateTimer();
break;
}
index++;
}
updateUi();
}
use of delta.games.lotro.lore.reputation.FactionLevel in project lotro-companion by dmorcellet.
the class FactionStatusEditionPanelController method buildStatusEditionPanel.
private JPanel buildStatusEditionPanel() {
JPanel panel = GuiFactory.buildPanel(new GridBagLayout());
// Header row 1
GridBagConstraints c = new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0);
JLabel tier = GuiFactory.buildLabel("Rank");
panel.add(tier, c);
// Header row 2
c.gridx = 1;
c.gridy = 1;
c.gridwidth = 1;
panel.add(GuiFactory.buildLabel("Completed"), c);
c.gridx++;
panel.add(GuiFactory.buildLabel("XP"), c);
c.gridx++;
panel.add(GuiFactory.buildLabel("Completion date"), c);
c.gridx++;
c.gridy++;
ActionListener l = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
handleCompletionChange(e.getSource());
}
};
DateListener dateListener = new DateListener() {
@Override
public void dateChanged(DateEditionController controller, Long newDate) {
long date = (newDate != null) ? newDate.longValue() : 0;
handleDateChange(controller, date);
}
};
// Data rows
Faction faction = _status.getFaction();
for (FactionLevel level : faction.getLevels()) {
FactionLevelStatus levelStatus = _status.getStatusForLevel(level);
c.gridx = 0;
JLabel tierLabel = GuiFactory.buildLabel(level.toString());
panel.add(tierLabel, c);
c.gridx++;
FactionLevelEditionGadgets gadgets = new FactionLevelEditionGadgets(levelStatus);
CheckboxController checkboxCtrl = gadgets.getCompleted();
JCheckBox checkbox = checkboxCtrl.getCheckbox();
panel.add(checkbox, c);
checkbox.addActionListener(l);
c.gridx++;
panel.add(gadgets.getXp().getTextField(), c);
c.gridx++;
DateEditionController dateCompletion = gadgets.getCompletionDate();
dateCompletion.addListener(dateListener);
panel.add(dateCompletion.getTextField(), c);
c.gridx++;
_gadgets.add(gadgets);
c.gridy++;
if (level == faction.getInitialLevel()) {
checkboxCtrl.setState(false);
}
}
return panel;
}
use of delta.games.lotro.lore.reputation.FactionLevel in project lotro-companion by dmorcellet.
the class FactionHistoryChartController method buildChart.
private JFreeChart buildChart() {
String title = "";
if (_showTitle) {
title = _stats.getFaction().getName();
}
updateData();
JFreeChart jfreechart = ChartFactory.createXYStepChart(title, "Time", "Level", _data, PlotOrientation.VERTICAL, true, true, false);
Color foregroundColor = GuiFactory.getForegroundColor();
Paint backgroundPaint = GuiFactory.getBackgroundPaint();
jfreechart.setBackgroundPaint(backgroundPaint);
TextTitle t = new TextTitle(title);
t.setFont(t.getFont().deriveFont(24.0f));
t.setPaint(foregroundColor);
jfreechart.setTitle(t);
XYPlot xyplot = (XYPlot) jfreechart.getPlot();
xyplot.setDomainPannable(false);
XYStepAreaRenderer xysteparearenderer = new XYStepAreaRenderer(XYStepAreaRenderer.AREA_AND_SHAPES);
Faction faction = _stats.getFaction();
final FactionLevel[] levels = faction.getLevels();
XYToolTipGenerator tooltip = new StandardXYToolTipGenerator() {
@Override
public String generateLabelString(XYDataset dataset, int series, int item) {
String label = "???";
int tier = (int) dataset.getYValue(series, item);
for (FactionLevel level : levels) {
if (level.getValue() == tier) {
label = level.getName();
}
}
double timestamp = dataset.getXValue(series, item);
String date = Formats.getDateString(Long.valueOf((long) timestamp));
return label + " (" + date + ")";
}
};
xysteparearenderer.setBaseToolTipGenerator(tooltip);
xysteparearenderer.setSeriesPaint(0, new Color(0, 0, 255));
xyplot.setRenderer(xysteparearenderer);
DateAxis axis = (DateAxis) xyplot.getDomainAxis();
SimpleDateFormat sdf = Formats.getDateFormatter();
axis.setDateFormatOverride(sdf);
axis.setAxisLinePaint(foregroundColor);
axis.setLabelPaint(foregroundColor);
axis.setTickLabelPaint(foregroundColor);
NumberAxis valueAxis = (NumberAxis) xyplot.getRangeAxis();
valueAxis.setAutoRange(false);
valueAxis.setAxisLinePaint(foregroundColor);
valueAxis.setLabelPaint(foregroundColor);
valueAxis.setTickLabelPaint(foregroundColor);
final int min = levels[0].getValue();
int max = levels[levels.length - 1].getValue();
valueAxis.setRange(min, max);
NumberFormat nf = new NumberFormat() {
private String format(int number) {
String ret = levels[number - min].getName();
return ret;
}
@Override
public StringBuffer format(double number, StringBuffer toAppendTo, FieldPosition pos) {
return toAppendTo.append(format((int) number));
}
@Override
public StringBuffer format(long number, StringBuffer toAppendTo, FieldPosition pos) {
return toAppendTo.append(format((int) number));
}
@Override
public Number parse(String source, ParsePosition parsePosition) {
return null;
}
};
valueAxis.setNumberFormatOverride(nf);
LegendTitle legend = jfreechart.getLegend();
legend.setItemPaint(foregroundColor);
legend.setBackgroundPaint(backgroundPaint);
return jfreechart;
}
Aggregations