Search in sources :

Example 1 with CraftingLevel

use of delta.games.lotro.lore.crafting.CraftingLevel in project lotro-companion by dmorcellet.

the class CraftingHistoryChartController method buildChart.

private JFreeChart buildChart() {
    String title = "";
    if (_showTitle) {
        title = _stats.getProfession().getLabel();
    }
    updateData();
    JFreeChart jfreechart = ChartFactory.createXYStepChart(title, "Time", "Tier", _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);
    XYToolTipGenerator tooltip = new StandardXYToolTipGenerator() {

        @Override
        public String generateLabelString(XYDataset dataset, int series, int item) {
            String label;
            int tier = (int) dataset.getYValue(series, item);
            if (tier == 0) {
                label = "Started profession";
            } else {
                CraftingLevel level = CraftingLevel.getByTier(tier);
                if (level != null) {
                    if (series == 0)
                        label = level.getMastery().getLabel();
                    else if (series == 1)
                        label = level.getProficiency().getLabel();
                    else
                        label = "???";
                } else {
                    label = "???";
                }
            }
            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(255, 235, 31));
    xysteparearenderer.setSeriesPaint(1, new Color(130, 80, 57));
    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);
    CraftingLevel maxLevel = CraftingLevel.getMaximumLevel();
    valueAxis.setRange(0, maxLevel.getTier());
    NumberFormat nf = new NumberFormat() {

        private String format(int number) {
            CraftingLevel level = CraftingLevel.getByTier(number);
            String ret = (level != null) ? level.getProficiency().getLabel() : "???";
            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) 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) CraftingLevel(delta.games.lotro.lore.crafting.CraftingLevel) SimpleDateFormat(java.text.SimpleDateFormat) NumberFormat(java.text.NumberFormat) ParsePosition(java.text.ParsePosition)

Example 2 with CraftingLevel

use of delta.games.lotro.lore.crafting.CraftingLevel in project lotro-companion by dmorcellet.

the class ProfessionHistoryChartPanelController method buildPanel.

private JPanel buildPanel() {
    JPanel panel = GuiFactory.buildBackgroundPanel(new GridBagLayout());
    // Mastery label
    CraftingLevel mastery = _stats.getMasteryLevel();
    String masteryStr = mastery.getMastery().getLabel() + " (" + mastery.getTier() + ")";
    _masteryLabel = GuiFactory.buildLabel("Mastery: " + masteryStr);
    // Proficiency label
    CraftingLevel proficiency = _stats.getProficiencyLevel();
    String proficiencyStr = proficiency.getProficiency().getLabel() + " (" + proficiency.getTier() + ")";
    _proficiencyLabel = GuiFactory.buildLabel("Proficiency: " + proficiencyStr);
    // History chart
    _history = new CraftingHistoryChartController(_stats, false);
    JPanel historyPanel = _history.getPanel();
    // Assembly
    JPanel labelsPanel = GuiFactory.buildPanel(null);
    labelsPanel.setLayout(new BoxLayout(labelsPanel, BoxLayout.PAGE_AXIS));
    _masteryLabel.setAlignmentX(Component.LEFT_ALIGNMENT);
    labelsPanel.add(_masteryLabel);
    _proficiencyLabel.setAlignmentX(Component.LEFT_ALIGNMENT);
    labelsPanel.add(_proficiencyLabel);
    GridBagConstraints c = new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 10, 0, 10), 0, 0);
    panel.add(labelsPanel, c);
    GridBagConstraints c2 = new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5, 10, 5, 10), 0, 0);
    panel.add(historyPanel, c2);
    return panel;
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) BoxLayout(javax.swing.BoxLayout) CraftingLevel(delta.games.lotro.lore.crafting.CraftingLevel)

Example 3 with CraftingLevel

use of delta.games.lotro.lore.crafting.CraftingLevel in project lotro-companion by dmorcellet.

the class ProfessionStatusEditionPanelController method handleCompletionChange.

private void handleCompletionChange(Object source) {
    CraftingLevel[] levels = CraftingLevel.ALL_TIERS;
    int index = 0;
    for (CraftingLevel level : levels) {
        CraftingLevelTierEditionGadgets proficiency = _proficiencyGadgets.get(index);
        if (source == proficiency.getCompleted().getCheckbox()) {
            boolean completed = proficiency.getCompleted().isSelected();
            _status.setCompletionStatus(level, false, completed);
        }
        CraftingLevelTierEditionGadgets mastery = _masteryGadgets.get(index);
        if (source == mastery.getCompleted().getCheckbox()) {
            boolean completed = mastery.getCompleted().isSelected();
            _status.setCompletionStatus(level, true, completed);
        }
        index++;
    }
    updateUiFromData();
}
Also used : CraftingLevel(delta.games.lotro.lore.crafting.CraftingLevel)

