diff --git a/src/main/config/forge_checks.xml b/src/main/config/forge_checks.xml index f8d57492c25..067a4f586fb 100644 --- a/src/main/config/forge_checks.xml +++ b/src/main/config/forge_checks.xml @@ -188,7 +188,7 @@ - + diff --git a/src/main/java/forge/deck/DeckManager.java b/src/main/java/forge/deck/DeckManager.java index 02b8ed5f904..85695ecffc4 100644 --- a/src/main/java/forge/deck/DeckManager.java +++ b/src/main/java/forge/deck/DeckManager.java @@ -698,7 +698,7 @@ public class DeckManager { private static void writeCardPool(final ItemPoolView pool, final BufferedWriter out) throws IOException { final List> main2sort = pool.getOrderedList(); - Collections.sort(main2sort, TableSorter.byNameThenSet); + Collections.sort(main2sort, TableSorter.BY_NAME_THEN_SET); for (final Entry e : main2sort) { final CardPrinted card = e.getKey(); final boolean hasBadSetInfo = "???".equals(card.getSet()) || StringUtils.isBlank(card.getSet()); diff --git a/src/main/java/forge/gui/deckeditor/CardPanelHeavy.java b/src/main/java/forge/gui/deckeditor/CardPanelHeavy.java index 82fc15d834a..d0d3d77b8b3 100644 --- a/src/main/java/forge/gui/deckeditor/CardPanelHeavy.java +++ b/src/main/java/forge/gui/deckeditor/CardPanelHeavy.java @@ -29,7 +29,7 @@ public class CardPanelHeavy extends CardPanelBase { private static final long serialVersionUID = -7134546689397508597L; - private JButton changeStateButton = new JButton(); + private final JButton changeStateButton = new JButton(); /* * Removed Oct 25 2011 - Hellfish private JButton changePictureButton = new @@ -38,33 +38,34 @@ public class CardPanelHeavy extends CardPanelBase { // Controls to show card details /** The detail. */ - protected CardDetailPanel detail = new CardDetailPanel(null); + private CardDetailPanel detail = new CardDetailPanel(null); /** The picture. */ - protected CardPanel picture = new CardPanel(null); + private CardPanel picture = new CardPanel(null); /** The picture view panel. */ - protected ViewPanel pictureViewPanel = new ViewPanel(); + private ViewPanel pictureViewPanel = new ViewPanel(); // fake card to allow picture changes /** The c card hq. */ - public Card cCardHQ; + private Card cCardHQ; /** Constant previousDirectory. */ - protected static File previousDirectory = null; + private static File previousDirectory = null; /** * Instantiates a new card panel heavy. */ public CardPanelHeavy() { - changeStateButton.setVisible(false); - changeStateButton.addActionListener(new java.awt.event.ActionListener() { + this.changeStateButton.setVisible(false); + this.changeStateButton.addActionListener(new java.awt.event.ActionListener() { + @Override public void actionPerformed(final ActionEvent e) { - changeStateButton_actionPerformed(e); + CardPanelHeavy.this.changeStateButtonActionPerformed(e); } }); if (!Singletons.getModel().getPreferences().lafFonts) { - changeStateButton.setFont(new java.awt.Font("Dialog", 0, 10)); + this.changeStateButton.setFont(new java.awt.Font("Dialog", 0, 10)); } /* @@ -86,17 +87,17 @@ public class CardPanelHeavy extends CardPanelBase { * removePictureButton.setFont(new java.awt.Font("Dialog", 0, 10)); */ - pictureViewPanel.setCardPanel(picture); + this.pictureViewPanel.setCardPanel(this.picture); this.setLayout(new MigLayout("fill, ins 0")); - this.add(detail, "w 239, h 323, grow, flowy, wrap"); + this.add(this.detail, "w 239, h 323, grow, flowy, wrap"); /* * Removed Oct 25 2011 - Hellfish this.add(changeStateButton, * "align 50% 0%, split 3, flowx"); this.add(changePictureButton, * "align 50% 0%"); this.add(removePictureButton, "align 50% 0%, wrap"); */ - this.add(changeStateButton, "align 50% 0%, flowx, wrap"); - this.add(pictureViewPanel, "wmin 239, hmin 323, grow"); + this.add(this.changeStateButton, "align 50% 0%, flowx, wrap"); + this.add(this.pictureViewPanel, "wmin 239, hmin 323, grow"); } /* @@ -105,10 +106,11 @@ public class CardPanelHeavy extends CardPanelBase { * @see * forge.gui.deckeditor.CardPanelBase#showCard(forge.item.InventoryItem) */ + @Override public final void showCard(final InventoryItem card) { - Card card2 = card instanceof CardPrinted ? ((CardPrinted) card).toForgeCard() : null; - detail.setCard(card2); - setCard(card2); + final Card card2 = card instanceof CardPrinted ? ((CardPrinted) card).toForgeCard() : null; + this.detail.setCard(card2); + this.setCard(card2); } /** @@ -118,22 +120,22 @@ public class CardPanelHeavy extends CardPanelBase { * the new card */ public final void setCard(final Card c) { - if (picture.getCard() != null) { - if (picture.getCard().isInAlternateState()) { - picture.getCard().changeState(); + if (this.picture.getCard() != null) { + if (this.picture.getCard().isInAlternateState()) { + this.picture.getCard().changeState(); } } - picture.setCard(c); + this.picture.setCard(c); if (c.hasAlternateState()) { - changeStateButton.setVisible(true); + this.changeStateButton.setVisible(true); if (c.isFlip()) { - changeStateButton.setText("Flip"); + this.changeStateButton.setText("Flip"); } else { - changeStateButton.setText("Transform"); + this.changeStateButton.setText("Transform"); } } else { - changeStateButton.setVisible(false); + this.changeStateButton.setVisible(false); } } @@ -145,12 +147,12 @@ public class CardPanelHeavy extends CardPanelBase { * @param e * a {@link java.awt.event.ActionEvent} object. */ - final void changeStateButton_actionPerformed(final ActionEvent e) { - Card cur = picture.getCard(); + final void changeStateButtonActionPerformed(final ActionEvent e) { + final Card cur = this.picture.getCard(); cur.changeState(); - picture.setCard(cur); - detail.setCard(cur); + this.picture.setCard(cur); + this.detail.setCard(cur); } /** @@ -161,23 +163,23 @@ public class CardPanelHeavy extends CardPanelBase { * @param e * a {@link java.awt.event.ActionEvent} object. */ - final void changePictureButton_actionPerformed(final ActionEvent e) { - if (cCardHQ != null) { - File file = getImportFilename(); + private void changePictureButtonActionPerformed(final ActionEvent e) { + if (this.cCardHQ != null) { + final File file = this.getImportFilename(); if (file != null) { - String fileName = GuiDisplayUtil.cleanString(cCardHQ.getName()) + ".jpg"; - File base = ForgeProps.getFile(NewConstants.IMAGE_BASE); - File f = new File(base, fileName); + final String fileName = GuiDisplayUtil.cleanString(this.cCardHQ.getName()) + ".jpg"; + final File base = ForgeProps.getFile(NewConstants.IMAGE_BASE); + final File f = new File(base, fileName); f.delete(); try { org.apache.commons.io.FileUtils.copyFile(file, f); - } catch (IOException e1) { + } catch (final IOException e1) { // TODO Auto-generated catch block ignores the exception, // but sends it to System.err and probably forge.log. e1.printStackTrace(); } - setCard(cCardHQ); + this.setCard(this.cCardHQ); } } } @@ -190,16 +192,16 @@ public class CardPanelHeavy extends CardPanelBase { * @return a {@link java.io.File} object. */ private File getImportFilename() { - JFileChooser chooser = new JFileChooser(previousDirectory); - ImagePreviewPanel preview = new ImagePreviewPanel(); + final JFileChooser chooser = new JFileChooser(CardPanelHeavy.previousDirectory); + final ImagePreviewPanel preview = new ImagePreviewPanel(); chooser.setAccessory(preview); chooser.addPropertyChangeListener(preview); - chooser.addChoosableFileFilter(dckFilter); - int returnVal = chooser.showOpenDialog(null); + chooser.addChoosableFileFilter(this.dckFilter); + final int returnVal = chooser.showOpenDialog(null); if (returnVal == JFileChooser.APPROVE_OPTION) { - File file = chooser.getSelectedFile(); - previousDirectory = file.getParentFile(); + final File file = chooser.getSelectedFile(); + CardPanelHeavy.previousDirectory = file.getParentFile(); return file; } @@ -208,7 +210,7 @@ public class CardPanelHeavy extends CardPanelBase { } /** The dck filter. */ - protected FileFilter dckFilter = new FileFilter() { + private FileFilter dckFilter = new FileFilter() { @Override public boolean accept(final File f) { @@ -231,20 +233,20 @@ public class CardPanelHeavy extends CardPanelBase { * @param e * the e */ - final void removePictureButton_actionPerformed(final ActionEvent e) { - if (cCardHQ != null) { - String options[] = { "Yes", "No" }; - int value = JOptionPane.showOptionDialog(null, "Do you want delete " + cCardHQ.getName() + " picture?", - "Delete picture", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, - options[1]); + final void removePictureButtonActionPerformed(final ActionEvent e) { + if (this.cCardHQ != null) { + final String[] options = { "Yes", "No" }; + final int value = JOptionPane.showOptionDialog(null, "Do you want delete " + this.cCardHQ.getName() + + " picture?", "Delete picture", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, + options, options[1]); if (value == 0) { - String fileName = GuiDisplayUtil.cleanString(cCardHQ.getName()) + ".jpg"; - File base = ForgeProps.getFile(NewConstants.IMAGE_BASE); - File f = new File(base, fileName); + final String fileName = GuiDisplayUtil.cleanString(this.cCardHQ.getName()) + ".jpg"; + final File base = ForgeProps.getFile(NewConstants.IMAGE_BASE); + final File f = new File(base, fileName); f.delete(); - JOptionPane.showMessageDialog(null, "Picture " + cCardHQ.getName() + " deleted.", "Delete picture", - JOptionPane.INFORMATION_MESSAGE); - setCard(cCardHQ); + JOptionPane.showMessageDialog(null, "Picture " + this.cCardHQ.getName() + " deleted.", + "Delete picture", JOptionPane.INFORMATION_MESSAGE); + this.setCard(this.cCardHQ); } } } @@ -255,7 +257,7 @@ public class CardPanelHeavy extends CardPanelBase { * @return the card */ public final Card getCard() { - return detail.getCard(); + return this.detail.getCard(); } } diff --git a/src/main/java/forge/gui/deckeditor/CardPanelLite.java b/src/main/java/forge/gui/deckeditor/CardPanelLite.java index 3de0f3b66f6..8f5556d8c50 100644 --- a/src/main/java/forge/gui/deckeditor/CardPanelLite.java +++ b/src/main/java/forge/gui/deckeditor/CardPanelLite.java @@ -23,29 +23,30 @@ public class CardPanelLite extends CardPanelBase { // Controls to show card details /** The detail. */ - protected CardDetailPanel detail = new CardDetailPanel(null); - private CardPicturePanel picture = new CardPicturePanel(null); - private JButton bChangeState = new JButton(); + private CardDetailPanel detail = new CardDetailPanel(null); + private final CardPicturePanel picture = new CardPicturePanel(null); + private final JButton bChangeState = new JButton(); /** * * Constructor. */ public CardPanelLite() { - bChangeState.setVisible(false); - bChangeState.addActionListener(new ActionListener() { + this.bChangeState.setVisible(false); + this.bChangeState.addActionListener(new ActionListener() { + @Override public void actionPerformed(final ActionEvent e) { - bChangeState_actionPerformed(e); + CardPanelLite.this.bChangeStateActionPerformed(e); } }); if (!Singletons.getModel().getPreferences().lafFonts) { - bChangeState.setFont(new java.awt.Font("Dialog", 0, 10)); + this.bChangeState.setFont(new java.awt.Font("Dialog", 0, 10)); } this.setLayout(new MigLayout("fill, ins 0")); - this.add(detail, "w 239, h 303, grow, flowy, wrap"); - this.add(bChangeState, "align 50% 0%, wrap"); - this.add(picture, "wmin 239, hmin 323, grow"); + this.add(this.detail, "w 239, h 303, grow, flowy, wrap"); + this.add(this.bChangeState, "align 50% 0%, wrap"); + this.add(this.picture, "wmin 239, hmin 323, grow"); } /** @@ -55,20 +56,21 @@ public class CardPanelLite extends CardPanelBase { * @param card * an InventoryItem */ + @Override public final void showCard(final InventoryItem card) { - picture.setCard(card); - boolean isCard = card != null && card instanceof CardPrinted; - detail.setVisible(isCard); + this.picture.setCard(card); + final boolean isCard = (card != null) && (card instanceof CardPrinted); + this.detail.setVisible(isCard); if (isCard) { - Card toSet = ((CardPrinted) card).toForgeCard(); + final Card toSet = ((CardPrinted) card).toForgeCard(); - detail.setCard(toSet); + this.detail.setCard(toSet); if (toSet.hasAlternateState()) { - bChangeState.setVisible(true); + this.bChangeState.setVisible(true); if (toSet.isFlip()) { - bChangeState.setText("Flip"); + this.bChangeState.setText("Flip"); } else { - bChangeState.setText("Transform"); + this.bChangeState.setText("Transform"); } } } @@ -81,15 +83,15 @@ public class CardPanelLite extends CardPanelBase { * the new card */ public final void setCard(final Card c) { - picture.setCard(c); + this.picture.setCard(c); if (c != null) { - detail.setCard(c); + this.detail.setCard(c); if (c.hasAlternateState()) { - bChangeState.setVisible(true); + this.bChangeState.setVisible(true); if (c.isFlip()) { - bChangeState.setText("Flip"); + this.bChangeState.setText("Flip"); } else { - bChangeState.setText("Transform"); + this.bChangeState.setText("Transform"); } } } @@ -102,15 +104,15 @@ public class CardPanelLite extends CardPanelBase { * @return Card */ public final Card getCard() { - return detail.getCard(); + return this.detail.getCard(); } - private void bChangeState_actionPerformed(final ActionEvent e) { - Card cur = detail.getCard(); + private void bChangeStateActionPerformed(final ActionEvent e) { + final Card cur = this.detail.getCard(); if (cur != null) { cur.changeState(); - setCard(cur); + this.setCard(cur); } } diff --git a/src/main/java/forge/gui/deckeditor/CheckBoxWithIcon.java b/src/main/java/forge/gui/deckeditor/CheckBoxWithIcon.java index fb3f5a2a3b8..a22e7147ba9 100644 --- a/src/main/java/forge/gui/deckeditor/CheckBoxWithIcon.java +++ b/src/main/java/forge/gui/deckeditor/CheckBoxWithIcon.java @@ -14,10 +14,10 @@ public class CheckBoxWithIcon extends JCheckBox { /* Custom check box class for filter icons */ private static final long serialVersionUID = -8099263807219520120L; - private String imagePath = "res/images/deckeditor/"; - private String iconYes; - private String iconNo; - private CheckBoxWithIcon cb; + private final String imagePath = "res/images/deckeditor/"; + private final String iconYes; + private final String iconNo; + private final CheckBoxWithIcon cb; /** * Instantiates a new check box with icon. @@ -29,17 +29,18 @@ public class CheckBoxWithIcon extends JCheckBox { */ CheckBoxWithIcon(final String filterName, final String toolTip) { super("", true); - cb = this; - iconYes = imagePath + "filter_" + filterName + "_y.png"; - iconNo = imagePath + "filter_" + filterName + "_n.png"; - this.setIcon(new ImageIcon(iconYes)); + this.cb = this; + this.iconYes = this.imagePath + "filter_" + filterName + "_y.png"; + this.iconNo = this.imagePath + "filter_" + filterName + "_n.png"; + this.setIcon(new ImageIcon(this.iconYes)); this.setToolTipText(toolTip); this.addActionListener(new ActionListener() { + @Override public void actionPerformed(final ActionEvent actionEvent) { - if (cb.isSelected()) { - cb.setIcon(new ImageIcon(iconYes)); + if (CheckBoxWithIcon.this.cb.isSelected()) { + CheckBoxWithIcon.this.cb.setIcon(new ImageIcon(CheckBoxWithIcon.this.iconYes)); } else { - cb.setIcon(new ImageIcon(iconNo)); + CheckBoxWithIcon.this.cb.setIcon(new ImageIcon(CheckBoxWithIcon.this.iconNo)); } } }); diff --git a/src/main/java/forge/gui/deckeditor/DeckAnalysis.java b/src/main/java/forge/gui/deckeditor/DeckAnalysis.java index 493e012416f..29a3c97579c 100644 --- a/src/main/java/forge/gui/deckeditor/DeckAnalysis.java +++ b/src/main/java/forge/gui/deckeditor/DeckAnalysis.java @@ -95,14 +95,14 @@ public class DeckAnalysis extends javax.swing.JDialog { private JSeparator jSeparator1; private JLabel jLabel2; private JButton jButtonOk; - private JFrame jF; + private final JFrame jF; // private ButtonGroup buttonGroup1; /** The filter card list. */ - public CardList filterCardList; + private CardList filterCardList; /** The deck. */ - public ItemPoolView deck; + private ItemPoolView deck; /** *

@@ -116,10 +116,10 @@ public class DeckAnalysis extends javax.swing.JDialog { */ public DeckAnalysis(final JFrame g, final ItemPoolView deckView) { super(g); - deck = deckView; + this.deck = deckView; - jF = g; - initGUI(); + this.jF = g; + this.initGUI(); } /** @@ -130,25 +130,25 @@ public class DeckAnalysis extends javax.swing.JDialog { private void initGUI() { try { - getContentPane().setLayout(null); - setVisible(true); - int wWidth = 600; - int wHeight = 600; + this.getContentPane().setLayout(null); + this.setVisible(true); + final int wWidth = 600; + final int wHeight = 600; this.setPreferredSize(new java.awt.Dimension(wWidth, wHeight)); - Dimension screen = getToolkit().getScreenSize(); - int x = (screen.width - wWidth) / 2; - int y = (screen.height - wHeight) / 2; + final Dimension screen = this.getToolkit().getScreenSize(); + final int x = (screen.width - wWidth) / 2; + final int y = (screen.height - wHeight) / 2; this.setBounds(x, y, wWidth, wHeight); this.setResizable(false); this.setTitle("Deck Analysis"); - pack(); + this.pack(); // this.setIconImage(null); this.addWindowListener(new WindowAdapter() { @Override public void windowClosing(final WindowEvent arg0) { - jF.setEnabled(true); + DeckAnalysis.this.jF.setEnabled(true); } @Override @@ -183,9 +183,9 @@ public class DeckAnalysis extends javax.swing.JDialog { mSixMore = 0; tManaCost = 0; - for (Entry e : deck) { + for (final Entry e : DeckAnalysis.this.deck) { c = e.getKey().getCard(); - int cnt = e.getValue(); + final int cnt = e.getValue(); if (c.getColor().isMulticolor()) { cMulticolor = cMulticolor + cnt; @@ -215,7 +215,7 @@ public class DeckAnalysis extends javax.swing.JDialog { } // count card types - CardType cType = c.getType(); + final CardType cType = c.getType(); if (cType.isArtifact()) { cArtifact = cArtifact + cnt; } @@ -238,7 +238,7 @@ public class DeckAnalysis extends javax.swing.JDialog { cSorcery = cSorcery + cnt; } - int cmc = c.getManaCost().getCMC(); + final int cmc = c.getManaCost().getCMC(); if (cmc == 0) { mZero = mZero + cnt; } else if (cmc == 1) { @@ -255,126 +255,130 @@ public class DeckAnalysis extends javax.swing.JDialog { mSixMore = mSixMore + 1; } - tManaCost = tManaCost + cmc * cnt; + tManaCost = tManaCost + (cmc * cnt); } - int total = deck.countAll(); + final int total = DeckAnalysis.this.deck.countAll(); BigDecimal aManaCost = new BigDecimal(tManaCost / total); aManaCost = aManaCost.setScale(2, BigDecimal.ROUND_HALF_UP); - jLabelTotal.setText("Information about deck (total cards: " + total + "):"); - jLabelManaCost.setText("Mana cost (ACC:" + aManaCost + ")"); - Color cr = new Color(100, 100, 100); + DeckAnalysis.this.jLabelTotal.setText("Information about deck (total cards: " + total + "):"); + DeckAnalysis.this.jLabelManaCost.setText("Mana cost (ACC:" + aManaCost + ")"); + final Color cr = new Color(100, 100, 100); if (cBlack == 0) { - jLabelBlack.setForeground(cr); + DeckAnalysis.this.jLabelBlack.setForeground(cr); } - jLabelBlack.setText(formatStat("Black", cBlack, total)); + DeckAnalysis.this.jLabelBlack.setText(DeckAnalysis.this.formatStat("Black", cBlack, total)); if (cBlue == 0) { - jLabelBlue.setForeground(cr); + DeckAnalysis.this.jLabelBlue.setForeground(cr); } - jLabelBlue.setText(formatStat("Blue", cBlue, total)); + DeckAnalysis.this.jLabelBlue.setText(DeckAnalysis.this.formatStat("Blue", cBlue, total)); if (cGreen == 0) { - jLabelGreen.setForeground(cr); + DeckAnalysis.this.jLabelGreen.setForeground(cr); } - jLabelGreen.setText(formatStat("Green", cGreen, total)); + DeckAnalysis.this.jLabelGreen.setText(DeckAnalysis.this.formatStat("Green", cGreen, total)); if (cRed == 0) { - jLabelRed.setForeground(cr); + DeckAnalysis.this.jLabelRed.setForeground(cr); } - jLabelRed.setText(formatStat("Red", cRed, total)); + DeckAnalysis.this.jLabelRed.setText(DeckAnalysis.this.formatStat("Red", cRed, total)); if (cWhite == 0) { - jLabelWhite.setForeground(cr); + DeckAnalysis.this.jLabelWhite.setForeground(cr); } - jLabelWhite.setText(formatStat("White", cWhite, total)); + DeckAnalysis.this.jLabelWhite.setText(DeckAnalysis.this.formatStat("White", cWhite, total)); if (cMulticolor == 0) { - jLabelMultiColor.setForeground(cr); + DeckAnalysis.this.jLabelMultiColor.setForeground(cr); } - jLabelMultiColor.setText(formatStat("Multicolor", cMulticolor, total)); + DeckAnalysis.this.jLabelMultiColor.setText(DeckAnalysis.this.formatStat("Multicolor", cMulticolor, + total)); if (cColorless == 0) { - jLabelColorless.setForeground(cr); + DeckAnalysis.this.jLabelColorless.setForeground(cr); } - jLabelColorless.setText(formatStat("Colorless", cColorless, total)); + DeckAnalysis.this.jLabelColorless.setText(DeckAnalysis.this.formatStat("Colorless", cColorless, + total)); if (cLand == 0) { - jLabelLand.setForeground(cr); + DeckAnalysis.this.jLabelLand.setForeground(cr); } - jLabelLand.setText(formatStat("Land", cLand, total)); + DeckAnalysis.this.jLabelLand.setText(DeckAnalysis.this.formatStat("Land", cLand, total)); if (cArtifact == 0) { - jLabelArtifact.setForeground(cr); + DeckAnalysis.this.jLabelArtifact.setForeground(cr); } - jLabelArtifact.setText(formatStat("Artifact", cArtifact, total)); + DeckAnalysis.this.jLabelArtifact.setText(DeckAnalysis.this.formatStat("Artifact", cArtifact, total)); if (cCreature == 0) { - jLabelCreature.setForeground(cr); + DeckAnalysis.this.jLabelCreature.setForeground(cr); } - jLabelCreature.setText(formatStat("Creature", cCreature, total)); + DeckAnalysis.this.jLabelCreature.setText(DeckAnalysis.this.formatStat("Creature", cCreature, total)); if (cEnchant == 0) { - jLabelEnchant.setForeground(cr); + DeckAnalysis.this.jLabelEnchant.setForeground(cr); } - jLabelEnchant.setText(formatStat("Enchant", cEnchant, total)); + DeckAnalysis.this.jLabelEnchant.setText(DeckAnalysis.this.formatStat("Enchant", cEnchant, total)); if (cInstant == 0) { - jLabelInstant.setForeground(cr); + DeckAnalysis.this.jLabelInstant.setForeground(cr); } - jLabelInstant.setText(formatStat("Instant", cInstant, total)); + DeckAnalysis.this.jLabelInstant.setText(DeckAnalysis.this.formatStat("Instant", cInstant, total)); if (cLandType == 0) { - jLabelLandType.setForeground(cr); + DeckAnalysis.this.jLabelLandType.setForeground(cr); } - jLabelLandType.setText(formatStat("Land", cLandType, total)); + DeckAnalysis.this.jLabelLandType.setText(DeckAnalysis.this.formatStat("Land", cLandType, total)); if (cPlaneswalker == 0) { - jLabelPlaneswalker.setForeground(cr); + DeckAnalysis.this.jLabelPlaneswalker.setForeground(cr); } - jLabelPlaneswalker.setText(formatStat("Planeswalker", cPlaneswalker, total)); + DeckAnalysis.this.jLabelPlaneswalker.setText(DeckAnalysis.this.formatStat("Planeswalker", + cPlaneswalker, total)); if (cSorcery == 0) { - jLabelSorcery.setForeground(cr); + DeckAnalysis.this.jLabelSorcery.setForeground(cr); } - jLabelSorcery.setText(formatStat("Sorcery", cSorcery, total)); + DeckAnalysis.this.jLabelSorcery.setText(DeckAnalysis.this.formatStat("Sorcery", cSorcery, total)); if (mZero == 0) { - jLabelZeroMana.setForeground(cr); + DeckAnalysis.this.jLabelZeroMana.setForeground(cr); } - jLabelZeroMana.setText(formatStat("Zero mana", mZero, total)); + DeckAnalysis.this.jLabelZeroMana.setText(DeckAnalysis.this.formatStat("Zero mana", mZero, total)); if (mOne == 0) { - jLabelOneMana.setForeground(cr); + DeckAnalysis.this.jLabelOneMana.setForeground(cr); } - jLabelOneMana.setText(formatStat("One mana", mOne, total)); + DeckAnalysis.this.jLabelOneMana.setText(DeckAnalysis.this.formatStat("One mana", mOne, total)); if (mTwo == 0) { - jLabelTwoMana.setForeground(cr); + DeckAnalysis.this.jLabelTwoMana.setForeground(cr); } - jLabelTwoMana.setText(formatStat("Two mana", mTwo, total)); + DeckAnalysis.this.jLabelTwoMana.setText(DeckAnalysis.this.formatStat("Two mana", mTwo, total)); if (mThree == 0) { - jLabelThreeMana.setForeground(cr); + DeckAnalysis.this.jLabelThreeMana.setForeground(cr); } - jLabelThreeMana.setText(formatStat("Three mana", mThree, total)); + DeckAnalysis.this.jLabelThreeMana.setText(DeckAnalysis.this.formatStat("Three mana", mThree, total)); if (mFour == 0) { - jLabelFourMana.setForeground(cr); + DeckAnalysis.this.jLabelFourMana.setForeground(cr); } - jLabelFourMana.setText(formatStat("Four mana", mFour, total)); + DeckAnalysis.this.jLabelFourMana.setText(DeckAnalysis.this.formatStat("Four mana", mFour, total)); if (mFive == 0) { - jLabelFiveMana.setForeground(cr); + DeckAnalysis.this.jLabelFiveMana.setForeground(cr); } - jLabelFiveMana.setText(formatStat("Five mana", mFive, total)); + DeckAnalysis.this.jLabelFiveMana.setText(DeckAnalysis.this.formatStat("Five mana", mFive, total)); if (mSixMore == 0) { - jLabelSixMana.setForeground(cr); + DeckAnalysis.this.jLabelSixMana.setForeground(cr); } - jLabelSixMana.setText(formatStat("Six and more", mSixMore, total)); + DeckAnalysis.this.jLabelSixMana.setText(DeckAnalysis.this.formatStat("Six and more", mSixMore, + total)); } }); - getContentPane().add(getJButton1()); - getContentPane().add(getJLabel1xx()); - getContentPane().add(getJButtonOk()); - getContentPane().add(getJPanel1()); - getContentPane().add(getJPanel2()); - getContentPane().add(getJPanel3()); - getContentPane().add(getJPanel4()); - getContentPane().add(getJPanel5()); - getContentPane().add(getJLabel1xxxxx()); + this.getContentPane().add(this.getJButton1()); + this.getContentPane().add(this.getJLabel1xx()); + this.getContentPane().add(this.getJButtonOk()); + this.getContentPane().add(this.getJPanel1()); + this.getContentPane().add(this.getJPanel2()); + this.getContentPane().add(this.getJPanel3()); + this.getContentPane().add(this.getJPanel4()); + this.getContentPane().add(this.getJPanel5()); + this.getContentPane().add(this.getJLabel1xxxxx()); - } catch (Exception e) { + } catch (final Exception e) { e.printStackTrace(); } } private String formatStat(final String statName, final int value, final int deckSize) { - return String.format("%s: %d (%f%%)", statName, value, 100f * value / deckSize); + return String.format("%s: %d (%f%%)", statName, value, (100f * value) / deckSize); } /** @@ -385,25 +389,25 @@ public class DeckAnalysis extends javax.swing.JDialog { * @return a {@link javax.swing.JPanel} object. */ private JPanel getJPanel1() { - if (jPanel1 == null) { - jPanel1 = new JPanel(); + if (this.jPanel1 == null) { + this.jPanel1 = new JPanel(); - jPanel1.setLayout(null); - jPanel1.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); - jPanel1.setBackground(new java.awt.Color(192, 192, 192)); - jPanel1.setBounds(5, 35, 137, 203); - jPanel1.add(getJLabel1()); - jPanel1.add(getJSeparator1()); - jPanel1.add(getJLabel2()); - jPanel1.add(getJLabel3()); - jPanel1.add(getJLabel4()); - jPanel1.add(getJLabel5()); - jPanel1.add(getJLabel6()); - jPanel1.add(getJLabel7()); - jPanel1.add(getJLabel8()); - jPanel1.add(getJLabel1x()); + this.jPanel1.setLayout(null); + this.jPanel1.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); + this.jPanel1.setBackground(new java.awt.Color(192, 192, 192)); + this.jPanel1.setBounds(5, 35, 137, 203); + this.jPanel1.add(this.getJLabel1()); + this.jPanel1.add(this.getJSeparator1()); + this.jPanel1.add(this.getJLabel2()); + this.jPanel1.add(this.getJLabel3()); + this.jPanel1.add(this.getJLabel4()); + this.jPanel1.add(this.getJLabel5()); + this.jPanel1.add(this.getJLabel6()); + this.jPanel1.add(this.getJLabel7()); + this.jPanel1.add(this.getJLabel8()); + this.jPanel1.add(this.getJLabel1x()); } - return jPanel1; + return this.jPanel1; } /** @@ -414,16 +418,16 @@ public class DeckAnalysis extends javax.swing.JDialog { * @return a {@link javax.swing.JLabel} object. */ private JLabel getJLabel2() { - if (jLabel2 == null) { - jLabel2 = new JLabel(); - jLabel2.setText("Color"); - jLabel2.setHorizontalAlignment(SwingConstants.CENTER); - jLabel2.setFont(new java.awt.Font("Segoe UI", 0, 14)); - jLabel2.setPreferredSize(new java.awt.Dimension(152, 39)); - jLabel2.setLayout(null); - jLabel2.setBounds(2, -3, 135, 26); + if (this.jLabel2 == null) { + this.jLabel2 = new JLabel(); + this.jLabel2.setText("Color"); + this.jLabel2.setHorizontalAlignment(SwingConstants.CENTER); + this.jLabel2.setFont(new java.awt.Font("Segoe UI", 0, 14)); + this.jLabel2.setPreferredSize(new java.awt.Dimension(152, 39)); + this.jLabel2.setLayout(null); + this.jLabel2.setBounds(2, -3, 135, 26); } - return jLabel2; + return this.jLabel2; } /** @@ -434,13 +438,13 @@ public class DeckAnalysis extends javax.swing.JDialog { * @return a {@link javax.swing.JSeparator} object. */ private JSeparator getJSeparator1() { - if (jSeparator1 == null) { - jSeparator1 = new JSeparator(); - jSeparator1.setPreferredSize(new java.awt.Dimension(117, 6)); - jSeparator1.setLayout(null); - jSeparator1.setBounds(1, 20, 136, 5); + if (this.jSeparator1 == null) { + this.jSeparator1 = new JSeparator(); + this.jSeparator1.setPreferredSize(new java.awt.Dimension(117, 6)); + this.jSeparator1.setLayout(null); + this.jSeparator1.setBounds(1, 20, 136, 5); } - return jSeparator1; + return this.jSeparator1; } /** @@ -451,20 +455,20 @@ public class DeckAnalysis extends javax.swing.JDialog { * @return a {@link javax.swing.JButton} object. */ private JButton getJButtonOk() { - if (jButtonOk == null) { - jButtonOk = new JButton(); - jButtonOk.setLayout(null); - jButtonOk.setText("OK"); - jButtonOk.setBounds(206, 536, 168, 31); - jButtonOk.addMouseListener(new MouseInputAdapter() { + if (this.jButtonOk == null) { + this.jButtonOk = new JButton(); + this.jButtonOk.setLayout(null); + this.jButtonOk.setText("OK"); + this.jButtonOk.setBounds(206, 536, 168, 31); + this.jButtonOk.addMouseListener(new MouseInputAdapter() { @Override public void mouseClicked(final MouseEvent e) { - jF.setEnabled(true); - dispose(); + DeckAnalysis.this.jF.setEnabled(true); + DeckAnalysis.this.dispose(); } }); } - return jButtonOk; + return this.jButtonOk; } /** @@ -475,14 +479,14 @@ public class DeckAnalysis extends javax.swing.JDialog { * @return a {@link javax.swing.JLabel} object. */ private JLabel getJLabel1() { - if (jLabelBlack == null) { - jLabelBlack = new JLabel(); - jLabelBlack.setText("Black:"); - jLabelBlack.setPreferredSize(new java.awt.Dimension(105, 12)); - jLabelBlack.setLayout(null); - jLabelBlack.setBounds(10, 28, 127, 13); + if (this.jLabelBlack == null) { + this.jLabelBlack = new JLabel(); + this.jLabelBlack.setText("Black:"); + this.jLabelBlack.setPreferredSize(new java.awt.Dimension(105, 12)); + this.jLabelBlack.setLayout(null); + this.jLabelBlack.setBounds(10, 28, 127, 13); } - return jLabelBlack; + return this.jLabelBlack; } /** @@ -493,13 +497,13 @@ public class DeckAnalysis extends javax.swing.JDialog { * @return a {@link javax.swing.JLabel} object. */ private JLabel getJLabel3() { - if (jLabelBlue == null) { - jLabelBlue = new JLabel(); - jLabelBlue.setText("Blue:"); - jLabelBlue.setLayout(null); - jLabelBlue.setBounds(10, 50, 127, 13); + if (this.jLabelBlue == null) { + this.jLabelBlue = new JLabel(); + this.jLabelBlue.setText("Blue:"); + this.jLabelBlue.setLayout(null); + this.jLabelBlue.setBounds(10, 50, 127, 13); } - return jLabelBlue; + return this.jLabelBlue; } /** @@ -510,13 +514,13 @@ public class DeckAnalysis extends javax.swing.JDialog { * @return a {@link javax.swing.JLabel} object. */ private JLabel getJLabel4() { - if (jLabelGreen == null) { - jLabelGreen = new JLabel(); - jLabelGreen.setText("Green:"); - jLabelGreen.setLayout(null); - jLabelGreen.setBounds(10, 72, 127, 13); + if (this.jLabelGreen == null) { + this.jLabelGreen = new JLabel(); + this.jLabelGreen.setText("Green:"); + this.jLabelGreen.setLayout(null); + this.jLabelGreen.setBounds(10, 72, 127, 13); } - return jLabelGreen; + return this.jLabelGreen; } /** @@ -527,13 +531,13 @@ public class DeckAnalysis extends javax.swing.JDialog { * @return a {@link javax.swing.JLabel} object. */ private JLabel getJLabel5() { - if (jLabelRed == null) { - jLabelRed = new JLabel(); - jLabelRed.setText("Red:"); - jLabelRed.setLayout(null); - jLabelRed.setBounds(10, 94, 127, 14); + if (this.jLabelRed == null) { + this.jLabelRed = new JLabel(); + this.jLabelRed.setText("Red:"); + this.jLabelRed.setLayout(null); + this.jLabelRed.setBounds(10, 94, 127, 14); } - return jLabelRed; + return this.jLabelRed; } /** @@ -544,13 +548,13 @@ public class DeckAnalysis extends javax.swing.JDialog { * @return a {@link javax.swing.JLabel} object. */ private JLabel getJLabel6() { - if (jLabelWhite == null) { - jLabelWhite = new JLabel(); - jLabelWhite.setText("White:"); - jLabelWhite.setLayout(null); - jLabelWhite.setBounds(10, 116, 127, 13); + if (this.jLabelWhite == null) { + this.jLabelWhite = new JLabel(); + this.jLabelWhite.setText("White:"); + this.jLabelWhite.setLayout(null); + this.jLabelWhite.setBounds(10, 116, 127, 13); } - return jLabelWhite; + return this.jLabelWhite; } /** @@ -561,13 +565,13 @@ public class DeckAnalysis extends javax.swing.JDialog { * @return a {@link javax.swing.JLabel} object. */ private JLabel getJLabel7() { - if (jLabelMultiColor == null) { - jLabelMultiColor = new JLabel(); - jLabelMultiColor.setText("Multicolor:"); - jLabelMultiColor.setLayout(null); - jLabelMultiColor.setBounds(10, 138, 127, 12); + if (this.jLabelMultiColor == null) { + this.jLabelMultiColor = new JLabel(); + this.jLabelMultiColor.setText("Multicolor:"); + this.jLabelMultiColor.setLayout(null); + this.jLabelMultiColor.setBounds(10, 138, 127, 12); } - return jLabelMultiColor; + return this.jLabelMultiColor; } /** @@ -578,13 +582,13 @@ public class DeckAnalysis extends javax.swing.JDialog { * @return a {@link javax.swing.JLabel} object. */ private JLabel getJLabel8() { - if (jLabelColorless == null) { - jLabelColorless = new JLabel(); - jLabelColorless.setText("Colorless:"); - jLabelColorless.setLayout(null); - jLabelColorless.setBounds(10, 160, 128, 11); + if (this.jLabelColorless == null) { + this.jLabelColorless = new JLabel(); + this.jLabelColorless.setText("Colorless:"); + this.jLabelColorless.setLayout(null); + this.jLabelColorless.setBounds(10, 160, 128, 11); } - return jLabelColorless; + return this.jLabelColorless; } /** @@ -595,13 +599,13 @@ public class DeckAnalysis extends javax.swing.JDialog { * @return a {@link javax.swing.JLabel} object. */ private JLabel getJLabel1x() { - if (jLabelLand == null) { - jLabelLand = new JLabel(); - jLabelLand.setText("Land: "); - jLabelLand.setLayout(null); - jLabelLand.setBounds(10, 182, 129, 10); + if (this.jLabelLand == null) { + this.jLabelLand = new JLabel(); + this.jLabelLand.setText("Land: "); + this.jLabelLand.setLayout(null); + this.jLabelLand.setBounds(10, 182, 129, 10); } - return jLabelLand; + return this.jLabelLand; } /** @@ -612,13 +616,13 @@ public class DeckAnalysis extends javax.swing.JDialog { * @return a {@link javax.swing.JLabel} object. */ private JLabel getJLabel1xx() { - if (jLabelTotal == null) { - jLabelTotal = new JLabel(); - jLabelTotal.setText("Information about deck:"); - jLabelTotal.setLayout(null); - jLabelTotal.setBounds(5, 0, 454, 35); + if (this.jLabelTotal == null) { + this.jLabelTotal = new JLabel(); + this.jLabelTotal.setText("Information about deck:"); + this.jLabelTotal.setLayout(null); + this.jLabelTotal.setBounds(5, 0, 454, 35); } - return jLabelTotal; + return this.jLabelTotal; } /** @@ -629,24 +633,24 @@ public class DeckAnalysis extends javax.swing.JDialog { * @return a {@link javax.swing.JPanel} object. */ private JPanel getJPanel2() { - if (jPanel2 == null) { - jPanel2 = new JPanel(); + if (this.jPanel2 == null) { + this.jPanel2 = new JPanel(); - jPanel2.setBackground(new java.awt.Color(192, 192, 192)); - jPanel2.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); - jPanel2.setLayout(null); - jPanel2.setBounds(153, 35, 137, 203); - jPanel2.add(getJLabel1xxx()); - jPanel2.add(getJSeparator2()); - jPanel2.add(getJLabel3x()); - jPanel2.add(getJLabel4x()); - jPanel2.add(getJLabel5x()); - jPanel2.add(getJLabel6x()); - jPanel2.add(getJLabel7x()); - jPanel2.add(getJLabel8x()); - jPanel2.add(getJLabel10()); + this.jPanel2.setBackground(new java.awt.Color(192, 192, 192)); + this.jPanel2.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); + this.jPanel2.setLayout(null); + this.jPanel2.setBounds(153, 35, 137, 203); + this.jPanel2.add(this.getJLabel1xxx()); + this.jPanel2.add(this.getJSeparator2()); + this.jPanel2.add(this.getJLabel3x()); + this.jPanel2.add(this.getJLabel4x()); + this.jPanel2.add(this.getJLabel5x()); + this.jPanel2.add(this.getJLabel6x()); + this.jPanel2.add(this.getJLabel7x()); + this.jPanel2.add(this.getJLabel8x()); + this.jPanel2.add(this.getJLabel10()); } - return jPanel2; + return this.jPanel2; } /** @@ -657,14 +661,14 @@ public class DeckAnalysis extends javax.swing.JDialog { * @return a {@link javax.swing.JLabel} object. */ private JLabel getJLabel1xxx() { - if (jLabelArtifact == null) { - jLabelArtifact = new JLabel(); - jLabelArtifact.setText("Artifact:"); - jLabelArtifact.setPreferredSize(new java.awt.Dimension(105, 12)); - jLabelArtifact.setLayout(null); - jLabelArtifact.setBounds(10, 28, 127, 13); + if (this.jLabelArtifact == null) { + this.jLabelArtifact = new JLabel(); + this.jLabelArtifact.setText("Artifact:"); + this.jLabelArtifact.setPreferredSize(new java.awt.Dimension(105, 12)); + this.jLabelArtifact.setLayout(null); + this.jLabelArtifact.setBounds(10, 28, 127, 13); } - return jLabelArtifact; + return this.jLabelArtifact; } /** @@ -675,13 +679,13 @@ public class DeckAnalysis extends javax.swing.JDialog { * @return a {@link javax.swing.JSeparator} object. */ private JSeparator getJSeparator2() { - if (jSeparator2 == null) { - jSeparator2 = new JSeparator(); - jSeparator2.setPreferredSize(new java.awt.Dimension(117, 6)); - jSeparator2.setLayout(null); - jSeparator2.setBounds(1, 20, 136, 5); + if (this.jSeparator2 == null) { + this.jSeparator2 = new JSeparator(); + this.jSeparator2.setPreferredSize(new java.awt.Dimension(117, 6)); + this.jSeparator2.setLayout(null); + this.jSeparator2.setBounds(1, 20, 136, 5); } - return jSeparator2; + return this.jSeparator2; } /** @@ -692,16 +696,16 @@ public class DeckAnalysis extends javax.swing.JDialog { * @return a {@link javax.swing.JLabel} object. */ private JLabel getJLabel3x() { - if (jLabel3 == null) { - jLabel3 = new JLabel(); - jLabel3.setText("Type"); - jLabel3.setHorizontalAlignment(SwingConstants.CENTER); - jLabel3.setFont(new java.awt.Font("Segoe UI", 0, 14)); - jLabel3.setPreferredSize(new java.awt.Dimension(152, 39)); - jLabel3.setLayout(null); - jLabel3.setBounds(2, -3, 135, 26); + if (this.jLabel3 == null) { + this.jLabel3 = new JLabel(); + this.jLabel3.setText("Type"); + this.jLabel3.setHorizontalAlignment(SwingConstants.CENTER); + this.jLabel3.setFont(new java.awt.Font("Segoe UI", 0, 14)); + this.jLabel3.setPreferredSize(new java.awt.Dimension(152, 39)); + this.jLabel3.setLayout(null); + this.jLabel3.setBounds(2, -3, 135, 26); } - return jLabel3; + return this.jLabel3; } /** @@ -712,13 +716,13 @@ public class DeckAnalysis extends javax.swing.JDialog { * @return a {@link javax.swing.JLabel} object. */ private JLabel getJLabel4x() { - if (jLabelCreature == null) { - jLabelCreature = new JLabel(); - jLabelCreature.setText("Creature:"); - jLabelCreature.setLayout(null); - jLabelCreature.setBounds(10, 53, 127, 13); + if (this.jLabelCreature == null) { + this.jLabelCreature = new JLabel(); + this.jLabelCreature.setText("Creature:"); + this.jLabelCreature.setLayout(null); + this.jLabelCreature.setBounds(10, 53, 127, 13); } - return jLabelCreature; + return this.jLabelCreature; } /** @@ -729,13 +733,13 @@ public class DeckAnalysis extends javax.swing.JDialog { * @return a {@link javax.swing.JLabel} object. */ private JLabel getJLabel5x() { - if (jLabelEnchant == null) { - jLabelEnchant = new JLabel(); - jLabelEnchant.setText("Enchant:"); - jLabelEnchant.setLayout(null); - jLabelEnchant.setBounds(10, 79, 127, 13); + if (this.jLabelEnchant == null) { + this.jLabelEnchant = new JLabel(); + this.jLabelEnchant.setText("Enchant:"); + this.jLabelEnchant.setLayout(null); + this.jLabelEnchant.setBounds(10, 79, 127, 13); } - return jLabelEnchant; + return this.jLabelEnchant; } /** @@ -746,13 +750,13 @@ public class DeckAnalysis extends javax.swing.JDialog { * @return a {@link javax.swing.JLabel} object. */ private JLabel getJLabel6x() { - if (jLabelInstant == null) { - jLabelInstant = new JLabel(); - jLabelInstant.setText("Instant:"); - jLabelInstant.setLayout(null); - jLabelInstant.setBounds(10, 105, 127, 14); + if (this.jLabelInstant == null) { + this.jLabelInstant = new JLabel(); + this.jLabelInstant.setText("Instant:"); + this.jLabelInstant.setLayout(null); + this.jLabelInstant.setBounds(10, 105, 127, 14); } - return jLabelInstant; + return this.jLabelInstant; } /** @@ -763,13 +767,13 @@ public class DeckAnalysis extends javax.swing.JDialog { * @return a {@link javax.swing.JLabel} object. */ private JLabel getJLabel7x() { - if (jLabelLandType == null) { - jLabelLandType = new JLabel(); - jLabelLandType.setText("Land:"); - jLabelLandType.setLayout(null); - jLabelLandType.setBounds(10, 130, 127, 13); + if (this.jLabelLandType == null) { + this.jLabelLandType = new JLabel(); + this.jLabelLandType.setText("Land:"); + this.jLabelLandType.setLayout(null); + this.jLabelLandType.setBounds(10, 130, 127, 13); } - return jLabelLandType; + return this.jLabelLandType; } /** @@ -780,13 +784,13 @@ public class DeckAnalysis extends javax.swing.JDialog { * @return a {@link javax.swing.JLabel} object. */ private JLabel getJLabel8x() { - if (jLabelPlaneswalker == null) { - jLabelPlaneswalker = new JLabel(); - jLabelPlaneswalker.setText("Planeswalker:"); - jLabelPlaneswalker.setLayout(null); - jLabelPlaneswalker.setBounds(10, 156, 127, 13); + if (this.jLabelPlaneswalker == null) { + this.jLabelPlaneswalker = new JLabel(); + this.jLabelPlaneswalker.setText("Planeswalker:"); + this.jLabelPlaneswalker.setLayout(null); + this.jLabelPlaneswalker.setBounds(10, 156, 127, 13); } - return jLabelPlaneswalker; + return this.jLabelPlaneswalker; } /** @@ -797,13 +801,13 @@ public class DeckAnalysis extends javax.swing.JDialog { * @return a {@link javax.swing.JLabel} object. */ private JLabel getJLabel10() { - if (jLabelSorcery == null) { - jLabelSorcery = new JLabel(); - jLabelSorcery.setText("Sorcery:"); - jLabelSorcery.setLayout(null); - jLabelSorcery.setBounds(10, 182, 127, 11); + if (this.jLabelSorcery == null) { + this.jLabelSorcery = new JLabel(); + this.jLabelSorcery.setText("Sorcery:"); + this.jLabelSorcery.setLayout(null); + this.jLabelSorcery.setBounds(10, 182, 127, 11); } - return jLabelSorcery; + return this.jLabelSorcery; } /** @@ -814,23 +818,23 @@ public class DeckAnalysis extends javax.swing.JDialog { * @return a {@link javax.swing.JPanel} object. */ private JPanel getJPanel3() { - if (jPanel3 == null) { - jPanel3 = new JPanel(); - jPanel3.setBackground(new java.awt.Color(192, 192, 192)); - jPanel3.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); - jPanel3.setLayout(null); - jPanel3.setBounds(302, 35, 137, 203); - jPanel3.add(getJLabel1xxxx()); - jPanel3.add(getJSeparator3()); - jPanel3.add(getJLabel4xx()); - jPanel3.add(getJLabel5xx()); - jPanel3.add(getJLabel6xx()); - jPanel3.add(getJLabel7xx()); - jPanel3.add(getJLabel8xx()); - jPanel3.add(getJLabel9()); - jPanel3.add(getJLabel10x()); + if (this.jPanel3 == null) { + this.jPanel3 = new JPanel(); + this.jPanel3.setBackground(new java.awt.Color(192, 192, 192)); + this.jPanel3.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); + this.jPanel3.setLayout(null); + this.jPanel3.setBounds(302, 35, 137, 203); + this.jPanel3.add(this.getJLabel1xxxx()); + this.jPanel3.add(this.getJSeparator3()); + this.jPanel3.add(this.getJLabel4xx()); + this.jPanel3.add(this.getJLabel5xx()); + this.jPanel3.add(this.getJLabel6xx()); + this.jPanel3.add(this.getJLabel7xx()); + this.jPanel3.add(this.getJLabel8xx()); + this.jPanel3.add(this.getJLabel9()); + this.jPanel3.add(this.getJLabel10x()); } - return jPanel3; + return this.jPanel3; } /** @@ -841,14 +845,14 @@ public class DeckAnalysis extends javax.swing.JDialog { * @return a {@link javax.swing.JLabel} object. */ private JLabel getJLabel1xxxx() { - if (jLabelZeroMana == null) { - jLabelZeroMana = new JLabel(); - jLabelZeroMana.setText("Zero mana:"); - jLabelZeroMana.setPreferredSize(new java.awt.Dimension(105, 12)); - jLabelZeroMana.setLayout(null); - jLabelZeroMana.setBounds(10, 28, 127, 13); + if (this.jLabelZeroMana == null) { + this.jLabelZeroMana = new JLabel(); + this.jLabelZeroMana.setText("Zero mana:"); + this.jLabelZeroMana.setPreferredSize(new java.awt.Dimension(105, 12)); + this.jLabelZeroMana.setLayout(null); + this.jLabelZeroMana.setBounds(10, 28, 127, 13); } - return jLabelZeroMana; + return this.jLabelZeroMana; } /** @@ -859,13 +863,13 @@ public class DeckAnalysis extends javax.swing.JDialog { * @return a {@link javax.swing.JSeparator} object. */ private JSeparator getJSeparator3() { - if (jSeparator3 == null) { - jSeparator3 = new JSeparator(); - jSeparator3.setPreferredSize(new java.awt.Dimension(117, 6)); - jSeparator3.setLayout(null); - jSeparator3.setBounds(1, 20, 136, 5); + if (this.jSeparator3 == null) { + this.jSeparator3 = new JSeparator(); + this.jSeparator3.setPreferredSize(new java.awt.Dimension(117, 6)); + this.jSeparator3.setLayout(null); + this.jSeparator3.setBounds(1, 20, 136, 5); } - return jSeparator3; + return this.jSeparator3; } /** @@ -876,16 +880,16 @@ public class DeckAnalysis extends javax.swing.JDialog { * @return a {@link javax.swing.JLabel} object. */ private JLabel getJLabel4xx() { - if (jLabelManaCost == null) { - jLabelManaCost = new JLabel(); - jLabelManaCost.setText("Mana cost"); - jLabelManaCost.setHorizontalAlignment(SwingConstants.CENTER); - jLabelManaCost.setFont(new java.awt.Font("Segoe UI", 0, 14)); - jLabelManaCost.setPreferredSize(new java.awt.Dimension(152, 39)); - jLabelManaCost.setLayout(null); - jLabelManaCost.setBounds(2, -3, 135, 26); + if (this.jLabelManaCost == null) { + this.jLabelManaCost = new JLabel(); + this.jLabelManaCost.setText("Mana cost"); + this.jLabelManaCost.setHorizontalAlignment(SwingConstants.CENTER); + this.jLabelManaCost.setFont(new java.awt.Font("Segoe UI", 0, 14)); + this.jLabelManaCost.setPreferredSize(new java.awt.Dimension(152, 39)); + this.jLabelManaCost.setLayout(null); + this.jLabelManaCost.setBounds(2, -3, 135, 26); } - return jLabelManaCost; + return this.jLabelManaCost; } /** @@ -896,13 +900,13 @@ public class DeckAnalysis extends javax.swing.JDialog { * @return a {@link javax.swing.JLabel} object. */ private JLabel getJLabel5xx() { - if (jLabelOneMana == null) { - jLabelOneMana = new JLabel(); - jLabelOneMana.setText("One mana:"); - jLabelOneMana.setLayout(null); - jLabelOneMana.setBounds(10, 53, 127, 13); + if (this.jLabelOneMana == null) { + this.jLabelOneMana = new JLabel(); + this.jLabelOneMana.setText("One mana:"); + this.jLabelOneMana.setLayout(null); + this.jLabelOneMana.setBounds(10, 53, 127, 13); } - return jLabelOneMana; + return this.jLabelOneMana; } /** @@ -913,13 +917,13 @@ public class DeckAnalysis extends javax.swing.JDialog { * @return a {@link javax.swing.JLabel} object. */ private JLabel getJLabel6xx() { - if (jLabelTwoMana == null) { - jLabelTwoMana = new JLabel(); - jLabelTwoMana.setText("Two mana:"); - jLabelTwoMana.setLayout(null); - jLabelTwoMana.setBounds(10, 79, 127, 13); + if (this.jLabelTwoMana == null) { + this.jLabelTwoMana = new JLabel(); + this.jLabelTwoMana.setText("Two mana:"); + this.jLabelTwoMana.setLayout(null); + this.jLabelTwoMana.setBounds(10, 79, 127, 13); } - return jLabelTwoMana; + return this.jLabelTwoMana; } /** @@ -930,13 +934,13 @@ public class DeckAnalysis extends javax.swing.JDialog { * @return a {@link javax.swing.JLabel} object. */ private JLabel getJLabel7xx() { - if (jLabelThreeMana == null) { - jLabelThreeMana = new JLabel(); - jLabelThreeMana.setText("Three mana:"); - jLabelThreeMana.setLayout(null); - jLabelThreeMana.setBounds(10, 105, 127, 14); + if (this.jLabelThreeMana == null) { + this.jLabelThreeMana = new JLabel(); + this.jLabelThreeMana.setText("Three mana:"); + this.jLabelThreeMana.setLayout(null); + this.jLabelThreeMana.setBounds(10, 105, 127, 14); } - return jLabelThreeMana; + return this.jLabelThreeMana; } /** @@ -947,13 +951,13 @@ public class DeckAnalysis extends javax.swing.JDialog { * @return a {@link javax.swing.JLabel} object. */ private JLabel getJLabel8xx() { - if (jLabelFourMana == null) { - jLabelFourMana = new JLabel(); - jLabelFourMana.setText("Four mana:"); - jLabelFourMana.setLayout(null); - jLabelFourMana.setBounds(10, 130, 127, 13); + if (this.jLabelFourMana == null) { + this.jLabelFourMana = new JLabel(); + this.jLabelFourMana.setText("Four mana:"); + this.jLabelFourMana.setLayout(null); + this.jLabelFourMana.setBounds(10, 130, 127, 13); } - return jLabelFourMana; + return this.jLabelFourMana; } /** @@ -964,13 +968,13 @@ public class DeckAnalysis extends javax.swing.JDialog { * @return a {@link javax.swing.JLabel} object. */ private JLabel getJLabel9() { - if (jLabelFiveMana == null) { - jLabelFiveMana = new JLabel(); - jLabelFiveMana.setText("Five mana:"); - jLabelFiveMana.setLayout(null); - jLabelFiveMana.setBounds(10, 156, 127, 13); + if (this.jLabelFiveMana == null) { + this.jLabelFiveMana = new JLabel(); + this.jLabelFiveMana.setText("Five mana:"); + this.jLabelFiveMana.setLayout(null); + this.jLabelFiveMana.setBounds(10, 156, 127, 13); } - return jLabelFiveMana; + return this.jLabelFiveMana; } /** @@ -981,13 +985,13 @@ public class DeckAnalysis extends javax.swing.JDialog { * @return a {@link javax.swing.JLabel} object. */ private JLabel getJLabel10x() { - if (jLabelSixMana == null) { - jLabelSixMana = new JLabel(); - jLabelSixMana.setText("Six and more:"); - jLabelSixMana.setLayout(null); - jLabelSixMana.setBounds(10, 182, 127, 11); + if (this.jLabelSixMana == null) { + this.jLabelSixMana = new JLabel(); + this.jLabelSixMana.setText("Six and more:"); + this.jLabelSixMana.setLayout(null); + this.jLabelSixMana.setBounds(10, 182, 127, 11); } - return jLabelSixMana; + return this.jLabelSixMana; } /** @@ -998,34 +1002,34 @@ public class DeckAnalysis extends javax.swing.JDialog { * @return a {@link javax.swing.JList} object. */ private JList getJList1() { - List rList = deck.toFlatList(); + final List rList = this.deck.toFlatList(); Collections.shuffle(rList, MyRandom.getRandom()); Collections.shuffle(rList, MyRandom.getRandom()); ListModel jList1Model; - if (jListFirstHand == null) { - jListFirstHand = new JList(); + if (this.jListFirstHand == null) { + this.jListFirstHand = new JList(); } if (rList.size() >= 40) { - jList1Model = new DefaultComboBoxModel(new String[] {rList.get(0).getName(), rList.get(1).getName(), + jList1Model = new DefaultComboBoxModel(new String[] { rList.get(0).getName(), rList.get(1).getName(), rList.get(2).getName(), rList.get(3).getName(), rList.get(4).getName(), rList.get(5).getName(), - rList.get(6).getName()}); + rList.get(6).getName() }); } else { - jList1Model = new DefaultComboBoxModel(new String[] {"Few cards."}); + jList1Model = new DefaultComboBoxModel(new String[] { "Few cards." }); } - jListFirstHand.setModel(jList1Model); - jListFirstHand.setLayout(null); - jListFirstHand.setBackground(new java.awt.Color(192, 192, 192)); - jListFirstHand.setSelectionBackground(new java.awt.Color(192, 192, 192)); - jListFirstHand.setSelectionForeground(new java.awt.Color(0, 0, 0)); - jListFirstHand.setFixedCellHeight(24); - jListFirstHand.setBounds(2, 21, 133, 167); + this.jListFirstHand.setModel(jList1Model); + this.jListFirstHand.setLayout(null); + this.jListFirstHand.setBackground(new java.awt.Color(192, 192, 192)); + this.jListFirstHand.setSelectionBackground(new java.awt.Color(192, 192, 192)); + this.jListFirstHand.setSelectionForeground(new java.awt.Color(0, 0, 0)); + this.jListFirstHand.setFixedCellHeight(24); + this.jListFirstHand.setBounds(2, 21, 133, 167); - return jListFirstHand; + return this.jListFirstHand; } /** @@ -1036,29 +1040,29 @@ public class DeckAnalysis extends javax.swing.JDialog { * @return a {@link javax.swing.JPanel} object. */ private JPanel getJPanel4() { - if (jPanel4 == null) { - jPanel4 = new JPanel(); - jPanel4.setBackground(new java.awt.Color(192, 192, 192)); - jPanel4.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); - jPanel4.setLayout(null); - jPanel4.setBounds(451, 35, 137, 202); - jPanel4.add(getJSeparator4()); - jPanel4.add(getJLabel4xxx()); - jPanel4.add(getJList1()); - jPanel4.add(getJButton1()); + if (this.jPanel4 == null) { + this.jPanel4 = new JPanel(); + this.jPanel4.setBackground(new java.awt.Color(192, 192, 192)); + this.jPanel4.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); + this.jPanel4.setLayout(null); + this.jPanel4.setBounds(451, 35, 137, 202); + this.jPanel4.add(this.getJSeparator4()); + this.jPanel4.add(this.getJLabel4xxx()); + this.jPanel4.add(this.getJList1()); + this.jPanel4.add(this.getJButton1()); } else { - jPanel4.removeAll(); - MigLayout jPanel4Layout = new MigLayout(); - jPanel4.setBackground(new java.awt.Color(192, 192, 192)); - jPanel4.setPreferredSize(new java.awt.Dimension(139, 201)); - jPanel4.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); - jPanel4.setLayout(jPanel4Layout); - jPanel4.add(getJSeparator4()); - jPanel4.add(getJLabel4xxx()); - jPanel4.add(getJList1()); - jPanel4.add(getJButton1()); + this.jPanel4.removeAll(); + final MigLayout jPanel4Layout = new MigLayout(); + this.jPanel4.setBackground(new java.awt.Color(192, 192, 192)); + this.jPanel4.setPreferredSize(new java.awt.Dimension(139, 201)); + this.jPanel4.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); + this.jPanel4.setLayout(jPanel4Layout); + this.jPanel4.add(this.getJSeparator4()); + this.jPanel4.add(this.getJLabel4xxx()); + this.jPanel4.add(this.getJList1()); + this.jPanel4.add(this.getJButton1()); } - return jPanel4; + return this.jPanel4; } @@ -1070,13 +1074,13 @@ public class DeckAnalysis extends javax.swing.JDialog { * @return a {@link javax.swing.JSeparator} object. */ private JSeparator getJSeparator4() { - if (jSeparator4 == null) { - jSeparator4 = new JSeparator(); - jSeparator4.setPreferredSize(new java.awt.Dimension(138, 8)); - jSeparator4.setLayout(null); - jSeparator4.setBounds(0, 19, 137, 7); + if (this.jSeparator4 == null) { + this.jSeparator4 = new JSeparator(); + this.jSeparator4.setPreferredSize(new java.awt.Dimension(138, 8)); + this.jSeparator4.setLayout(null); + this.jSeparator4.setBounds(0, 19, 137, 7); } - return jSeparator4; + return this.jSeparator4; } /** @@ -1087,16 +1091,16 @@ public class DeckAnalysis extends javax.swing.JDialog { * @return a {@link javax.swing.JLabel} object. */ private JLabel getJLabel4xxx() { - if (jLabel4 == null) { - jLabel4 = new JLabel(); - jLabel4.setText("Random start hand"); - jLabel4.setHorizontalAlignment(SwingConstants.CENTER); - jLabel4.setFont(new java.awt.Font("Segoe UI", 0, 14)); - jLabel4.setPreferredSize(new java.awt.Dimension(136, 24)); - jLabel4.setLayout(null); - jLabel4.setBounds(2, 0, 135, 20); + if (this.jLabel4 == null) { + this.jLabel4 = new JLabel(); + this.jLabel4.setText("Random start hand"); + this.jLabel4.setHorizontalAlignment(SwingConstants.CENTER); + this.jLabel4.setFont(new java.awt.Font("Segoe UI", 0, 14)); + this.jLabel4.setPreferredSize(new java.awt.Dimension(136, 24)); + this.jLabel4.setLayout(null); + this.jLabel4.setBounds(2, 0, 135, 20); } - return jLabel4; + return this.jLabel4; } /** @@ -1108,25 +1112,26 @@ public class DeckAnalysis extends javax.swing.JDialog { */ private JButton getJButton1() { - if (jButtonRegenerate == null) { - if (deck.countAll() >= 40) { - jButtonRegenerate = new JButton(); - jButtonRegenerate.setLayout(null); - jButtonRegenerate.setText("Regenerate hand"); - jButtonRegenerate.setPreferredSize(new java.awt.Dimension(139, 21)); - jButtonRegenerate.setBounds(2, 189, 133, 13); - jButtonRegenerate.addActionListener(new java.awt.event.ActionListener() { + if (this.jButtonRegenerate == null) { + if (this.deck.countAll() >= 40) { + this.jButtonRegenerate = new JButton(); + this.jButtonRegenerate.setLayout(null); + this.jButtonRegenerate.setText("Regenerate hand"); + this.jButtonRegenerate.setPreferredSize(new java.awt.Dimension(139, 21)); + this.jButtonRegenerate.setBounds(2, 189, 133, 13); + this.jButtonRegenerate.addActionListener(new java.awt.event.ActionListener() { + @Override public void actionPerformed(final ActionEvent e) { - jButtonRegenerate_actionPerformed(e); + DeckAnalysis.this.jButtonRegenerateActionPerformed(e); } }); } else { - jButtonRegenerate = new JButton(); - jButtonRegenerate.setBounds(2, 189, 133, 13); - jButtonRegenerate.setVisible(false); + this.jButtonRegenerate = new JButton(); + this.jButtonRegenerate.setBounds(2, 189, 133, 13); + this.jButtonRegenerate.setVisible(false); } } - return jButtonRegenerate; + return this.jButtonRegenerate; } /** @@ -1137,18 +1142,18 @@ public class DeckAnalysis extends javax.swing.JDialog { * @param e * a {@link java.awt.event.ActionEvent} object. */ - final void jButtonRegenerate_actionPerformed(final ActionEvent e) { - getContentPane().removeAll(); - getContentPane().add(getJPanel5()); - getContentPane().add(getJLabel1xx()); - getContentPane().add(getJButtonOk()); - getContentPane().add(getJPanel1()); - getContentPane().add(getJPanel2()); - getContentPane().add(getJPanel3()); - getContentPane().add(getJPanel4()); - getContentPane().add(getJPanel5()); - getContentPane().add(getJLabel1xxxxx()); - getContentPane().repaint(); + final void jButtonRegenerateActionPerformed(final ActionEvent e) { + this.getContentPane().removeAll(); + this.getContentPane().add(this.getJPanel5()); + this.getContentPane().add(this.getJLabel1xx()); + this.getContentPane().add(this.getJButtonOk()); + this.getContentPane().add(this.getJPanel1()); + this.getContentPane().add(this.getJPanel2()); + this.getContentPane().add(this.getJPanel3()); + this.getContentPane().add(this.getJPanel4()); + this.getContentPane().add(this.getJPanel5()); + this.getContentPane().add(this.getJLabel1xxxxx()); + this.getContentPane().repaint(); } @@ -1160,14 +1165,14 @@ public class DeckAnalysis extends javax.swing.JDialog { * @return a {@link javax.swing.JPanel} object. */ private JPanel getJPanel5() { - if (jPanel5 == null) { - jPanel5 = new JPanel(); - jPanel5.setLayout(null); - jPanel5.setBounds(5, 262, 583, 270); - jPanel5.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); - jPanel5.add(getJScrollPane1()); + if (this.jPanel5 == null) { + this.jPanel5 = new JPanel(); + this.jPanel5.setLayout(null); + this.jPanel5.setBounds(5, 262, 583, 270); + this.jPanel5.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); + this.jPanel5.add(this.getJScrollPane1()); } - return jPanel5; + return this.jPanel5; } /** @@ -1178,14 +1183,14 @@ public class DeckAnalysis extends javax.swing.JDialog { * @return a {@link javax.swing.JTable} object. */ private JTable getJTable1() { - if (jTable1 == null) { - DefaultTableModel dm = new DefaultTableModel(); - dm.setDataVector(new Object[][] { {} }, new Object[] {"Card", "Qty", "1st", "2nd", "3rd", "4th", "5th", - "6th", "7th"}); + if (this.jTable1 == null) { + final DefaultTableModel dm = new DefaultTableModel(); + dm.setDataVector(new Object[][] { {} }, new Object[] { "Card", "Qty", "1st", "2nd", "3rd", "4th", "5th", + "6th", "7th" }); - jTable1 = new JTable(dm); - List rList = deck.toFlatList(); - String[] cardsName = new String[rList.size()]; + this.jTable1 = new JTable(dm); + final List rList = this.deck.toFlatList(); + final String[] cardsName = new String[rList.size()]; int cCount; float fCount; float firstTurnF, secondTurnF, thirdTurnF, fourthTurnF, fivethTurnF, sixthTurnF, seventhTurnF; @@ -1194,114 +1199,114 @@ public class DeckAnalysis extends javax.swing.JDialog { cardsName[i] = rList.get(i).getName(); } Arrays.sort(cardsName); - jTable1.setValueAt("Few cards.", 0, 0); + this.jTable1.setValueAt("Few cards.", 0, 0); if (rList.size() >= 40) { - jTable1.setValueAt(cardsName[0], 0, 0); + this.jTable1.setValueAt(cardsName[0], 0, 0); cCount = 1; for (int i = 1; i < cardsName.length; i++) { if (cardsName[i].equals(cardsName[i - 1])) { cCount = cCount + 1; } else { - dm.addRow(new Object[][] {{}}); - jTable1.setValueAt(cardsName[i], dm.getRowCount() - 1, 0); - jTable1.setValueAt(cCount, dm.getRowCount() - 2, 1); + dm.addRow(new Object[][] { {} }); + this.jTable1.setValueAt(cardsName[i], dm.getRowCount() - 1, 0); + this.jTable1.setValueAt(cCount, dm.getRowCount() - 2, 1); fCount = cCount; firstTurnF = fCount / rList.size(); BigDecimal firstTurn = new BigDecimal(firstTurnF * 100); firstTurn = firstTurn.setScale(1, BigDecimal.ROUND_HALF_UP); - jTable1.setValueAt(firstTurn.toString() + " %", dm.getRowCount() - 2, 2); + this.jTable1.setValueAt(firstTurn.toString() + " %", dm.getRowCount() - 2, 2); - secondTurnF = (1 - firstTurnF) * fCount / (rList.size() - 1) + firstTurnF; + secondTurnF = (((1 - firstTurnF) * fCount) / (rList.size() - 1)) + firstTurnF; BigDecimal secondTurn = new BigDecimal(secondTurnF * 100); secondTurn = secondTurn.setScale(1, BigDecimal.ROUND_HALF_UP); - jTable1.setValueAt(secondTurn.toString() + " %", dm.getRowCount() - 2, 3); + this.jTable1.setValueAt(secondTurn.toString() + " %", dm.getRowCount() - 2, 3); - thirdTurnF = (1 - secondTurnF) * fCount / (rList.size() - 2) + secondTurnF; + thirdTurnF = (((1 - secondTurnF) * fCount) / (rList.size() - 2)) + secondTurnF; BigDecimal thirdTurn = new BigDecimal(thirdTurnF * 100); thirdTurn = thirdTurn.setScale(1, BigDecimal.ROUND_HALF_UP); - jTable1.setValueAt(thirdTurn.toString() + " %", dm.getRowCount() - 2, 4); + this.jTable1.setValueAt(thirdTurn.toString() + " %", dm.getRowCount() - 2, 4); - fourthTurnF = (1 - thirdTurnF) * fCount / (rList.size() - 3) + thirdTurnF; + fourthTurnF = (((1 - thirdTurnF) * fCount) / (rList.size() - 3)) + thirdTurnF; BigDecimal fourthTurn = new BigDecimal(fourthTurnF * 100); fourthTurn = fourthTurn.setScale(1, BigDecimal.ROUND_HALF_UP); - jTable1.setValueAt(fourthTurn.toString() + " %", dm.getRowCount() - 2, 5); + this.jTable1.setValueAt(fourthTurn.toString() + " %", dm.getRowCount() - 2, 5); - fivethTurnF = (1 - fourthTurnF) * fCount / (rList.size() - 4) + fourthTurnF; + fivethTurnF = (((1 - fourthTurnF) * fCount) / (rList.size() - 4)) + fourthTurnF; BigDecimal fivethTurn = new BigDecimal(fivethTurnF * 100); fivethTurn = fivethTurn.setScale(1, BigDecimal.ROUND_HALF_UP); - jTable1.setValueAt(fivethTurn.toString() + " %", dm.getRowCount() - 2, 6); + this.jTable1.setValueAt(fivethTurn.toString() + " %", dm.getRowCount() - 2, 6); - sixthTurnF = (1 - fivethTurnF) * fCount / (rList.size() - 5) + fivethTurnF; + sixthTurnF = (((1 - fivethTurnF) * fCount) / (rList.size() - 5)) + fivethTurnF; BigDecimal sixthTurn = new BigDecimal(sixthTurnF * 100); sixthTurn = sixthTurn.setScale(1, BigDecimal.ROUND_HALF_UP); - jTable1.setValueAt(sixthTurn.toString() + " %", dm.getRowCount() - 2, 7); + this.jTable1.setValueAt(sixthTurn.toString() + " %", dm.getRowCount() - 2, 7); - seventhTurnF = (1 - sixthTurnF) * fCount / (rList.size() - 6) + sixthTurnF; + seventhTurnF = (((1 - sixthTurnF) * fCount) / (rList.size() - 6)) + sixthTurnF; BigDecimal seventhTurn = new BigDecimal(seventhTurnF * 100); seventhTurn = seventhTurn.setScale(1, BigDecimal.ROUND_HALF_UP); - jTable1.setValueAt(seventhTurn.toString() + " %", dm.getRowCount() - 2, 8); + this.jTable1.setValueAt(seventhTurn.toString() + " %", dm.getRowCount() - 2, 8); cCount = 1; } - if (i == cardsName.length - 1) { - jTable1.setValueAt(cCount, dm.getRowCount() - 1, 1); + if (i == (cardsName.length - 1)) { + this.jTable1.setValueAt(cCount, dm.getRowCount() - 1, 1); fCount = cCount; firstTurnF = fCount / rList.size(); BigDecimal firstTurn = new BigDecimal(firstTurnF * 100); firstTurn = firstTurn.setScale(1, BigDecimal.ROUND_HALF_UP); - jTable1.setValueAt(firstTurn.toString() + " %", dm.getRowCount() - 1, 2); + this.jTable1.setValueAt(firstTurn.toString() + " %", dm.getRowCount() - 1, 2); - secondTurnF = (1 - firstTurnF) * fCount / (rList.size() - 1) + firstTurnF; + secondTurnF = (((1 - firstTurnF) * fCount) / (rList.size() - 1)) + firstTurnF; BigDecimal secondTurn = new BigDecimal(secondTurnF * 100); secondTurn = secondTurn.setScale(1, BigDecimal.ROUND_HALF_UP); - jTable1.setValueAt(secondTurn.toString() + " %", dm.getRowCount() - 1, 3); + this.jTable1.setValueAt(secondTurn.toString() + " %", dm.getRowCount() - 1, 3); - thirdTurnF = (1 - secondTurnF) * fCount / (rList.size() - 2) + secondTurnF; + thirdTurnF = (((1 - secondTurnF) * fCount) / (rList.size() - 2)) + secondTurnF; BigDecimal thirdTurn = new BigDecimal(thirdTurnF * 100); thirdTurn = thirdTurn.setScale(1, BigDecimal.ROUND_HALF_UP); - jTable1.setValueAt(thirdTurn.toString() + " %", dm.getRowCount() - 1, 4); + this.jTable1.setValueAt(thirdTurn.toString() + " %", dm.getRowCount() - 1, 4); - fourthTurnF = (1 - thirdTurnF) * fCount / (rList.size() - 3) + thirdTurnF; + fourthTurnF = (((1 - thirdTurnF) * fCount) / (rList.size() - 3)) + thirdTurnF; BigDecimal fourthTurn = new BigDecimal(fourthTurnF * 100); fourthTurn = fourthTurn.setScale(1, BigDecimal.ROUND_HALF_UP); - jTable1.setValueAt(fourthTurn.toString() + " %", dm.getRowCount() - 1, 5); + this.jTable1.setValueAt(fourthTurn.toString() + " %", dm.getRowCount() - 1, 5); - fivethTurnF = (1 - fourthTurnF) * fCount / (rList.size() - 4) + fourthTurnF; + fivethTurnF = (((1 - fourthTurnF) * fCount) / (rList.size() - 4)) + fourthTurnF; BigDecimal fivethTurn = new BigDecimal(fivethTurnF * 100); fivethTurn = fivethTurn.setScale(1, BigDecimal.ROUND_HALF_UP); - jTable1.setValueAt(fivethTurn.toString() + " %", dm.getRowCount() - 1, 6); + this.jTable1.setValueAt(fivethTurn.toString() + " %", dm.getRowCount() - 1, 6); - sixthTurnF = (1 - fivethTurnF) * fCount / (rList.size() - 5) + fivethTurnF; + sixthTurnF = (((1 - fivethTurnF) * fCount) / (rList.size() - 5)) + fivethTurnF; BigDecimal sixthTurn = new BigDecimal(sixthTurnF * 100); sixthTurn = sixthTurn.setScale(1, BigDecimal.ROUND_HALF_UP); - jTable1.setValueAt(sixthTurn.toString() + " %", dm.getRowCount() - 1, 7); + this.jTable1.setValueAt(sixthTurn.toString() + " %", dm.getRowCount() - 1, 7); - seventhTurnF = (1 - sixthTurnF) * fCount / (rList.size() - 6) + sixthTurnF; + seventhTurnF = (((1 - sixthTurnF) * fCount) / (rList.size() - 6)) + sixthTurnF; BigDecimal seventhTurn = new BigDecimal(seventhTurnF * 100); seventhTurn = seventhTurn.setScale(1, BigDecimal.ROUND_HALF_UP); - jTable1.setValueAt(seventhTurn.toString() + " %", dm.getRowCount() - 1, 8); + this.jTable1.setValueAt(seventhTurn.toString() + " %", dm.getRowCount() - 1, 8); } } } - jTable1.getColumn("Qty").setMaxWidth(50); - jTable1.getColumn("1st").setMaxWidth(50); - jTable1.getColumn("2nd").setMaxWidth(50); - jTable1.getColumn("3rd").setMaxWidth(50); - jTable1.getColumn("4th").setMaxWidth(50); - jTable1.getColumn("5th").setMaxWidth(50); - jTable1.getColumn("6th").setMaxWidth(50); - jTable1.getColumn("7th").setMaxWidth(50); - jTable1.setRowHeight(18); - jTable1.setPreferredSize(new java.awt.Dimension(576, 18 * dm.getRowCount() + 3)); + this.jTable1.getColumn("Qty").setMaxWidth(50); + this.jTable1.getColumn("1st").setMaxWidth(50); + this.jTable1.getColumn("2nd").setMaxWidth(50); + this.jTable1.getColumn("3rd").setMaxWidth(50); + this.jTable1.getColumn("4th").setMaxWidth(50); + this.jTable1.getColumn("5th").setMaxWidth(50); + this.jTable1.getColumn("6th").setMaxWidth(50); + this.jTable1.getColumn("7th").setMaxWidth(50); + this.jTable1.setRowHeight(18); + this.jTable1.setPreferredSize(new java.awt.Dimension(576, (18 * dm.getRowCount()) + 3)); } - return jTable1; + return this.jTable1; } /** @@ -1312,13 +1317,13 @@ public class DeckAnalysis extends javax.swing.JDialog { * @return a {@link javax.swing.JScrollPane} object. */ private JScrollPane getJScrollPane1() { - if (jScrollPane1 == null) { - jScrollPane1 = new JScrollPane(); - jScrollPane1.setBounds(2, 2, 582, 268); - jScrollPane1.setSize(580, 268); - jScrollPane1.setViewportView(getJTable1()); + if (this.jScrollPane1 == null) { + this.jScrollPane1 = new JScrollPane(); + this.jScrollPane1.setBounds(2, 2, 582, 268); + this.jScrollPane1.setSize(580, 268); + this.jScrollPane1.setViewportView(this.getJTable1()); } - return jScrollPane1; + return this.jScrollPane1; } /** @@ -1329,13 +1334,13 @@ public class DeckAnalysis extends javax.swing.JDialog { * @return a {@link javax.swing.JLabel} object. */ private JLabel getJLabel1xxxxx() { - if (jLabel1 == null) { - jLabel1 = new JLabel(); - jLabel1.setText("Draw Probabilities:"); - jLabel1.setLayout(null); - jLabel1.setBounds(7, 237, 447, 25); + if (this.jLabel1 == null) { + this.jLabel1 = new JLabel(); + this.jLabel1.setText("Draw Probabilities:"); + this.jLabel1.setLayout(null); + this.jLabel1.setBounds(7, 237, 447, 25); } - return jLabel1; + return this.jLabel1; } } diff --git a/src/main/java/forge/gui/deckeditor/DeckEditorBase.java b/src/main/java/forge/gui/deckeditor/DeckEditorBase.java index a7463d5ea27..4ef689f2de2 100644 --- a/src/main/java/forge/gui/deckeditor/DeckEditorBase.java +++ b/src/main/java/forge/gui/deckeditor/DeckEditorBase.java @@ -24,21 +24,21 @@ public abstract class DeckEditorBase extends JFrame implements DeckDisplay { private static final long serialVersionUID = -401223933343539977L; /** The filter boxes. */ - protected FilterCheckBoxes filterBoxes; + private FilterCheckBoxes filterBoxes; // set this to false when resetting filter from code (like // "clearFiltersPressed"), reset when done. /** The is filters change firing update. */ - protected boolean isFiltersChangeFiringUpdate = true; + private boolean isFiltersChangeFiringUpdate = true; /** The card view. */ - protected CardPanelBase cardView; + private CardPanelBase cardView; // CardPools and Table data for top and bottom lists /** The top. */ - protected TableWithCards top; + private TableWithCards topTableWithCards; /** The bottom. */ - protected TableWithCards bottom; + private TableWithCards bottomTableWithCards; private GameType gameType; @@ -47,8 +47,9 @@ public abstract class DeckEditorBase extends JFrame implements DeckDisplay { * * @see forge.gui.deckeditor.DeckDisplay#getGameType() */ + @Override public final GameType getGameType() { - return gameType; + return this.gameType; } // top shows available card pool @@ -61,7 +62,7 @@ public abstract class DeckEditorBase extends JFrame implements DeckDisplay { * @return the top table model */ public final TableWithCards getTopTableModel() { - return top; + return this.getTopTableWithCards(); } /* @@ -69,8 +70,9 @@ public abstract class DeckEditorBase extends JFrame implements DeckDisplay { * * @see forge.gui.deckeditor.DeckDisplay#getTop() */ + @Override public final ItemPoolView getTop() { - return top.getCards(); + return this.getTopTableWithCards().getCards(); } // bottom shows player's choice - be it deck or draft @@ -79,8 +81,9 @@ public abstract class DeckEditorBase extends JFrame implements DeckDisplay { * * @see forge.gui.deckeditor.DeckDisplay#getBottom() */ + @Override public final ItemPoolView getBottom() { - return bottom.getCards(); + return this.getBottomTableWithCards().getCards(); } // THIS IS HERE FOR OVERLOADING!!!1 @@ -99,14 +102,15 @@ public abstract class DeckEditorBase extends JFrame implements DeckDisplay { * @param e * the e */ - final void analysisButton_actionPerformed(final ActionEvent e) { - ItemPoolView deck = ItemPool.createFrom(bottom.getCards(), CardPrinted.class); + final void analysisButtonActionPerformed(final ActionEvent e) { + final ItemPoolView deck = ItemPool.createFrom(this.getBottomTableWithCards().getCards(), + CardPrinted.class); if (deck.isEmpty()) { JOptionPane.showMessageDialog(null, "Cards in deck not found.", "Analysis Deck", JOptionPane.INFORMATION_MESSAGE); } else { - DeckEditorBase g = DeckEditorBase.this; - DeckAnalysis dAnalysis = new DeckAnalysis(g, deck); + final DeckEditorBase g = DeckEditorBase.this; + final DeckAnalysis dAnalysis = new DeckAnalysis(g, deck); dAnalysis.setVisible(true); g.setEnabled(false); } @@ -119,7 +123,7 @@ public abstract class DeckEditorBase extends JFrame implements DeckDisplay { * the gametype */ public DeckEditorBase(final GameType gametype) { - gameType = gametype; + this.gameType = gametype; } /* @@ -128,11 +132,12 @@ public abstract class DeckEditorBase extends JFrame implements DeckDisplay { * @see forge.gui.deckeditor.DeckDisplay#setDeck(forge.item.ItemPoolView, * forge.item.ItemPoolView, forge.game.GameType) */ + @Override public void setDeck(final ItemPoolView topParam, final ItemPoolView bottomParam, final GameType gt) { - gameType = gt; - top.setDeck(topParam); - bottom.setDeck(bottomParam); + this.gameType = gt; + this.getTopTableWithCards().setDeck(topParam); + this.getBottomTableWithCards().setDeck(bottomParam); } /* @@ -141,25 +146,27 @@ public abstract class DeckEditorBase extends JFrame implements DeckDisplay { * @see forge.gui.deckeditor.DeckDisplay#setItems(forge.item.ItemPoolView, * forge.item.ItemPoolView, forge.game.GameType) */ + @Override public final void setItems(final ItemPoolView topParam, final ItemPoolView bottomParam, final GameType gt) { - gameType = gt; - top.setDeck(topParam); - bottom.setDeck(bottomParam); + this.gameType = gt; + this.getTopTableWithCards().setDeck(topParam); + this.getBottomTableWithCards().setDeck(bottomParam); } /** * Update display. */ public final void updateDisplay() { - top.setFilter(buildFilter()); + this.getTopTableWithCards().setFilter(this.buildFilter()); } /** The item listener updates display. */ - protected ItemListener itemListenerUpdatesDisplay = new ItemListener() { + private ItemListener itemListenerUpdatesDisplay = new ItemListener() { + @Override public void itemStateChanged(final ItemEvent e) { - if (isFiltersChangeFiringUpdate) { - updateDisplay(); + if (DeckEditorBase.this.isFiltersChangeFiringUpdate()) { + DeckEditorBase.this.updateDisplay(); } } }; @@ -170,8 +177,8 @@ public abstract class DeckEditorBase extends JFrame implements DeckDisplay { */ protected class OnChangeTextUpdateDisplay implements DocumentListener { private void onChange() { - if (isFiltersChangeFiringUpdate) { - updateDisplay(); + if (DeckEditorBase.this.isFiltersChangeFiringUpdate()) { + DeckEditorBase.this.updateDisplay(); } } @@ -184,7 +191,7 @@ public abstract class DeckEditorBase extends JFrame implements DeckDisplay { */ @Override public final void insertUpdate(final DocumentEvent e) { - onChange(); + this.onChange(); } /* @@ -196,7 +203,7 @@ public abstract class DeckEditorBase extends JFrame implements DeckDisplay { */ @Override public final void removeUpdate(final DocumentEvent e) { - onChange(); + this.onChange(); } /* @@ -216,15 +223,116 @@ public abstract class DeckEditorBase extends JFrame implements DeckDisplay { * * @see forge.gui.deckeditor.DeckDisplay#getDeck() */ + @Override public final Deck getDeck() { - Deck deck = new Deck(gameType); - deck.addMain(ItemPool.createFrom(getBottom(), CardPrinted.class)); + final Deck deck = new Deck(this.gameType); + deck.addMain(ItemPool.createFrom(this.getBottom(), CardPrinted.class)); // if sealed or draft, move "top" to sideboard - if (gameType.isLimited() && gameType != GameType.Quest) { - deck.addSideboard(ItemPool.createFrom(getTop(), CardPrinted.class)); + if (this.gameType.isLimited() && (this.gameType != GameType.Quest)) { + deck.addSideboard(ItemPool.createFrom(this.getTop(), CardPrinted.class)); } return deck; - }// getDeck() + } // getDeck() + + /** + * @return the itemListenerUpdatesDisplay + */ + public ItemListener getItemListenerUpdatesDisplay() { + return itemListenerUpdatesDisplay; + } + + /** + * @param itemListenerUpdatesDisplay + * the itemListenerUpdatesDisplay to set + */ + public void setItemListenerUpdatesDisplay(ItemListener itemListenerUpdatesDisplay) { + this.itemListenerUpdatesDisplay = itemListenerUpdatesDisplay; // TODO: + // Add 0 + // to + // parameter's + // name. + } + + /** + * @return the isFiltersChangeFiringUpdate + */ + public boolean isFiltersChangeFiringUpdate() { + return isFiltersChangeFiringUpdate; + } + + /** + * @param isFiltersChangeFiringUpdate + * the isFiltersChangeFiringUpdate to set + */ + public void setFiltersChangeFiringUpdate(boolean isFiltersChangeFiringUpdate) { + this.isFiltersChangeFiringUpdate = isFiltersChangeFiringUpdate; // TODO: + // Add 0 + // to + // parameter's + // name. + } + + /** + * @return the cardView + */ + public CardPanelBase getCardView() { + return cardView; + } + + /** + * @param cardView + * the cardView to set + */ + public void setCardView(CardPanelBase cardView) { + this.cardView = cardView; // TODO: Add 0 to parameter's name. + } + + /** + * @return the filterBoxes + */ + public FilterCheckBoxes getFilterBoxes() { + return filterBoxes; + } + + /** + * @param filterBoxes + * the filterBoxes to set + */ + public void setFilterBoxes(FilterCheckBoxes filterBoxes) { + this.filterBoxes = filterBoxes; // TODO: Add 0 to parameter's name. + } + + /** + * @return the bottomTableWithCards + */ + public TableWithCards getBottomTableWithCards() { + return bottomTableWithCards; + } + + /** + * @param bottomTableWithCards + * the bottomTableWithCards to set + */ + public void setBottomTableWithCards(TableWithCards bottomTableWithCards) { + this.bottomTableWithCards = bottomTableWithCards; // TODO: Add 0 to + // parameter's name. + } + + /** + * @return the topTableWithCards + */ + public TableWithCards getTopTableWithCards() { + return topTableWithCards; + } + + /** + * @param topTableWithCards + * the topTableWithCards to set + */ + public void setTopTableWithCards(TableWithCards topTableWithCards) { + this.topTableWithCards = topTableWithCards; // TODO: Add 0 to + // parameter's name. + } } diff --git a/src/main/java/forge/gui/deckeditor/DeckEditorCommon.java b/src/main/java/forge/gui/deckeditor/DeckEditorCommon.java index a4211030a39..465d10c674e 100644 --- a/src/main/java/forge/gui/deckeditor/DeckEditorCommon.java +++ b/src/main/java/forge/gui/deckeditor/DeckEditorCommon.java @@ -40,20 +40,20 @@ import forge.item.ItemPoolView; * @version $Id$ */ public final class DeckEditorCommon extends DeckEditorBase { - /** Constant serialVersionUID=130339644136746796L */ + /** Constant serialVersionUID=130339644136746796L. */ private static final long serialVersionUID = 130339644136746796L; /** The custom menu. */ - public DeckEditorCommonMenu customMenu; + private DeckEditorCommonMenu customMenu; - private JButton removeButton = new JButton(); - private JButton addButton = new JButton(); - private JButton importButton = new JButton(); + private final JButton removeButton = new JButton(); + private final JButton addButton = new JButton(); + private final JButton importButton = new JButton(); - private JButton analysisButton = new JButton(); - private JButton clearFilterButton = new JButton(); + private final JButton analysisButton = new JButton(); + private final JButton clearFilterButton = new JButton(); - private JLabel jLabelAnalysisGap = new JLabel(""); + private final JLabel jLabelAnalysisGap = new JLabel(""); private FilterNameTypeSetPanel filterNameTypeSet; /** @@ -66,41 +66,44 @@ public final class DeckEditorCommon extends DeckEditorBase { final Command exit = new Command() { private static final long serialVersionUID = 5210924838133689758L; + @Override public void execute() { DeckEditorCommon.this.dispose(); exitCommand.execute(); } }; - customMenu = new DeckEditorCommonMenu(this, AllZone.getDeckManager(), exit); - this.setJMenuBar(customMenu); + this.setCustomMenu(new DeckEditorCommonMenu(this, AllZone.getDeckManager(), exit)); + this.setJMenuBar(this.getCustomMenu()); // do not change this!!!! this.addWindowListener(new WindowAdapter() { @Override public void windowClosing(final WindowEvent ev) { - customMenu.close(); + DeckEditorCommon.this.getCustomMenu().close(); } }); - setup(); + this.setup(); // show cards, makes this user friendly - if (!getGameType().isLimited()) { - customMenu.newConstructed(false); + if (!this.getGameType().isLimited()) { + this.getCustomMenu().newConstructed(false); } - top.sort(1, true); - bottom.sort(1, true); + this.getTopTableWithCards().sort(1, true); + this.getBottomTableWithCards().sort(1, true); } // show(Command) private void setup() { - List> columns = new ArrayList>(); - columns.add(new TableColumnInfo("Qty", 30, PresetColumns.FN_QTY_COMPARE, PresetColumns.FN_QTY_GET)); + final List> columns = new ArrayList>(); + columns.add(new TableColumnInfo("Qty", 30, PresetColumns.FN_QTY_COMPARE, + PresetColumns.FN_QTY_GET)); columns.add(new TableColumnInfo("Name", 175, PresetColumns.FN_NAME_COMPARE, PresetColumns.FN_NAME_GET)); - columns.add(new TableColumnInfo("Cost", 75, PresetColumns.FN_COST_COMPARE, PresetColumns.FN_COST_GET)); + columns.add(new TableColumnInfo("Cost", 75, PresetColumns.FN_COST_COMPARE, + PresetColumns.FN_COST_GET)); columns.add(new TableColumnInfo("Color", 60, PresetColumns.FN_COLOR_COMPARE, PresetColumns.FN_COLOR_GET)); columns.add(new TableColumnInfo("Type", 100, PresetColumns.FN_TYPE_COMPARE, @@ -109,18 +112,19 @@ public final class DeckEditorCommon extends DeckEditorBase { PresetColumns.FN_STATS_GET)); columns.add(new TableColumnInfo("R", 25, PresetColumns.FN_RARITY_COMPARE, PresetColumns.FN_RARITY_GET)); - columns.add(new TableColumnInfo("Set", 40, PresetColumns.FN_SET_COMPARE, PresetColumns.FN_SET_GET)); + columns.add(new TableColumnInfo("Set", 40, PresetColumns.FN_SET_COMPARE, + PresetColumns.FN_SET_GET)); columns.add(new TableColumnInfo("AI", 30, PresetColumns.FN_AI_STATUS_COMPARE, PresetColumns.FN_AI_STATUS_GET)); columns.get(2).setCellRenderer(new ManaCostRenderer()); - top.setup(columns, cardView); - bottom.setup(columns, cardView); + this.getTopTableWithCards().setup(columns, this.getCardView()); + this.getBottomTableWithCards().setup(columns, this.getCardView()); - filterNameTypeSet.setListeners(new OnChangeTextUpdateDisplay(), itemListenerUpdatesDisplay); + this.filterNameTypeSet.setListeners(new OnChangeTextUpdateDisplay(), this.getItemListenerUpdatesDisplay()); - setSize(1024, 740); - setExtendedState(Frame.MAXIMIZED_BOTH); + this.setSize(1024, 740); + this.setExtendedState(Frame.MAXIMIZED_BOTH); } @@ -133,14 +137,14 @@ public final class DeckEditorCommon extends DeckEditorBase { public DeckEditorCommon(final GameType gameType) { super(gameType); try { - filterBoxes = new FilterCheckBoxes(true); - top = new TableWithCards("Avaliable Cards", true, true); - bottom = new TableWithCards("Deck", true); - cardView = new CardPanelHeavy(); - filterNameTypeSet = new FilterNameTypeSetPanel(); + this.setFilterBoxes(new FilterCheckBoxes(true)); + this.setTopTableWithCards(new TableWithCards("Avaliable Cards", true, true)); + this.setBottomTableWithCards(new TableWithCards("Deck", true)); + this.setCardView(new CardPanelHeavy()); + this.filterNameTypeSet = new FilterNameTypeSetPanel(); - jbInit(); - } catch (Exception ex) { + this.jbInit(); + } catch (final Exception ex) { ErrorViewer.showError(ex); } } @@ -148,49 +152,54 @@ public final class DeckEditorCommon extends DeckEditorBase { private void jbInit() { if (!Singletons.getModel().getPreferences().lafFonts) { - Font fButtons = new java.awt.Font("Dialog", 0, 13); - removeButton.setFont(fButtons); - addButton.setFont(fButtons); - importButton.setFont(fButtons); - clearFilterButton.setFont(fButtons); - analysisButton.setFont(fButtons); + final Font fButtons = new java.awt.Font("Dialog", 0, 13); + this.removeButton.setFont(fButtons); + this.addButton.setFont(fButtons); + this.importButton.setFont(fButtons); + this.clearFilterButton.setFont(fButtons); + this.analysisButton.setFont(fButtons); } - addButton.setText("Add to Deck"); - removeButton.setText("Remove from Deck"); - importButton.setText("Import a Deck"); - clearFilterButton.setText("Clear Filter"); - analysisButton.setText("Deck Analysis"); + this.addButton.setText("Add to Deck"); + this.removeButton.setText("Remove from Deck"); + this.importButton.setText("Import a Deck"); + this.clearFilterButton.setText("Clear Filter"); + this.analysisButton.setText("Deck Analysis"); - removeButton.addActionListener(new java.awt.event.ActionListener() { + this.removeButton.addActionListener(new java.awt.event.ActionListener() { + @Override public void actionPerformed(final ActionEvent e) { - removeButtonClicked(e); + DeckEditorCommon.this.removeButtonClicked(e); } }); - addButton.addActionListener(new java.awt.event.ActionListener() { + this.addButton.addActionListener(new java.awt.event.ActionListener() { + @Override public void actionPerformed(final ActionEvent e) { - addButton_actionPerformed(e); + DeckEditorCommon.this.addButtonActionPerformed(e); } }); - importButton.addActionListener(new java.awt.event.ActionListener() { + this.importButton.addActionListener(new java.awt.event.ActionListener() { + @Override public void actionPerformed(final ActionEvent e) { - importButton_actionPerformed(e); + DeckEditorCommon.this.importButtonActionPerformed(e); } }); - clearFilterButton.addActionListener(new java.awt.event.ActionListener() { + this.clearFilterButton.addActionListener(new java.awt.event.ActionListener() { + @Override public void actionPerformed(final ActionEvent e) { - clearFilterButton_actionPerformed(e); + DeckEditorCommon.this.clearFilterButtonActionPerformed(e); } }); - analysisButton.addActionListener(new java.awt.event.ActionListener() { + this.analysisButton.addActionListener(new java.awt.event.ActionListener() { + @Override public void actionPerformed(final ActionEvent e) { - analysisButton_actionPerformed(e); + DeckEditorCommon.this.analysisButtonActionPerformed(e); } }); // Type filtering - Font f = new Font("Tahoma", Font.PLAIN, 10); - for (JCheckBox box : filterBoxes.allTypes) { + final Font f = new Font("Tahoma", Font.PLAIN, 10); + for (final JCheckBox box : this.getFilterBoxes().getAllTypes()) { if (!Singletons.getModel().getPreferences().lafFonts) { box.setFont(f); } @@ -198,7 +207,7 @@ public final class DeckEditorCommon extends DeckEditorBase { } // Color filtering - for (JCheckBox box : filterBoxes.allColors) { + for (final JCheckBox box : this.getFilterBoxes().getAllColors()) { box.setOpaque(false); } @@ -206,58 +215,58 @@ public final class DeckEditorCommon extends DeckEditorBase { // x 768 screen size this.setTitle("Deck Editor"); - Container content = this.getContentPane(); - MigLayout layout = new MigLayout("fill"); + final Container content = this.getContentPane(); + final MigLayout layout = new MigLayout("fill"); content.setLayout(layout); boolean isFirst = true; - for (JCheckBox box : filterBoxes.allTypes) { + for (final JCheckBox box : this.getFilterBoxes().getAllTypes()) { String growParameter = "grow"; if (isFirst) { growParameter = "cell 0 0, egx checkbox, grow, split 14"; isFirst = false; } content.add(box, growParameter); - box.addItemListener(itemListenerUpdatesDisplay); + box.addItemListener(this.getItemListenerUpdatesDisplay()); } - for (JCheckBox box : filterBoxes.allColors) { + for (final JCheckBox box : this.getFilterBoxes().getAllColors()) { content.add(box, "grow"); - box.addItemListener(itemListenerUpdatesDisplay); + box.addItemListener(this.getItemListenerUpdatesDisplay()); } - content.add(clearFilterButton, "wmin 100, hmin 25, wmax 140, hmax 25, grow"); + content.add(this.clearFilterButton, "wmin 100, hmin 25, wmax 140, hmax 25, grow"); - content.add(filterNameTypeSet, "cell 0 1, grow"); - content.add(top.getTableDecorated(), "cell 0 2 1 2, pushy, grow"); - content.add(top.getLabel(), "cell 0 4"); + content.add(this.filterNameTypeSet, "cell 0 1, grow"); + content.add(this.getTopTableWithCards().getTableDecorated(), "cell 0 2 1 2, pushy, grow"); + content.add(this.getTopTableWithCards().getLabel(), "cell 0 4"); - content.add(addButton, "w 100, h 49, sg button, cell 0 5, split 5"); - content.add(removeButton, "w 100, h 49, sg button"); - content.add(importButton, "w 100, h 49, sg button, gapleft 40px"); + content.add(this.addButton, "w 100, h 49, sg button, cell 0 5, split 5"); + content.add(this.removeButton, "w 100, h 49, sg button"); + content.add(this.importButton, "w 100, h 49, sg button, gapleft 40px"); // Label is used to push the analysis button to the right to separate // analysis button from add/remove card ones - content.add(jLabelAnalysisGap, "wmin 75, growx"); - content.add(analysisButton, "w 100, h 49, wrap"); + content.add(this.jLabelAnalysisGap, "wmin 75, growx"); + content.add(this.analysisButton, "w 100, h 49, wrap"); - content.add(bottom.getTableDecorated(), "cell 0 6, grow"); - content.add(bottom.getLabel(), "cell 0 7"); + content.add(this.getBottomTableWithCards().getTableDecorated(), "cell 0 6, grow"); + content.add(this.getBottomTableWithCards().getLabel(), "cell 0 7"); - content.add(cardView, "cell 1 0 1 8, flowy, grow"); + content.add(this.getCardView(), "cell 1 0 1 8, flowy, grow"); - top.getTable().addMouseListener(new MouseAdapter() { + this.getTopTableWithCards().getTable().addMouseListener(new MouseAdapter() { @Override public void mouseClicked(final MouseEvent e) { if (e.getClickCount() == 2) { - addCardToDeck(); + DeckEditorCommon.this.addCardToDeck(); } } }); - top.getTable().addKeyListener(new KeyAdapter() { + this.getTopTableWithCards().getTable().addKeyListener(new KeyAdapter() { @Override public void keyPressed(final KeyEvent e) { if (e.getKeyChar() == ' ') { - addCardToDeck(); + DeckEditorCommon.this.addCardToDeck(); } } }); @@ -273,8 +282,8 @@ public final class DeckEditorCommon extends DeckEditorBase { */ @Override protected Predicate buildFilter() { - Predicate cardFilter = Predicate.and( - Predicate.and(filterBoxes.buildFilter(), filterNameTypeSet.buildFilter()), + final Predicate cardFilter = Predicate.and( + Predicate.and(this.getFilterBoxes().buildFilter(), this.filterNameTypeSet.buildFilter()), CardPrinted.Predicates.Presets.nonAlternate); return Predicate.instanceOf(cardFilter, CardPrinted.class); } @@ -288,11 +297,11 @@ public final class DeckEditorCommon extends DeckEditorBase { @Override public void setDeck(final ItemPoolView topParam, final ItemPoolView bottomParam, final GameType gt) { - boolean keepRecievedCards = gt.isLimited() || topParam != null; + final boolean keepRecievedCards = gt.isLimited() || (topParam != null); // if constructed, can add the all cards above - ItemPoolView top = keepRecievedCards ? topParam : ItemPool.createFrom(CardDb.instance() + final ItemPoolView top = keepRecievedCards ? topParam : ItemPool.createFrom(CardDb.instance() .getAllCards(), CardPrinted.class); - importButton.setVisible(!gt.isLimited()); + this.importButton.setVisible(!gt.isLimited()); super.setDeck(top, bottomParam, gt); } @@ -302,26 +311,26 @@ public final class DeckEditorCommon extends DeckEditorBase { * @param e * the e */ - void clearFilterButton_actionPerformed(final ActionEvent e) { + void clearFilterButtonActionPerformed(final ActionEvent e) { // disable automatic update triggered by listeners - isFiltersChangeFiringUpdate = false; + this.setFiltersChangeFiringUpdate(false); - for (JCheckBox box : filterBoxes.allTypes) { + for (final JCheckBox box : this.getFilterBoxes().getAllTypes()) { if (!box.isSelected()) { box.doClick(); } } - for (JCheckBox box : filterBoxes.allColors) { + for (final JCheckBox box : this.getFilterBoxes().getAllColors()) { if (!box.isSelected()) { box.doClick(); } } - filterNameTypeSet.clearFilters(); + this.filterNameTypeSet.clearFilters(); - isFiltersChangeFiringUpdate = true; + this.setFiltersChangeFiringUpdate(true); - top.setFilter(null); + this.getTopTableWithCards().setFilter(null); } /** @@ -330,28 +339,28 @@ public final class DeckEditorCommon extends DeckEditorBase { * @param e * the e */ - void addButton_actionPerformed(final ActionEvent e) { - addCardToDeck(); + void addButtonActionPerformed(final ActionEvent e) { + this.addCardToDeck(); } /** * Adds the card to deck. */ void addCardToDeck() { - InventoryItem item = top.getSelectedCard(); - if (item == null || !(item instanceof CardPrinted)) { + final InventoryItem item = this.getTopTableWithCards().getSelectedCard(); + if ((item == null) || !(item instanceof CardPrinted)) { return; } - CardPrinted card = (CardPrinted) item; - setTitle("Deck Editor : " + customMenu.getDeckName() + " : unsaved"); + final CardPrinted card = (CardPrinted) item; + this.setTitle("Deck Editor : " + this.getCustomMenu().getDeckName() + " : unsaved"); - bottom.addCard(card); - if (getGameType().isLimited()) { - top.removeCard(card); + this.getBottomTableWithCards().addCard(card); + if (this.getGameType().isLimited()) { + this.getTopTableWithCards().removeCard(card); } - customMenu.notifyDeckChange(); + this.getCustomMenu().notifyDeckChange(); } /** @@ -361,21 +370,21 @@ public final class DeckEditorCommon extends DeckEditorBase { * the e */ void removeButtonClicked(final ActionEvent e) { - InventoryItem item = bottom.getSelectedCard(); - if (item == null || !(item instanceof CardPrinted)) { + final InventoryItem item = this.getBottomTableWithCards().getSelectedCard(); + if ((item == null) || !(item instanceof CardPrinted)) { return; } - CardPrinted card = (CardPrinted) item; + final CardPrinted card = (CardPrinted) item; - setTitle("Deck Editor : " + customMenu.getDeckName() + " : unsaved"); + this.setTitle("Deck Editor : " + this.getCustomMenu().getDeckName() + " : unsaved"); - bottom.removeCard(card); - if (getGameType().isLimited()) { - top.addCard(card); + this.getBottomTableWithCards().removeCard(card); + if (this.getGameType().isLimited()) { + this.getTopTableWithCards().addCard(card); } - customMenu.notifyDeckChange(); + this.getCustomMenu().notifyDeckChange(); } /** @@ -384,11 +393,26 @@ public final class DeckEditorCommon extends DeckEditorBase { * @param e * the e */ - void importButton_actionPerformed(final ActionEvent e) { - DeckEditorBase g = this; - DeckImport dImport = new DeckImport(g); + void importButtonActionPerformed(final ActionEvent e) { + final DeckEditorBase g = this; + final DeckImport dImport = new DeckImport(g); dImport.setModalityType(ModalityType.APPLICATION_MODAL); dImport.setVisible(true); } + /** + * @return the customMenu + */ + public DeckEditorCommonMenu getCustomMenu() { + return customMenu; + } + + /** + * @param customMenu + * the customMenu to set + */ + public void setCustomMenu(DeckEditorCommonMenu customMenu) { + this.customMenu = customMenu; // TODO: Add 0 to parameter's name. + } + } diff --git a/src/main/java/forge/gui/deckeditor/DeckEditorCommonMenu.java b/src/main/java/forge/gui/deckeditor/DeckEditorCommonMenu.java index 3ecb851d610..ac4261b01b9 100644 --- a/src/main/java/forge/gui/deckeditor/DeckEditorCommonMenu.java +++ b/src/main/java/forge/gui/deckeditor/DeckEditorCommonMenu.java @@ -49,14 +49,14 @@ public final class DeckEditorCommonMenu extends JMenuBar implements NewConstants /** Constant previousDirectory. */ private static File previousDirectory = null; - private DeckManager deckManager; + private final DeckManager deckManager; private boolean isDeckSaved = true; private String currentDeckName; - private DeckDisplay deckDisplay; + private final DeckDisplay deckDisplay; - private Command exitCommand; + private final Command exitCommand; /** * @@ -70,16 +70,16 @@ public final class DeckEditorCommonMenu extends JMenuBar implements NewConstants * a Command */ public DeckEditorCommonMenu(final DeckDisplay inDisplay, final DeckManager dckManager, final Command exit) { - deckDisplay = inDisplay; - exitCommand = exit; - deckManager = dckManager; + this.deckDisplay = inDisplay; + this.exitCommand = exit; + this.deckManager = dckManager; // this is added just to make save() and saveAs() work ok // when first started up, just a silly patch - setDeckData("", true); + this.setDeckData("", true); - setupMenu(); - setupSortMenu(); + this.setupMenu(); + this.setupSortMenu(); } /** @@ -88,14 +88,14 @@ public final class DeckEditorCommonMenu extends JMenuBar implements NewConstants *

*/ private void setupSortMenu() { - JMenuItem name = new JMenuItem("Card Name"); - JMenuItem cost = new JMenuItem("Cost"); - JMenuItem color = new JMenuItem("Color"); - JMenuItem type = new JMenuItem("Type"); - JMenuItem stats = new JMenuItem("Power/Toughness"); - JMenuItem rarity = new JMenuItem("Rarity"); + final JMenuItem name = new JMenuItem("Card Name"); + final JMenuItem cost = new JMenuItem("Cost"); + final JMenuItem color = new JMenuItem("Color"); + final JMenuItem type = new JMenuItem("Type"); + final JMenuItem stats = new JMenuItem("Power/Toughness"); + final JMenuItem rarity = new JMenuItem("Rarity"); - JMenu menu = new JMenu("Sort By"); + final JMenu menu = new JMenu("Sort By"); menu.add(name); menu.add(cost); menu.add(color); @@ -106,8 +106,9 @@ public final class DeckEditorCommonMenu extends JMenuBar implements NewConstants this.add(menu); name.addActionListener(new ActionListener() { + @Override public void actionPerformed(final ActionEvent ev) { - ((DeckEditorCommon) deckDisplay).getTopTableModel().sort(1, true); + ((DeckEditorCommon) DeckEditorCommonMenu.this.deckDisplay).getTopTableModel().sort(1, true); } }); @@ -115,33 +116,40 @@ public final class DeckEditorCommonMenu extends JMenuBar implements NewConstants // private String column[] = {"Qty", "Name", "Cost", "Color", "Type", // "Stats", "Rarity"}; cost.addActionListener(new ActionListener() { + @Override public void actionPerformed(final ActionEvent ev) { - ((DeckEditorCommon) deckDisplay).getTopTableModel().sort(4).sort(3).sort(2); + ((DeckEditorCommon) DeckEditorCommonMenu.this.deckDisplay).getTopTableModel().sort(4).sort(3).sort(2); } }); color.addActionListener(new ActionListener() { + @Override public void actionPerformed(final ActionEvent ev) { - ((DeckEditorCommon) deckDisplay).getTopTableModel().sort(4).sort(2).sort(3); + ((DeckEditorCommon) DeckEditorCommonMenu.this.deckDisplay).getTopTableModel().sort(4).sort(2).sort(3); } }); type.addActionListener(new ActionListener() { + @Override public void actionPerformed(final ActionEvent ev) { - ((DeckEditorCommon) deckDisplay).getTopTableModel().sort(2).sort(3).sort(4); + ((DeckEditorCommon) DeckEditorCommonMenu.this.deckDisplay).getTopTableModel().sort(2).sort(3).sort(4); } }); stats.addActionListener(new ActionListener() { + @Override public void actionPerformed(final ActionEvent ev) { - ((DeckEditorCommon) deckDisplay).getTopTableModel().sort(4).sort(2).sort(3).sort(5); + ((DeckEditorCommon) DeckEditorCommonMenu.this.deckDisplay).getTopTableModel().sort(4).sort(2).sort(3) + .sort(5); } }); rarity.addActionListener(new ActionListener() { + @Override public void actionPerformed(final ActionEvent ev) { // sort by cost, type, color, rarity - ((DeckEditorCommon) deckDisplay).getTopTableModel().sort(2).sort(4).sort(3).sort(6); + ((DeckEditorCommon) DeckEditorCommonMenu.this.deckDisplay).getTopTableModel().sort(2).sort(4).sort(3) + .sort(6); } }); } // setupSortMenu() @@ -153,27 +161,28 @@ public final class DeckEditorCommonMenu extends JMenuBar implements NewConstants * a boolean */ public void newConstructed(final boolean careAboutOldDeck) { - if (careAboutOldDeck && !canLeaveCurrentDeck()) { + if (careAboutOldDeck && !this.canLeaveCurrentDeck()) { return; } - setDeckData("", true); + this.setDeckData("", true); - deckDisplay.setDeck(null, null, GameType.Constructed); + this.deckDisplay.setDeck(null, null, GameType.Constructed); } private void newRandomConstructed() { - if (!canLeaveCurrentDeck()) { + if (!this.canLeaveCurrentDeck()) { return; } - setDeckData("", false); + this.setDeckData("", false); // The only remaining reference to global variable! - CardList random = new CardList(forge.AllZone.getCardFactory().getRandomCombinationWithoutRepetition(15 * 5)); + final CardList random = new CardList(forge.AllZone.getCardFactory().getRandomCombinationWithoutRepetition( + 15 * 5)); - ItemPool cpRandom = new ItemPool(CardPrinted.class); - for (Card c : random) { + final ItemPool cpRandom = new ItemPool(CardPrinted.class); + for (final Card c : random) { cpRandom.add(CardDb.instance().getCard(c)); } cpRandom.add(CardDb.instance().getCard("Forest")); @@ -183,62 +192,62 @@ public final class DeckEditorCommonMenu extends JMenuBar implements NewConstants cpRandom.add(CardDb.instance().getCard("Mountain")); cpRandom.add(CardDb.instance().getCard("Terramorphic Expanse")); - deckDisplay.setDeck(cpRandom, null, GameType.Constructed); + this.deckDisplay.setDeck(cpRandom, null, GameType.Constructed); } private void newGenerateConstructed() { - if (!canLeaveCurrentDeck()) { + if (!this.canLeaveCurrentDeck()) { return; } - setDeckData("", false); + this.setDeckData("", false); - GenerateConstructedDeck gen = new GenerateConstructedDeck(); + final GenerateConstructedDeck gen = new GenerateConstructedDeck(); - ItemPool generated = new ItemPool(CardPrinted.class); - for (Card c : gen.generateDeck()) { + final ItemPool generated = new ItemPool(CardPrinted.class); + for (final Card c : gen.generateDeck()) { generated.add(CardDb.instance().getCard(c)); } - deckDisplay.setDeck(null, generated, GameType.Constructed); + this.deckDisplay.setDeck(null, generated, GameType.Constructed); } private File getImportFilename() { - JFileChooser chooser = new JFileChooser(previousDirectory); + final JFileChooser chooser = new JFileChooser(DeckEditorCommonMenu.previousDirectory); chooser.addChoosableFileFilter(DeckManager.DCK_FILTER); - int returnVal = chooser.showOpenDialog(null); + final int returnVal = chooser.showOpenDialog(null); if (returnVal == JFileChooser.APPROVE_OPTION) { - File file = chooser.getSelectedFile(); - previousDirectory = file.getParentFile(); + final File file = chooser.getSelectedFile(); + DeckEditorCommonMenu.previousDirectory = file.getParentFile(); return file; } return null; } // openFileDialog() private void importDeck() { - File file = getImportFilename(); + final File file = this.getImportFilename(); if (file == null) { } else if (file.getName().endsWith(".dck")) { try { - FileChannel srcChannel = new FileInputStream(file).getChannel(); - File dst = new File(ForgeProps.getFile(NEW_DECKS).getAbsolutePath(), file.getName()); + final FileChannel srcChannel = new FileInputStream(file).getChannel(); + final File dst = new File(ForgeProps.getFile(NewConstants.NEW_DECKS).getAbsolutePath(), file.getName()); if (!dst.createNewFile()) { JOptionPane.showMessageDialog(null, "Cannot import deck " + file.getName() + ", a deck currently has that name."); return; } - FileChannel dstChannel = new FileOutputStream(dst).getChannel(); + final FileChannel dstChannel = new FileOutputStream(dst).getChannel(); dstChannel.transferFrom(srcChannel, 0, srcChannel.size()); srcChannel.close(); dstChannel.close(); - Deck newDeck = DeckManager.readDeck(file); - deckManager.addDeck(newDeck); - showDeck(newDeck, newDeck.getDeckType()); + final Deck newDeck = DeckManager.readDeck(file); + this.deckManager.addDeck(newDeck); + this.showDeck(newDeck, newDeck.getDeckType()); - } catch (Exception ex) { + } catch (final Exception ex) { ErrorViewer.showError(ex); throw new RuntimeException("Gui_DeckEditor_Menu : importDeck() error, " + ex); } @@ -252,31 +261,31 @@ public final class DeckEditorCommonMenu extends JMenuBar implements NewConstants *

*/ private void exportDeck() { - File filename = getExportFilename(); + final File filename = this.getExportFilename(); if (filename == null) { return; } - Deck deck = getDeck(); + final Deck deck = this.getDeck(); try { DeckManager.writeDeck(deck, filename); - } catch (Exception ex) { + } catch (final Exception ex) { ErrorViewer.showError(ex); throw new RuntimeException("Gui_DeckEditor_Menu : exportDeck() error, " + ex); } } private File getExportFilename() { - JFileChooser save = new JFileChooser(previousDirectory); + final JFileChooser save = new JFileChooser(DeckEditorCommonMenu.previousDirectory); save.setDialogTitle("Export Deck Filename"); save.setDialogType(JFileChooser.SAVE_DIALOG); save.setFileFilter(DeckManager.DCK_FILTER); if (save.showSaveDialog(null) == JFileChooser.APPROVE_OPTION) { - File file = save.getSelectedFile(); - String check = file.getAbsolutePath(); + final File file = save.getSelectedFile(); + final String check = file.getAbsolutePath(); - previousDirectory = file.getParentFile(); + DeckEditorCommonMenu.previousDirectory = file.getParentFile(); return check.endsWith(".dck") ? file : new File(check + ".dck"); } @@ -289,31 +298,31 @@ public final class DeckEditorCommonMenu extends JMenuBar implements NewConstants *

*/ private void generateProxies() { - File filename = getProxiesFilename(); + final File filename = this.getProxiesFilename(); if (filename == null) { return; } - Deck deck = getDeck(); + final Deck deck = this.getDeck(); try { DeckManager.writeDeckHtml(deck, filename); - } catch (Exception ex) { + } catch (final Exception ex) { ErrorViewer.showError(ex); throw new RuntimeException("Gui_DeckEditor_Menu : printProxies() error, " + ex); } } private File getProxiesFilename() { - JFileChooser save = new JFileChooser(previousDirectory); + final JFileChooser save = new JFileChooser(DeckEditorCommonMenu.previousDirectory); save.setDialogTitle("Proxy HTML Filename"); save.setDialogType(JFileChooser.SAVE_DIALOG); save.setFileFilter(DeckManager.HTML_FILTER); if (save.showSaveDialog(null) == JFileChooser.APPROVE_OPTION) { - File file = save.getSelectedFile(); - String check = file.getAbsolutePath(); + final File file = save.getSelectedFile(); + final String check = file.getAbsolutePath(); - previousDirectory = file.getParentFile(); + DeckEditorCommonMenu.previousDirectory = file.getParentFile(); return check.endsWith(".html") ? file : new File(check + ".html"); } @@ -321,18 +330,19 @@ public final class DeckEditorCommonMenu extends JMenuBar implements NewConstants } private void openDeck(final GameType gameType) { - if (!canLeaveCurrentDeck()) { + if (!this.canLeaveCurrentDeck()) { return; } - String name = getUserInputOpenDeck(gameType); + final String name = this.getUserInputOpenDeck(gameType); if (StringUtils.isBlank(name)) { return; } - Deck deck = gameType == GameType.Draft ? deckManager.getDraftDeck(name)[0] : deckManager.getDeck(name); - showDeck(deck, gameType); + final Deck deck = gameType == GameType.Draft ? this.deckManager.getDraftDeck(name)[0] : this.deckManager + .getDeck(name); + this.showDeck(deck, gameType); } /** @@ -345,83 +355,83 @@ public final class DeckEditorCommonMenu extends JMenuBar implements NewConstants * a GameType */ public void showDeck(final Deck deck, final GameType gameType) { - setDeckData(deck.getName(), true); + this.setDeckData(deck.getName(), true); if (gameType.isLimited()) { - deckDisplay.setDeck(deck.getSideboard(), deck.getMain(), gameType); + this.deckDisplay.setDeck(deck.getSideboard(), deck.getMain(), gameType); } else { - deckDisplay.setDeck(null, deck.getMain(), gameType); + this.deckDisplay.setDeck(null, deck.getMain(), gameType); } } private void save() { - if (currentDeckName.equals("")) { - saveAs(); + if (this.currentDeckName.equals("")) { + this.saveAs(); return; } - Deck deck = getDeck(); - if (deckDisplay.getGameType().equals(GameType.Draft)) { - setDeckData(currentDeckName, true); + final Deck deck = this.getDeck(); + if (this.deckDisplay.getGameType().equals(GameType.Draft)) { + this.setDeckData(this.currentDeckName, true); // write booster deck - Deck[] all = deckManager.getDraftDeck(currentDeckName); + final Deck[] all = this.deckManager.getDraftDeck(this.currentDeckName); all[0] = deck; - deckManager.addDraftDeck(all); + this.deckManager.addDraftDeck(all); DeckManager.writeDraftDecks(all); } else { // constructed or sealed - setDeckData(currentDeckName, true); - deckManager.addDeck(deck); + this.setDeckData(this.currentDeckName, true); + this.deckManager.addDeck(deck); DeckManager.writeDeck(deck, DeckManager.makeFileName(deck)); } - isDeckSaved = true; + this.isDeckSaved = true; } private void saveAs() { - String name = getDeckNameFromDialog(); + final String name = this.getDeckNameFromDialog(); if (name.equals("")) { return; } - setDeckData(name, true); + this.setDeckData(name, true); - Deck deck = getDeck(); - if (deckDisplay.getGameType().equals(GameType.Draft)) { + final Deck deck = this.getDeck(); + if (this.deckDisplay.getGameType().equals(GameType.Draft)) { // MUST copy array - Deck[] read = deckManager.getDraftDeck(currentDeckName); - Deck[] all = new Deck[read.length]; + final Deck[] read = this.deckManager.getDraftDeck(this.currentDeckName); + final Deck[] all = new Deck[read.length]; System.arraycopy(read, 0, all, 0, read.length); all[0] = deck; - deckManager.addDraftDeck(all); + this.deckManager.addDraftDeck(all); DeckManager.writeDraftDecks(all); } else { // constructed and sealed - deckManager.addDeck(deck); + this.deckManager.addDeck(deck); DeckManager.writeDeck(deck, DeckManager.makeFileName(deck)); } - isDeckSaved = true; + this.isDeckSaved = true; } private void delete() { - if (StringUtils.isBlank(currentDeckName)) { + if (StringUtils.isBlank(this.currentDeckName)) { return; } - int n = JOptionPane.showConfirmDialog(null, "Do you want to delete this deck " + currentDeckName + " ?", - "Delete", JOptionPane.YES_NO_OPTION); + final int n = JOptionPane.showConfirmDialog(null, "Do you want to delete this deck " + this.currentDeckName + + " ?", "Delete", JOptionPane.YES_NO_OPTION); if (n == JOptionPane.NO_OPTION) { return; } - if (deckDisplay.getGameType().equals(GameType.Draft)) { - deckManager.deleteDraftDeck(currentDeckName); + if (this.deckDisplay.getGameType().equals(GameType.Draft)) { + this.deckManager.deleteDraftDeck(this.currentDeckName); } else { - deckManager.deleteDeck(currentDeckName); + this.deckManager.deleteDeck(this.currentDeckName); } - setDeckData("", true); - deckDisplay.setDeck(null, null, deckDisplay.getGameType()); + this.setDeckData("", true); + this.deckDisplay.setDeck(null, null, this.deckDisplay.getGameType()); } /** @@ -429,20 +439,20 @@ public final class DeckEditorCommonMenu extends JMenuBar implements NewConstants * close window. */ public void close() { - if (!canLeaveCurrentDeck()) { + if (!this.canLeaveCurrentDeck()) { return; } - exitCommand.execute(); + this.exitCommand.execute(); } private boolean canLeaveCurrentDeck() { - if (isSaved()) { + if (this.isSaved()) { return true; } - String message = String.format("Do you wish to save changes you made to your current deck '%s'?", - currentDeckName); - int choice = JOptionPane - .showConfirmDialog((Component) deckDisplay, message, "You have unsaved changes in your deck", + final String message = String.format("Do you wish to save changes you made to your current deck '%s'?", + this.currentDeckName); + final int choice = JOptionPane + .showConfirmDialog((Component) this.deckDisplay, message, "You have unsaved changes in your deck", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (JOptionPane.CANCEL_OPTION == choice) { return false; @@ -451,23 +461,23 @@ public final class DeckEditorCommonMenu extends JMenuBar implements NewConstants return true; } - Deck deck = getDeck(); - deck.setName(currentDeckName); + final Deck deck = this.getDeck(); + deck.setName(this.currentDeckName); DeckManager.writeDeck(deck, DeckManager.makeFileName(deck)); return true; } private Deck getDeck() { - Deck deck = deckDisplay.getDeck(); - deck.setName(currentDeckName); + final Deck deck = this.deckDisplay.getDeck(); + deck.setName(this.currentDeckName); return deck; } private void setDeckData(final String deckName, final boolean inDeckSaved) { - currentDeckName = deckName; - isDeckSaved = inDeckSaved; + this.currentDeckName = deckName; + this.isDeckSaved = inDeckSaved; - deckDisplay.setTitle("Deck Editor : " + currentDeckName); + this.deckDisplay.setTitle("Deck Editor : " + this.currentDeckName); } /** @@ -477,7 +487,7 @@ public final class DeckEditorCommonMenu extends JMenuBar implements NewConstants * @return a String */ public String getDeckName() { - return currentDeckName; + return this.currentDeckName; } /** @@ -487,7 +497,7 @@ public final class DeckEditorCommonMenu extends JMenuBar implements NewConstants * @return a boolean */ public boolean isSaved() { - return isDeckSaved; + return this.isDeckSaved; } /** @@ -498,33 +508,34 @@ public final class DeckEditorCommonMenu extends JMenuBar implements NewConstants * @return a {@link java.lang.String} object. */ private String getDeckNameFromDialog() { - Object o = JOptionPane.showInputDialog(null, "Save As", "Deck Name", JOptionPane.OK_CANCEL_OPTION); + final Object o = JOptionPane.showInputDialog(null, "Save As", "Deck Name", JOptionPane.OK_CANCEL_OPTION); if (o == null) { return ""; } - String deckName = DeckManager.cleanDeckName(o.toString()); - boolean isDraft = deckDisplay.getGameType() == GameType.Draft; - boolean isUniqueName = isDraft ? deckManager.isUniqueDraft(deckName) : deckManager.isUnique(deckName); - boolean isGoodName = isUniqueName && StringUtils.isNotBlank(deckName); + final String deckName = DeckManager.cleanDeckName(o.toString()); + final boolean isDraft = this.deckDisplay.getGameType() == GameType.Draft; + final boolean isUniqueName = isDraft ? this.deckManager.isUniqueDraft(deckName) : this.deckManager + .isUnique(deckName); + final boolean isGoodName = isUniqueName && StringUtils.isNotBlank(deckName); if (isGoodName) { return deckName; } JOptionPane.showMessageDialog(null, "Please pick another deck name, another deck currently has that name."); - return getDeckNameFromDialog(); + return this.getDeckNameFromDialog(); } private String getUserInputOpenDeck(final GameType deckType) { - ArrayList choices = deckManager.getDeckNames(deckType); + final ArrayList choices = this.deckManager.getDeckNames(deckType); if (choices.isEmpty()) { JOptionPane.showMessageDialog(null, "No decks found", "Open Deck", JOptionPane.PLAIN_MESSAGE); return null; } - Object o = GuiUtils.getChoiceOptional("Open Deck", choices.toArray()); + final Object o = GuiUtils.getChoiceOptional("Open Deck", choices.toArray()); return o == null ? null : o.toString(); } @@ -535,35 +546,35 @@ public final class DeckEditorCommonMenu extends JMenuBar implements NewConstants * Notify of a Deck Change. */ public void notifyDeckChange() { - isDeckSaved = false; + this.isDeckSaved = false; } private void setupMenu() { - JMenuItem newConstructed = new JMenuItem("New Deck - Constructed"); + final JMenuItem newConstructed = new JMenuItem("New Deck - Constructed"); // JMenuItem newSealed = new JMenuItem("New Deck - Sealed"); // JMenuItem newDraft = new JMenuItem("New Deck - Draft"); - JMenuItem newRandomConstructed = new JMenuItem("New Deck - Generate Random Constructed Cardpool"); - JMenuItem newGenerateConstructed = new JMenuItem("New Deck - Generate Constructed Deck"); + final JMenuItem newRandomConstructed = new JMenuItem("New Deck - Generate Random Constructed Cardpool"); + final JMenuItem newGenerateConstructed = new JMenuItem("New Deck - Generate Constructed Deck"); - JMenuItem importDeck = new JMenuItem("Import Deck..."); - JMenuItem exportDeck = new JMenuItem("Export Deck..."); + final JMenuItem importDeck = new JMenuItem("Import Deck..."); + final JMenuItem exportDeck = new JMenuItem("Export Deck..."); // JMenuItem downloadDeck = new JMenuItem("Download Deck"); - JMenuItem openConstructed = new JMenuItem("Open Deck - Constructed..."); - JMenuItem openSealed = new JMenuItem("Open Deck - Sealed"); - JMenuItem openDraft = new JMenuItem("Open Deck - Draft"); + final JMenuItem openConstructed = new JMenuItem("Open Deck - Constructed..."); + final JMenuItem openSealed = new JMenuItem("Open Deck - Sealed"); + final JMenuItem openDraft = new JMenuItem("Open Deck - Draft"); // newDraftItem = newDraft; // newDraftItem.setEnabled(false); - JMenuItem save = new JMenuItem("Save"); - JMenuItem saveAs = new JMenuItem("Save As..."); - JMenuItem delete = new JMenuItem("Delete"); - JMenuItem close = new JMenuItem("Close"); + final JMenuItem save = new JMenuItem("Save"); + final JMenuItem saveAs = new JMenuItem("Save As..."); + final JMenuItem delete = new JMenuItem("Delete"); + final JMenuItem close = new JMenuItem("Close"); - JMenu fileMenu = new JMenu("Deck Actions"); + final JMenu fileMenu = new JMenu("Deck Actions"); fileMenu.add(newConstructed); // fileMenu.add(newSealed); @@ -578,18 +589,20 @@ public final class DeckEditorCommonMenu extends JMenuBar implements NewConstants fileMenu.add(importDeck); fileMenu.add(exportDeck); - JMenuItem generateProxies = new JMenuItem("Generate Proxies..."); + final JMenuItem generateProxies = new JMenuItem("Generate Proxies..."); fileMenu.add(generateProxies); generateProxies.addActionListener(new ActionListener() { + @Override public void actionPerformed(final ActionEvent ev) { try { SwingUtilities.invokeLater(new Runnable() { + @Override public void run() { - generateProxies(); + DeckEditorCommonMenu.this.generateProxies(); } }); - } catch (Exception ex) { + } catch (final Exception ex) { ErrorViewer.showError(ex); throw new RuntimeException("Gui_DeckEditor_Menu : generateProxies() error - " + ex); } @@ -613,14 +626,16 @@ public final class DeckEditorCommonMenu extends JMenuBar implements NewConstants // add listeners exportDeck.addActionListener(new ActionListener() { + @Override public void actionPerformed(final ActionEvent ev) { try { SwingUtilities.invokeLater(new Runnable() { + @Override public void run() { - exportDeck(); + DeckEditorCommonMenu.this.exportDeck(); } }); - } catch (Exception ex) { + } catch (final Exception ex) { ErrorViewer.showError(ex); throw new RuntimeException("Gui_DeckEditor_Menu : exportDeck() error - " + ex); } @@ -628,14 +643,16 @@ public final class DeckEditorCommonMenu extends JMenuBar implements NewConstants }); importDeck.addActionListener(new ActionListener() { + @Override public void actionPerformed(final ActionEvent ev) { try { SwingUtilities.invokeLater(new Runnable() { + @Override public void run() { - importDeck(); + DeckEditorCommonMenu.this.importDeck(); } }); - } catch (Exception ex) { + } catch (final Exception ex) { ErrorViewer.showError(ex); throw new RuntimeException("Gui_DeckEditor_Menu : importDeck() error - " + ex); } @@ -652,14 +669,16 @@ public final class DeckEditorCommonMenu extends JMenuBar implements NewConstants * ex); } } }); */ newConstructed.addActionListener(new ActionListener() { + @Override public void actionPerformed(final ActionEvent ev) { try { SwingUtilities.invokeLater(new Runnable() { + @Override public void run() { - newConstructed(true); + DeckEditorCommonMenu.this.newConstructed(true); } }); - } catch (Exception ex) { + } catch (final Exception ex) { ErrorViewer.showError(ex); throw new RuntimeException("Gui_DeckEditor_Menu : newConstructed() error - " + ex); } @@ -667,14 +686,16 @@ public final class DeckEditorCommonMenu extends JMenuBar implements NewConstants }); newRandomConstructed.addActionListener(new ActionListener() { + @Override public void actionPerformed(final ActionEvent ev) { try { SwingUtilities.invokeLater(new Runnable() { + @Override public void run() { - newRandomConstructed(); + DeckEditorCommonMenu.this.newRandomConstructed(); } }); - } catch (Exception ex) { + } catch (final Exception ex) { ErrorViewer.showError(ex); throw new RuntimeException("Gui_DeckEditor_Menu : newRandomConstructed() error - " + ex); } @@ -682,14 +703,16 @@ public final class DeckEditorCommonMenu extends JMenuBar implements NewConstants }); newGenerateConstructed.addActionListener(new ActionListener() { + @Override public void actionPerformed(final ActionEvent ev) { try { SwingUtilities.invokeLater(new Runnable() { + @Override public void run() { - newGenerateConstructed(); + DeckEditorCommonMenu.this.newGenerateConstructed(); } }); - } catch (Exception ex) { + } catch (final Exception ex) { ErrorViewer.showError(ex); throw new RuntimeException("Gui_DeckEditor_Menu : newRandomConstructed() error - " + ex); } @@ -697,14 +720,16 @@ public final class DeckEditorCommonMenu extends JMenuBar implements NewConstants }); openConstructed.addActionListener(new ActionListener() { + @Override public void actionPerformed(final ActionEvent ev) { try { SwingUtilities.invokeLater(new Runnable() { + @Override public void run() { - openDeck(GameType.Constructed); + DeckEditorCommonMenu.this.openDeck(GameType.Constructed); } }); - } catch (Exception ex) { + } catch (final Exception ex) { ErrorViewer.showError(ex); throw new RuntimeException("Gui_DeckEditor_Menu : openConstructed() error - " + ex); } @@ -712,14 +737,16 @@ public final class DeckEditorCommonMenu extends JMenuBar implements NewConstants }); openSealed.addActionListener(new ActionListener() { + @Override public void actionPerformed(final ActionEvent ev) { try { SwingUtilities.invokeLater(new Runnable() { + @Override public void run() { - openDeck(GameType.Sealed); + DeckEditorCommonMenu.this.openDeck(GameType.Sealed); } }); - } catch (Exception ex) { + } catch (final Exception ex) { ErrorViewer.showError(ex); throw new RuntimeException("Gui_DeckEditor_Menu : openSealed() error - " + ex); } @@ -727,14 +754,16 @@ public final class DeckEditorCommonMenu extends JMenuBar implements NewConstants }); openDraft.addActionListener(new ActionListener() { + @Override public void actionPerformed(final ActionEvent ev) { try { SwingUtilities.invokeLater(new Runnable() { + @Override public void run() { - openDeck(GameType.Draft); + DeckEditorCommonMenu.this.openDeck(GameType.Draft); } }); - } catch (Exception ex) { + } catch (final Exception ex) { ErrorViewer.showError(ex); throw new RuntimeException("Gui_DeckEditor_Menu : openDraft() error - " + ex); } @@ -742,14 +771,16 @@ public final class DeckEditorCommonMenu extends JMenuBar implements NewConstants }); save.addActionListener(new ActionListener() { + @Override public void actionPerformed(final ActionEvent ev) { try { SwingUtilities.invokeLater(new Runnable() { + @Override public void run() { - save(); + DeckEditorCommonMenu.this.save(); } }); - } catch (Exception ex) { + } catch (final Exception ex) { ErrorViewer.showError(ex); throw new RuntimeException("Gui_DeckEditor_Menu : save() error - " + ex); } @@ -757,14 +788,16 @@ public final class DeckEditorCommonMenu extends JMenuBar implements NewConstants }); saveAs.addActionListener(new ActionListener() { + @Override public void actionPerformed(final ActionEvent ev) { try { SwingUtilities.invokeLater(new Runnable() { + @Override public void run() { - saveAs(); + DeckEditorCommonMenu.this.saveAs(); } }); - } catch (Exception ex) { + } catch (final Exception ex) { ErrorViewer.showError(ex); throw new RuntimeException("Gui_DeckEditor_Menu : saveAs() error - " + ex); } @@ -772,14 +805,16 @@ public final class DeckEditorCommonMenu extends JMenuBar implements NewConstants }); delete.addActionListener(new ActionListener() { + @Override public void actionPerformed(final ActionEvent ev) { try { SwingUtilities.invokeLater(new Runnable() { + @Override public void run() { - delete(); + DeckEditorCommonMenu.this.delete(); } }); - } catch (Exception ex) { + } catch (final Exception ex) { ErrorViewer.showError(ex); throw new RuntimeException("Gui_DeckEditor_Menu : delete() error - " + ex); } @@ -787,14 +822,16 @@ public final class DeckEditorCommonMenu extends JMenuBar implements NewConstants }); close.addActionListener(new ActionListener() { + @Override public void actionPerformed(final ActionEvent ev) { try { SwingUtilities.invokeLater(new Runnable() { + @Override public void run() { - close(); + DeckEditorCommonMenu.this.close(); } }); - } catch (Exception ex) { + } catch (final Exception ex) { ErrorViewer.showError(ex); throw new RuntimeException("Gui_DeckEditor_Menu : close() error - " + ex); } diff --git a/src/main/java/forge/gui/deckeditor/DeckEditorDraft.java b/src/main/java/forge/gui/deckeditor/DeckEditorDraft.java index 496a21329a1..25d913dde05 100644 --- a/src/main/java/forge/gui/deckeditor/DeckEditorDraft.java +++ b/src/main/java/forge/gui/deckeditor/DeckEditorDraft.java @@ -17,6 +17,7 @@ import java.util.List; import javax.swing.JButton; import javax.swing.JOptionPane; import javax.swing.JTable; +import javax.swing.WindowConstants; import net.slightlymagic.maxmtg.Predicate; import forge.AllZone; @@ -34,6 +35,7 @@ import forge.item.ItemPool; import forge.item.ItemPoolView; import forge.properties.ForgeProps; import forge.properties.NewConstants; +import forge.properties.NewConstants.LANG.Gui_BoosterDraft; import forge.view.swing.Gui_HomeScreen; import forge.view.swing.OldGuiNewGame; @@ -47,28 +49,28 @@ import forge.view.swing.OldGuiNewGame; */ public class DeckEditorDraft extends DeckEditorBase implements NewConstants, NewConstants.LANG.Gui_BoosterDraft { /** - * Constant serialVersionUID=-6055633915602448260L + * Constant serialVersionUID=-6055633915602448260L. */ private static final long serialVersionUID = -6055633915602448260L; private BoosterDraft boosterDraft; - private JButton jButtonPick = new JButton(); + private final JButton jButtonPick = new JButton(); private CardPanelLite cardView = new CardPanelLite(); - private MouseListener pickWithMouse = new MouseAdapter() { + private final MouseListener pickWithMouse = new MouseAdapter() { @Override public void mouseClicked(final MouseEvent e) { // Pick on left-button double click - if ((e.getModifiers() & InputEvent.BUTTON1_MASK) != 0 && e.getClickCount() == 2) { - jButtonPickClicked(null); + if (((e.getModifiers() & InputEvent.BUTTON1_MASK) != 0) && (e.getClickCount() == 2)) { + DeckEditorDraft.this.jButtonPickClicked(null); } else if ((e.getModifiers() & InputEvent.BUTTON3_MASK) != 0) { // pick // on // right // click - JTable table = top.getTable(); - int rowNumber = table.rowAtPoint(e.getPoint()); + final JTable table = DeckEditorDraft.this.getTopTableWithCards().getTable(); + final int rowNumber = table.rowAtPoint(e.getPoint()); // after hittest - if it was outside of rows - discard this // click if (rowNumber == -1) { @@ -79,7 +81,7 @@ public class DeckEditorDraft extends DeckEditorBase implements NewConstants, New if (rowNumber != table.getSelectedRow()) { table.getSelectionModel().setSelectionInterval(rowNumber, rowNumber); } else { - jButtonPickClicked(null); + DeckEditorDraft.this.jButtonPickClicked(null); } } } @@ -88,20 +90,20 @@ public class DeckEditorDraft extends DeckEditorBase implements NewConstants, New /** * Show gui. * - * @param in_boosterDraft + * @param inBoosterDraft * the in_booster draft */ - public final void showGui(final BoosterDraft in_boosterDraft) { - boosterDraft = in_boosterDraft; + public final void showGui(final BoosterDraft inBoosterDraft) { + this.boosterDraft = inBoosterDraft; - setup(); - showChoices(boosterDraft.nextChoice()); - bottom.setDeck((Iterable) null); + this.setup(); + this.showChoices(this.boosterDraft.nextChoice()); + this.getBottomTableWithCards().setDeck((Iterable) null); - top.sort(1, true); - bottom.sort(1, true); + this.getTopTableWithCards().sort(1, true); + this.getBottomTableWithCards().sort(1, true); - setVisible(true); + this.setVisible(true); } /** @@ -113,14 +115,14 @@ public class DeckEditorDraft extends DeckEditorBase implements NewConstants, New this.addWindowListener(new WindowAdapter() { @Override public void windowClosing(final WindowEvent ev) { - int n = JOptionPane.showConfirmDialog(null, ForgeProps.getLocalized(CLOSE_MESSAGE), "", - JOptionPane.YES_NO_OPTION); + final int n = JOptionPane.showConfirmDialog(null, + ForgeProps.getLocalized(Gui_BoosterDraft.CLOSE_MESSAGE), "", JOptionPane.YES_NO_OPTION); if (n == JOptionPane.YES_OPTION) { - dispose(); + DeckEditorDraft.this.dispose(); if (System.getenv("NG2") != null) { if (System.getenv("NG2").equalsIgnoreCase("true")) { - String[] argz = {}; + final String[] argz = {}; Gui_HomeScreen.main(argz); } else { new OldGuiNewGame(); @@ -130,9 +132,9 @@ public class DeckEditorDraft extends DeckEditorBase implements NewConstants, New } } - }// windowClosing() + } // windowClosing() }); - }// addListeners() + } // addListeners() /** *

@@ -140,14 +142,16 @@ public class DeckEditorDraft extends DeckEditorBase implements NewConstants, New *

*/ private void setup() { - addListeners(); + this.addListeners(); // setupMenu(); - List> columns = new ArrayList>(); - columns.add(new TableColumnInfo("Qty", 30, PresetColumns.FN_QTY_COMPARE, PresetColumns.FN_QTY_GET)); + final List> columns = new ArrayList>(); + columns.add(new TableColumnInfo("Qty", 30, PresetColumns.FN_QTY_COMPARE, + PresetColumns.FN_QTY_GET)); columns.add(new TableColumnInfo("Name", 180, PresetColumns.FN_NAME_COMPARE, PresetColumns.FN_NAME_GET)); - columns.add(new TableColumnInfo("Cost", 70, PresetColumns.FN_COST_COMPARE, PresetColumns.FN_COST_GET)); + columns.add(new TableColumnInfo("Cost", 70, PresetColumns.FN_COST_COMPARE, + PresetColumns.FN_COST_GET)); columns.add(new TableColumnInfo("Color", 50, PresetColumns.FN_COLOR_COMPARE, PresetColumns.FN_COLOR_GET)); columns.add(new TableColumnInfo("Type", 100, PresetColumns.FN_TYPE_COMPARE, @@ -156,24 +160,25 @@ public class DeckEditorDraft extends DeckEditorBase implements NewConstants, New PresetColumns.FN_STATS_GET)); columns.add(new TableColumnInfo("R", 35, PresetColumns.FN_RARITY_COMPARE, PresetColumns.FN_RARITY_GET)); - columns.add(new TableColumnInfo("Set", 40, PresetColumns.FN_SET_COMPARE, PresetColumns.FN_SET_GET)); + columns.add(new TableColumnInfo("Set", 40, PresetColumns.FN_SET_COMPARE, + PresetColumns.FN_SET_GET)); columns.add(new TableColumnInfo("AI", 30, PresetColumns.FN_AI_STATUS_COMPARE, PresetColumns.FN_AI_STATUS_GET)); columns.get(2).setCellRenderer(new ManaCostRenderer()); - top.setup(columns, cardView); - bottom.setup(columns, cardView); + this.getTopTableWithCards().setup(columns, this.cardView); + this.getBottomTableWithCards().setup(columns, this.cardView); this.setSize(980, 740); GuiUtils.centerFrame(this); this.setResizable(false); - top.getTable().addMouseListener(pickWithMouse); - top.getTable().addKeyListener(new KeyAdapter() { + this.getTopTableWithCards().getTable().addMouseListener(this.pickWithMouse); + this.getTopTableWithCards().getTable().addKeyListener(new KeyAdapter() { @Override public void keyPressed(final KeyEvent e) { if (e.getKeyChar() == ' ') { - jButtonPickClicked(null); + DeckEditorDraft.this.jButtonPickClicked(null); } } }); @@ -186,12 +191,12 @@ public class DeckEditorDraft extends DeckEditorBase implements NewConstants, New public DeckEditorDraft() { super(GameType.Draft); try { - top = new TableWithCards("Choose one card", false); - bottom = new TableWithCards("Previously picked cards", true); - filterBoxes = null; - cardView = new CardPanelLite(); - jbInit(); - } catch (Exception ex) { + this.setTopTableWithCards(new TableWithCards("Choose one card", false)); + this.setBottomTableWithCards(new TableWithCards("Previously picked cards", true)); + this.setFilterBoxes(null); + this.cardView = new CardPanelLite(); + this.jbInit(); + } catch (final Exception ex) { ErrorViewer.showError(ex); } } @@ -207,29 +212,30 @@ public class DeckEditorDraft extends DeckEditorBase implements NewConstants, New private void jbInit() throws Exception { this.getContentPane().setLayout(null); - top.getTableDecorated().setBounds(new Rectangle(19, 28, 680, 344)); - bottom.getTableDecorated().setBounds(new Rectangle(19, 478, 680, 184)); - bottom.getLabel().setBounds(new Rectangle(19, 680, 665, 31)); + this.getTopTableWithCards().getTableDecorated().setBounds(new Rectangle(19, 28, 680, 344)); + this.getBottomTableWithCards().getTableDecorated().setBounds(new Rectangle(19, 478, 680, 184)); + this.getBottomTableWithCards().getLabel().setBounds(new Rectangle(19, 680, 665, 31)); - cardView.setBounds(new Rectangle(715, 23, 240, 666)); + this.cardView.setBounds(new Rectangle(715, 23, 240, 666)); - this.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); + this.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); this.setTitle("Booster Draft"); - jButtonPick.setBounds(new Rectangle(238, 418, 147, 44)); - jButtonPick.setFont(new java.awt.Font("Dialog", 0, 16)); - jButtonPick.setText("Choose Card"); - jButtonPick.addActionListener(new ActionListener() { + this.jButtonPick.setBounds(new Rectangle(238, 418, 147, 44)); + this.jButtonPick.setFont(new java.awt.Font("Dialog", 0, 16)); + this.jButtonPick.setText("Choose Card"); + this.jButtonPick.addActionListener(new ActionListener() { + @Override public void actionPerformed(final ActionEvent e) { - jButtonPickClicked(e); + DeckEditorDraft.this.jButtonPickClicked(e); } }); - this.getContentPane().add(cardView, null); - this.getContentPane().add(top.getTableDecorated(), null); - this.getContentPane().add(bottom.getLabel(), null); - this.getContentPane().add(bottom.getTableDecorated(), null); - this.getContentPane().add(jButtonPick, null); + this.getContentPane().add(this.cardView, null); + this.getContentPane().add(this.getTopTableWithCards().getTableDecorated(), null); + this.getContentPane().add(this.getBottomTableWithCards().getLabel(), null); + this.getContentPane().add(this.getBottomTableWithCards().getTableDecorated(), null); + this.getContentPane().add(this.jButtonPick, null); } /** @@ -241,27 +247,27 @@ public class DeckEditorDraft extends DeckEditorBase implements NewConstants, New * a {@link java.awt.event.ActionEvent} object. */ final void jButtonPickClicked(final ActionEvent e) { - InventoryItem item = top.getSelectedCard(); - if (item == null || !(item instanceof CardPrinted)) { + final InventoryItem item = this.getTopTableWithCards().getSelectedCard(); + if ((item == null) || !(item instanceof CardPrinted)) { return; } - CardPrinted card = (CardPrinted) item; + final CardPrinted card = (CardPrinted) item; - bottom.addCard(card); + this.getBottomTableWithCards().addCard(card); // get next booster pack - boosterDraft.setChoice(card); - if (boosterDraft.hasNextChoice()) { - showChoices(boosterDraft.nextChoice()); + this.boosterDraft.setChoice(card); + if (this.boosterDraft.hasNextChoice()) { + this.showChoices(this.boosterDraft.nextChoice()); } else { - boosterDraft.finishedDrafting(); + this.boosterDraft.finishedDrafting(); // quit - saveDraft(); - dispose(); + this.saveDraft(); + this.dispose(); } - }/* OK Button */ + } /* OK Button */ /** *

@@ -272,10 +278,10 @@ public class DeckEditorDraft extends DeckEditorBase implements NewConstants, New * a {@link forge.CardList} object. */ private void showChoices(final ItemPoolView list) { - top.setDeck(list); - cardView.showCard(null); - top.fixSelection(0); - }// showChoices() + this.getTopTableWithCards().setDeck(list); + this.cardView.showCard(null); + this.getTopTableWithCards().fixSelection(0); + } // showChoices() /** *

@@ -285,23 +291,23 @@ public class DeckEditorDraft extends DeckEditorBase implements NewConstants, New * @return a {@link forge.deck.Deck} object. */ private Deck getPlayersDeck() { - Deck deck = new Deck(GameType.Draft); + final Deck deck = new Deck(GameType.Draft); Constant.Runtime.HUMAN_DECK[0] = deck; // add sideboard to deck - ItemPoolView list = ItemPool.createFrom(bottom.getCards(), CardPrinted.class); + final ItemPoolView list = ItemPool.createFrom(this.getBottomTableWithCards().getCards(), CardPrinted.class); deck.addSideboard(list); - String landSet = BoosterDraft.LAND_SET_CODE[0]; - final int LANDS_COUNT = 20; - deck.addSideboard(CardDb.instance().getCard("Forest", landSet), LANDS_COUNT); - deck.addSideboard(CardDb.instance().getCard("Mountain", landSet), LANDS_COUNT); - deck.addSideboard(CardDb.instance().getCard("Swamp", landSet), LANDS_COUNT); - deck.addSideboard(CardDb.instance().getCard("Island", landSet), LANDS_COUNT); - deck.addSideboard(CardDb.instance().getCard("Plains", landSet), LANDS_COUNT); + final String landSet = BoosterDraft.LAND_SET_CODE[0]; + final int landsCount = 20; + deck.addSideboard(CardDb.instance().getCard("Forest", landSet), landsCount); + deck.addSideboard(CardDb.instance().getCard("Mountain", landSet), landsCount); + deck.addSideboard(CardDb.instance().getCard("Swamp", landSet), landsCount); + deck.addSideboard(CardDb.instance().getCard("Island", landSet), landsCount); + deck.addSideboard(CardDb.instance().getCard("Plains", landSet), landsCount); return deck; - }// getPlayersDeck() + } // getPlayersDeck() /** *

@@ -310,21 +316,22 @@ public class DeckEditorDraft extends DeckEditorBase implements NewConstants, New */ private void saveDraft() { String s = ""; - while (s == null || s.length() == 0) { - s = JOptionPane.showInputDialog(null, ForgeProps.getLocalized(SAVE_DRAFT_MESSAGE), - ForgeProps.getLocalized(SAVE_DRAFT_TITLE), JOptionPane.QUESTION_MESSAGE); + while ((s == null) || (s.length() == 0)) { + s = JOptionPane.showInputDialog(null, ForgeProps.getLocalized(Gui_BoosterDraft.SAVE_DRAFT_MESSAGE), + ForgeProps.getLocalized(Gui_BoosterDraft.SAVE_DRAFT_TITLE), JOptionPane.QUESTION_MESSAGE); } // TODO: check if overwriting the same name, and let the user delete old // drafts // construct computer's decks // save draft - Deck[] computer = boosterDraft.getDecks(); + final Deck[] computer = this.boosterDraft.getDecks(); - Deck human = getPlayersDeck(); + final Deck human = this.getPlayersDeck(); human.setName(s); - Deck[] all = { human, computer[0], computer[1], computer[2], computer[3], computer[4], computer[5], computer[6] }; + final Deck[] all = { human, computer[0], computer[1], computer[2], computer[3], computer[4], computer[5], + computer[6] }; for (int i = 1; i < all.length; i++) { all[i].setName(String.format("Draft %s - Computer %d", s, i)); @@ -332,18 +339,18 @@ public class DeckEditorDraft extends DeckEditorBase implements NewConstants, New // DeckManager deckManager = new // DeckManager(ForgeProps.getFile(NEW_DECKS)); - DeckManager deckManager = AllZone.getDeckManager(); + final DeckManager deckManager = AllZone.getDeckManager(); deckManager.addDraftDeck(all); // write file DeckManager.writeDraftDecks(all); // close and open next screen - dispose(); + this.dispose(); if (System.getenv("NG2") != null) { if (System.getenv("NG2").equalsIgnoreCase("true")) { - String[] argz = {}; + final String[] argz = {}; Gui_HomeScreen.main(argz); } else { new OldGuiNewGame(); @@ -352,7 +359,7 @@ public class DeckEditorDraft extends DeckEditorBase implements NewConstants, New new OldGuiNewGame(); } - }/* saveDraft() */ + } /* saveDraft() */ /* * (non-Javadoc) diff --git a/src/main/java/forge/gui/deckeditor/DeckEditorQuest.java b/src/main/java/forge/gui/deckeditor/DeckEditorQuest.java index 6d06ef8f0b5..0cde1139e9a 100644 --- a/src/main/java/forge/gui/deckeditor/DeckEditorQuest.java +++ b/src/main/java/forge/gui/deckeditor/DeckEditorQuest.java @@ -40,23 +40,23 @@ import forge.quest.data.QuestData; * @version $Id$ */ public final class DeckEditorQuest extends DeckEditorBase implements NewConstants { - /** Constant serialVersionUID=152061168634545L */ + /** Constant serialVersionUID=152061168634545L. */ private static final long serialVersionUID = 152061168634545L; /** The custom menu. */ - DeckEditorQuestMenu customMenu; + private DeckEditorQuestMenu customMenu; // private ImageIcon upIcon = Constant.IO.upIcon; // private ImageIcon downIcon = Constant.IO.downIcon; // private JLabel labelSortHint = new JLabel(); - private JButton addButton = new JButton(); - private JButton removeButton = new JButton(); - private JButton analysisButton = new JButton(); + private final JButton addButton = new JButton(); + private final JButton removeButton = new JButton(); + private final JButton analysisButton = new JButton(); private FilterNameTypeSetPanel filterNameTypeSet; - private QuestData questData; + private final QuestData questData; /** * Show. @@ -68,6 +68,7 @@ public final class DeckEditorQuest extends DeckEditorBase implements NewConstant final Command exit = new Command() { private static final long serialVersionUID = -7428793574300520612L; + @Override public void execute() { DeckEditorQuest.this.dispose(); exitCommand.execute(); @@ -78,44 +79,44 @@ public final class DeckEditorQuest extends DeckEditorBase implements NewConstant this.addWindowListener(new WindowAdapter() { @Override public void windowClosing(final WindowEvent ev) { - customMenu.close(); + DeckEditorQuest.this.customMenu.close(); } }); - setup(); + this.setup(); - customMenu = new DeckEditorQuestMenu(questData, this, exit); - this.setJMenuBar(customMenu); + this.customMenu = new DeckEditorQuestMenu(this.questData, this, exit); + this.setJMenuBar(this.customMenu); Deck deck = null; // open deck that the player used if QuestData has it - if (Constant.Runtime.HUMAN_DECK[0] != null - && questData.getDeckNames().contains(Constant.Runtime.HUMAN_DECK[0].getName())) { - deck = questData.getDeck(Constant.Runtime.HUMAN_DECK[0].getName()); + if ((Constant.Runtime.HUMAN_DECK[0] != null) + && this.questData.getDeckNames().contains(Constant.Runtime.HUMAN_DECK[0].getName())) { + deck = this.questData.getDeck(Constant.Runtime.HUMAN_DECK[0].getName()); } else { deck = new Deck(GameType.Sealed); deck.setName(""); } // tell Gui_Quest_DeckEditor the name of the deck - customMenu.setPlayerDeckName(deck.getName()); + this.customMenu.setPlayerDeckName(deck.getName()); - ItemPoolView bottomPool = deck.getMain(); - ItemPool cardpool = new ItemPool(CardPrinted.class); - cardpool.addAll(questData.getCards().getCardpool()); + final ItemPoolView bottomPool = deck.getMain(); + final ItemPool cardpool = new ItemPool(CardPrinted.class); + cardpool.addAll(this.questData.getCards().getCardpool()); // remove bottom cards that are in the deck from the card pool cardpool.removeAll(bottomPool); // show cards, makes this user friendly - setDeck(cardpool, bottomPool, GameType.Quest); + this.setDeck(cardpool, bottomPool, GameType.Quest); // this affects the card pool - top.sort(4, true); // sort by type - top.sort(3, true); // then sort by color + this.getTopTableWithCards().sort(4, true); // sort by type + this.getTopTableWithCards().sort(3, true); // then sort by color - bottom.sort(1, true); + this.getBottomTableWithCards().sort(1, true); } // show(Command) /** @@ -126,11 +127,13 @@ public final class DeckEditorQuest extends DeckEditorBase implements NewConstant public void setup() { this.setLayout(null); - List> columns = new ArrayList>(); - columns.add(new TableColumnInfo("Qty", 30, PresetColumns.FN_QTY_COMPARE, PresetColumns.FN_QTY_GET)); + final List> columns = new ArrayList>(); + columns.add(new TableColumnInfo("Qty", 30, PresetColumns.FN_QTY_COMPARE, + PresetColumns.FN_QTY_GET)); columns.add(new TableColumnInfo("Name", 180, PresetColumns.FN_NAME_COMPARE, PresetColumns.FN_NAME_GET)); - columns.add(new TableColumnInfo("Cost", 70, PresetColumns.FN_COST_COMPARE, PresetColumns.FN_COST_GET)); + columns.add(new TableColumnInfo("Cost", 70, PresetColumns.FN_COST_COMPARE, + PresetColumns.FN_COST_GET)); columns.add(new TableColumnInfo("Color", 50, PresetColumns.FN_COLOR_COMPARE, PresetColumns.FN_COLOR_GET)); columns.add(new TableColumnInfo("Type", 100, PresetColumns.FN_TYPE_COMPARE, @@ -139,16 +142,17 @@ public final class DeckEditorQuest extends DeckEditorBase implements NewConstant PresetColumns.FN_STATS_GET)); columns.add(new TableColumnInfo("R", 35, PresetColumns.FN_RARITY_COMPARE, PresetColumns.FN_RARITY_GET)); - columns.add(new TableColumnInfo("Set", 40, PresetColumns.FN_SET_COMPARE, PresetColumns.FN_SET_GET)); - columns.add(new TableColumnInfo("New", 30, questData.getCards().fnNewCompare, questData - .getCards().fnNewGet)); + columns.add(new TableColumnInfo("Set", 40, PresetColumns.FN_SET_COMPARE, + PresetColumns.FN_SET_GET)); + columns.add(new TableColumnInfo("New", 30, this.questData.getCards().fnNewCompare, + this.questData.getCards().fnNewGet)); columns.get(2).setCellRenderer(new ManaCostRenderer()); - top.setup(columns, cardView); - bottom.setup(columns, cardView); + this.getTopTableWithCards().setup(columns, this.getCardView()); + this.getBottomTableWithCards().setup(columns, this.getCardView()); - filterNameTypeSet.setListeners(new OnChangeTextUpdateDisplay(), itemListenerUpdatesDisplay); + this.filterNameTypeSet.setListeners(new OnChangeTextUpdateDisplay(), this.getItemListenerUpdatesDisplay()); this.setSize(1024, 768); GuiUtils.centerFrame(this); @@ -168,15 +172,15 @@ public final class DeckEditorQuest extends DeckEditorBase implements NewConstant */ public DeckEditorQuest(final QuestData questData2) { super(GameType.Quest); - questData = questData2; + this.questData = questData2; try { - filterBoxes = new FilterCheckBoxes(false); - top = new TableWithCards("All Cards", true); - bottom = new TableWithCards("Your deck", true); - cardView = new CardPanelHeavy(); - filterNameTypeSet = new FilterNameTypeSetPanel(); - jbInit(); - } catch (Exception ex) { + this.setFilterBoxes(new FilterCheckBoxes(false)); + this.setTopTableWithCards(new TableWithCards("All Cards", true)); + this.setBottomTableWithCards(new TableWithCards("Your deck", true)); + this.setCardView(new CardPanelHeavy()); + this.filterNameTypeSet = new FilterNameTypeSetPanel(); + this.jbInit(); + } catch (final Exception ex) { ErrorViewer.showError(ex); } } @@ -187,113 +191,116 @@ public final class DeckEditorQuest extends DeckEditorBase implements NewConstant // labelSortHint.setText("Click on the column name (like name or color) to sort the cards"); // labelSortHint.setBounds(new Rectangle(20, 27, 400, 19)); - filterNameTypeSet.setBounds(new Rectangle(19, 10, 726, 25)); - top.getTableDecorated().setBounds(new Rectangle(19, 40, 726, 316)); - bottom.getTableDecorated().setBounds(new Rectangle(19, 458, 726, 218)); + this.filterNameTypeSet.setBounds(new Rectangle(19, 10, 726, 25)); + this.getTopTableWithCards().getTableDecorated().setBounds(new Rectangle(19, 40, 726, 316)); + this.getBottomTableWithCards().getTableDecorated().setBounds(new Rectangle(19, 458, 726, 218)); - removeButton.setBounds(new Rectangle(180, 403, 146, 49)); + this.removeButton.setBounds(new Rectangle(180, 403, 146, 49)); // removeButton.setIcon(upIcon); if (!Singletons.getModel().getPreferences().lafFonts) { - removeButton.setFont(new java.awt.Font("Dialog", 0, 13)); + this.removeButton.setFont(new java.awt.Font("Dialog", 0, 13)); } - removeButton.setText("Remove Card"); - removeButton.addActionListener(new ActionListener() { + this.removeButton.setText("Remove Card"); + this.removeButton.addActionListener(new ActionListener() { + @Override public void actionPerformed(final ActionEvent e) { - removeButtonActionPerformed(e); + DeckEditorQuest.this.removeButtonActionPerformed(e); } }); - addButton.setText("Add Card"); - addButton.addActionListener(new ActionListener() { + this.addButton.setText("Add Card"); + this.addButton.addActionListener(new ActionListener() { + @Override public void actionPerformed(final ActionEvent e) { - addButtonActionPerformed(e); + DeckEditorQuest.this.addButtonActionPerformed(e); } }); // addButton.setIcon(downIcon); if (!Singletons.getModel().getPreferences().lafFonts) { - addButton.setFont(new java.awt.Font("Dialog", 0, 13)); + this.addButton.setFont(new java.awt.Font("Dialog", 0, 13)); } - addButton.setBounds(new Rectangle(23, 403, 146, 49)); + this.addButton.setBounds(new Rectangle(23, 403, 146, 49)); - analysisButton.setText("Deck Analysis"); - analysisButton.addActionListener(new ActionListener() { + this.analysisButton.setText("Deck Analysis"); + this.analysisButton.addActionListener(new ActionListener() { + @Override public void actionPerformed(final ActionEvent e) { - analysisButton_actionPerformed(e); + DeckEditorQuest.this.analysisButtonActionPerformed(e); } }); if (!Singletons.getModel().getPreferences().lafFonts) { - analysisButton.setFont(new java.awt.Font("Dialog", 0, 13)); + this.analysisButton.setFont(new java.awt.Font("Dialog", 0, 13)); } - analysisButton.setBounds(new Rectangle(578, 426, 166, 25)); + this.analysisButton.setBounds(new Rectangle(578, 426, 166, 25)); /** * Type filtering */ - filterBoxes.land.setBounds(340, 400, 48, 20); - filterBoxes.creature.setBounds(385, 400, 65, 20); - filterBoxes.sorcery.setBounds(447, 400, 62, 20); - filterBoxes.instant.setBounds(505, 400, 60, 20); - filterBoxes.planeswalker.setBounds(558, 400, 85, 20); - filterBoxes.artifact.setBounds(638, 400, 58, 20); - filterBoxes.enchantment.setBounds(692, 400, 80, 20); + this.getFilterBoxes().getLand().setBounds(340, 400, 48, 20); + this.getFilterBoxes().getCreature().setBounds(385, 400, 65, 20); + this.getFilterBoxes().getSorcery().setBounds(447, 400, 62, 20); + this.getFilterBoxes().getInstant().setBounds(505, 400, 60, 20); + this.getFilterBoxes().getPlaneswalker().setBounds(558, 400, 85, 20); + this.getFilterBoxes().getArtifact().setBounds(638, 400, 58, 20); + this.getFilterBoxes().getEnchantment().setBounds(692, 400, 80, 20); - Font f = new Font("Tahoma", Font.PLAIN, 10); - for (JCheckBox box : filterBoxes.allTypes) { + final Font f = new Font("Tahoma", Font.PLAIN, 10); + for (final JCheckBox box : this.getFilterBoxes().getAllTypes()) { if (!Singletons.getModel().getPreferences().lafFonts) { box.setFont(f); } box.setOpaque(false); - box.addItemListener(itemListenerUpdatesDisplay); + box.addItemListener(this.getItemListenerUpdatesDisplay()); } /** * Color filtering */ - filterBoxes.white.setBounds(340, 430, 40, 20); - filterBoxes.blue.setBounds(380, 430, 40, 20); - filterBoxes.black.setBounds(420, 430, 40, 20); - filterBoxes.red.setBounds(460, 430, 40, 20); - filterBoxes.green.setBounds(500, 430, 40, 20); - filterBoxes.colorless.setBounds(540, 430, 40, 20); + this.getFilterBoxes().getWhite().setBounds(340, 430, 40, 20); + this.getFilterBoxes().getBlue().setBounds(380, 430, 40, 20); + this.getFilterBoxes().getBlack().setBounds(420, 430, 40, 20); + this.getFilterBoxes().getRed().setBounds(460, 430, 40, 20); + this.getFilterBoxes().getGreen().setBounds(500, 430, 40, 20); + this.getFilterBoxes().getColorless().setBounds(540, 430, 40, 20); - for (JCheckBox box : filterBoxes.allColors) { + for (final JCheckBox box : this.getFilterBoxes().getAllColors()) { box.setOpaque(false); - box.addItemListener(itemListenerUpdatesDisplay); + box.addItemListener(this.getItemListenerUpdatesDisplay()); } /** * Other */ - cardView.setBounds(new Rectangle(765, 23, 239, 687)); - top.getLabel().setBounds(new Rectangle(19, 365, 720, 31)); - bottom.getLabel().setBounds(new Rectangle(19, 672, 720, 31)); + this.getCardView().setBounds(new Rectangle(765, 23, 239, 687)); + this.getTopTableWithCards().getLabel().setBounds(new Rectangle(19, 365, 720, 31)); + this.getBottomTableWithCards().getLabel().setBounds(new Rectangle(19, 672, 720, 31)); // Do not lower statsLabel any lower, we want this to be visible at 1024 // x 768 screen size this.setTitle("Deck Editor"); - this.getContentPane().add(filterNameTypeSet, null); - this.getContentPane().add(top.getTableDecorated(), null); - this.getContentPane().add(bottom.getTableDecorated(), null); - this.getContentPane().add(addButton, null); - this.getContentPane().add(removeButton, null); - this.getContentPane().add(analysisButton, null); - this.getContentPane().add(bottom.getLabel(), null); - this.getContentPane().add(top.getLabel(), null); + this.getContentPane().add(this.filterNameTypeSet, null); + this.getContentPane().add(this.getTopTableWithCards().getTableDecorated(), null); + this.getContentPane().add(this.getBottomTableWithCards().getTableDecorated(), null); + this.getContentPane().add(this.addButton, null); + this.getContentPane().add(this.removeButton, null); + this.getContentPane().add(this.analysisButton, null); + this.getContentPane().add(this.getBottomTableWithCards().getLabel(), null); + this.getContentPane().add(this.getTopTableWithCards().getLabel(), null); // this.getContentPane().add(labelSortHint, null); - this.getContentPane().add(cardView, null); + this.getContentPane().add(this.getCardView(), null); - for (JCheckBox box : filterBoxes.allTypes) { + for (final JCheckBox box : this.getFilterBoxes().getAllTypes()) { this.getContentPane().add(box, null); } - for (JCheckBox box : filterBoxes.allColors) { + for (final JCheckBox box : this.getFilterBoxes().getAllColors()) { this.getContentPane().add(box, null); } - top.getTable().addKeyListener(new KeyAdapter() { + this.getTopTableWithCards().getTable().addKeyListener(new KeyAdapter() { @Override public void keyPressed(final KeyEvent e) { if (e.getKeyChar() == ' ') { - addButtonActionPerformed(null); + DeckEditorQuest.this.addButtonActionPerformed(null); } } }); @@ -306,36 +313,37 @@ public final class DeckEditorQuest extends DeckEditorBase implements NewConstant */ @Override protected Predicate buildFilter() { - Predicate cardFilter = Predicate.and(filterBoxes.buildFilter(), filterNameTypeSet.buildFilter()); + final Predicate cardFilter = Predicate.and(this.getFilterBoxes().buildFilter(), + this.filterNameTypeSet.buildFilter()); return Predicate.instanceOf(cardFilter, CardPrinted.class); } private void addButtonActionPerformed(final ActionEvent e) { - InventoryItem item = top.getSelectedCard(); - if (item == null || !(item instanceof CardPrinted)) { + final InventoryItem item = this.getTopTableWithCards().getSelectedCard(); + if ((item == null) || !(item instanceof CardPrinted)) { return; } - CardPrinted card = (CardPrinted) item; + final CardPrinted card = (CardPrinted) item; - setTitle("Deck Editor : " + customMenu.getDeckName() + " : unsaved"); + this.setTitle("Deck Editor : " + this.customMenu.getDeckName() + " : unsaved"); - top.removeCard(card); - bottom.addCard(card); + this.getTopTableWithCards().removeCard(card); + this.getBottomTableWithCards().addCard(card); } private void removeButtonActionPerformed(final ActionEvent e) { - InventoryItem item = bottom.getSelectedCard(); - if (item == null || !(item instanceof CardPrinted)) { + final InventoryItem item = this.getBottomTableWithCards().getSelectedCard(); + if ((item == null) || !(item instanceof CardPrinted)) { return; } - CardPrinted card = (CardPrinted) item; + final CardPrinted card = (CardPrinted) item; - setTitle("Deck Editor : " + customMenu.getDeckName() + " : unsaved"); + this.setTitle("Deck Editor : " + this.customMenu.getDeckName() + " : unsaved"); - top.addCard(card); - bottom.removeCard(card); + this.getTopTableWithCards().addCard(card); + this.getBottomTableWithCards().removeCard(card); } /** @@ -345,8 +353,8 @@ public final class DeckEditorQuest extends DeckEditorBase implements NewConstant * the card */ public void addCheatCard(final CardPrinted card) { - top.addCard(card); - questData.getCards().getCardpool().add(card); + this.getTopTableWithCards().addCard(card); + this.questData.getCards().getCardpool().add(card); } } diff --git a/src/main/java/forge/gui/deckeditor/DeckEditorQuestMenu.java b/src/main/java/forge/gui/deckeditor/DeckEditorQuestMenu.java index b4a3adf9d14..acda2fb2efc 100644 --- a/src/main/java/forge/gui/deckeditor/DeckEditorQuestMenu.java +++ b/src/main/java/forge/gui/deckeditor/DeckEditorQuestMenu.java @@ -51,18 +51,18 @@ public class DeckEditorQuestMenu extends JMenuBar { private static final long serialVersionUID = -4052319220021158574L; /** Constant deckEditorName="Deck Editor". */ - private static final String deckEditorName = "Deck Editor"; + private static final String DECK_EDITOR_NAME = "Deck Editor"; // used for import and export, try to made the gui user friendly /** Constant previousDirectory. */ private static File previousDirectory = null; - private Command exitCommand; - private forge.quest.data.QuestData questData; + private final Command exitCommand; + private final forge.quest.data.QuestData questData; private Deck currentDeck; // the class DeckDisplay is in the file "Gui_DeckEditor_Menu.java" - private DeckDisplay deckDisplay; + private final DeckDisplay deckDisplay; /** *

@@ -78,14 +78,14 @@ public class DeckEditorQuestMenu extends JMenuBar { */ public DeckEditorQuestMenu(final QuestData q, final DeckDisplay d, final Command exit) { - deckDisplay = d; - questData = q; + this.deckDisplay = d; + this.questData = q; - d.setTitle(deckEditorName); + d.setTitle(DeckEditorQuestMenu.DECK_EDITOR_NAME); - exitCommand = exit; + this.exitCommand = exit; - setupMenu(); + this.setupMenu(); } /** @@ -99,18 +99,20 @@ public class DeckEditorQuestMenu extends JMenuBar { * a boolean. */ private void addImportExport(final JMenu menu, final boolean isHumanMenu) { - JMenuItem import2 = new JMenuItem("Import"); - JMenuItem export = new JMenuItem("Export"); + final JMenuItem import2 = new JMenuItem("Import"); + final JMenuItem export = new JMenuItem("Export"); import2.addActionListener(new ActionListener() { + @Override public void actionPerformed(final ActionEvent a) { - importDeck(); // importDeck(isHumanMenu); + DeckEditorQuestMenu.this.importDeck(); // importDeck(isHumanMenu); } }); // import export.addActionListener(new ActionListener() { + @Override public void actionPerformed(final ActionEvent a) { - exportDeck(); + DeckEditorQuestMenu.this.exportDeck(); } }); // export @@ -125,7 +127,7 @@ public class DeckEditorQuestMenu extends JMenuBar { *

*/ private void exportDeck() { - File filename = getExportFilename(); + final File filename = this.getExportFilename(); if (filename == null) { return; @@ -133,21 +135,21 @@ public class DeckEditorQuestMenu extends JMenuBar { // write is an Object variable because you might just // write one Deck object - Deck deck = cardPoolToDeck(deckDisplay.getBottom()); + final Deck deck = this.cardPoolToDeck(this.deckDisplay.getBottom()); deck.setName(filename.getName()); try { - ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(filename)); + final ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(filename)); out.writeObject(deck); out.flush(); out.close(); - } catch (Exception ex) { + } catch (final Exception ex) { ErrorViewer.showError(ex); throw new RuntimeException("Gui_Quest_DeckEditor_Menu : exportDeck() error, " + ex); } - exportDeckText(getExportDeckText(deck), filename.getAbsolutePath()); + this.exportDeckText(this.getExportDeckText(deck), filename.getAbsolutePath()); } // exportDeck() @@ -164,16 +166,16 @@ public class DeckEditorQuestMenu extends JMenuBar { private void exportDeckText(final String deckText, String filename) { // remove ".deck" extension - int cut = filename.indexOf("."); + final int cut = filename.indexOf("."); filename = filename.substring(0, cut); try { - FileWriter writer = new FileWriter(filename + ".txt"); + final FileWriter writer = new FileWriter(filename + ".txt"); writer.write(deckText); writer.flush(); writer.close(); - } catch (Exception ex) { + } catch (final Exception ex) { ErrorViewer.showError(ex); throw new RuntimeException("Gui_Quest_DeckEditor_Menu : exportDeckText() error, " + ex.getMessage() + " : " + Arrays.toString(ex.getStackTrace())); @@ -191,12 +193,12 @@ public class DeckEditorQuestMenu extends JMenuBar { */ private String getExportDeckText(final Deck aDeck) { // convert Deck into CardList - ItemPoolView all = aDeck.getMain(); + final ItemPoolView all = aDeck.getMain(); // sort by card name - Collections.sort(all.getOrderedList(), TableSorter.byNameThenSet); + Collections.sort(all.getOrderedList(), TableSorter.BY_NAME_THEN_SET); - StringBuffer sb = new StringBuffer(); - String newLine = "\r\n"; + final StringBuffer sb = new StringBuffer(); + final String newLine = "\r\n"; sb.append(String.format("%d Total Cards%n%n", all.countAll())); @@ -204,21 +206,22 @@ public class DeckEditorQuestMenu extends JMenuBar { sb.append(String.format("%d Creatures%n-------------%n", CardRules.Predicates.Presets.IS_CREATURE.aggregate(all, all.fnToCard, all.fnToCount))); - for (Entry e : CardRules.Predicates.Presets.IS_CREATURE.select(all, all.fnToCard)) { + for (final Entry e : CardRules.Predicates.Presets.IS_CREATURE.select(all, all.fnToCard)) { sb.append(String.format("%d x %s%n", e.getValue(), e.getKey().getName())); } // spells sb.append(String.format("%d Spells%n----------%n", CardRules.Predicates.Presets.IS_NON_CREATURE_SPELL.aggregate(all, all.fnToCard, all.fnToCount))); - for (Entry e : CardRules.Predicates.Presets.IS_NON_CREATURE_SPELL.select(all, all.fnToCard)) { + for (final Entry e : CardRules.Predicates.Presets.IS_NON_CREATURE_SPELL.select(all, + all.fnToCard)) { sb.append(String.format("%d x %s%n", e.getValue(), e.getKey().getName())); } // lands sb.append(String.format("%d Land%n--------%n", CardRules.Predicates.Presets.IS_LAND.aggregate(all, all.fnToCard, all.fnToCount))); - for (Entry e : CardRules.Predicates.Presets.IS_LAND.select(all, all.fnToCard)) { + for (final Entry e : CardRules.Predicates.Presets.IS_LAND.select(all, all.fnToCard)) { sb.append(String.format("%d x %s%n", e.getValue(), e.getKey().getName())); } @@ -235,7 +238,7 @@ public class DeckEditorQuestMenu extends JMenuBar { * @return a {@link javax.swing.filechooser.FileFilter} object. */ private FileFilter getFileFilter() { - FileFilter filter = new FileFilter() { + final FileFilter filter = new FileFilter() { @Override public boolean accept(final File f) { return f.getName().endsWith(".dck") || f.isDirectory(); @@ -260,20 +263,20 @@ public class DeckEditorQuestMenu extends JMenuBar { private File getExportFilename() { // Object o = null; // unused - JFileChooser save = new JFileChooser(previousDirectory); + final JFileChooser save = new JFileChooser(DeckEditorQuestMenu.previousDirectory); save.setDialogTitle("Export Deck Filename"); save.setDialogType(JFileChooser.SAVE_DIALOG); - save.addChoosableFileFilter(getFileFilter()); - save.setSelectedFile(new File(currentDeck.getName() + ".deck")); + save.addChoosableFileFilter(this.getFileFilter()); + save.setSelectedFile(new File(this.currentDeck.getName() + ".deck")); - int returnVal = save.showSaveDialog(null); + final int returnVal = save.showSaveDialog(null); if (returnVal == JFileChooser.APPROVE_OPTION) { - File file = save.getSelectedFile(); - String check = file.getAbsolutePath(); + final File file = save.getSelectedFile(); + final String check = file.getAbsolutePath(); - previousDirectory = file.getParentFile(); + DeckEditorQuestMenu.previousDirectory = file.getParentFile(); if (check.endsWith(".deck")) { return file; @@ -291,26 +294,26 @@ public class DeckEditorQuestMenu extends JMenuBar { *

*/ private void importDeck() { - File file = getImportFilename(); + final File file = this.getImportFilename(); if (file == null) { } else if (file.getName().endsWith(".dck")) { try { - Deck newDeck = DeckManager.readDeck(file); - questData.addDeck(newDeck); + final Deck newDeck = DeckManager.readDeck(file); + this.questData.addDeck(newDeck); - ItemPool cardpool = ItemPool.createFrom(questData.getCards().getCardpool(), + final ItemPool cardpool = ItemPool.createFrom(this.questData.getCards().getCardpool(), CardPrinted.class); - ItemPool decklist = new ItemPool(CardPrinted.class); - for (Entry s : newDeck.getMain()) { - CardPrinted cp = s.getKey(); + final ItemPool decklist = new ItemPool(CardPrinted.class); + for (final Entry s : newDeck.getMain()) { + final CardPrinted cp = s.getKey(); decklist.add(cp, s.getValue()); cardpool.add(cp, s.getValue()); - questData.getCards().getCardpool().add(cp, s.getValue()); + this.questData.getCards().getCardpool().add(cp, s.getValue()); } - deckDisplay.setDeck(cardpool, decklist, GameType.Quest); + this.deckDisplay.setDeck(cardpool, decklist, GameType.Quest); - } catch (Exception ex) { + } catch (final Exception ex) { ErrorViewer.showError(ex); throw new RuntimeException("Gui_DeckEditor_Menu : importDeck() error, " + ex); } @@ -326,14 +329,14 @@ public class DeckEditorQuestMenu extends JMenuBar { * @return a {@link java.io.File} object. */ private File getImportFilename() { - JFileChooser chooser = new JFileChooser(previousDirectory); + final JFileChooser chooser = new JFileChooser(DeckEditorQuestMenu.previousDirectory); - chooser.addChoosableFileFilter(getFileFilter()); - int returnVal = chooser.showOpenDialog(null); + chooser.addChoosableFileFilter(this.getFileFilter()); + final int returnVal = chooser.showOpenDialog(null); if (returnVal == JFileChooser.APPROVE_OPTION) { - File file = chooser.getSelectedFile(); - previousDirectory = file.getParentFile(); + final File file = chooser.getSelectedFile(); + DeckEditorQuestMenu.previousDirectory = file.getParentFile(); return file; } @@ -341,57 +344,64 @@ public class DeckEditorQuestMenu extends JMenuBar { } // openFileDialog() private final ActionListener addCardActionListener = new ActionListener() { + @Override public void actionPerformed(final ActionEvent a) { // Provide a model here: all unique cards to be displayed by only // name (unlike default toString) - Iterable uniqueCards = CardDb.instance().getAllUniqueCards(); - List cards = new ArrayList(); - for (CardPrinted c : uniqueCards) { + final Iterable uniqueCards = CardDb.instance().getAllUniqueCards(); + final List cards = new ArrayList(); + for (final CardPrinted c : uniqueCards) { cards.add(c.getName()); } Collections.sort(cards); // use standard forge's list selection dialog - ListChooser c = new ListChooser("Cheat - Add Card to Your Cardpool", 0, 1, cards); + final ListChooser c = new ListChooser("Cheat - Add Card to Your Cardpool", 0, 1, cards); if (c.show()) { - String cardName = c.getSelectedValue(); - DeckEditorQuest g = (DeckEditorQuest) deckDisplay; + final String cardName = c.getSelectedValue(); + final DeckEditorQuest g = (DeckEditorQuest) DeckEditorQuestMenu.this.deckDisplay; g.addCheatCard(CardDb.instance().getCard(cardName)); } } }; private final ActionListener openDeckActionListener = new ActionListener() { + @Override public void actionPerformed(final ActionEvent a) { - String deckName = getUserInput_OpenDeck(questData.getDeckNames()); + final String deckName = DeckEditorQuestMenu.this.getUserInputOpenDeck(DeckEditorQuestMenu.this.questData + .getDeckNames()); // check if user selected "cancel" if (StringUtils.isBlank(deckName)) { return; } - setPlayerDeckName(deckName); - ItemPool cards = ItemPool.createFrom(questData.getCards().getCardpool().getView(), - CardPrinted.class); - ItemPoolView deck = questData.getDeck(deckName).getMain(); + DeckEditorQuestMenu.this.setPlayerDeckName(deckName); + final ItemPool cards = ItemPool.createFrom(DeckEditorQuestMenu.this.questData.getCards() + .getCardpool().getView(), CardPrinted.class); + final ItemPoolView deck = DeckEditorQuestMenu.this.questData.getDeck(deckName).getMain(); // show in pool all cards except ones used in deck cards.removeAll(deck); - deckDisplay.setDeck(cards, deck, GameType.Quest); + DeckEditorQuestMenu.this.deckDisplay.setDeck(cards, deck, GameType.Quest); } }; private final ActionListener newDeckActionListener = new ActionListener() { + @Override public void actionPerformed(final ActionEvent a) { - deckDisplay.setItems(questData.getCards().getCardpool().getView(), null, GameType.Quest); - setPlayerDeckName(""); + DeckEditorQuestMenu.this.deckDisplay.setItems(DeckEditorQuestMenu.this.questData.getCards().getCardpool() + .getView(), null, GameType.Quest); + DeckEditorQuestMenu.this.setPlayerDeckName(""); } }; private final ActionListener renameDeckActionListener = new ActionListener() { + @Override public void actionPerformed(final ActionEvent a) { - String deckName = getUserInput_GetDeckName(questData.getDeckNames()); + final String deckName = DeckEditorQuestMenu.this + .getUserInputGetDeckName(DeckEditorQuestMenu.this.questData.getDeckNames()); // check if user cancels if (StringUtils.isBlank(deckName)) { @@ -399,27 +409,30 @@ public class DeckEditorQuestMenu extends JMenuBar { } // is the current deck already saved and in QuestData? - if (questData.getDeckNames().contains(currentDeck.getName())) { - questData.removeDeck(currentDeck.getName()); + if (DeckEditorQuestMenu.this.questData.getDeckNames().contains( + DeckEditorQuestMenu.this.currentDeck.getName())) { + DeckEditorQuestMenu.this.questData.removeDeck(DeckEditorQuestMenu.this.currentDeck.getName()); } - currentDeck.setName(deckName); + DeckEditorQuestMenu.this.currentDeck.setName(deckName); - Deck deck = cardPoolToDeck(deckDisplay.getBottom()); + final Deck deck = DeckEditorQuestMenu.this.cardPoolToDeck(DeckEditorQuestMenu.this.deckDisplay.getBottom()); deck.setName(deckName); - questData.addDeck(deck); + DeckEditorQuestMenu.this.questData.addDeck(deck); - setPlayerDeckName(deckName); + DeckEditorQuestMenu.this.setPlayerDeckName(deckName); } }; private final ActionListener saveDeckActionListener = new ActionListener() { + @Override public void actionPerformed(final ActionEvent a) { - String name = currentDeck.getName(); + String name = DeckEditorQuestMenu.this.currentDeck.getName(); // check to see if name is set if (name.equals("")) { - name = getUserInput_GetDeckName(questData.getDeckNames()); + name = DeckEditorQuestMenu.this.getUserInputGetDeckName(DeckEditorQuestMenu.this.questData + .getDeckNames()); // check if user cancels if (name.equals("")) { @@ -427,51 +440,55 @@ public class DeckEditorQuestMenu extends JMenuBar { } } - setPlayerDeckName(name); + DeckEditorQuestMenu.this.setPlayerDeckName(name); - Deck deck = cardPoolToDeck(deckDisplay.getBottom()); + final Deck deck = DeckEditorQuestMenu.this.cardPoolToDeck(DeckEditorQuestMenu.this.deckDisplay.getBottom()); deck.setName(name); - questData.addDeck(deck); + DeckEditorQuestMenu.this.questData.addDeck(deck); } }; private final ActionListener copyDeckActionListener = new ActionListener() { + @Override public void actionPerformed(final ActionEvent a) { - String name = getUserInput_GetDeckName(questData.getDeckNames()); + final String name = DeckEditorQuestMenu.this.getUserInputGetDeckName(DeckEditorQuestMenu.this.questData + .getDeckNames()); // check if user cancels if (name.equals("")) { return; } - setPlayerDeckName(name); + DeckEditorQuestMenu.this.setPlayerDeckName(name); - Deck deck = cardPoolToDeck(deckDisplay.getBottom()); + final Deck deck = DeckEditorQuestMenu.this.cardPoolToDeck(DeckEditorQuestMenu.this.deckDisplay.getBottom()); deck.setName(name); - questData.addDeck(deck); + DeckEditorQuestMenu.this.questData.addDeck(deck); } }; private final ActionListener deleteDeckActionListener = new ActionListener() { + @Override public void actionPerformed(final ActionEvent a) { - if (currentDeck.getName().equals("")) { + if (DeckEditorQuestMenu.this.currentDeck.getName().equals("")) { return; } - int check = JOptionPane.showConfirmDialog(null, "Do you really want to delete this deck?", "Delete", + final int check = JOptionPane.showConfirmDialog(null, "Do you really want to delete this deck?", "Delete", JOptionPane.YES_NO_OPTION); if (check == JOptionPane.NO_OPTION) { return; // stop here } - questData.removeDeck(currentDeck.getName()); + DeckEditorQuestMenu.this.questData.removeDeck(DeckEditorQuestMenu.this.currentDeck.getName()); // show card pool - deckDisplay.setItems(questData.getCards().getCardpool().getView(), null, GameType.Quest); + DeckEditorQuestMenu.this.deckDisplay.setItems(DeckEditorQuestMenu.this.questData.getCards().getCardpool() + .getView(), null, GameType.Quest); - setPlayerDeckName(""); + DeckEditorQuestMenu.this.setPlayerDeckName(""); } }; @@ -482,32 +499,33 @@ public class DeckEditorQuestMenu extends JMenuBar { *

*/ private void setupMenu() { - JMenuItem openDeck = new JMenuItem("Open"); - JMenuItem newDeck = new JMenuItem("New"); - JMenuItem rename = new JMenuItem("Rename"); - JMenuItem save = new JMenuItem("Save"); - JMenuItem copy = new JMenuItem("Copy"); - JMenuItem delete = new JMenuItem("Delete"); - JMenuItem exit = new JMenuItem("Exit"); + final JMenuItem openDeck = new JMenuItem("Open"); + final JMenuItem newDeck = new JMenuItem("New"); + final JMenuItem rename = new JMenuItem("Rename"); + final JMenuItem save = new JMenuItem("Save"); + final JMenuItem copy = new JMenuItem("Copy"); + final JMenuItem delete = new JMenuItem("Delete"); + final JMenuItem exit = new JMenuItem("Exit"); - JMenuItem addCard = new JMenuItem("Cheat - Add Card"); + final JMenuItem addCard = new JMenuItem("Cheat - Add Card"); - addCard.addActionListener(addCardActionListener); - openDeck.addActionListener(openDeckActionListener); - newDeck.addActionListener(newDeckActionListener); - rename.addActionListener(renameDeckActionListener); - save.addActionListener(saveDeckActionListener); - copy.addActionListener(copyDeckActionListener); - delete.addActionListener(deleteDeckActionListener); + addCard.addActionListener(this.addCardActionListener); + openDeck.addActionListener(this.openDeckActionListener); + newDeck.addActionListener(this.newDeckActionListener); + rename.addActionListener(this.renameDeckActionListener); + save.addActionListener(this.saveDeckActionListener); + copy.addActionListener(this.copyDeckActionListener); + delete.addActionListener(this.deleteDeckActionListener); // human exit.addActionListener(new ActionListener() { + @Override public void actionPerformed(final ActionEvent a) { DeckEditorQuestMenu.this.close(); } }); - JMenu deckMenu = new JMenu("Deck"); + final JMenu deckMenu = new JMenu("Deck"); deckMenu.add(openDeck); deckMenu.add(newDeck); deckMenu.add(rename); @@ -520,7 +538,7 @@ public class DeckEditorQuestMenu extends JMenuBar { } deckMenu.addSeparator(); - addImportExport(deckMenu, true); + this.addImportExport(deckMenu, true); deckMenu.addSeparator(); deckMenu.add(delete); @@ -542,7 +560,7 @@ public class DeckEditorQuestMenu extends JMenuBar { */ private Deck cardPoolToDeck(final ItemPoolView list) { // put CardPool into Deck main - Deck deck = new Deck(GameType.Sealed); + final Deck deck = new Deck(GameType.Sealed); deck.addMain(ItemPool.createFrom(list, CardPrinted.class)); return deck; } @@ -558,10 +576,10 @@ public class DeckEditorQuestMenu extends JMenuBar { */ public final void setPlayerDeckName(final String deckName) { // the gui uses this, Gui_Quest_DeckEditor - currentDeck = new Deck(GameType.Sealed); - currentDeck.setName(deckName); + this.currentDeck = new Deck(GameType.Sealed); + this.currentDeck.setName(deckName); - deckDisplay.setTitle(deckEditorName + " - " + deckName); + this.deckDisplay.setTitle(DeckEditorQuestMenu.DECK_EDITOR_NAME + " - " + deckName); } // only accepts numbers, letters or dashes up to 20 characters in length @@ -575,11 +593,11 @@ public class DeckEditorQuestMenu extends JMenuBar { * @return a {@link java.lang.String} object. */ private String cleanString(final String in) { - StringBuffer out = new StringBuffer(); - char[] c = in.toCharArray(); + final StringBuffer out = new StringBuffer(); + final char[] c = in.toCharArray(); - for (int i = 0; i < c.length && i < 20; i++) { - if (Character.isLetterOrDigit(c[i]) || c[i] == '-' || c[i] == '_' || c[i] == ' ') { + for (int i = 0; (i < c.length) && (i < 20); i++) { + if (Character.isLetterOrDigit(c[i]) || (c[i] == '-') || (c[i] == '_') || (c[i] == ' ')) { out.append(c[i]); } } @@ -597,18 +615,18 @@ public class DeckEditorQuestMenu extends JMenuBar { * a {@link java.util.List} object. * @return a {@link java.lang.String} object. */ - private String getUserInput_GetDeckName(final List nameList) { - Object o = JOptionPane.showInputDialog(null, "", "Deck Name", JOptionPane.OK_CANCEL_OPTION); + private String getUserInputGetDeckName(final List nameList) { + final Object o = JOptionPane.showInputDialog(null, "", "Deck Name", JOptionPane.OK_CANCEL_OPTION); if (o == null) { return ""; } - String deckName = cleanString(o.toString()); + final String deckName = this.cleanString(o.toString()); if (nameList.contains(deckName) || deckName.equals("")) { JOptionPane.showMessageDialog(null, "Please pick another deck name, a deck currently has that name."); - return getUserInput_GetDeckName(nameList); + return this.getUserInputGetDeckName(nameList); } return deckName; @@ -624,8 +642,8 @@ public class DeckEditorQuestMenu extends JMenuBar { * a {@link java.util.List} object. * @return a {@link java.lang.String} object. */ - private String getUserInput_OpenDeck(final List deckNameList) { - List choices = deckNameList; + private String getUserInputOpenDeck(final List deckNameList) { + final List choices = deckNameList; if (choices.size() == 0) { JOptionPane.showMessageDialog(null, "No decks found", "Open Deck", JOptionPane.PLAIN_MESSAGE); return ""; @@ -634,7 +652,7 @@ public class DeckEditorQuestMenu extends JMenuBar { // Object o = JOptionPane.showInputDialog(null, "Deck Name", // "Open Deck", JOptionPane.OK_CANCEL_OPTION, null, // choices.toArray(), choices.toArray()[0]); - Object o = GuiUtils.getChoiceOptional("Select Deck", choices.toArray()); + final Object o = GuiUtils.getChoiceOptional("Select Deck", choices.toArray()); if (o == null) { return ""; @@ -650,7 +668,7 @@ public class DeckEditorQuestMenu extends JMenuBar { *

*/ public final void close() { - exitCommand.execute(); + this.exitCommand.execute(); } // used by Gui_Quest_DeckEditor @@ -662,7 +680,7 @@ public class DeckEditorQuestMenu extends JMenuBar { * @return a {@link java.lang.String} object. */ public final String getDeckName() { - return currentDeck.getName(); + return this.currentDeck.getName(); } } diff --git a/src/main/java/forge/gui/deckeditor/DeckEditorShop.java b/src/main/java/forge/gui/deckeditor/DeckEditorShop.java index d6f7f0ace1e..9903208d889 100644 --- a/src/main/java/forge/gui/deckeditor/DeckEditorShop.java +++ b/src/main/java/forge/gui/deckeditor/DeckEditorShop.java @@ -45,21 +45,21 @@ public final class DeckEditorShop extends DeckEditorBase { /** Constant serialVersionUID=3988857075791576483L. */ private static final long serialVersionUID = 3988857075791576483L; - private JButton buyButton = new JButton(); - private JButton sellButton = new JButton(); + private final JButton buyButton = new JButton(); + private final JButton sellButton = new JButton(); - private JLabel creditsLabel = new JLabel(); - private JLabel jLabel1 = new JLabel(); - private JLabel sellPercentageLabel = new JLabel(); + private final JLabel creditsLabel = new JLabel(); + private final JLabel jLabel1 = new JLabel(); + private final JLabel sellPercentageLabel = new JLabel(); private double multiplier; - private QuestData questData; + private final QuestData questData; // private CardPoolView newCardsList; // get pricelist: - private ReadPriceList r = new ReadPriceList(); - private Map mapPrices = r.getPriceList(); + private final ReadPriceList r = new ReadPriceList(); + private final Map mapPrices = this.r.getPriceList(); private Map decksUsingMyCards; /** @@ -72,6 +72,7 @@ public final class DeckEditorShop extends DeckEditorBase { final Command exit = new Command() { private static final long serialVersionUID = -7428793574300520612L; + @Override public void execute() { DeckEditorShop.this.dispose(); exitCommand.execute(); @@ -86,46 +87,46 @@ public final class DeckEditorShop extends DeckEditorBase { } }); - setup(); + this.setup(); - decksUsingMyCards = countDecksForEachCard(); + this.decksUsingMyCards = this.countDecksForEachCard(); - multiplier = questData.getCards().getSellMutliplier(); + this.multiplier = this.questData.getCards().getSellMutliplier(); - ItemPoolView forSale = questData.getCards().getShopList(); + ItemPoolView forSale = this.questData.getCards().getShopList(); if (forSale.isEmpty()) { - questData.getCards().generateCardsInShop(); - forSale = questData.getCards().getShopList(); + this.questData.getCards().generateCardsInShop(); + forSale = this.questData.getCards().getShopList(); } - ItemPoolView owned = questData.getCards().getCardpool().getView(); + final ItemPoolView owned = this.questData.getCards().getCardpool().getView(); // newCardsList = questData.getCards().getNewCards(); - setItems(forSale, owned, GameType.Quest); + this.setItems(forSale, owned, GameType.Quest); - double multiPercent = multiplier * 100; - NumberFormat formatter = new DecimalFormat("#0.00"); + final double multiPercent = this.multiplier * 100; + final NumberFormat formatter = new DecimalFormat("#0.00"); String maxSellingPrice = ""; - int maxSellPrice = questData.getCards().getSellPriceLimit(); + final int maxSellPrice = this.questData.getCards().getSellPriceLimit(); if (maxSellPrice < Integer.MAX_VALUE) { maxSellingPrice = String.format("Max selling price: %d", maxSellPrice); } - sellPercentageLabel.setText("(You can sell cards at " + formatter.format(multiPercent) + this.sellPercentageLabel.setText("(You can sell cards at " + formatter.format(multiPercent) + "% of their value)
" + maxSellingPrice + ""); - top.sort(1, true); - bottom.sort(1, true); + this.getTopTableWithCards().sort(1, true); + this.getBottomTableWithCards().sort(1, true); } // show(Command) // fills number of decks using each card private Map countDecksForEachCard() { - Map result = new HashMap(); - for (String deckName : questData.getDeckNames()) { - Deck deck = questData.getDeck(deckName); - for (Entry e : deck.getMain()) { - CardPrinted card = e.getKey(); - Integer iValue = result.get(card); - int cntDecks = iValue == null ? 1 : 1 + iValue.intValue(); + final Map result = new HashMap(); + for (final String deckName : this.questData.getDeckNames()) { + final Deck deck = this.questData.getDeck(deckName); + for (final Entry e : deck.getMain()) { + final CardPrinted card = e.getKey(); + final Integer iValue = result.get(card); + final int cntDecks = iValue == null ? 1 : 1 + iValue.intValue(); result.put(card, Integer.valueOf(cntDecks)); } } @@ -138,11 +139,13 @@ public final class DeckEditorShop extends DeckEditorBase { *

*/ private void setup() { - List> columns = new ArrayList>(); - columns.add(new TableColumnInfo("Qty", 30, PresetColumns.FN_QTY_COMPARE, PresetColumns.FN_QTY_GET)); + final List> columns = new ArrayList>(); + columns.add(new TableColumnInfo("Qty", 30, PresetColumns.FN_QTY_COMPARE, + PresetColumns.FN_QTY_GET)); columns.add(new TableColumnInfo("Name", 180, PresetColumns.FN_NAME_COMPARE, PresetColumns.FN_NAME_GET)); - columns.add(new TableColumnInfo("Cost", 70, PresetColumns.FN_COST_COMPARE, PresetColumns.FN_COST_GET)); + columns.add(new TableColumnInfo("Cost", 70, PresetColumns.FN_COST_COMPARE, + PresetColumns.FN_COST_GET)); columns.add(new TableColumnInfo("Color", 50, PresetColumns.FN_COLOR_COMPARE, PresetColumns.FN_COLOR_GET)); columns.add(new TableColumnInfo("Type", 100, PresetColumns.FN_TYPE_COMPARE, @@ -151,18 +154,19 @@ public final class DeckEditorShop extends DeckEditorBase { PresetColumns.FN_STATS_GET)); columns.add(new TableColumnInfo("R", 30, PresetColumns.FN_RARITY_COMPARE, PresetColumns.FN_RARITY_GET)); - columns.add(new TableColumnInfo("Set", 35, PresetColumns.FN_SET_COMPARE, PresetColumns.FN_SET_GET)); + columns.add(new TableColumnInfo("Set", 35, PresetColumns.FN_SET_COMPARE, + PresetColumns.FN_SET_GET)); columns.get(2).setCellRenderer(new ManaCostRenderer()); - List> columnsBelow = new ArrayList>(columns); - columns.add(new TableColumnInfo("Price", 36, fnPriceCompare, fnPriceGet)); - top.setup(columns, cardView); + final List> columnsBelow = new ArrayList>(columns); + columns.add(new TableColumnInfo("Price", 36, this.fnPriceCompare, this.fnPriceGet)); + this.getTopTableWithCards().setup(columns, this.getCardView()); - columnsBelow.add(new TableColumnInfo("Dks", 30, fnDeckCompare, fnDeckGet)); - columnsBelow.add(new TableColumnInfo("New", 35, questData.getCards().fnNewCompare, questData - .getCards().fnNewGet)); - columnsBelow.add(new TableColumnInfo("Price", 36, fnPriceCompare, fnPriceSellGet)); - bottom.setup(columnsBelow, cardView); + columnsBelow.add(new TableColumnInfo("Dks", 30, this.fnDeckCompare, this.fnDeckGet)); + columnsBelow.add(new TableColumnInfo("New", 35, this.questData.getCards().fnNewCompare, + this.questData.getCards().fnNewGet)); + columnsBelow.add(new TableColumnInfo("Price", 36, this.fnPriceCompare, this.fnPriceSellGet)); + this.getBottomTableWithCards().setup(columnsBelow, this.getCardView()); this.setSize(1024, 768); GuiUtils.centerFrame(this); @@ -179,14 +183,14 @@ public final class DeckEditorShop extends DeckEditorBase { */ public DeckEditorShop(final QuestData qd) { super(GameType.Quest); - questData = qd; + this.questData = qd; try { - filterBoxes = null; - top = new TableWithCards("Cards for sale", false); - bottom = new TableWithCards("Owned Cards", false); - cardView = new CardPanelLite(); - jbInit(); - } catch (Exception ex) { + this.setFilterBoxes(null); + this.setTopTableWithCards(new TableWithCards("Cards for sale", false)); + this.setBottomTableWithCards(new TableWithCards("Owned Cards", false)); + this.setCardView(new CardPanelLite()); + this.jbInit(); + } catch (final Exception ex) { ErrorViewer.showError(ex); } } @@ -202,64 +206,66 @@ public final class DeckEditorShop extends DeckEditorBase { private void jbInit() throws Exception { this.setLayout(null); - top.getTableDecorated().setBounds(new Rectangle(19, 20, 726, 346)); - bottom.getTableDecorated().setBounds(new Rectangle(19, 458, 726, 276)); + this.getTopTableWithCards().getTableDecorated().setBounds(new Rectangle(19, 20, 726, 346)); + this.getBottomTableWithCards().getTableDecorated().setBounds(new Rectangle(19, 458, 726, 276)); - sellButton.setBounds(new Rectangle(180, 403, 146, 49)); + this.sellButton.setBounds(new Rectangle(180, 403, 146, 49)); // removeButton.setIcon(upIcon); if (!Singletons.getModel().getPreferences().lafFonts) { - sellButton.setFont(new java.awt.Font("Dialog", 0, 13)); + this.sellButton.setFont(new java.awt.Font("Dialog", 0, 13)); } - sellButton.setText("Sell Card"); - sellButton.addActionListener(new java.awt.event.ActionListener() { + this.sellButton.setText("Sell Card"); + this.sellButton.addActionListener(new java.awt.event.ActionListener() { + @Override public void actionPerformed(final ActionEvent e) { - sellButtonActionPerformed(e); + DeckEditorShop.this.sellButtonActionPerformed(e); } }); - buyButton.setText("Buy Card"); - buyButton.addActionListener(new java.awt.event.ActionListener() { + this.buyButton.setText("Buy Card"); + this.buyButton.addActionListener(new java.awt.event.ActionListener() { + @Override public void actionPerformed(final ActionEvent e) { - buyButtonActionPerformed(e); + DeckEditorShop.this.buyButtonActionPerformed(e); } }); if (!Singletons.getModel().getPreferences().lafFonts) { - buyButton.setFont(new java.awt.Font("Dialog", 0, 13)); + this.buyButton.setFont(new java.awt.Font("Dialog", 0, 13)); } - buyButton.setBounds(new Rectangle(23, 403, 146, 49)); + this.buyButton.setBounds(new Rectangle(23, 403, 146, 49)); - cardView.setBounds(new Rectangle(765, 23, 239, 710)); + this.getCardView().setBounds(new Rectangle(765, 23, 239, 710)); // Do not lower statsLabel any lower, we want this to be visible at 1024 // x 768 screen size this.setTitle("Card Shop"); - creditsLabel.setBounds(new Rectangle(19, 365, 720, 31)); - creditsLabel.setText("Total credits: " + questData.getCredits()); + this.creditsLabel.setBounds(new Rectangle(19, 365, 720, 31)); + this.creditsLabel.setText("Total credits: " + this.questData.getCredits()); if (!Singletons.getModel().getPreferences().lafFonts) { - creditsLabel.setFont(new java.awt.Font("Dialog", 0, 14)); + this.creditsLabel.setFont(new java.awt.Font("Dialog", 0, 14)); } - sellPercentageLabel.setBounds(new Rectangle(350, 403, 450, 31)); - sellPercentageLabel.setText("(Sell percentage: " + multiplier + ")"); + this.sellPercentageLabel.setBounds(new Rectangle(350, 403, 450, 31)); + this.sellPercentageLabel.setText("(Sell percentage: " + this.multiplier + ")"); if (!Singletons.getModel().getPreferences().lafFonts) { - sellPercentageLabel.setFont(new java.awt.Font("Dialog", 0, 14)); + this.sellPercentageLabel.setFont(new java.awt.Font("Dialog", 0, 14)); } - jLabel1.setText("Click on the column name (like name or color) to sort the cards"); - jLabel1.setBounds(new Rectangle(20, 1, 400, 19)); + this.jLabel1.setText("Click on the column name (like name or color) to sort the cards"); + this.jLabel1.setBounds(new Rectangle(20, 1, 400, 19)); - this.getContentPane().add(cardView, null); - this.getContentPane().add(top.getTableDecorated(), null); - this.getContentPane().add(bottom.getTableDecorated(), null); - this.getContentPane().add(creditsLabel, null); - this.getContentPane().add(buyButton, null); - this.getContentPane().add(sellButton, null); - this.getContentPane().add(sellPercentageLabel, null); - this.getContentPane().add(jLabel1, null); + this.getContentPane().add(this.getCardView(), null); + this.getContentPane().add(this.getTopTableWithCards().getTableDecorated(), null); + this.getContentPane().add(this.getBottomTableWithCards().getTableDecorated(), null); + this.getContentPane().add(this.creditsLabel, null); + this.getContentPane().add(this.buyButton, null); + this.getContentPane().add(this.sellButton, null); + this.getContentPane().add(this.sellPercentageLabel, null); + this.getContentPane().add(this.jLabel1, null); } // TODO: move to cardshop private Integer getCardValue(final InventoryItem card) { - if (mapPrices.containsKey(card.getName())) { - return mapPrices.get(card.getName()); + if (this.mapPrices.containsKey(card.getName())) { + return this.mapPrices.get(card.getName()); } else if (card instanceof CardPrinted) { switch (((CardPrinted) card).getRarity()) { case BasicLand: @@ -282,34 +288,34 @@ public final class DeckEditorShop extends DeckEditorBase { } private void buyButtonActionPerformed(final ActionEvent e) { - InventoryItem item = top.getSelectedCard(); + final InventoryItem item = this.getTopTableWithCards().getSelectedCard(); if (item == null) { return; } - int value = getCardValue(item); + final int value = this.getCardValue(item); - if (value <= questData.getCredits()) { + if (value <= this.questData.getCredits()) { if (item instanceof CardPrinted) { - CardPrinted card = (CardPrinted) item; - bottom.addCard(card); - top.removeCard(card); + final CardPrinted card = (CardPrinted) item; + this.getBottomTableWithCards().addCard(card); + this.getTopTableWithCards().removeCard(card); - questData.getCards().buyCard(card, value); + this.questData.getCards().buyCard(card, value); } else if (item instanceof BoosterPack) { - top.removeCard(item); - BoosterPack booster = (BoosterPack) ((BoosterPack) item).clone(); - questData.getCards().buyBooster(booster, value); - List newCards = booster.getCards(); - for (CardPrinted card : newCards) { - bottom.addCard(card); + this.getTopTableWithCards().removeCard(item); + final BoosterPack booster = (BoosterPack) ((BoosterPack) item).clone(); + this.questData.getCards().buyBooster(booster, value); + final List newCards = booster.getCards(); + for (final CardPrinted card : newCards) { + this.getBottomTableWithCards().addCard(card); } - CardListViewer c = new CardListViewer(booster.getName(), "You have found the following cards inside:", - newCards); + final CardListViewer c = new CardListViewer(booster.getName(), + "You have found the following cards inside:", newCards); c.show(); } - creditsLabel.setText("Total credits: " + questData.getCredits()); + this.creditsLabel.setText("Total credits: " + this.questData.getCredits()); } else { JOptionPane.showMessageDialog(null, "Not enough credits!"); } @@ -326,38 +332,39 @@ public final class DeckEditorShop extends DeckEditorBase { } private void sellButtonActionPerformed(final ActionEvent e) { - InventoryItem item = bottom.getSelectedCard(); - if (item == null || !(item instanceof CardPrinted)) { + final InventoryItem item = this.getBottomTableWithCards().getSelectedCard(); + if ((item == null) || !(item instanceof CardPrinted)) { return; } - CardPrinted card = (CardPrinted) item; - bottom.removeCard(card); - top.addCard(card); + final CardPrinted card = (CardPrinted) item; + this.getBottomTableWithCards().removeCard(card); + this.getTopTableWithCards().addCard(card); - int price = Math.min((int) (multiplier * getCardValue(card)), questData.getCards().getSellPriceLimit()); - questData.getCards().sellCard(card, price); + final int price = Math.min((int) (this.multiplier * this.getCardValue(card)), this.questData.getCards() + .getSellPriceLimit()); + this.questData.getCards().sellCard(card, price); - creditsLabel.setText("Total credits: " + questData.getCredits()); + this.creditsLabel.setText("Total credits: " + this.questData.getCredits()); } @SuppressWarnings("rawtypes") private final Lambda1> fnPriceCompare = new Lambda1>() { @Override public Comparable apply(final Entry from) { - return getCardValue(from.getKey()); + return DeckEditorShop.this.getCardValue(from.getKey()); } }; private final Lambda1> fnPriceGet = new Lambda1>() { @Override public Object apply(final Entry from) { - return getCardValue(from.getKey()); + return DeckEditorShop.this.getCardValue(from.getKey()); } }; private final Lambda1> fnPriceSellGet = new Lambda1>() { @Override public Object apply(final Entry from) { - return (int) (multiplier * getCardValue(from.getKey())); + return (int) (DeckEditorShop.this.multiplier * DeckEditorShop.this.getCardValue(from.getKey())); } }; @@ -365,14 +372,14 @@ public final class DeckEditorShop extends DeckEditorBase { private final Lambda1> fnDeckCompare = new Lambda1>() { @Override public Comparable apply(final Entry from) { - Integer iValue = decksUsingMyCards.get(from.getKey()); + final Integer iValue = DeckEditorShop.this.decksUsingMyCards.get(from.getKey()); return iValue == null ? Integer.valueOf(0) : iValue; } }; private final Lambda1> fnDeckGet = new Lambda1>() { @Override public Object apply(final Entry from) { - Integer iValue = decksUsingMyCards.get(from.getKey()); + final Integer iValue = DeckEditorShop.this.decksUsingMyCards.get(from.getKey()); return iValue == null ? "" : iValue.toString(); } }; diff --git a/src/main/java/forge/gui/deckeditor/DeckImport.java b/src/main/java/forge/gui/deckeditor/DeckImport.java index 8239479de60..6d7a3eb341f 100644 --- a/src/main/java/forge/gui/deckeditor/DeckImport.java +++ b/src/main/java/forge/gui/deckeditor/DeckImport.java @@ -37,17 +37,18 @@ import forge.item.CardPrinted; public class DeckImport extends JDialog { private static final long serialVersionUID = -5837776824284093004L; - private JTextArea txtInput = new JTextArea(); - private static final String stylesheet = ""; - private static final String htmlWelcomeText = "" - + stylesheet + private static final String HTML_WELCOME_TEXT = "" + + DeckImport.STYLESHEET + "

You'll see recognized cards here

" + "
Legend
" + "
    " @@ -57,16 +58,16 @@ public class DeckImport extends JDialog { + "
    Submit feedback to Max mtg on slightlymagic.net forum
    " + "
    Post bug-reports to http://cardforge.org/bugz/
    " + ""; - private JEditorPane htmlOutput = new JEditorPane("text/html", htmlWelcomeText); - private JScrollPane scrollInput = new JScrollPane(txtInput); - private JScrollPane scrollOutput = new JScrollPane(htmlOutput); - private JLabel summaryMain = new JLabel("Imported deck summary will appear here"); - private JLabel summarySide = new JLabel("This is second line"); - private JButton cmdAccept = new JButton("Import Deck"); - private JButton cmdCancel = new JButton("Cancel"); + private final JEditorPane htmlOutput = new JEditorPane("text/html", DeckImport.HTML_WELCOME_TEXT); + private final JScrollPane scrollInput = new JScrollPane(this.txtInput); + private final JScrollPane scrollOutput = new JScrollPane(this.htmlOutput); + private final JLabel summaryMain = new JLabel("Imported deck summary will appear here"); + private final JLabel summarySide = new JLabel("This is second line"); + private final JButton cmdAccept = new JButton("Import Deck"); + private final JButton cmdCancel = new JButton("Cancel"); /** The tokens. */ - List tokens = new ArrayList(); + private List tokens = new ArrayList(); private final DeckEditorBase host; @@ -77,131 +78,132 @@ public class DeckImport extends JDialog { * the g */ public DeckImport(final DeckEditorBase g) { - host = g; + this.host = g; - int wWidth = 600; - int wHeight = 600; + final int wWidth = 600; + final int wHeight = 600; - setPreferredSize(new java.awt.Dimension(wWidth, wHeight)); - setSize(wWidth, wHeight); + this.setPreferredSize(new java.awt.Dimension(wWidth, wHeight)); + this.setSize(wWidth, wHeight); GuiUtils.centerFrame(this); - setResizable(false); - setTitle("Deck Import (wip)"); + this.setResizable(false); + this.setTitle("Deck Import (wip)"); if (!Singletons.getModel().getPreferences().lafFonts) { - Font fButtons = new java.awt.Font("Dialog", 0, 13); - cmdAccept.setFont(fButtons); - cmdCancel.setFont(fButtons); + final Font fButtons = new java.awt.Font("Dialog", 0, 13); + this.cmdAccept.setFont(fButtons); + this.cmdCancel.setFont(fButtons); - txtInput.setFont(fButtons); + this.txtInput.setFont(fButtons); // htmlOutput.setFont(fButtons); } - htmlOutput.setEditable(false); + this.htmlOutput.setEditable(false); - scrollInput.setBorder(new TitledBorder(BorderFactory.createEtchedBorder(), "Paste or type a decklist")); - scrollOutput.setBorder(new TitledBorder(BorderFactory.createEtchedBorder(), + this.scrollInput.setBorder(new TitledBorder(BorderFactory.createEtchedBorder(), "Paste or type a decklist")); + this.scrollOutput.setBorder(new TitledBorder(BorderFactory.createEtchedBorder(), "Expect the recognized lines to appear")); - scrollInput.setViewportBorder(BorderFactory.createLoweredBevelBorder()); - scrollOutput.setViewportBorder(BorderFactory.createLoweredBevelBorder()); + this.scrollInput.setViewportBorder(BorderFactory.createLoweredBevelBorder()); + this.scrollOutput.setViewportBorder(BorderFactory.createLoweredBevelBorder()); - getContentPane().setLayout(new MigLayout("fill")); - getContentPane().add(scrollInput, "cell 0 0, w 50%, sy 4, growy, pushy"); - getContentPane().add(scrollOutput, "cell 1 0, w 50%, growy, pushy"); + this.getContentPane().setLayout(new MigLayout("fill")); + this.getContentPane().add(this.scrollInput, "cell 0 0, w 50%, sy 4, growy, pushy"); + this.getContentPane().add(this.scrollOutput, "cell 1 0, w 50%, growy, pushy"); - getContentPane().add(summaryMain, "cell 1 1, label"); - getContentPane().add(summarySide, "cell 1 2, label"); + this.getContentPane().add(this.summaryMain, "cell 1 1, label"); + this.getContentPane().add(this.summarySide, "cell 1 2, label"); - getContentPane().add(cmdAccept, "cell 1 3, split 2, w 100, align c"); - getContentPane().add(cmdCancel, "w 100"); + this.getContentPane().add(this.cmdAccept, "cell 1 3, split 2, w 100, align c"); + this.getContentPane().add(this.cmdCancel, "w 100"); - cmdCancel.addActionListener(new ActionListener() { + this.cmdCancel.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { - processWindowEvent(new WindowEvent(DeckImport.this, WindowEvent.WINDOW_CLOSING)); + DeckImport.this.processWindowEvent(new WindowEvent(DeckImport.this, WindowEvent.WINDOW_CLOSING)); } }); - cmdAccept.addActionListener(new ActionListener() { + this.cmdAccept.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { - String warning = "This will replace contents of your currently open deck with whatever you are importing. Proceed?"; - int answer = JOptionPane.showConfirmDialog(DeckImport.this, warning, "Replacing old deck", + final String warning = "This will replace contents of your currently open deck with whatever you are importing. Proceed?"; + final int answer = JOptionPane.showConfirmDialog(DeckImport.this, warning, "Replacing old deck", JOptionPane.YES_NO_OPTION); if (JOptionPane.NO_OPTION == answer) { return; } - Deck toSet = buildDeck(); - host.setDeck(null, toSet.getMain(), toSet.getDeckType()); - processWindowEvent(new WindowEvent(DeckImport.this, WindowEvent.WINDOW_CLOSING)); + final Deck toSet = DeckImport.this.buildDeck(); + DeckImport.this.host.setDeck(null, toSet.getMain(), toSet.getDeckType()); + DeckImport.this.processWindowEvent(new WindowEvent(DeckImport.this, WindowEvent.WINDOW_CLOSING)); } }); - txtInput.getDocument().addDocumentListener(new OnChangeTextUpdate()); - cmdAccept.setEnabled(false); + this.txtInput.getDocument().addDocumentListener(new OnChangeTextUpdate()); + this.cmdAccept.setEnabled(false); } private void readInput() { - tokens.clear(); - ElementIterator it = new ElementIterator(txtInput.getDocument().getDefaultRootElement()); + this.tokens.clear(); + final ElementIterator it = new ElementIterator(this.txtInput.getDocument().getDefaultRootElement()); Element e; while ((e = it.next()) != null) { if (!e.isLeaf()) { continue; } - int rangeStart = e.getStartOffset(); - int rangeEnd = e.getEndOffset(); + final int rangeStart = e.getStartOffset(); + final int rangeEnd = e.getEndOffset(); try { - String line = txtInput.getText(rangeStart, rangeEnd - rangeStart); - tokens.add(DeckRecognizer.recognizeLine(line)); - } catch (BadLocationException ex) { + final String line = this.txtInput.getText(rangeStart, rangeEnd - rangeStart); + this.tokens.add(DeckRecognizer.recognizeLine(line)); + } catch (final BadLocationException ex) { } } } private void displayTokens() { - StringBuilder sbOut = new StringBuilder(""); - sbOut.append(stylesheet); - for (DeckRecognizer.Token t : tokens) { - sbOut.append(makeHtmlViewOfToken(t)); + final StringBuilder sbOut = new StringBuilder(""); + sbOut.append(DeckImport.STYLESHEET); + for (final DeckRecognizer.Token t : this.tokens) { + sbOut.append(this.makeHtmlViewOfToken(t)); } sbOut.append(""); - htmlOutput.setText(sbOut.toString()); + this.htmlOutput.setText(sbOut.toString()); } private void updateSummaries() { - int[] cardsOk = new int[2]; - int[] cardsUnknown = new int[2]; + final int[] cardsOk = new int[2]; + final int[] cardsUnknown = new int[2]; int idx = 0; - for (DeckRecognizer.Token t : tokens) { + for (final DeckRecognizer.Token t : this.tokens) { if (t.getType() == TokenType.KnownCard) { cardsOk[idx] += t.getNumber(); } if (t.getType() == TokenType.UnknownCard) { cardsUnknown[idx] += t.getNumber(); } - if (t.getType() == TokenType.SectionName && t.getText().toLowerCase().contains("side")) { + if ((t.getType() == TokenType.SectionName) && t.getText().toLowerCase().contains("side")) { idx = 1; } } - summaryMain.setText(String.format("Main: %d cards recognized, %d unknown cards", cardsOk[0], cardsUnknown[0])); - summarySide.setText(String.format("Sideboard: %d cards recognized, %d unknown cards", cardsOk[1], + this.summaryMain.setText(String.format("Main: %d cards recognized, %d unknown cards", cardsOk[0], + cardsUnknown[0])); + this.summarySide.setText(String.format("Sideboard: %d cards recognized, %d unknown cards", cardsOk[1], cardsUnknown[1])); - cmdAccept.setEnabled(cardsOk[0] > 0); + this.cmdAccept.setEnabled(cardsOk[0] > 0); } private Deck buildDeck() { - Deck result = new Deck(GameType.Constructed); + final Deck result = new Deck(GameType.Constructed); boolean isMain = true; - for (DeckRecognizer.Token t : tokens) { - DeckRecognizer.TokenType type = t.getType(); - if (type == DeckRecognizer.TokenType.SectionName && t.getText().toLowerCase().contains("side")) { + for (final DeckRecognizer.Token t : this.tokens) { + final DeckRecognizer.TokenType type = t.getType(); + if ((type == DeckRecognizer.TokenType.SectionName) && t.getText().toLowerCase().contains("side")) { isMain = false; } if (type != DeckRecognizer.TokenType.KnownCard) { continue; } - CardPrinted crd = t.getCard(); + final CardPrinted crd = t.getCard(); if (crd.isAlternate()) { continue; } @@ -219,9 +221,9 @@ public class DeckImport extends JDialog { */ protected class OnChangeTextUpdate implements DocumentListener { private void onChange() { - readInput(); - displayTokens(); - updateSummaries(); + DeckImport.this.readInput(); + DeckImport.this.displayTokens(); + DeckImport.this.updateSummaries(); } /* @@ -233,7 +235,7 @@ public class DeckImport extends JDialog { */ @Override public final void insertUpdate(final DocumentEvent e) { - onChange(); + this.onChange(); } /* @@ -245,7 +247,7 @@ public class DeckImport extends JDialog { */ @Override public final void removeUpdate(final DocumentEvent e) { - onChange(); + this.onChange(); } /* diff --git a/src/main/java/forge/gui/deckeditor/FilterCheckBoxes.java b/src/main/java/forge/gui/deckeditor/FilterCheckBoxes.java index 169781cb29e..a09da2c7331 100644 --- a/src/main/java/forge/gui/deckeditor/FilterCheckBoxes.java +++ b/src/main/java/forge/gui/deckeditor/FilterCheckBoxes.java @@ -18,50 +18,50 @@ import forge.item.CardPrinted; class FilterCheckBoxes { /** The white. */ - public final JCheckBox white; + private final JCheckBox white; /** The blue. */ - public final JCheckBox blue; + private final JCheckBox blue; /** The black. */ - public final JCheckBox black; + private final JCheckBox black; /** The red. */ - public final JCheckBox red; + private final JCheckBox red; /** The green. */ - public final JCheckBox green; + private final JCheckBox green; /** The colorless. */ - public final JCheckBox colorless; + private final JCheckBox colorless; /** The land. */ - public final JCheckBox land; + private final JCheckBox land; /** The creature. */ - public final JCheckBox creature; + private final JCheckBox creature; /** The sorcery. */ - public final JCheckBox sorcery; + private final JCheckBox sorcery; /** The instant. */ - public final JCheckBox instant; + private final JCheckBox instant; /** The planeswalker. */ - public final JCheckBox planeswalker; + private final JCheckBox planeswalker; /** The artifact. */ - public final JCheckBox artifact; + private final JCheckBox artifact; /** The enchantment. */ - public final JCheckBox enchantment; + private final JCheckBox enchantment; // Very handy for classes using mass operations on an array of checkboxes /** The all colors. */ - public final List allColors; + private final List allColors; /** The all types. */ - public final List allTypes; + private final List allTypes; /** * Instantiates a new filter check boxes. @@ -71,40 +71,41 @@ class FilterCheckBoxes { */ public FilterCheckBoxes(final boolean useGraphicalBoxes) { if (useGraphicalBoxes) { - white = new CheckBoxWithIcon("white", "White"); - blue = new CheckBoxWithIcon("blue", "Blue"); - black = new CheckBoxWithIcon("black", "Black"); - red = new CheckBoxWithIcon("red", "Red"); - green = new CheckBoxWithIcon("green", "Green"); - colorless = new CheckBoxWithIcon("colorless", "Colorless"); + this.white = new CheckBoxWithIcon("white", "White"); + this.blue = new CheckBoxWithIcon("blue", "Blue"); + this.black = new CheckBoxWithIcon("black", "Black"); + this.red = new CheckBoxWithIcon("red", "Red"); + this.green = new CheckBoxWithIcon("green", "Green"); + this.colorless = new CheckBoxWithIcon("colorless", "Colorless"); - land = new CheckBoxWithIcon("land", "Land"); - creature = new CheckBoxWithIcon("creature", "Creature"); - sorcery = new CheckBoxWithIcon("sorcery", "Sorcery"); - instant = new CheckBoxWithIcon("instant", "Instant"); - planeswalker = new CheckBoxWithIcon("planeswalker", "Planeswalker"); - artifact = new CheckBoxWithIcon("artifact", "Artifact"); - enchantment = new CheckBoxWithIcon("enchant", "Enchantment"); + this.land = new CheckBoxWithIcon("land", "Land"); + this.creature = new CheckBoxWithIcon("creature", "Creature"); + this.sorcery = new CheckBoxWithIcon("sorcery", "Sorcery"); + this.instant = new CheckBoxWithIcon("instant", "Instant"); + this.planeswalker = new CheckBoxWithIcon("planeswalker", "Planeswalker"); + this.artifact = new CheckBoxWithIcon("artifact", "Artifact"); + this.enchantment = new CheckBoxWithIcon("enchant", "Enchantment"); } else { - white = new JCheckBox("W", true); - blue = new JCheckBox("U", true); - black = new JCheckBox("B", true); - red = new JCheckBox("R", true); - green = new JCheckBox("G", true); - colorless = new JCheckBox("C", true); + this.white = new JCheckBox("W", true); + this.blue = new JCheckBox("U", true); + this.black = new JCheckBox("B", true); + this.red = new JCheckBox("R", true); + this.green = new JCheckBox("G", true); + this.colorless = new JCheckBox("C", true); - land = new JCheckBox("Land", true); - creature = new JCheckBox("Creature", true); - sorcery = new JCheckBox("Sorcery", true); - instant = new JCheckBox("Instant", true); - planeswalker = new JCheckBox("Planeswalker", true); - artifact = new JCheckBox("Artifact", true); - enchantment = new JCheckBox("Enchant", true); + this.land = new JCheckBox("Land", true); + this.creature = new JCheckBox("Creature", true); + this.sorcery = new JCheckBox("Sorcery", true); + this.instant = new JCheckBox("Instant", true); + this.planeswalker = new JCheckBox("Planeswalker", true); + this.artifact = new JCheckBox("Artifact", true); + this.enchantment = new JCheckBox("Enchant", true); } - allColors = Arrays.asList(new JCheckBox[] { white, blue, black, red, green, colorless }); - allTypes = Arrays.asList(new JCheckBox[] { land, creature, sorcery, instant, planeswalker, artifact, - enchantment }); + this.allColors = Arrays.asList(new JCheckBox[] { this.getWhite(), this.getBlue(), this.getBlack(), this.getRed(), this.getGreen(), + this.getColorless() }); + this.allTypes = Arrays.asList(new JCheckBox[] { this.getLand(), this.getCreature(), this.getSorcery(), this.getInstant(), + this.getPlaneswalker(), this.getArtifact(), this.getEnchantment() }); } /** @@ -113,54 +114,159 @@ class FilterCheckBoxes { * @return the predicate */ public final Predicate buildFilter() { - List> colors = new ArrayList>(); - if (white.isSelected()) { + final List> colors = new ArrayList>(); + if (this.getWhite().isSelected()) { colors.add(CardRules.Predicates.Presets.IS_WHITE); } - if (blue.isSelected()) { + if (this.getBlue().isSelected()) { colors.add(CardRules.Predicates.Presets.IS_BLUE); } - if (black.isSelected()) { + if (this.getBlack().isSelected()) { colors.add(CardRules.Predicates.Presets.IS_BLACK); } - if (red.isSelected()) { + if (this.getRed().isSelected()) { colors.add(CardRules.Predicates.Presets.IS_RED); } - if (green.isSelected()) { + if (this.getGreen().isSelected()) { colors.add(CardRules.Predicates.Presets.IS_GREEN); } - if (colorless.isSelected()) { + if (this.getColorless().isSelected()) { colors.add(CardRules.Predicates.Presets.IS_COLORLESS); } - Predicate filterByColor = colors.size() == 6 ? CardRules.Predicates.Presets.CONSTANT_TRUE : Predicate - .or(colors); + final Predicate filterByColor = colors.size() == 6 ? CardRules.Predicates.Presets.CONSTANT_TRUE + : Predicate.or(colors); - List> types = new ArrayList>(); - if (land.isSelected()) { + final List> types = new ArrayList>(); + if (this.getLand().isSelected()) { types.add(CardRules.Predicates.Presets.IS_LAND); } - if (creature.isSelected()) { + if (this.getCreature().isSelected()) { types.add(CardRules.Predicates.Presets.IS_CREATURE); } - if (sorcery.isSelected()) { + if (this.getSorcery().isSelected()) { types.add(CardRules.Predicates.Presets.IS_SORCERY); } - if (instant.isSelected()) { + if (this.getInstant().isSelected()) { types.add(CardRules.Predicates.Presets.IS_INSTANT); } - if (planeswalker.isSelected()) { + if (this.getPlaneswalker().isSelected()) { types.add(CardRules.Predicates.Presets.IS_PLANESWALKER); } - if (artifact.isSelected()) { + if (this.getArtifact().isSelected()) { types.add(CardRules.Predicates.Presets.IS_ARTIFACT); } - if (enchantment.isSelected()) { + if (this.getEnchantment().isSelected()) { types.add(CardRules.Predicates.Presets.IS_ENCHANTMENT); } - Predicate filterByType = types.size() == 7 ? CardRules.Predicates.Presets.CONSTANT_TRUE : Predicate - .or(types); + final Predicate filterByType = types.size() == 7 ? CardRules.Predicates.Presets.CONSTANT_TRUE + : Predicate.or(types); return Predicate.brigde(Predicate.and(filterByColor, filterByType), CardPrinted.fnGetRules); } + /** + * @return the allTypes + */ + public List getAllTypes() { + return allTypes; + } + + /** + * @return the white + */ + public JCheckBox getWhite() { + return white; + } + + /** + * @return the blue + */ + public JCheckBox getBlue() { + return blue; + } + + /** + * @return the black + */ + public JCheckBox getBlack() { + return black; + } + + /** + * @return the red + */ + public JCheckBox getRed() { + return red; + } + + /** + * @return the colorless + */ + public JCheckBox getColorless() { + return colorless; + } + + /** + * @return the green + */ + public JCheckBox getGreen() { + return green; + } + + /** + * @return the land + */ + public JCheckBox getLand() { + return land; + } + + /** + * @return the allColors + */ + public List getAllColors() { + return allColors; + } + + /** + * @return the creature + */ + public JCheckBox getCreature() { + return creature; + } + + /** + * @return the sorcery + */ + public JCheckBox getSorcery() { + return sorcery; + } + + /** + * @return the instant + */ + public JCheckBox getInstant() { + return instant; + } + + /** + * @return the planeswalker + */ + public JCheckBox getPlaneswalker() { + return planeswalker; + } + + /** + * @return the artifact + */ + public JCheckBox getArtifact() { + return artifact; + } + + /** + * @return the enchantment + */ + public JCheckBox getEnchantment() { + return enchantment; + } + } diff --git a/src/main/java/forge/gui/deckeditor/FilterNameTypeSetPanel.java b/src/main/java/forge/gui/deckeditor/FilterNameTypeSetPanel.java index af4424cac8d..3aae1659c0e 100644 --- a/src/main/java/forge/gui/deckeditor/FilterNameTypeSetPanel.java +++ b/src/main/java/forge/gui/deckeditor/FilterNameTypeSetPanel.java @@ -31,25 +31,25 @@ public class FilterNameTypeSetPanel extends JComponent { private static final long serialVersionUID = -6409564625432765430L; /** The label filter name. */ - public final JLabel labelFilterName = new JLabel(); + private final JLabel labelFilterName = new JLabel(); /** The label filter type. */ - public final JLabel labelFilterType = new JLabel(); + private final JLabel labelFilterType = new JLabel(); /** The label filter rules. */ - public final JLabel labelFilterRules = new JLabel(); + private final JLabel labelFilterRules = new JLabel(); /** The txt card name. */ - public final JTextField txtCardName = new JTextField(); + private final JTextField txtCardName = new JTextField(); /** The txt card type. */ - public final JTextField txtCardType = new JTextField(); + private final JTextField txtCardType = new JTextField(); /** The txt card rules. */ - public final JTextField txtCardRules = new JTextField(); + private final JTextField txtCardRules = new JTextField(); /** The search set combo. */ - public final JComboBox searchSetCombo = new JComboBox(); + private final JComboBox searchSetCombo = new JComboBox(); /** * Instantiates a new filter name type set panel. @@ -57,31 +57,31 @@ public class FilterNameTypeSetPanel extends JComponent { public FilterNameTypeSetPanel() { this.setLayout(new MigLayout("fill, ins 0")); - labelFilterName.setText("Name:"); - labelFilterName.setToolTipText("Card names must include the text in this field"); - this.add(labelFilterName, "cell 0 1, split 7"); - this.add(txtCardName, "wmin 100, grow"); + this.labelFilterName.setText("Name:"); + this.labelFilterName.setToolTipText("Card names must include the text in this field"); + this.add(this.labelFilterName, "cell 0 1, split 7"); + this.add(this.txtCardName, "wmin 100, grow"); - labelFilterType.setText("Type:"); - labelFilterType.setToolTipText("Card types must include the text in this field"); - this.add(labelFilterType, ""); - this.add(txtCardType, "wmin 100, grow"); + this.labelFilterType.setText("Type:"); + this.labelFilterType.setToolTipText("Card types must include the text in this field"); + this.add(this.labelFilterType, ""); + this.add(this.txtCardType, "wmin 100, grow"); - labelFilterRules.setText("Text:"); - labelFilterRules.setToolTipText("Card descriptions must include the text in this field"); - this.add(labelFilterRules, ""); - this.add(txtCardRules, "wmin 200, grow"); + this.labelFilterRules.setText("Text:"); + this.labelFilterRules.setToolTipText("Card descriptions must include the text in this field"); + this.add(this.labelFilterRules, ""); + this.add(this.txtCardRules, "wmin 200, grow"); - searchSetCombo.removeAllItems(); - searchSetCombo.addItem("(all sets and formats)"); - for (GameFormat s : SetUtils.getFormats()) { - searchSetCombo.addItem(s); + this.searchSetCombo.removeAllItems(); + this.searchSetCombo.addItem("(all sets and formats)"); + for (final GameFormat s : SetUtils.getFormats()) { + this.searchSetCombo.addItem(s); } - for (CardSet s : SetUtils.getAllSets()) { - searchSetCombo.addItem(s); + for (final CardSet s : SetUtils.getAllSets()) { + this.searchSetCombo.addItem(s); } - this.add(searchSetCombo, "wmin 150, grow"); + this.add(this.searchSetCombo, "wmin 150, grow"); } /** @@ -93,10 +93,10 @@ public class FilterNameTypeSetPanel extends JComponent { * the on combo change */ public final void setListeners(final DocumentListener onTextChange, final ItemListener onComboChange) { - txtCardType.getDocument().addDocumentListener(onTextChange); - txtCardRules.getDocument().addDocumentListener(onTextChange); - txtCardName.getDocument().addDocumentListener(onTextChange); - searchSetCombo.addItemListener(onComboChange); + this.txtCardType.getDocument().addDocumentListener(onTextChange); + this.txtCardRules.getDocument().addDocumentListener(onTextChange); + this.txtCardName.getDocument().addDocumentListener(onTextChange); + this.searchSetCombo.addItemListener(onComboChange); } /** @@ -105,23 +105,23 @@ public class FilterNameTypeSetPanel extends JComponent { * @return the predicate */ public final Predicate buildFilter() { - List> rules = new ArrayList>(4); - if (StringUtils.isNotBlank(txtCardName.getText())) { - rules.add(CardPrinted.Predicates.name(StringOp.CONTAINS, txtCardName.getText())); + final List> rules = new ArrayList>(4); + if (StringUtils.isNotBlank(this.txtCardName.getText())) { + rules.add(CardPrinted.Predicates.name(StringOp.CONTAINS, this.txtCardName.getText())); } - if (StringUtils.isNotBlank(txtCardType.getText())) { - rules.add(Predicate.brigde(CardRules.Predicates.joinedType(StringOp.CONTAINS, txtCardType.getText()), + if (StringUtils.isNotBlank(this.txtCardType.getText())) { + rules.add(Predicate.brigde(CardRules.Predicates.joinedType(StringOp.CONTAINS, this.txtCardType.getText()), CardPrinted.fnGetRules)); } - if (StringUtils.isNotBlank(txtCardRules.getText())) { - rules.add(Predicate.brigde(CardRules.Predicates.rules(StringOp.CONTAINS, txtCardRules.getText()), + if (StringUtils.isNotBlank(this.txtCardRules.getText())) { + rules.add(Predicate.brigde(CardRules.Predicates.rules(StringOp.CONTAINS, this.txtCardRules.getText()), CardPrinted.fnGetRules)); } - if (searchSetCombo.getSelectedIndex() != 0) { - Object selected = searchSetCombo.getSelectedItem(); + if (this.searchSetCombo.getSelectedIndex() != 0) { + final Object selected = this.searchSetCombo.getSelectedItem(); if (selected instanceof CardSet) { rules.add(CardPrinted.Predicates.printedInSets(((CardSet) selected).getCode())); } else if (selected instanceof GameFormat) { @@ -145,9 +145,9 @@ public class FilterNameTypeSetPanel extends JComponent { * TODO: Write javadoc for this method. */ public final void clearFilters() { - txtCardName.setText(""); - txtCardType.setText(""); - txtCardRules.setText(""); - searchSetCombo.setSelectedIndex(0); + this.txtCardName.setText(""); + this.txtCardType.setText(""); + this.txtCardRules.setText(""); + this.searchSetCombo.setSelectedIndex(0); } } diff --git a/src/main/java/forge/gui/deckeditor/ManaCostRenderer.java b/src/main/java/forge/gui/deckeditor/ManaCostRenderer.java index ebf9f5d4de7..6d622b45db5 100644 --- a/src/main/java/forge/gui/deckeditor/ManaCostRenderer.java +++ b/src/main/java/forge/gui/deckeditor/ManaCostRenderer.java @@ -27,10 +27,10 @@ public class ManaCostRenderer extends DefaultTableCellRenderer { * (javax.swing.JTable, java.lang.Object, boolean, boolean, int, int) */ @Override - public final Component getTableCellRendererComponent(final JTable table, final Object value, final boolean isSelected, - final boolean hasFocus, final int row, final int column) { + public final Component getTableCellRendererComponent(final JTable table, final Object value, + final boolean isSelected, final boolean hasFocus, final int row, final int column) { this.value = (CardManaCost) value; - setToolTipText(this.value.toString()); + this.setToolTipText(this.value.toString()); return super.getTableCellRendererComponent(table, "", isSelected, hasFocus, row, column); } @@ -49,23 +49,23 @@ public class ManaCostRenderer extends DefaultTableCellRenderer { float xpos = padding; - int genericManaCost = value.getGenericCost(); - boolean hasGeneric = genericManaCost > 0 || value.isPureGeneric(); - List shards = value.getShards(); + final int genericManaCost = this.value.getGenericCost(); + final boolean hasGeneric = (genericManaCost > 0) || this.value.isPureGeneric(); + final List shards = this.value.getShards(); - int cellWidth = getWidth(); - int cntGlyphs = hasGeneric ? shards.size() + 1 : shards.size(); - float offsetIfNoSpace = cntGlyphs > 1 ? (cellWidth - padding - elemtWidth) / (cntGlyphs - 1f) : elemtWidth - + elemtGap; - float offset = Math.min(elemtWidth + elemtGap, offsetIfNoSpace); + final int cellWidth = this.getWidth(); + final int cntGlyphs = hasGeneric ? shards.size() + 1 : shards.size(); + final float offsetIfNoSpace = cntGlyphs > 1 ? (cellWidth - padding - elemtWidth) / (cntGlyphs - 1f) + : elemtWidth + elemtGap; + final float offset = Math.min(elemtWidth + elemtGap, offsetIfNoSpace); if (hasGeneric) { - String sGeneric = Integer.toString(genericManaCost); + final String sGeneric = Integer.toString(genericManaCost); ManaSymbols.drawSymbol(sGeneric, g, (int) xpos, 1); xpos += offset; } - for (CardManaCostShard s : shards) { + for (final CardManaCostShard s : shards) { ManaSymbols.drawSymbol(s.getImageKey(), g, (int) xpos, 1); xpos += offset; } diff --git a/src/main/java/forge/gui/deckeditor/TableColumnInfo.java b/src/main/java/forge/gui/deckeditor/TableColumnInfo.java index 68f8bfe9117..a500bbbfdf0 100644 --- a/src/main/java/forge/gui/deckeditor/TableColumnInfo.java +++ b/src/main/java/forge/gui/deckeditor/TableColumnInfo.java @@ -20,24 +20,24 @@ public class TableColumnInfo { private final String name; /** The min width. */ - public int minWidth; + private int minWidth; /** The max width. */ - public int maxWidth; + private int maxWidth; /** The nominal width. */ - public int nominalWidth; + private int nominalWidth; /** The is min max applied. */ - public boolean isMinMaxApplied = true; + private boolean isMinMaxApplied = true; /** The fn sort. */ - public final Lambda1> fnSort; // this will be + private final Lambda1> fnSort; // this will be // used for // sorting /** The fn display. */ - public final Lambda1> fnDisplay; // this is used + private final Lambda1> fnDisplay; // this is used // to display private TableCellRenderer cellRenderer = null; @@ -48,7 +48,7 @@ public class TableColumnInfo { * @return the name */ public final String getName() { - return name; + return this.name; } /** @@ -63,8 +63,8 @@ public class TableColumnInfo { */ public TableColumnInfo(final String colName, final Lambda1> fieldSort, final Lambda1> fieldDisplay) { - fnSort = fieldSort; - fnDisplay = fieldDisplay; + this.fnSort = fieldSort; + this.fnDisplay = fieldDisplay; this.name = colName; } @@ -84,9 +84,9 @@ public class TableColumnInfo { final Lambda1> fieldSort, final Lambda1> fieldDisplay) { this(colName, fieldSort, fieldDisplay); - this.maxWidth = width; - this.minWidth = width; - this.nominalWidth = width; + this.setMaxWidth(width); + this.setMinWidth(width); + this.setNominalWidth(width); } /** @@ -109,9 +109,9 @@ public class TableColumnInfo { final Lambda1> fieldSort, final Lambda1> fieldDisplay) { this(colName, fieldSort, fieldDisplay); - this.maxWidth = wMax; - this.minWidth = wMin; - this.nominalWidth = width; + this.setMaxWidth(wMax); + this.setMinWidth(wMin); + this.setNominalWidth(width); } /** @@ -121,7 +121,7 @@ public class TableColumnInfo { * the new cell renderer */ public final void setCellRenderer(final TableCellRenderer renderer) { - cellRenderer = renderer; + this.cellRenderer = renderer; } /** @@ -130,6 +130,76 @@ public class TableColumnInfo { * @return the cell renderer */ public final TableCellRenderer getCellRenderer() { - return cellRenderer; + return this.cellRenderer; + } + + /** + * @return the minWidth + */ + public int getMinWidth() { + return minWidth; + } + + /** + * @param minWidth the minWidth to set + */ + public void setMinWidth(int minWidth) { + this.minWidth = minWidth; // TODO: Add 0 to parameter's name. + } + + /** + * @return the maxWidth + */ + public int getMaxWidth() { + return maxWidth; + } + + /** + * @param maxWidth the maxWidth to set + */ + public void setMaxWidth(int maxWidth) { + this.maxWidth = maxWidth; // TODO: Add 0 to parameter's name. + } + + /** + * @return the nominalWidth + */ + public int getNominalWidth() { + return nominalWidth; + } + + /** + * @param nominalWidth the nominalWidth to set + */ + public void setNominalWidth(int nominalWidth) { + this.nominalWidth = nominalWidth; // TODO: Add 0 to parameter's name. + } + + /** + * @return the isMinMaxApplied + */ + public boolean isMinMaxApplied() { + return isMinMaxApplied; + } + + /** + * @param isMinMaxApplied the isMinMaxApplied to set + */ + public void setMinMaxApplied(boolean isMinMaxApplied) { + this.isMinMaxApplied = isMinMaxApplied; // TODO: Add 0 to parameter's name. + } + + /** + * @return the fnSort + */ + public Lambda1> getFnSort() { + return fnSort; + } + + /** + * @return the fnDisplay + */ + public Lambda1> getFnDisplay() { + return fnDisplay; } } diff --git a/src/main/java/forge/gui/deckeditor/TableModel.java b/src/main/java/forge/gui/deckeditor/TableModel.java index 5449ad8e749..9506e68dab0 100644 --- a/src/main/java/forge/gui/deckeditor/TableModel.java +++ b/src/main/java/forge/gui/deckeditor/TableModel.java @@ -39,23 +39,23 @@ public final class TableModel extends AbstractTableMode private final class SortOrders { private class Order { - public final int sortColumn; - public boolean isSortAsc = true; + private final int sortColumn; + private boolean isSortAsc = true; public Order(final int col) { - sortColumn = col; + this.sortColumn = col; } }; - private final int MAX_DEPTH = 3; - private List orders = new ArrayList(3); + private final int maxDepth = 3; + private final List orders = new ArrayList(3); private TableSorterCascade sorter = null; private boolean isSorterReady = false; private int indexOfColumn(final int column) { - int posColumn = orders.size() - 1; + int posColumn = this.orders.size() - 1; for (; posColumn >= 0; posColumn--) { - if (orders.get(posColumn) != null && orders.get(posColumn).sortColumn == column) { + if ((this.orders.get(posColumn) != null) && (this.orders.get(posColumn).sortColumn == column)) { break; } } @@ -64,47 +64,48 @@ public final class TableModel extends AbstractTableMode // index of column to sort by, desired direction public void add(final int column, final boolean wantAsc) { - add(column); - orders.get(0).isSortAsc = wantAsc; - isSorterReady = false; + this.add(column); + this.orders.get(0).isSortAsc = wantAsc; + this.isSorterReady = false; } // puts desired direction on top, set "asc"; if already was on top, // inverts direction; public void add(final int column) { - int posColumn = indexOfColumn(column); + final int posColumn = this.indexOfColumn(column); switch (posColumn) { case -1: // no such column here - let's add then - orders.add(0, new Order(column)); + this.orders.add(0, new Order(column)); break; case 0: // found at top-level, should invert - orders.get(0).isSortAsc ^= true; // invert + this.orders.get(0).isSortAsc ^= true; // invert break; default: // found somewhere, move down others, set this one onto // top; - orders.remove(posColumn); - orders.add(0, new Order(column)); + this.orders.remove(posColumn); + this.orders.add(0, new Order(column)); break; } - if (orders.size() > MAX_DEPTH) { - orders.remove(MAX_DEPTH); + if (this.orders.size() > this.maxDepth) { + this.orders.remove(this.maxDepth); } - isSorterReady = false; + this.isSorterReady = false; } public TableSorterCascade getSorter() { - if (!isSorterReady) { - List> oneColSorters = new ArrayList>(MAX_DEPTH); - for (Order order : orders) { - oneColSorters.add(new TableSorter(columns.get(order.sortColumn).fnSort, order.isSortAsc)); + if (!this.isSorterReady) { + final List> oneColSorters = new ArrayList>(this.maxDepth); + for (final Order order : this.orders) { + oneColSorters.add(new TableSorter(TableModel.this.columns.get(order.sortColumn).getFnSort(), + order.isSortAsc)); } - sorter = new TableSorterCascade(oneColSorters); + this.sorter = new TableSorterCascade(oneColSorters); } - return sorter; + return this.sorter; } } - private ItemPool data; + private final ItemPool data; private final CardPanelBase cardDisplay; private final List> columns; private final SortOrders sortOrders = new SortOrders(); @@ -120,10 +121,10 @@ public final class TableModel extends AbstractTableMode * the cls */ public TableModel(final CardPanelBase cd, final List> columnsToShow, final Class cls) { - data = new ItemPool(cls); - cardDisplay = cd; - columns = columnsToShow; - columns.get(4).isMinMaxApplied = false; + this.data = new ItemPool(cls); + this.cardDisplay = cd; + this.columns = columnsToShow; + this.columns.get(4).setMinMaxApplied(false); } /** @@ -136,12 +137,12 @@ public final class TableModel extends AbstractTableMode TableColumn tableColumn = null; for (int i = 0; i < table.getColumnCount(); i++) { tableColumn = table.getColumnModel().getColumn(i); - TableColumnInfo colInfo = columns.get(i); + final TableColumnInfo colInfo = this.columns.get(i); - tableColumn.setPreferredWidth(colInfo.nominalWidth); - if (colInfo.isMinMaxApplied) { - tableColumn.setMinWidth(colInfo.minWidth); - tableColumn.setMaxWidth(colInfo.maxWidth); + tableColumn.setPreferredWidth(colInfo.getNominalWidth()); + if (colInfo.isMinMaxApplied()) { + tableColumn.setMinWidth(colInfo.getMinWidth()); + tableColumn.setMaxWidth(colInfo.getMaxWidth()); } } } @@ -150,7 +151,7 @@ public final class TableModel extends AbstractTableMode * Clear. */ public void clear() { - data.clear(); + this.data.clear(); } /** @@ -159,7 +160,7 @@ public final class TableModel extends AbstractTableMode * @return the cards */ public ItemPoolView getCards() { - return data.getView(); + return this.data.getView(); } /** @@ -171,10 +172,10 @@ public final class TableModel extends AbstractTableMode * a {@link forge.Card} object. */ public void removeCard(final T c) { - boolean wasThere = data.count(c) > 0; + final boolean wasThere = this.data.count(c) > 0; if (wasThere) { - data.remove(c); - fireTableDataChanged(); + this.data.remove(c); + this.fireTableDataChanged(); } } @@ -185,8 +186,8 @@ public final class TableModel extends AbstractTableMode * the c */ public void addCard(final T c) { - data.add(c); - fireTableDataChanged(); + this.data.add(c); + this.fireTableDataChanged(); } /** @@ -198,8 +199,8 @@ public final class TableModel extends AbstractTableMode * the count */ public void addCard(final T c, final int count) { - data.add(c, count); - fireTableDataChanged(); + this.data.add(c, count); + this.fireTableDataChanged(); } /** @@ -209,8 +210,8 @@ public final class TableModel extends AbstractTableMode * the e */ public void addCard(final Entry e) { - data.add(e.getKey(), e.getValue()); - fireTableDataChanged(); + this.data.add(e.getKey(), e.getValue()); + this.fireTableDataChanged(); } /** @@ -220,8 +221,8 @@ public final class TableModel extends AbstractTableMode * the c */ public void addCards(final Iterable> c) { - data.addAll(c); - fireTableDataChanged(); + this.data.addAll(c); + this.fireTableDataChanged(); } /** @@ -231,8 +232,8 @@ public final class TableModel extends AbstractTableMode * the c */ public void addAllCards(final Iterable c) { - data.addAllCards(c); - fireTableDataChanged(); + this.data.addAllCards(c); + this.fireTableDataChanged(); } /** @@ -243,8 +244,8 @@ public final class TableModel extends AbstractTableMode * @return the entry */ public Entry rowToCard(final int row) { - List> model = data.getOrderedList(); - return row >= 0 && row < model.size() ? model.get(row) : null; + final List> model = this.data.getOrderedList(); + return (row >= 0) && (row < model.size()) ? model.get(row) : null; } /* @@ -253,10 +254,13 @@ public final class TableModel extends AbstractTableMode * @see javax.swing.table.TableModel#getRowCount() */ /** + * Gets the row count. + * * @return int */ + @Override public int getRowCount() { - return data.countDistinct(); + return this.data.countDistinct(); } /* @@ -265,36 +269,40 @@ public final class TableModel extends AbstractTableMode * @see javax.swing.table.TableModel#getColumnCount() */ /** + * Gets the column count. + * * @return int */ + @Override public int getColumnCount() { - return columns.size(); + return this.columns.size(); } /** {@inheritDoc} */ @Override public String getColumnName(final int n) { - return columns.get(n).getName(); + return this.columns.get(n).getName(); } /** {@inheritDoc} */ + @Override public Object getValueAt(final int row, final int column) { - return columns.get(column).fnDisplay.apply(rowToCard(row)); + return this.columns.get(column).getFnDisplay().apply(this.rowToCard(row)); } /** * The listener interface for receiving column events. The class that is * interested in processing a column event implements this interface, and * the object created with that class is registered with a component using - * the component's addColumnListener method. When - * the column event occurs, that object's appropriate - * method is invoked. - * + * the component's addColumnListener method. When the column event occurs, + * that object's appropriate method is invoked. + * + * @see ColumnEvent */ class ColumnListener extends MouseAdapter { /** The table. */ - protected JTable table; + private JTable table; /** * Instantiates a new column listener. @@ -303,7 +311,7 @@ public final class TableModel extends AbstractTableMode * the t */ public ColumnListener(final JTable t) { - table = t; + this.table = t; } /* @@ -313,29 +321,32 @@ public final class TableModel extends AbstractTableMode * java.awt.event.MouseAdapter#mouseClicked(java.awt.event.MouseEvent) */ /** + * Mouse clicked. + * * @param e MouseEvent */ + @Override public void mouseClicked(final MouseEvent e) { - TableColumnModel colModel = table.getColumnModel(); - int columnModelIndex = colModel.getColumnIndexAtX(e.getX()); - int modelIndex = colModel.getColumn(columnModelIndex).getModelIndex(); + final TableColumnModel colModel = this.table.getColumnModel(); + final int columnModelIndex = colModel.getColumnIndexAtX(e.getX()); + final int modelIndex = colModel.getColumn(columnModelIndex).getModelIndex(); if (modelIndex < 0) { return; } // This will invert if needed - sortOrders.add(modelIndex); + TableModel.this.sortOrders.add(modelIndex); - for (int i = 0; i < columns.size(); i++) { - TableColumn column = colModel.getColumn(i); - column.setHeaderValue(getColumnName(column.getModelIndex())); + for (int i = 0; i < TableModel.this.columns.size(); i++) { + final TableColumn column = colModel.getColumn(i); + column.setHeaderValue(TableModel.this.getColumnName(column.getModelIndex())); } - table.getTableHeader().repaint(); + this.table.getTableHeader().repaint(); - resort(); - table.tableChanged(new TableModelEvent(TableModel.this)); - table.repaint(); + TableModel.this.resort(); + this.table.tableChanged(new TableModelEvent(TableModel.this)); + this.table.repaint(); } } @@ -346,10 +357,10 @@ public final class TableModel extends AbstractTableMode * the table */ public void showSelectedCard(final JTable table) { - int row = table.getSelectedRow(); + final int row = table.getSelectedRow(); if (row != -1) { - T cp = rowToCard(row).getKey(); - cardDisplay.showCard(cp); + final T cp = this.rowToCard(row).getKey(); + this.cardDisplay.showCard(cp); } } @@ -367,7 +378,7 @@ public final class TableModel extends AbstractTableMode @Override public void valueChanged(final ListSelectionEvent arg0) { - showSelectedCard(table); + TableModel.this.showSelectedCard(table); } }); table.addFocusListener(new FocusListener() { @@ -378,7 +389,7 @@ public final class TableModel extends AbstractTableMode @Override public void focusGained(final FocusEvent e) { - showSelectedCard(table); + TableModel.this.showSelectedCard(table); } }); @@ -390,7 +401,7 @@ public final class TableModel extends AbstractTableMode * Resort. */ public void resort() { - Collections.sort(data.getOrderedList(), sortOrders.getSorter()); + Collections.sort(this.data.getOrderedList(), this.sortOrders.getSorter()); } /** @@ -402,8 +413,8 @@ public final class TableModel extends AbstractTableMode * the is asc */ public void sort(final int iCol, final boolean isAsc) { - sortOrders.add(iCol, isAsc); - resort(); + this.sortOrders.add(iCol, isAsc); + this.resort(); } } // CardTableModel diff --git a/src/main/java/forge/gui/deckeditor/TableSorter.java b/src/main/java/forge/gui/deckeditor/TableSorter.java index 910bd9b5e20..5186cb455c3 100644 --- a/src/main/java/forge/gui/deckeditor/TableSorter.java +++ b/src/main/java/forge/gui/deckeditor/TableSorter.java @@ -19,9 +19,9 @@ import forge.item.CardPrinted; @SuppressWarnings("unchecked") // Comparable needs public class TableSorter implements Comparator> { - private boolean ascending; + private final boolean ascending; @SuppressWarnings("rawtypes") - private Lambda1> field; + private final Lambda1> field; /** *

    @@ -30,18 +30,18 @@ public class TableSorter implements Comparator> { * * @param field * the field - * @param in_ascending + * @param inAscending * a boolean. */ @SuppressWarnings("rawtypes") - public TableSorter(final Lambda1> field, final boolean in_ascending) { + public TableSorter(final Lambda1> field, final boolean inAscending) { this.field = field; - ascending = in_ascending; + this.ascending = inAscending; } /** The Constant byNameThenSet. */ @SuppressWarnings("rawtypes") - public static final TableSorter byNameThenSet = new TableSorter( + public static final TableSorter BY_NAME_THEN_SET = new TableSorter( new Lambda1>() { @Override public Comparable apply(final Entry from) { @@ -57,10 +57,10 @@ public class TableSorter implements Comparator> { @SuppressWarnings("rawtypes") @Override public final int compare(final Entry arg0, final Entry arg1) { - Comparable obj1 = field.apply(arg0); - Comparable obj2 = field.apply(arg1); + final Comparable obj1 = this.field.apply(arg0); + final Comparable obj2 = this.field.apply(arg1); // System.out.println(String.format("%s vs %s _______ %s vs %s", arg0, // arg1, obj1, obj2)); - return ascending ? obj1.compareTo(obj2) : obj2.compareTo(obj1); + return this.ascending ? obj1.compareTo(obj2) : obj2.compareTo(obj1); } } diff --git a/src/main/java/forge/gui/deckeditor/TableSorterCascade.java b/src/main/java/forge/gui/deckeditor/TableSorterCascade.java index aaa26d14cd8..d9694143a64 100644 --- a/src/main/java/forge/gui/deckeditor/TableSorterCascade.java +++ b/src/main/java/forge/gui/deckeditor/TableSorterCascade.java @@ -17,7 +17,7 @@ import forge.item.InventoryItem; * @version $Id: TableSorter.java 10146 2011-09-01 18:11:00Z Max mtg $ */ public class TableSorterCascade implements Comparator> { - private List> sorters; + private final List> sorters; private final int cntFields; /** @@ -29,7 +29,7 @@ public class TableSorterCascade implements Comparator> sortersCascade) { this.sorters = sortersCascade; - cntFields = sortersCascade.size(); + this.cntFields = sortersCascade.size(); } /* @@ -41,8 +41,9 @@ public class TableSorterCascade implements Comparator arg0, final Entry arg1) { int lastCompare = 0; int iField = -1; - while (++iField < cntFields && lastCompare == 0) { // reverse iteration - TableSorter sorter = sorters.get(iField); + while ((++iField < this.cntFields) && (lastCompare == 0)) { // reverse + // iteration + final TableSorter sorter = this.sorters.get(iField); if (sorter == null) { break; } diff --git a/src/main/java/forge/gui/deckeditor/TableWithCards.java b/src/main/java/forge/gui/deckeditor/TableWithCards.java index b2347241378..ce5fa260e4d 100644 --- a/src/main/java/forge/gui/deckeditor/TableWithCards.java +++ b/src/main/java/forge/gui/deckeditor/TableWithCards.java @@ -28,28 +28,28 @@ import forge.item.ItemPoolView; public final class TableWithCards { /** The pool. */ - protected ItemPool pool; + private ItemPool pool; /** The model. */ - protected TableModel model; + private TableModel model; /** The table. */ - protected JTable table = new JTable(); + private JTable table = new JTable(); /** The j scroll pane. */ - protected JScrollPane jScrollPane = new JScrollPane(); + private JScrollPane jScrollPane = new JScrollPane(); /** The stats label. */ - protected JLabel statsLabel = new JLabel(); + private JLabel statsLabel = new JLabel(); /** The filter. */ - protected Predicate filter = null; + private Predicate filter = null; /** The is tracking stats. */ - protected boolean isTrackingStats = false; + private boolean isTrackingStats = false; /** The want unique. */ - protected boolean wantUnique = false; + private boolean wantUnique = false; // need this to allow users place its contents /** @@ -59,7 +59,7 @@ public final class TableWithCards { * @return JComponent */ public JComponent getTableDecorated() { - return jScrollPane; + return this.jScrollPane; } /** @@ -69,7 +69,7 @@ public final class TableWithCards { * @return JTable */ public JTable getTable() { - return table; + return this.table; } /** @@ -79,7 +79,7 @@ public final class TableWithCards { * @return JComponent */ public JComponent getLabel() { - return statsLabel; + return this.statsLabel; } /** @@ -108,22 +108,22 @@ public final class TableWithCards { */ public TableWithCards(final String title, final boolean showStats, final boolean forceUnique) { // components - Color gray = new Color(148, 145, 140); - TitledBorder titledBorder = new TitledBorder(BorderFactory.createEtchedBorder(Color.white, gray), title); + final Color gray = new Color(148, 145, 140); + final TitledBorder titledBorder = new TitledBorder(BorderFactory.createEtchedBorder(Color.white, gray), title); - String tableToolTip = "Click on the column name (like name or color) to sort the cards"; - jScrollPane.setBorder(titledBorder); - jScrollPane.setToolTipText(tableToolTip); - jScrollPane.getViewport().add(table, null); + final String tableToolTip = "Click on the column name (like name or color) to sort the cards"; + this.jScrollPane.setBorder(titledBorder); + this.jScrollPane.setToolTipText(tableToolTip); + this.jScrollPane.getViewport().add(this.table, null); if (!Singletons.getModel().getPreferences().lafFonts) { - statsLabel.setFont(new java.awt.Font("Dialog", 0, 13)); + this.statsLabel.setFont(new java.awt.Font("Dialog", 0, 13)); } - statsLabel.setText("Total: 0, Creatures: 0, Land: 0"); + this.statsLabel.setText("Total: 0, Creatures: 0, Land: 0"); // class data - isTrackingStats = showStats; - wantUnique = forceUnique; + this.isTrackingStats = showStats; + this.wantUnique = forceUnique; } /** @@ -136,24 +136,25 @@ public final class TableWithCards { * a CardPanelBase */ public void setup(final List> columns, final CardPanelBase cardView) { - model = new TableModel(cardView, columns, InventoryItem.class); - model.addListeners(table); - table.setModel(model); - model.resizeCols(table); + this.model = new TableModel(cardView, columns, InventoryItem.class); + this.model.addListeners(this.table); + this.table.setModel(this.model); + this.model.resizeCols(this.table); for (int idx = columns.size() - 1; idx >= 0; idx--) { - TableCellRenderer renderer = columns.get(idx).getCellRenderer(); + final TableCellRenderer renderer = columns.get(idx).getCellRenderer(); if (null != renderer) { - table.getColumnModel().getColumn(idx).setCellRenderer(renderer); + this.table.getColumnModel().getColumn(idx).setCellRenderer(renderer); } } - if (isTrackingStats) { + if (this.isTrackingStats) { // get stats from deck - model.addTableModelListener(new TableModelListener() { + this.model.addTableModelListener(new TableModelListener() { + @Override public void tableChanged(final TableModelEvent ev) { - ItemPoolView deck = model.getCards(); - statsLabel.setText(getStats(deck)); + final ItemPoolView deck = TableWithCards.this.model.getCards(); + TableWithCards.this.statsLabel.setText(TableWithCards.getStats(deck)); } }); } @@ -169,15 +170,15 @@ public final class TableWithCards { * @return String */ public static String getStats(final ItemPoolView deck) { - int total = deck.countAll(); - int creature = CardRules.Predicates.Presets.IS_CREATURE.aggregate(deck, deck.fnToCard, deck.fnToCount); - int land = CardRules.Predicates.Presets.IS_LAND.aggregate(deck, deck.fnToCard, deck.fnToCount); + final int total = deck.countAll(); + final int creature = CardRules.Predicates.Presets.IS_CREATURE.aggregate(deck, deck.fnToCard, deck.fnToCount); + final int land = CardRules.Predicates.Presets.IS_LAND.aggregate(deck, deck.fnToCard, deck.fnToCount); - StringBuffer show = new StringBuffer(); + final StringBuffer show = new StringBuffer(); show.append("Total - ").append(total).append(", Creatures - ").append(creature).append(", Land - ") .append(land); - String[] color = Constant.Color.ONLY_COLORS; - List> predicates = CardRules.Predicates.Presets.COLORS; + final String[] color = Constant.Color.ONLY_COLORS; + final List> predicates = CardRules.Predicates.Presets.COLORS; for (int i = 0; i < color.length; ++i) { show.append(String.format(", %s - %d", color[i], predicates.get(i).count(deck, deck.fnToCard))); } @@ -194,7 +195,7 @@ public final class TableWithCards { * @return TableWithCards */ public TableWithCards sort(final int iCol) { - return sort(iCol, true); + return this.sort(iCol, true); } /** @@ -208,7 +209,7 @@ public final class TableWithCards { * @return TableWithCards */ public TableWithCards sort(final int iCol, final boolean isAsc) { - model.sort(iCol, isAsc); + this.model.sort(iCol, isAsc); return this; } @@ -222,12 +223,12 @@ public final class TableWithCards { public void fixSelection(final int rowLastSelected) { // 3 cases: 0 cards left, select the same row, select prev row int newRow = rowLastSelected; - int cntRowsAbove = model.getRowCount(); + final int cntRowsAbove = this.model.getRowCount(); if (cntRowsAbove != 0) { if (cntRowsAbove == newRow) { newRow--; } // move selection away from the last, already missing, option - table.setRowSelectionInterval(newRow, newRow); + this.table.setRowSelectionInterval(newRow, newRow); } } @@ -239,7 +240,7 @@ public final class TableWithCards { * an Iterable */ public void setDeck(final Iterable cards) { - setDeckImpl(ItemPool.createFrom(cards, InventoryItem.class)); + this.setDeckImpl(ItemPool.createFrom(cards, InventoryItem.class)); } /** @@ -251,7 +252,7 @@ public final class TableWithCards { * an ItemPoolView */ public void setDeck(final ItemPoolView poolView) { - setDeckImpl(ItemPool.createFrom(poolView, InventoryItem.class)); + this.setDeckImpl(ItemPool.createFrom(poolView, InventoryItem.class)); } /** @@ -262,10 +263,10 @@ public final class TableWithCards { * an ItemPool */ protected void setDeckImpl(final ItemPool thePool) { - model.clear(); - pool = thePool; - model.addCards(pool); - updateView(true); + this.model.clear(); + this.pool = thePool; + this.model.addCards(this.pool); + this.updateView(true); } /** @@ -275,12 +276,12 @@ public final class TableWithCards { * @return InventoryItem */ public InventoryItem getSelectedCard() { - int iRow = table.getSelectedRow(); - return iRow >= 0 ? model.rowToCard(iRow).getKey() : null; + final int iRow = this.table.getSelectedRow(); + return iRow >= 0 ? this.model.rowToCard(iRow).getKey() : null; } private boolean isUnfiltered() { - return filter == null || filter.is1(); + return (this.filter == null) || this.filter.is1(); } /** @@ -291,8 +292,8 @@ public final class TableWithCards { * a Predicate */ public void setFilter(final Predicate filterToSet) { - filter = filterToSet; - updateView(true); + this.filter = filterToSet; + this.updateView(true); } /** @@ -304,11 +305,11 @@ public final class TableWithCards { */ public void addCard(final InventoryItem card) { // int n = table.getSelectedRow(); - pool.add(card); - if (isUnfiltered()) { - model.addCard(card); + this.pool.add(card); + if (this.isUnfiltered()) { + this.model.addCard(card); } - updateView(false); + this.updateView(false); } /** @@ -319,13 +320,13 @@ public final class TableWithCards { * an InventoryItem */ public void removeCard(final InventoryItem card) { - int n = table.getSelectedRow(); - pool.remove(card); - if (isUnfiltered()) { - model.removeCard(card); + final int n = this.table.getSelectedRow(); + this.pool.remove(card); + if (this.isUnfiltered()) { + this.model.removeCard(card); } - updateView(false); - fixSelection(n); + this.updateView(false); + this.fixSelection(n); } /** @@ -336,22 +337,22 @@ public final class TableWithCards { * a boolean */ public void updateView(final boolean bForceFilter) { - boolean useFilter = (bForceFilter && filter != null) || !isUnfiltered(); + final boolean useFilter = (bForceFilter && (this.filter != null)) || !this.isUnfiltered(); - if (useFilter || wantUnique) { - model.clear(); + if (useFilter || this.wantUnique) { + this.model.clear(); } - if (useFilter && wantUnique) { - model.addCards(filter.uniqueByLast(pool, pool.fnToCardName, pool.fnToPrinted)); + if (useFilter && this.wantUnique) { + this.model.addCards(this.filter.uniqueByLast(this.pool, this.pool.fnToCardName, this.pool.fnToPrinted)); } else if (useFilter) { - model.addCards(filter.select(pool, pool.fnToPrinted)); - } else if (wantUnique) { - model.addCards(CardRules.Predicates.Presets.CONSTANT_TRUE.uniqueByLast(pool, pool.fnToCardName, - pool.fnToCard)); + this.model.addCards(this.filter.select(this.pool, this.pool.fnToPrinted)); + } else if (this.wantUnique) { + this.model.addCards(CardRules.Predicates.Presets.CONSTANT_TRUE.uniqueByLast(this.pool, + this.pool.fnToCardName, this.pool.fnToCard)); } - model.resort(); + this.model.resort(); } /** @@ -361,7 +362,7 @@ public final class TableWithCards { * @return ItemPoolView */ public ItemPoolView getCards() { - return pool; + return this.pool; } } diff --git a/src/main/java/forge/view/swing/OldGuiNewGame.java b/src/main/java/forge/view/swing/OldGuiNewGame.java index 7c28489c394..2e0d97a82b4 100644 --- a/src/main/java/forge/view/swing/OldGuiNewGame.java +++ b/src/main/java/forge/view/swing/OldGuiNewGame.java @@ -702,7 +702,7 @@ public class OldGuiNewGame extends JFrame implements NewConstants, NewConstants. editor.show(exit); if (deck != null) { - editor.customMenu.showDeck(deck, gt); + editor.getCustomMenu().showDeck(deck, gt); } this.setVisible(false);