Search in sources :

Example 76 with MagicCard

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));
    }
}
Also used : MagicCard(org.magic.api.beans.MagicCard) DisplayableCard(org.magic.game.gui.components.DisplayableCard)

Example 77 with MagicCard

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;
}
Also used : MagicCard(org.magic.api.beans.MagicCard) TreeMap(java.util.TreeMap) DefaultCategoryDataset(org.jfree.data.category.DefaultCategoryDataset)

Example 78 with MagicCard

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);
                }
            }
        }
    });
}
Also used : MouseEvent(java.awt.event.MouseEvent) MagicCard(org.magic.api.beans.MagicCard) BorderLayout(java.awt.BorderLayout) MagicCardDetailPanel(org.magic.gui.components.MagicCardDetailPanel) LineBorder(javax.swing.border.LineBorder) MouseAdapter(java.awt.event.MouseAdapter) MagicEdition(org.magic.api.beans.MagicEdition) JPopupMenu(javax.swing.JPopupMenu)

Example 79 with MagicCard

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;
}
Also used : MagicCard(org.magic.api.beans.MagicCard) ArrayList(java.util.ArrayList) Point(java.awt.Point)

Example 80 with MagicCard

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");
}
Also used : MagicCard(org.magic.api.beans.MagicCard) Rectangle2D(java.awt.geom.Rectangle2D) Point(java.awt.Point)

Aggregations

MagicCard (org.magic.api.beans.MagicCard)106 MagicEdition (org.magic.api.beans.MagicEdition)40 ArrayList (java.util.ArrayList)31 IOException (java.io.IOException)28 MagicDeck (org.magic.api.beans.MagicDeck)21 MagicCollection (org.magic.api.beans.MagicCollection)14 SQLException (java.sql.SQLException)12 Date (java.util.Date)11 MagicCardStock (org.magic.api.beans.MagicCardStock)10 DisplayableCard (org.magic.game.gui.components.DisplayableCard)10 JsonArray (com.google.gson.JsonArray)8 List (java.util.List)8 FileReader (java.io.FileReader)7 Before (org.junit.Before)7 BufferedReader (java.io.BufferedReader)6 File (java.io.File)6 FileWriter (java.io.FileWriter)6 MalformedURLException (java.net.MalformedURLException)6 PreparedStatement (java.sql.PreparedStatement)6 ResultSet (java.sql.ResultSet)6