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