use of org.magic.gui.renderer.CardShakeRenderer in project MtgDesktopCompanion by nicho92.
the class BestTrendingDashlet method init.
@Override
public void init() {
ThreadManager.getInstance().execute(() -> {
try {
List<CardShake> shakes = new ArrayList<>();
if (boxM.isSelected())
shakes.addAll(MTGControler.getInstance().getEnabledDashBoard().getShakerFor(FORMAT.MODERN.toString()));
if (boxS.isSelected())
shakes.addAll(MTGControler.getInstance().getEnabledDashBoard().getShakerFor(FORMAT.STANDARD.toString()));
if (boxL.isSelected())
shakes.addAll(MTGControler.getInstance().getEnabledDashBoard().getShakerFor(FORMAT.LEGACY.toString()));
if (boxV.isSelected())
shakes.addAll(MTGControler.getInstance().getEnabledDashBoard().getShakerFor(FORMAT.VINTAGE.toString()));
Collections.sort(shakes, (CardShake o1, CardShake o2) -> {
if (o1.getPriceDayChange() > o2.getPriceDayChange())
return -1;
if (o1.getPriceDayChange() < o2.getPriceDayChange())
return 1;
return 0;
});
int val = (Integer) spinner.getValue();
save("LIMIT", String.valueOf(val));
save("STD", String.valueOf(boxS.isSelected()));
save("MDN", String.valueOf(boxM.isSelected()));
save("LEG", String.valueOf(boxL.isSelected()));
save("VIN", String.valueOf(boxV.isSelected()));
List<CardShake> ret = new ArrayList<>();
// X first
ret.addAll(shakes.subList(0, val));
// x last
ret.addAll(shakes.subList(shakes.size() - (val + 1), shakes.size()));
modStandard.init(ret);
} catch (IOException e) {
MTGLogger.printStackTrace(e);
}
table.setModel(modStandard);
table.setRowSorter(new TableRowSorter(modStandard));
table.packAll();
table.getColumnModel().getColumn(3).setCellRenderer(new CardShakeRenderer());
modStandard.fireTableDataChanged();
}, "Init best Dashlet");
}
use of org.magic.gui.renderer.CardShakeRenderer in project MtgDesktopCompanion by nicho92.
the class EditionsDashlet method initGUI.
public void initGUI() {
JPanel panel = new JPanel();
getContentPane().add(panel, BorderLayout.NORTH);
modEdition = new EditionsShakerTableModel();
List<MagicEdition> eds = new ArrayList<>();
try {
eds.addAll(MTGControler.getInstance().getEnabledProviders().loadEditions());
Collections.sort(eds);
eds.add(0, null);
} catch (Exception e) {
MTGLogger.printStackTrace(e);
}
cboEditions = new JComboBox(new DefaultComboBoxModel<MagicEdition>(eds.toArray(new MagicEdition[eds.size()])));
cboEditions.setRenderer(new MagicEditionListRenderer());
panel.add(cboEditions);
lblLoading = new JLabel("");
lblLoading.setIcon(MTGConstants.ICON_LOADING);
lblLoading.setVisible(false);
panel.add(lblLoading);
JScrollPane scrollPane = new JScrollPane();
getContentPane().add(scrollPane, BorderLayout.CENTER);
table = new JXTable(modEdition);
initToolTip(table, 0, 1);
table.getColumnModel().getColumn(3).setCellRenderer(new CardShakeRenderer());
table.getColumnModel().getColumn(5).setCellRenderer(new CardShakeRenderer());
scrollPane.setViewportView(table);
setVisible(true);
cboEditions.addActionListener(ae -> init());
if (getProperties().size() > 0) {
Rectangle r = new Rectangle((int) Double.parseDouble(getProperty("x")), (int) Double.parseDouble(getProperty("y")), (int) Double.parseDouble(getProperty("w")), (int) Double.parseDouble(getProperty("h")));
MagicEdition ed;
try {
ed = MTGControler.getInstance().getEnabledProviders().getSetById(getProperty("EDITION"));
cboEditions.setSelectedItem(ed);
} catch (Exception e) {
logger.error("Error retrieve editions", e);
}
setBounds(r);
}
try {
table.packAll();
} catch (Exception e) {
MTGLogger.printStackTrace(e);
}
new TableFilterHeader(table, AutoChoices.ENABLED);
}
use of org.magic.gui.renderer.CardShakeRenderer in project MtgDesktopCompanion by nicho92.
the class TrendingDashlet method init.
public void init() {
ThreadManager.getInstance().execute(() -> {
lblLoading.setVisible(true);
modStandard.init((FORMAT) cboFormats.getSelectedItem());
try {
table.setModel(modStandard);
} catch (Exception e) {
MTGLogger.printStackTrace(e);
}
setProperty("FORMAT", ((FORMAT) cboFormats.getSelectedItem()).toString());
lblLoading.setVisible(false);
table.getColumnModel().getColumn(3).setCellRenderer(new CardShakeRenderer());
lblInfoUpdate.setText(MTGControler.getInstance().getEnabledDashBoard().getName() + "(updated : " + new SimpleDateFormat("dd/MM/yyyy HH:mm").format(MTGControler.getInstance().getEnabledDashBoard().getUpdatedDate()) + ")");
List<SortKey> keys = new ArrayList<>();
// column index 2
SortKey sortKey = new SortKey(3, SortOrder.DESCENDING);
keys.add(sortKey);
try {
table.setRowSorter(new TableRowSorter(modStandard));
((TableRowSorter) table.getRowSorter()).setSortKeys(keys);
((TableRowSorter) table.getRowSorter()).sort();
modStandard.fireTableDataChanged();
table.packAll();
} catch (Exception e) {
MTGLogger.printStackTrace(e);
}
}, "Init Formats Dashlet");
}
Aggregations