Deck Editor: CardTableSelector. Done, but not in place yet: need to add buttons to add cards to deck and sideboard as well as switching between two card selectors.

This commit is contained in:
magenoxx 2011-05-11 09:41:54 +04:00
parent 6353ccce62
commit 539cf2552f
8 changed files with 1146 additions and 16 deletions

View file

@ -62,7 +62,7 @@ import mage.view.CardsView;
*
* @author BetaSteward_at_googlemail.com
*/
public class CardGrid extends javax.swing.JLayeredPane implements MouseListener {
public class CardGrid extends javax.swing.JLayeredPane implements MouseListener, ICardGrid {
protected CardEventSource cardEventSource = new CardEventSource();
protected BigCard bigCard;

View file

@ -0,0 +1,43 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.client.cards;
import mage.client.util.Event;
import mage.client.util.Listener;
/**
* Interface for card container.
*
* @author nantuko
*
*/
public interface ICardGrid {
void clearCardEventListeners();
void addCardEventListener(Listener<Event> listener);
}

View file

@ -37,8 +37,15 @@ package mage.client.deckeditor;
import java.awt.Cursor;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.UUID;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JTable;
import mage.Constants.CardType;
import mage.cards.Card;
import mage.cards.ExpansionSet;
@ -70,6 +77,8 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
jScrollPane1.setOpaque(false);
jScrollPane1.getViewport().setOpaque(false);
cbSortBy.setModel(new DefaultComboBoxModel(SortBy.values()));
mainTable.setOpaque(false);
}
public void loadCards(List<Card> sideboard, BigCard bigCard, boolean construct) {
@ -560,7 +569,8 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
this.cardGrid.drawCards((SortBy) cbSortBy.getSelectedItem(), chkPiles.isSelected());
}//GEN-LAST:event_chkPilesActionPerformed
private JTable mainTable = new JTable();
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton btnBooster;
private javax.swing.JButton btnClear;

View file

@ -34,19 +34,9 @@
package mage.client.deckeditor;
import mage.cards.Card;
import mage.cards.decks.Deck;
import mage.client.MageFrame;
import mage.client.plugins.impl.Plugins;
import mage.client.util.Event;
import mage.client.util.Listener;
import mage.components.CardInfoPane;
import mage.game.GameException;
import mage.view.CardView;
import javax.swing.*;
import javax.swing.filechooser.FileFilter;
import java.awt.*;
import java.awt.Component;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
@ -55,10 +45,27 @@ import java.util.ArrayList;
import java.util.UUID;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JComponent;
import javax.swing.JFileChooser;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.Timer;
import javax.swing.filechooser.FileFilter;
import mage.cards.Card;
import mage.cards.decks.Deck;
import mage.client.MageFrame;
import mage.client.cards.BigCard;
import mage.client.constants.Constants.DeckEditorMode;
import mage.client.dialog.AddLandDialog;
import mage.client.plugins.impl.Plugins;
import mage.client.util.Event;
import mage.client.util.Listener;
import mage.components.CardInfoPane;
import mage.game.GameException;
import mage.sets.Sets;
import mage.view.CardView;
/**
*
@ -253,6 +260,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
private void initComponents() {
jSplitPane1 = new javax.swing.JSplitPane();
//cardSelector = new mage.client.deckeditor.table.CardTableSelector();
cardSelector = new mage.client.deckeditor.CardSelector();
deckArea = new mage.client.deckeditor.DeckArea();
jPanel1 = new javax.swing.JPanel();
@ -551,6 +559,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
private javax.swing.JButton btnLoad;
private javax.swing.JButton btnNew;
private javax.swing.JButton btnSave;
//private mage.client.deckeditor.table.CardTableSelector cardSelector;
private mage.client.deckeditor.CardSelector cardSelector;
private mage.client.deckeditor.DeckArea deckArea;
private javax.swing.JPanel jPanel1;

View file

@ -0,0 +1,77 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.client.deckeditor.table;
import mage.Constants.CardType;
import mage.cards.MageCard;
/**
* Helper methods for {@link MageCard}.
*
* @author nantuko
*/
public class CardHelper {
private CardHelper() {
}
public static String getColor(MageCard c) {
if (c.getOriginal().getColor().getColorCount() == 0) return "Colorless";
else if (c.getOriginal().getColor().getColorCount() > 1) return "Gold";
else if (c.getOriginal().getColor().isBlack()) return "Black";
else if (c.getOriginal().getColor().isBlue()) return "Blue";
else if (c.getOriginal().getColor().isWhite()) return "White";
else if (c.getOriginal().getColor().isGreen()) return "Green";
else if (c.getOriginal().getColor().isRed()) return "Red";
return "";
}
public static String getType(MageCard c) {
StringBuilder type = new StringBuilder();
for (String superType : c.getOriginal().getSuperTypes()) {
type.append(superType);
type.append(" ");
}
for (CardType cardType : c.getOriginal().getCardTypes()) {
type.append(cardType.toString());
type.append(" ");
}
if (c.getOriginal().getSubTypes().size() > 0) {
type.append("- ");
for (String subType : c.getOriginal().getSubTypes()) {
type.append(subType);
type.append(" ");
}
}
return type.toString();
}
public static boolean isCreature(MageCard c) {
return c.getOriginal().getCardTypes().contains(CardType.CREATURE);
}
}

View file

@ -0,0 +1,624 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.client.deckeditor.table;
import java.awt.Color;
import java.awt.Cursor;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.UUID;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JTable;
import javax.swing.table.DefaultTableCellRenderer;
import mage.Constants.CardType;
import mage.cards.Card;
import mage.cards.ExpansionSet;
import mage.client.cards.BigCard;
import mage.client.cards.CardsStorage;
import mage.client.cards.ICardGrid;
import mage.client.constants.Constants.SortBy;
import mage.filter.Filter.ComparisonScope;
import mage.filter.FilterCard;
import mage.sets.Sets;
import mage.view.CardsView;
/**
*
* @author BetaSteward_at_googlemail.com
*/
public class CardTableSelector extends javax.swing.JPanel implements ComponentListener {
private final List<Card> cards = new ArrayList<Card>();
private final FilterCard filter = new FilterCard();
private BigCard bigCard;
public CardTableSelector() {
initComponents();
this.addComponentListener(this);
setOpaque(false);
mainTable.setOpaque(false);
jScrollPane1.setOpaque(false);
jScrollPane1.getViewport().setOpaque(false);
cbSortBy.setModel(new DefaultComboBoxModel(SortBy.values()));
}
public void loadCards(List<Card> sideboard, BigCard bigCard, boolean construct) {
this.bigCard = bigCard;
this.btnBooster.setVisible(false);
this.btnClear.setVisible(false);
this.cbExpansionSet.setVisible(false);
this.cards.clear();
for (Card card: sideboard) {
this.cards.add(card);
}
initFilter();
filterCards();
}
public void loadCards(BigCard bigCard) {
this.bigCard = bigCard;
this.btnBooster.setVisible(true);
this.btnClear.setVisible(true);
this.cbExpansionSet.setVisible(true);
Object[] l = Sets.getInstance().values().toArray();
Arrays.sort(l, new Comparator<Object>() {
@Override
public int compare(Object o1, Object o2) {
return ((ExpansionSet)o1).getName().compareTo(((ExpansionSet)o2).getName());
}
});
cbExpansionSet.setModel(new DefaultComboBoxModel(l));
// cbExpansionSet.insertItemAt("All sets", 0);
cbExpansionSet.setSelectedIndex(0);
initFilter();
filter.getExpansionSetCode().add(((ExpansionSet)this.cbExpansionSet.getSelectedItem()).getCode());
filterCards();
}
private void initFilter() {
filter.setUseColor(true);
filter.getColor().setBlack(true);
filter.getColor().setBlue(true);
filter.getColor().setGreen(true);
filter.getColor().setWhite(true);
filter.getColor().setRed(true);
filter.setColorless(true);
filter.setUseColorless(true);
filter.setNotColor(false);
filter.setScopeColor(ComparisonScope.Any);
filter.getCardType().add(CardType.LAND);
filter.getCardType().add(CardType.ARTIFACT);
filter.getCardType().add(CardType.CREATURE);
filter.getCardType().add(CardType.ENCHANTMENT);
filter.getCardType().add(CardType.INSTANT);
filter.getCardType().add(CardType.PLANESWALKER);
filter.getCardType().add(CardType.SORCERY);
filter.setScopeCardType(ComparisonScope.Any);
}
private void filterCards() {
try {
List<Card> filteredCards = new ArrayList<Card>();
setCursor(new Cursor(Cursor.WAIT_CURSOR));
if (!cards.isEmpty()) {
for (Card card: cards) {
if (filter.match(card))
filteredCards.add(card);
}
}
else {
for (Card card: CardsStorage.getAllCards()) {
if (filter.match(card))
filteredCards.add(card);
}
}
this.mainModel.loadCards(new CardsView(filteredCards), (SortBy) cbSortBy.getSelectedItem(), chkPiles.isSelected(), bigCard, null);
}
finally {
setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
}
}
public ICardGrid getCardsList() {
return this.mainModel;
}
public void removeCard(UUID cardId) {
this.mainModel.removeCard(cardId);
for (Card card: cards) {
if (card.getId().equals(cardId)) {
cards.remove(card);
break;
}
}
}
public Card getCard(UUID cardId) {
if (!cards.isEmpty()) {
for (Card card: cards) {
if (card.getId().equals(cardId))
return card;
}
}
else {
for (Card card: CardsStorage.getAllCards()) {
if (card.getId().equals(cardId))
return card;
}
}
return null;
}
private void initComponents() {
tbColor = new javax.swing.JToolBar();
rdoRed = new javax.swing.JRadioButton();
rdoGreen = new javax.swing.JRadioButton();
rdoBlue = new javax.swing.JRadioButton();
rdoBlack = new javax.swing.JRadioButton();
rdoWhite = new javax.swing.JRadioButton();
rdoColorless = new javax.swing.JRadioButton();
cbExpansionSet = new javax.swing.JComboBox();
btnBooster = new javax.swing.JButton();
btnClear = new javax.swing.JButton();
jScrollPane1 = new javax.swing.JScrollPane();
mainTable = new JTable();
tbTypes = new javax.swing.JToolBar();
rdoLand = new javax.swing.JRadioButton();
rdoCreatures = new javax.swing.JRadioButton();
rdoArtifacts = new javax.swing.JRadioButton();
rdoEnchantments = new javax.swing.JRadioButton();
rdoInstants = new javax.swing.JRadioButton();
rdoSorceries = new javax.swing.JRadioButton();
rdoPlaneswalkers = new javax.swing.JRadioButton();
chkPiles = new javax.swing.JCheckBox();
cbSortBy = new javax.swing.JComboBox();
tbColor.setFloatable(false);
tbColor.setRollover(true);
rdoRed.setSelected(true);
rdoRed.setText("Red ");
rdoRed.setFocusable(false);
rdoRed.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
rdoRed.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
rdoRed.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
rdoRedActionPerformed(evt);
}
});
tbColor.add(rdoRed);
rdoGreen.setSelected(true);
rdoGreen.setText("Green ");
rdoGreen.setFocusable(false);
rdoGreen.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
rdoGreen.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
rdoGreen.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
rdoGreenActionPerformed(evt);
}
});
tbColor.add(rdoGreen);
rdoBlue.setSelected(true);
rdoBlue.setText("Blue ");
rdoBlue.setFocusable(false);
rdoBlue.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
rdoBlue.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
rdoBlue.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
rdoBlueActionPerformed(evt);
}
});
tbColor.add(rdoBlue);
rdoBlack.setSelected(true);
rdoBlack.setText("Black ");
rdoBlack.setFocusable(false);
rdoBlack.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
rdoBlack.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
rdoBlack.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
rdoBlackActionPerformed(evt);
}
});
tbColor.add(rdoBlack);
rdoWhite.setSelected(true);
rdoWhite.setText("White ");
rdoWhite.setFocusable(false);
rdoWhite.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
rdoWhite.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
rdoWhite.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
rdoWhiteActionPerformed(evt);
}
});
tbColor.add(rdoWhite);
rdoColorless.setSelected(true);
rdoColorless.setText("Colorless ");
rdoColorless.setFocusable(false);
rdoColorless.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
rdoColorless.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
rdoColorless.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
rdoColorlessActionPerformed(evt);
}
});
tbColor.add(rdoColorless);
cbExpansionSet.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
cbExpansionSet.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cbExpansionSetActionPerformed(evt);
}
});
tbColor.add(cbExpansionSet);
btnBooster.setText("Open Booster");
btnBooster.setFocusable(false);
btnBooster.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
btnBooster.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
btnBooster.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnBoosterActionPerformed(evt);
}
});
tbColor.add(btnBooster);
btnClear.setText("Clear");
btnClear.setFocusable(false);
btnClear.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
btnClear.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
btnClear.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnClearActionPerformed(evt);
}
});
tbColor.add(btnClear);
mainModel = new TableModel();
mainModel.addListeners(mainTable);
mainTable.setModel(mainModel);
mainTable.setForeground(Color.white);
DefaultTableCellRenderer myRenderer = (DefaultTableCellRenderer) mainTable.getDefaultRenderer(String.class);
myRenderer.setBackground(new Color(0, 0, 0, 100));
mainTable.getColumnModel().getColumn(0).setMaxWidth(0);
mainTable.getColumnModel().getColumn(0).setPreferredWidth(10);
mainTable.getColumnModel().getColumn(1).setPreferredWidth(110);
mainTable.getColumnModel().getColumn(2).setPreferredWidth(90);
mainTable.getColumnModel().getColumn(3).setPreferredWidth(50);
mainTable.getColumnModel().getColumn(4).setPreferredWidth(170);
mainTable.getColumnModel().getColumn(5).setPreferredWidth(30);
mainTable.getColumnModel().getColumn(6).setPreferredWidth(15);
mainTable.getColumnModel().getColumn(7).setPreferredWidth(15);
jScrollPane1.setViewportView(mainTable);
tbTypes.setFloatable(false);
tbTypes.setRollover(true);
rdoLand.setSelected(true);
rdoLand.setFocusable(false);
rdoLand.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
rdoLand.setLabel("Land ");
rdoLand.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
rdoLand.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
rdoLandActionPerformed(evt);
}
});
tbTypes.add(rdoLand);
rdoCreatures.setSelected(true);
rdoCreatures.setFocusable(false);
rdoCreatures.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
rdoCreatures.setLabel("Creatures ");
rdoCreatures.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
rdoCreatures.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
rdoCreaturesActionPerformed(evt);
}
});
tbTypes.add(rdoCreatures);
rdoArtifacts.setSelected(true);
rdoArtifacts.setText("Artifacts ");
rdoArtifacts.setFocusable(false);
rdoArtifacts.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
rdoArtifacts.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
rdoArtifacts.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
rdoArtifactsActionPerformed(evt);
}
});
tbTypes.add(rdoArtifacts);
rdoEnchantments.setSelected(true);
rdoEnchantments.setText("Enchantments ");
rdoEnchantments.setFocusable(false);
rdoEnchantments.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
rdoEnchantments.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
rdoEnchantments.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
rdoEnchantmentsActionPerformed(evt);
}
});
tbTypes.add(rdoEnchantments);
rdoInstants.setSelected(true);
rdoInstants.setText("Instants ");
rdoInstants.setFocusable(false);
rdoInstants.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
rdoInstants.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
rdoInstants.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
rdoInstantsActionPerformed(evt);
}
});
tbTypes.add(rdoInstants);
rdoSorceries.setSelected(true);
rdoSorceries.setText("Sorceries ");
rdoSorceries.setFocusable(false);
rdoSorceries.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
rdoSorceries.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
rdoSorceries.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
rdoSorceriesActionPerformed(evt);
}
});
tbTypes.add(rdoSorceries);
rdoPlaneswalkers.setSelected(true);
rdoPlaneswalkers.setText("Planeswalkers ");
rdoPlaneswalkers.setFocusable(false);
rdoPlaneswalkers.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
rdoPlaneswalkers.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
rdoPlaneswalkers.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
rdoPlaneswalkersActionPerformed(evt);
}
});
tbTypes.add(rdoPlaneswalkers);
chkPiles.setText("Piles");
chkPiles.setFocusable(false);
chkPiles.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
chkPiles.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
chkPiles.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
chkPilesActionPerformed(evt);
}
});
tbTypes.add(chkPiles);
cbSortBy.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
cbSortBy.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cbSortByActionPerformed(evt);
}
});
tbTypes.add(cbSortBy);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(tbColor, javax.swing.GroupLayout.DEFAULT_SIZE, 917, Short.MAX_VALUE)
.addComponent(tbTypes, javax.swing.GroupLayout.DEFAULT_SIZE, 917, Short.MAX_VALUE)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 917, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(tbColor, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, 0)
.addComponent(tbTypes, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, 0)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 316, Short.MAX_VALUE))
);
}
private void rdoGreenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdoGreenActionPerformed
filter.getColor().setGreen(this.rdoGreen.isSelected());
filterCards();
}//GEN-LAST:event_rdoGreenActionPerformed
private void rdoBlackActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdoBlackActionPerformed
filter.getColor().setBlack(this.rdoBlack.isSelected());
filterCards();
}//GEN-LAST:event_rdoBlackActionPerformed
private void rdoWhiteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdoWhiteActionPerformed
filter.getColor().setWhite(this.rdoWhite.isSelected());
filterCards();
}//GEN-LAST:event_rdoWhiteActionPerformed
private void rdoRedActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdoRedActionPerformed
filter.getColor().setRed(this.rdoRed.isSelected());
filterCards();
}//GEN-LAST:event_rdoRedActionPerformed
private void rdoBlueActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdoBlueActionPerformed
filter.getColor().setBlue(this.rdoBlue.isSelected());
filterCards();
}//GEN-LAST:event_rdoBlueActionPerformed
private void rdoColorlessActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdoColorlessActionPerformed
filter.setColorless(this.rdoColorless.isSelected());
filterCards();
}//GEN-LAST:event_rdoColorlessActionPerformed
private void rdoLandActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdoLandActionPerformed
if (this.rdoLand.isSelected())
filter.getCardType().add(CardType.LAND);
else
filter.getCardType().remove(CardType.LAND);
filterCards();
}//GEN-LAST:event_rdoLandActionPerformed
private void rdoCreaturesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdoCreaturesActionPerformed
if (this.rdoCreatures.isSelected())
filter.getCardType().add(CardType.CREATURE);
else
filter.getCardType().remove(CardType.CREATURE);
filterCards();
}//GEN-LAST:event_rdoCreaturesActionPerformed
private void rdoArtifactsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdoArtifactsActionPerformed
if (this.rdoArtifacts.isSelected())
filter.getCardType().add(CardType.ARTIFACT);
else
filter.getCardType().remove(CardType.ARTIFACT);
filterCards();
}//GEN-LAST:event_rdoArtifactsActionPerformed
private void rdoEnchantmentsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdoEnchantmentsActionPerformed
if (this.rdoEnchantments.isSelected())
filter.getCardType().add(CardType.ENCHANTMENT);
else
filter.getCardType().remove(CardType.ENCHANTMENT);
filterCards();
}//GEN-LAST:event_rdoEnchantmentsActionPerformed
private void rdoInstantsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdoInstantsActionPerformed
if (this.rdoInstants.isSelected())
filter.getCardType().add(CardType.INSTANT);
else
filter.getCardType().remove(CardType.INSTANT);
filterCards();
}//GEN-LAST:event_rdoInstantsActionPerformed
private void rdoSorceriesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdoSorceriesActionPerformed
if (this.rdoSorceries.isSelected())
filter.getCardType().add(CardType.SORCERY);
else
filter.getCardType().remove(CardType.SORCERY);
filterCards();
}//GEN-LAST:event_rdoSorceriesActionPerformed
private void rdoPlaneswalkersActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rdoPlaneswalkersActionPerformed
if (this.rdoPlaneswalkers.isSelected())
filter.getCardType().add(CardType.PLANESWALKER);
else
filter.getCardType().remove(CardType.PLANESWALKER);
filterCards();
}//GEN-LAST:event_rdoPlaneswalkersActionPerformed
private void cbExpansionSetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbExpansionSetActionPerformed
filter.getExpansionSetCode().clear();
if (cbExpansionSet.getSelectedItem() instanceof ExpansionSet) {
filter.getExpansionSetCode().add(((ExpansionSet)this.cbExpansionSet.getSelectedItem()).getCode());
}
filterCards();
}//GEN-LAST:event_cbExpansionSetActionPerformed
private void btnClearActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnClearActionPerformed
cards.clear();
filterCards();
}//GEN-LAST:event_btnClearActionPerformed
private void btnBoosterActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBoosterActionPerformed
List<Card> booster = ((ExpansionSet)this.cbExpansionSet.getSelectedItem()).createBooster();
for (Card card: booster) {
cards.add(card);
}
filterCards();
}//GEN-LAST:event_btnBoosterActionPerformed
private void cbSortByActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbSortByActionPerformed
if (cbSortBy.getSelectedItem() instanceof SortBy)
this.mainModel.drawCards((SortBy) cbSortBy.getSelectedItem(), chkPiles.isSelected());
}//GEN-LAST:event_cbSortByActionPerformed
private void chkPilesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chkPilesActionPerformed
if (cbSortBy.getSelectedItem() instanceof SortBy)
this.mainModel.drawCards((SortBy) cbSortBy.getSelectedItem(), chkPiles.isSelected());
}//GEN-LAST:event_chkPilesActionPerformed
private TableModel mainModel;
private javax.swing.JButton btnBooster;
private javax.swing.JButton btnClear;
private JTable mainTable = new JTable();
private javax.swing.JComboBox cbExpansionSet;
private javax.swing.JComboBox cbSortBy;
private javax.swing.JCheckBox chkPiles;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JRadioButton rdoArtifacts;
private javax.swing.JRadioButton rdoBlack;
private javax.swing.JRadioButton rdoBlue;
private javax.swing.JRadioButton rdoColorless;
private javax.swing.JRadioButton rdoCreatures;
private javax.swing.JRadioButton rdoEnchantments;
private javax.swing.JRadioButton rdoGreen;
private javax.swing.JRadioButton rdoInstants;
private javax.swing.JRadioButton rdoLand;
private javax.swing.JRadioButton rdoPlaneswalkers;
private javax.swing.JRadioButton rdoRed;
private javax.swing.JRadioButton rdoSorceries;
private javax.swing.JRadioButton rdoWhite;
private javax.swing.JToolBar tbColor;
private javax.swing.JToolBar tbTypes;
@Override
public void componentResized(ComponentEvent e) {
if (cbSortBy.getSelectedItem() instanceof SortBy)
this.mainModel.drawCards((SortBy) cbSortBy.getSelectedItem(), chkPiles.isSelected());
}
@Override
public void componentMoved(ComponentEvent e) {
if (cbSortBy.getSelectedItem() instanceof SortBy)
this.mainModel.drawCards((SortBy) cbSortBy.getSelectedItem(), chkPiles.isSelected());
}
@Override
public void componentShown(ComponentEvent e) {
if (cbSortBy.getSelectedItem() instanceof SortBy)
this.mainModel.drawCards((SortBy) cbSortBy.getSelectedItem(), chkPiles.isSelected());
}
@Override
public void componentHidden(ComponentEvent e) {
if (cbSortBy.getSelectedItem() instanceof SortBy)
this.mainModel.drawCards((SortBy) cbSortBy.getSelectedItem(), chkPiles.isSelected());
}
}

