use of org.magic.api.beans.MagicCard in project MtgDesktopCompanion by nicho92.
the class SealedPanel method sort.
public void sort(MTGComparator<MagicCard> sorter) {
Collections.sort(list, sorter);
panelOpenedBooster.clear();
for (MagicCard mc : list) {
DisplayableCard c = createCard(mc);
panelOpenedBooster.addComponent(c, sorter.getWeight(mc));
}
}
use of org.magic.api.beans.MagicCard in project MtgDesktopCompanion by nicho92.
the class CmcChartPanel method getManaCurveDataSet.
private CategoryDataset getManaCurveDataSet() {
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
TreeMap<Integer, Number> temp = new TreeMap<>();
for (MagicCard mc : cards) {
if ((mc.getCmc() != null) && !mc.getTypes().contains("Land"))
temp.put(mc.getCmc(), count(mc.getCmc()));
}
for (Entry<Integer, Number> k : temp.entrySet()) dataset.addValue(k.getValue(), "cmc", k.getKey());
return dataset;
}
use of org.magic.api.beans.MagicCard in project MtgDesktopCompanion by nicho92.
the class AbstractJDashlet method initToolTip.
protected void initToolTip(final JTable table, final Integer cardPos, final Integer edPos) {
pane = new MagicCardDetailPanel();
pane.enableThumbnail(true);
final JPopupMenu popUp = new JPopupMenu();
table.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
int row = table.rowAtPoint(e.getPoint());
if (row > -1) {
table.setRowSelectionInterval(row, row);
String cardName = table.getValueAt(row, cardPos.intValue()).toString();
if (cardName.indexOf('(') >= 0)
cardName = cardName.substring(0, cardName.indexOf('(')).trim();
MagicEdition ed = null;
if (edPos != null) {
String edID = table.getValueAt(row, edPos).toString();
ed = new MagicEdition();
ed.setId(edID);
}
try {
MagicCard mc = MTGControler.getInstance().getEnabledProviders().searchCardByCriteria("name", cardName, ed, true).get(0);
pane.setMagicCard(mc);
popUp.setBorder(new LineBorder(Color.black));
popUp.setVisible(false);
popUp.removeAll();
popUp.setLayout(new BorderLayout());
popUp.add(pane, BorderLayout.CENTER);
popUp.show(table, e.getX(), e.getY());
popUp.setVisible(true);
} catch (Exception ex) {
logger.error("Error on " + cardName, ex);
}
}
}
});
}
use of org.magic.api.beans.MagicCard in project MtgDesktopCompanion by nicho92.
the class CardSearchPanel method getMultiSelection.
public List<MagicCard> getMultiSelection() {
int[] viewRow = tableCards.getSelectedRows();
List<MagicCard> listCards = new ArrayList<>();
for (int i : viewRow) {
int modelRow = tableCards.convertRowIndexToModel(i);
MagicCard mc = (MagicCard) tableCards.getModel().getValueAt(modelRow, 0);
listCards.add(mc);
}
return listCards;
}
use of org.magic.api.beans.MagicCard in project MtgDesktopCompanion by nicho92.
the class CardsPicPanel method showPhoto.
public void showPhoto(MagicCard mc, MagicEdition edition) {
this.card = mc;
if (!mc.isTranformable()) {
back = MTGControler.getInstance().getEnabledPicturesProvider().getBackPicture();
} else {
try {
MagicCard flipC = MTGControler.getInstance().getEnabledProviders().searchCardByCriteria("name", card.getRotatedCardName(), card.getEditions().get(0), true).get(0);
back = MTGControler.getInstance().getEnabledPicturesProvider().getPicture(flipC, null);
} catch (Exception e) {
MTGLogger.printStackTrace(e);
}
}
ThreadManager.getInstance().execute(() -> {
try {
if (edition == null)
imgFront = renderer.appendReflection(MTGControler.getInstance().getEnabledPicturesProvider().getPicture(card, null));
else
imgFront = renderer.appendReflection(MTGControler.getInstance().getEnabledPicturesProvider().getPicture(card, edition));
back = mirroring(back);
back = renderer.appendReflection(back);
printed = imgFront;
int x = 15;
int y = 15;
selectedShape = new Rectangle2D.Double(x, y, printed.getWidth(null), printed.getHeight(null));
} catch (Exception e) {
imgFront = back;
}
repaint();
}, "showPhoto");
}
Aggregations