Search in sources :

Example 51 with MagicEdition

use of org.magic.api.beans.MagicEdition in project MtgDesktopCompanion by nicho92.

the class CardStockTableModel method updateEdition.

private void updateEdition(MagicCardStock magicCardStock, MagicEdition aValue) {
    MagicEdition ed = aValue;
    magicCardStock.getMagicCard().getEditions().remove(ed);
    magicCardStock.getMagicCard().getEditions().add(0, (MagicEdition) aValue);
}
Also used : MagicEdition(org.magic.api.beans.MagicEdition)

Example 52 with MagicEdition

use of org.magic.api.beans.MagicEdition in project MtgDesktopCompanion by nicho92.

the class ManualImportDialog method getAsDeck.

public MagicDeck getAsDeck() {
    if (editorPane.getText().length() == 0)
        return deck;
    String[] line = editorPane.getText().split("\n");
    for (String l : line) {
        int nb = Integer.parseInt(l.substring(0, l.indexOf(' ')));
        String name = l.substring(l.indexOf(' '), l.length());
        try {
            MagicCard mc;
            if (name.trim().equalsIgnoreCase("Plains") || name.trim().equalsIgnoreCase("Island") || name.trim().equalsIgnoreCase("Swamp") || name.trim().equalsIgnoreCase("Mountain") || name.trim().equalsIgnoreCase("Forest")) {
                MagicEdition ed = new MagicEdition();
                ed.setId(MTGControler.getInstance().get("default-land-deck"));
                mc = MTGControler.getInstance().getEnabledProviders().searchCardByCriteria("name", name.trim(), ed, true).get(0);
            } else {
                mc = MTGControler.getInstance().getEnabledProviders().searchCardByCriteria("name", name.trim(), null, true).get(0);
            }
            if (mc != null) {
                deck.getMap().put(mc, nb);
            }
        } catch (Exception e) {
            logger.error(e);
        }
    }
    return deck;
}
Also used : MagicCard(org.magic.api.beans.MagicCard) MagicEdition(org.magic.api.beans.MagicEdition)

Example 53 with MagicEdition

use of org.magic.api.beans.MagicEdition in project MtgDesktopCompanion by nicho92.

the class MagicEditionsTableModel method calculate.

public void calculate() throws SQLException {
    MagicCollection mc = new MagicCollection(MTGControler.getInstance().get("default-library"));
    Map<String, Integer> temp = MTGControler.getInstance().getEnabledDAO().getCardsCountGlobal(mc);
    countDefaultLibrary = 0;
    countTotal = 0;
    for (MagicEdition me : list) {
        mapCount.put(me, (temp.get(me.getId()) == null) ? 0 : temp.get(me.getId()));
        countDefaultLibrary += mapCount.get(me);
    }
    for (MagicEdition me : list) countTotal += me.getCardCount();
}
Also used : MagicEdition(org.magic.api.beans.MagicEdition) MagicCollection(org.magic.api.beans.MagicCollection)

Example 54 with MagicEdition

use of org.magic.api.beans.MagicEdition in project MtgDesktopCompanion by nicho92.

the class SealedPackTableModel method setValueAt.

@Override
public void setValueAt(Object aValue, int row, int column) {
    MagicEdition ed = pack.listEditions().get(row);
    if (column == 0)
        pack.set((MagicEdition) aValue, 0);
    else if (column == 1)
        if (Integer.parseInt(aValue.toString()) > 0) {
            pack.set(ed, Integer.parseInt(aValue.toString()));
        } else {
            pack.remove(ed);
        }
    fireTableDataChanged();
}
Also used : MagicEdition(org.magic.api.beans.MagicEdition)

Example 55 with MagicEdition

use of org.magic.api.beans.MagicEdition in project MtgDesktopCompanion by nicho92.

the class EditionCellRenderer method getTableCellRendererComponent.

@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
    pane.removeAll();
    pane.setBackground(super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column).getBackground());
    for (MagicEdition ed : (List<MagicEdition>) value) {
        JLabel l = new JLabel(IconSetProvider.getInstance().get16(ed.getId()));
        l.setToolTipText(ed.getSet());
        l.setOpaque(false);
        pane.add(l);
    }
    return pane;
}
Also used : MagicEdition(org.magic.api.beans.MagicEdition) JLabel(javax.swing.JLabel) List(java.util.List)

Aggregations

MagicEdition (org.magic.api.beans.MagicEdition)67 MagicCard (org.magic.api.beans.MagicCard)38 IOException (java.io.IOException)24 ArrayList (java.util.ArrayList)18 MagicCollection (org.magic.api.beans.MagicCollection)11 MagicDeck (org.magic.api.beans.MagicDeck)10 JsonObject (com.google.gson.JsonObject)9 InputStreamReader (java.io.InputStreamReader)9 JsonReader (com.google.gson.stream.JsonReader)8 List (java.util.List)8 JsonParser (com.google.gson.JsonParser)7 MalformedURLException (java.net.MalformedURLException)7 SQLException (java.sql.SQLException)7 Date (java.util.Date)7 JLabel (javax.swing.JLabel)7 Before (org.junit.Before)7 JsonArray (com.google.gson.JsonArray)6 BufferedImage (java.awt.image.BufferedImage)6 URL (java.net.URL)6 Map (java.util.Map)6