Search in sources :

Example 1 with FactionLevelStatus

use of delta.games.lotro.character.reputation.FactionLevelStatus 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;
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) CheckboxController(delta.common.ui.swing.checkbox.CheckboxController) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) ActionEvent(java.awt.event.ActionEvent) JLabel(javax.swing.JLabel) FactionLevel(delta.games.lotro.lore.reputation.FactionLevel) JCheckBox(javax.swing.JCheckBox) ActionListener(java.awt.event.ActionListener) DateListener(delta.common.ui.swing.text.dates.DateListener) DateEditionController(delta.common.ui.swing.text.dates.DateEditionController) FactionLevelStatus(delta.games.lotro.character.reputation.FactionLevelStatus) Faction(delta.games.lotro.lore.reputation.Faction)

Example 2 with FactionLevelStatus

use of delta.games.lotro.character.reputation.FactionLevelStatus in project lotro-companion by dmorcellet.

the class FactionStatusEditionPanelController method handleDateChange.

private void handleDateChange(DateEditionController source, long completionDate) {
    int index = 0;
    Faction faction = _status.getFaction();
    for (FactionLevel level : faction.getLevels()) {
        FactionLevelStatus status = _status.getStatusForLevel(level);
        FactionLevelEditionGadgets proficiency = _gadgets.get(index);
        if (source == proficiency.getCompletionDate()) {
            status.setCompletionDate(completionDate);
        }
        index++;
    }
    triggerChartUpdateTimer();
}
Also used : FactionLevelStatus(delta.games.lotro.character.reputation.FactionLevelStatus) FactionLevel(delta.games.lotro.lore.reputation.FactionLevel) Faction(delta.games.lotro.lore.reputation.Faction)

Example 3 with FactionLevelStatus

use of delta.games.lotro.character.reputation.FactionLevelStatus 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)

Aggregations

FactionLevelStatus (delta.games.lotro.character.reputation.FactionLevelStatus)3 Faction (delta.games.lotro.lore.reputation.Faction)3 FactionLevel (delta.games.lotro.lore.reputation.FactionLevel)3 CheckboxController (delta.common.ui.swing.checkbox.CheckboxController)1 DateEditionController (delta.common.ui.swing.text.dates.DateEditionController)1 DateListener (delta.common.ui.swing.text.dates.DateListener)1 GridBagConstraints (java.awt.GridBagConstraints)1 GridBagLayout (java.awt.GridBagLayout)1 Insets (java.awt.Insets)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 JCheckBox (javax.swing.JCheckBox)1 JLabel (javax.swing.JLabel)1 JPanel (javax.swing.JPanel)1 XYSeries (org.jfree.data.xy.XYSeries)1