View file

@ -0,0 +1,101 @@
/* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.client.deckeditor.table;
import java.util.Comparator;
import java.util.List;
import mage.cards.MageCard;
/**
* {@link MageCard} comparator. Used to sort cards in Deck Editor Table View pane.
*
* @author nantuko
*/
public class MageCardComparator implements Comparator<MageCard> {
private final int column;
private boolean ascending;
public MageCardComparator(int column, boolean ascending) {
this.column = column;
this.ascending = ascending;
}
public int compare(MageCard a, MageCard b) {
Comparable aCom = null;
Comparable bCom = null;
if (column == 0)// #skip
{
aCom = Integer.valueOf(1);
bCom = Integer.valueOf(1);
} else if (column == 1)// Name
{
aCom = a.getOriginal().getName();
bCom = b.getOriginal().getName();
if (aCom.equals(bCom) && a.getOriginal().getExpansionSetCode().equals(b.getOriginal().getExpansionSetCode())) {
aCom = a.getOriginal().getCardNumber();
bCom = b.getOriginal().getCardNumber();
}
} else if (column == 2)// Cost
{
aCom = a.getOriginal().getConvertedManaCost();
bCom = b.getOriginal().getConvertedManaCost();
} else if (column == 3)// Color
{
aCom = CardHelper.getColor(a);
bCom = CardHelper.getColor(b);
} else if (column == 4)// Type
{
aCom = CardHelper.getType(a);
bCom = CardHelper.getType(b);
} else if (column == 5)// Stats, attack and defense
{
aCom = new Float(-1);
bCom = new Float(-1);
if (CardHelper.isCreature(a))
aCom = new Float(a.getOriginal().getPower() + "." + a.getOriginal().getToughness());
if (CardHelper.isCreature(b))
bCom = new Float(b.getOriginal().getPower() + "." + b.getOriginal().getToughness());
} else if (column == 6)// Rarity
{
aCom = a.getOriginal().getRarity().toString();
bCom = b.getOriginal().getRarity().toString();
} else if (column == 7)// Set name
{
aCom = a.getOriginal().getExpansionSetCode();
bCom = b.getOriginal().getExpansionSetCode();
}
if (ascending)
return aCom.compareTo(bCom);
else
return bCom.compareTo(aCom);
}// compare()
}

