Search in sources :

Example 1 with FactionLevel

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);
}
Also used : FactionLevel(delta.games.lotro.lore.reputation.FactionLevel) FactionStatus(delta.games.lotro.character.reputation.FactionStatus) Faction(delta.games.lotro.lore.reputation.Faction)

Example 2 with FactionLevel

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);
}
Also used : FactionLevel(delta.games.lotro.lore.reputation.FactionLevel)

Example 3 with FactionLevel

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();
}
Also used : FactionLevel(delta.games.lotro.lore.reputation.FactionLevel) Faction(delta.games.lotro.lore.reputation.Faction)

Example 4 with FactionLevel

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;
}
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 5 with FactionLevel

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;
}
Also used : DateAxis(org.jfree.chart.axis.DateAxis) NumberAxis(org.jfree.chart.axis.NumberAxis) Color(java.awt.Color) XYStepAreaRenderer(org.jfree.chart.renderer.xy.XYStepAreaRenderer) LegendTitle(org.jfree.chart.title.LegendTitle) Paint(java.awt.Paint) FieldPosition(java.text.FieldPosition) JFreeChart(org.jfree.chart.JFreeChart) FactionLevel(delta.games.lotro.lore.reputation.FactionLevel) Paint(java.awt.Paint) TextTitle(org.jfree.chart.title.TextTitle) StandardXYToolTipGenerator(org.jfree.chart.labels.StandardXYToolTipGenerator) XYPlot(org.jfree.chart.plot.XYPlot) XYDataset(org.jfree.data.xy.XYDataset) StandardXYToolTipGenerator(org.jfree.chart.labels.StandardXYToolTipGenerator) XYToolTipGenerator(org.jfree.chart.labels.XYToolTipGenerator) SimpleDateFormat(java.text.SimpleDateFormat) Faction(delta.games.lotro.lore.reputation.Faction) NumberFormat(java.text.NumberFormat) ParsePosition(java.text.ParsePosition)

Aggregations

FactionLevel (delta.games.lotro.lore.reputation.FactionLevel)9 Faction (delta.games.lotro.lore.reputation.Faction)6 FactionLevelStatus (delta.games.lotro.character.reputation.FactionLevelStatus)3 Color (java.awt.Color)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 FactionStatus (delta.games.lotro.character.reputation.FactionStatus)1 Dimension (java.awt.Dimension)1 GridBagConstraints (java.awt.GridBagConstraints)1 GridBagLayout (java.awt.GridBagLayout)1 Insets (java.awt.Insets)1 Paint (java.awt.Paint)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 FieldPosition (java.text.FieldPosition)1 NumberFormat (java.text.NumberFormat)1 ParsePosition (java.text.ParsePosition)1 SimpleDateFormat (java.text.SimpleDateFormat)1 JCheckBox (javax.swing.JCheckBox)1