Example 4 with CraftingLevel

use of delta.games.lotro.lore.crafting.CraftingLevel in project lotro-companion by dmorcellet.

the class CraftingSynopsisTableController method buildCraftingTierColumn.

private TableColumnController<CraftingSynopsisItem, CraftingLevel> buildCraftingTierColumn(final boolean mastery) {
    CellDataProvider<CraftingSynopsisItem, CraftingLevel> cell = new CellDataProvider<CraftingSynopsisItem, CraftingLevel>() {

        @Override
        public CraftingLevel getData(CraftingSynopsisItem item) {
            return item.getLevel(mastery);
        }
    };
    String columnName = mastery ? "Mastery" : "Proficiency";
    String id = columnName;
    TableColumnController<CraftingSynopsisItem, CraftingLevel> column = new TableColumnController<CraftingSynopsisItem, CraftingLevel>(id, columnName, CraftingLevel.class, cell);
    // Header cell renderer
    JPanel panel = buildCraftingTierPanel(mastery);
    TableCellRenderer headerRenderer = buildSimpleCellRenderer(panel);
    column.setHeaderCellRenderer(headerRenderer);
    // Cell renderer
    TableCellRenderer renderer = buildCraftingLevelCellRenderer(mastery);
    column.setCellRenderer(renderer);
    // Init widths
    column.setMinWidth(150);
    column.setPreferredWidth(200);
    column.setMaxWidth(300);
    // Comparator
    Comparator<CraftingLevel> statsComparator = new Comparator<CraftingLevel>() {

        @Override
        public int compare(CraftingLevel data1, CraftingLevel data2) {
            return Integer.compare(data1.getTier(), data2.getTier());
        }
    };
    column.setComparator(statsComparator);
    return column;
}
Also used : JPanel(javax.swing.JPanel) TableCellRenderer(javax.swing.table.TableCellRenderer) DefaultTableCellRenderer(javax.swing.table.DefaultTableCellRenderer) TableColumnController(delta.common.ui.swing.tables.TableColumnController) CraftingLevel(delta.games.lotro.lore.crafting.CraftingLevel) CellDataProvider(delta.common.ui.swing.tables.CellDataProvider) FactionLevelComparator(delta.games.lotro.lore.reputation.FactionLevelComparator) ProfessionComparator(delta.games.lotro.lore.crafting.ProfessionComparator) Comparator(java.util.Comparator)

Example 5 with CraftingLevel

use of delta.games.lotro.lore.crafting.CraftingLevel in project lotro-companion by dmorcellet.

the class CraftingSynopsisTableController method buildCraftingLevelCellRenderer.

private TableCellRenderer buildCraftingLevelCellRenderer(final boolean mastery) {
    final JLabel label = GuiFactory.buildLabel("");
    TableCellRenderer renderer = new TableCellRenderer() {

        @Override
        public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
            CraftingLevel data = (CraftingLevel) value;
            configureCraftingLevelLabel(mastery, label, data);
            return label;
        }
    };
    return renderer;
}
Also used : TableCellRenderer(javax.swing.table.TableCellRenderer) DefaultTableCellRenderer(javax.swing.table.DefaultTableCellRenderer) JTable(javax.swing.JTable) JLabel(javax.swing.JLabel) CraftingLevel(delta.games.lotro.lore.crafting.CraftingLevel)

Aggregations

CraftingLevel (delta.games.lotro.lore.crafting.CraftingLevel)8 JPanel (javax.swing.JPanel)3 GridBagConstraints (java.awt.GridBagConstraints)2 GridBagLayout (java.awt.GridBagLayout)2 Insets (java.awt.Insets)2 Paint (java.awt.Paint)2 JLabel (javax.swing.JLabel)2 DefaultTableCellRenderer (javax.swing.table.DefaultTableCellRenderer)2 TableCellRenderer (javax.swing.table.TableCellRenderer)2 CellDataProvider (delta.common.ui.swing.tables.CellDataProvider)1 TableColumnController (delta.common.ui.swing.tables.TableColumnController)1 DateEditionController (delta.common.ui.swing.text.dates.DateEditionController)1 DateListener (delta.common.ui.swing.text.dates.DateListener)1 CraftingLevelStatus (delta.games.lotro.character.crafting.CraftingLevelStatus)1 CraftingLevelTierStatus (delta.games.lotro.character.crafting.CraftingLevelTierStatus)1 ProfessionComparator (delta.games.lotro.lore.crafting.ProfessionComparator)1 FactionLevelComparator (delta.games.lotro.lore.reputation.FactionLevelComparator)1 Color (java.awt.Color)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1