View file

@ -0,0 +1,266 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.client.deckeditor.table;
import java.awt.Dimension;
import java.awt.Image;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.UUID;
import javax.swing.JTable;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.TableColumnModel;
import mage.cards.MageCard;
import mage.client.cards.BigCard;
import mage.client.cards.CardEventSource;
import mage.client.cards.ICardGrid;
import mage.client.constants.Constants.SortBy;
import mage.client.plugins.impl.Plugins;
import mage.client.util.Config;
import mage.client.util.Event;
import mage.client.util.ImageHelper;
import mage.client.util.Listener;
import mage.view.CardView;
import mage.view.CardsView;
/**
* Table Model for card list.
*
* @author nantuko
*/
public class TableModel extends AbstractTableModel implements ICardGrid {
private static final long serialVersionUID = -528008802935423088L;
protected CardEventSource cardEventSource = new CardEventSource();
protected BigCard bigCard;
protected UUID gameId;
private Map<UUID, MageCard> cards = new LinkedHashMap<UUID, MageCard>();
private List<MageCard> view = new ArrayList<MageCard>();
private Dimension cardDimension;
private String column[] = { "", "Name", "Cost", "Color", "Type", "Stats",
"Rarity", "Set" };
private int recentSortedColumn;
private boolean recentAscending;
public void loadCards(CardsView showCards, SortBy sortBy, boolean piles,
BigCard bigCard, UUID gameId) {
this.bigCard = bigCard;
this.gameId = gameId;
for (CardView card : showCards.values()) {
if (!cards.containsKey(card.getId())) {
addCard(card, bigCard, gameId);
}
}
for (Iterator<Entry<UUID, MageCard>> i = cards.entrySet().iterator(); i
.hasNext();) {
Entry<UUID, MageCard> entry = i.next();
if (!showCards.containsKey(entry.getKey())) {
i.remove();
for (MageCard v : view) {
if (v.getOriginal().getId().equals(entry.getKey())) {
view.remove(v);
break;
}
}
}
}
drawCards(sortBy, piles);
}
public void clear() {
view.clear();
cards.clear();
}
public int getRowCount() {
return view.size();
}
public int getColumnCount() {
return column.length;
}
public String getColumnName(int n) {
return column[n];
}
public Object getValueAt(int row, int column) {
return getColumn(view.get(row), column);
}
private Object getColumn(Object obj, int column) {
MageCard c = (MageCard) obj;
switch (column) {
case 0:
return "";
case 1:
return c.getOriginal().getName();
case 2:
StringBuilder s = new StringBuilder();
for (String cost : c.getOriginal().getManaCost()) {
s.append(cost);
}
String cost = s.toString();
if (cost.isEmpty()) {
return "0";
}
return cost;
case 3:
return CardHelper.getColor(c);
case 4:
return CardHelper.getType(c);
case 5:
return CardHelper.isCreature(c) ? c.getOriginal().getPower() + "/"
+ c.getOriginal().getToughness() : "-";
case 6:
return c.getOriginal().getRarity().toString();
case 7:
return c.getOriginal().getExpansionSetCode();
default:
return "error";
}
}
private void addCard(CardView card, BigCard bigCard, UUID gameId) {
if (cardDimension == null) {
cardDimension = new Dimension(Config.dimensions.frameWidth,
Config.dimensions.frameHeight);
}
MageCard cardImg = Plugins.getInstance().getMageCard(card, bigCard,
cardDimension, gameId, true);
cards.put(card.getId(), cardImg);
cardImg.update(card);
view.add(cardImg);
}
public void drawCards(SortBy sortBy, boolean piles) {
fireTableDataChanged();
}
public void removeCard(UUID cardId) {
cards.remove(cardId);
for (MageCard v : view) {
if (v.getOriginal().getId().equals(cardId)) {
view.remove(v);
break;
}
}
}
public void addCardEventListener(Listener<Event> listener) {
cardEventSource.addListener(listener);
}
public void clearCardEventListeners() {
cardEventSource.clearListeners();
}
public void addListeners(final JTable table) {
// updates card detail, listens to any key strokes
/*
* table.addKeyListener(new KeyListener() { public void
* keyPressed(KeyEvent ev) { }
*
* public void keyTyped(KeyEvent ev) { }
*
* public void keyReleased(KeyEvent ev) { int row =
* table.getSelectedRow(); if (row != -1) { MageCard card =
* (MageCard)cards.values().toArray()[row];
* bigCard.setCard(card.getOriginal().getId(), card.getImage(), new
* ArrayList<String>(), false); } } });
*/
// updates card detail, listens to any mouse clicks
table.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent e) {
int row = table.getSelectedRow();
if (row != -1) {
MageCard card = view.get(row);
if (card.getOriginal().getId().equals(bigCard.getCardId())) {
Image image = card.getImage();
if (image != null && image instanceof BufferedImage) {
image = ImageHelper.getResizedImage(
(BufferedImage) image, bigCard.getWidth(),
bigCard.getHeight());
}
bigCard.setCard(card.getOriginal().getId(), image,
new ArrayList<String>(), false);
}
}
}
});
// sorts
MouseListener mouse = new MouseAdapter() {
public void mousePressed(MouseEvent e) {
TableColumnModel columnModel = table.getColumnModel();
int viewColumn = columnModel.getColumnIndexAtX(e.getX());
int column = table.convertColumnIndexToModel(viewColumn);
if (column != -1) {
// sort ascending
boolean asc = true;
if (recentSortedColumn == column) {
asc = !recentAscending;
}
boolean change = sort(column, asc);
fireTableDataChanged();
}
}
};
table.getTableHeader().addMouseListener(mouse);
}
public boolean sort(int column, boolean ascending) {
// used by addCard() to resort the cards
recentSortedColumn = column;
recentAscending = ascending;
MageCardComparator sorter = new MageCardComparator(column, ascending);
Collections.sort(view, sorter);
fireTableDataChanged();
return true;
}
}