diff --git a/src/main/java/forge/quest/data/bazaar/QuestStallDefinition.java b/src/main/java/forge/quest/data/bazaar/QuestStallDefinition.java index f47d0d64792..d5c02d90a71 100644 --- a/src/main/java/forge/quest/data/bazaar/QuestStallDefinition.java +++ b/src/main/java/forge/quest/data/bazaar/QuestStallDefinition.java @@ -36,7 +36,8 @@ public class QuestStallDefinition { * @param iconName * a {@link java.lang.String} object. */ - public QuestStallDefinition(final String name, final String displayName, final String fluff, final String iconName) { + public QuestStallDefinition(final String name, + final String displayName, final String fluff, final String iconName) { this.name = name; this.displayName = displayName; this.fluff = fluff; diff --git a/src/main/java/forge/quest/data/bazaar/QuestStallManager.java b/src/main/java/forge/quest/data/bazaar/QuestStallManager.java index 11b95e5e1ef..f075391257b 100644 --- a/src/main/java/forge/quest/data/bazaar/QuestStallManager.java +++ b/src/main/java/forge/quest/data/bazaar/QuestStallManager.java @@ -117,7 +117,7 @@ public class QuestStallManager { * a {@link java.lang.String} object. * @return a {@link java.util.List} object. */ - public static List getItems(String stallName) { + public static List getItems(final String stallName) { if (items == null) { buildItems(); } @@ -134,19 +134,19 @@ public class QuestStallManager { /** Constant ALCHEMIST="Alchemist". */ public static final String ALCHEMIST = "Alchemist"; - + /** Constant BANKER="Banker". */ public static final String BANKER = "Banker"; - + /** Constant BOOKSTORE="Bookstore". */ public static final String BOOKSTORE = "Bookstore"; - + /** Constant GEAR="Gear". */ public static final String GEAR = "Gear"; - + /** Constant NURSERY="Nursery". */ public static final String NURSERY = "Nursery"; - + /** Constant PET_SHOP="Pet Shop". */ public static final String PET_SHOP = "Pet Shop"; diff --git a/src/main/java/forge/quest/data/bazaar/QuestStallPurchasable.java b/src/main/java/forge/quest/data/bazaar/QuestStallPurchasable.java index 5af5cde6fc0..d2357a61771 100644 --- a/src/main/java/forge/quest/data/bazaar/QuestStallPurchasable.java +++ b/src/main/java/forge/quest/data/bazaar/QuestStallPurchasable.java @@ -2,7 +2,7 @@ package forge.quest.data.bazaar; /** * This interface defines a thing that can be sold at the Bazaar. - * + * * @author Forge * @version $Id$ */ @@ -45,10 +45,10 @@ public interface QuestStallPurchasable extends Comparable { /** * Returns if the item is available for purchase;. - * + * * @return true if the item can be displayed in a store - * false if the item should not be displayed in store - * since, for example, prerequisites are not met + * false if the item should not be displayed in store + * since, for example, prerequisites are not met */ boolean isAvailableForPurchase(); diff --git a/src/main/java/forge/quest/gui/bazaar/QuestBazaarItem.java b/src/main/java/forge/quest/gui/bazaar/QuestBazaarItem.java index 93a175695dc..97e0d216323 100644 --- a/src/main/java/forge/quest/gui/bazaar/QuestBazaarItem.java +++ b/src/main/java/forge/quest/gui/bazaar/QuestBazaarItem.java @@ -1,56 +1,74 @@ package forge.quest.gui.bazaar; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javax.swing.ImageIcon; +import javax.swing.JButton; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.border.CompoundBorder; +import javax.swing.border.EmptyBorder; +import javax.swing.border.LineBorder; import forge.AllZone; import forge.gui.GuiUtils; import forge.gui.MultiLineLabel; import forge.quest.data.bazaar.QuestStallPurchasable; -import javax.swing.*; -import javax.swing.border.CompoundBorder; -import javax.swing.border.EmptyBorder; -import javax.swing.border.LineBorder; -import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - - /** - *

QuestBazaarItem class.

- * + *

+ * QuestBazaarItem class. + *

+ * * @author Forge * @version $Id$ */ public class QuestBazaarItem { + /** The item. */ QuestStallPurchasable item; /** - *

Constructor for QuestBazaarItem.

- * - * @param purchasable a {@link forge.quest.data.bazaar.QuestStallPurchasable} object. + *

+ * Constructor for QuestBazaarItem. + *

+ * + * @param purchasable + * a {@link forge.quest.data.bazaar.QuestStallPurchasable} + * object. */ - protected QuestBazaarItem(QuestStallPurchasable purchasable) { + protected QuestBazaarItem(final QuestStallPurchasable purchasable) { this.item = purchasable; } /** - * Invoked by the Bazaar UI when the item is purchased. The credits of the item should not be deducted here. + * Invoked by the Bazaar UI when the item is purchased. The credits of the + * item should not be deducted here. */ - public void purchaseItem() { + public final void purchaseItem() { item.onPurchase(); } /** - *

getItemPanel.

- * + *

+ * getItemPanel. + *

+ * * @return a {@link javax.swing.JPanel} object. */ protected final JPanel getItemPanel() { ImageIcon icon = GuiUtils.getIconFromFile(item.getImageName()); if (icon == null) { - // The original size was only 40 x 40 pixels. - // Increased the size to give added pixels for more detail. + // The original size was only 40 x 40 pixels. + // Increased the size to give added pixels for more detail. icon = GuiUtils.getEmptyIcon(80, 80); } // The original size was only 40 x 40 pixels. @@ -71,10 +89,9 @@ public class QuestBazaarItem { JLabel priceLabel = new JLabel("Cost: " + item.getPrice() + " credits"); priceLabel.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 12)); - JButton purchaseButton = new JButton("Buy"); purchaseButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { + public void actionPerformed(final ActionEvent e) { AllZone.getQuestData().subtractCredits(item.getPrice()); purchaseItem(); AllZone.getQuestData().saveData(); @@ -134,7 +151,6 @@ public class QuestBazaarItem { itemPanel.setMinimumSize(new Dimension(0, 0)); - return itemPanel; } } diff --git a/src/main/java/forge/quest/gui/bazaar/QuestBazaarPanel.java b/src/main/java/forge/quest/gui/bazaar/QuestBazaarPanel.java index dd2b5f93a71..5a8e9191316 100644 --- a/src/main/java/forge/quest/gui/bazaar/QuestBazaarPanel.java +++ b/src/main/java/forge/quest/gui/bazaar/QuestBazaarPanel.java @@ -1,45 +1,62 @@ package forge.quest.gui.bazaar; -import forge.quest.data.bazaar.QuestStallManager; -import forge.quest.gui.QuestAbstractPanel; -import forge.quest.gui.QuestFrame; - -import javax.swing.*; -import java.awt.*; +import java.awt.BorderLayout; +import java.awt.CardLayout; +import java.awt.Dimension; +import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.ArrayList; import java.util.LinkedList; import java.util.List; +import javax.swing.JButton; +import javax.swing.JPanel; +import javax.swing.JToggleButton; + +import forge.quest.data.bazaar.QuestStallManager; +import forge.quest.gui.QuestAbstractPanel; +import forge.quest.gui.QuestFrame; + /** - *

QuestBazaarPanel class.

- * + *

+ * QuestBazaarPanel class. + *

+ * * @author Forge * @version $Id$ */ public class QuestBazaarPanel extends QuestAbstractPanel { - /** Constant serialVersionUID=1418913010051869222L */ + /** Constant serialVersionUID=1418913010051869222L. */ private static final long serialVersionUID = 1418913010051869222L; - /** Constant stallList */ + /** Constant stallList. */ static List stallList = new ArrayList(); + /** The button panel. */ JPanel buttonPanel = new JPanel(new BorderLayout()); + + /** The button panel main. */ JPanel buttonPanelMain = new JPanel(); + /** The stall panel. */ JPanel stallPanel = new JPanel(); + /** The selected stall. */ JToggleButton selectedStall = null; + /** The stall layout. */ CardLayout stallLayout = new CardLayout(); /** - *

Constructor for QuestBazaarPanel.

- * - * @param mainFrame a {@link forge.quest.gui.QuestFrame} object. + *

+ * Constructor for QuestBazaarPanel. + *

+ * + * @param mainFrame + * a {@link forge.quest.gui.QuestFrame} object. */ - public QuestBazaarPanel(QuestFrame mainFrame) { + public QuestBazaarPanel(final QuestFrame mainFrame) { super(mainFrame); this.setLayout(new BorderLayout()); @@ -60,7 +77,7 @@ public class QuestBazaarPanel extends QuestAbstractPanel { for (QuestBazaarStall stall : stallList) { JToggleButton stallButton = new JToggleButton(stall.getStallName(), stall.getStallIcon()); stallButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { + public void actionPerformed(final ActionEvent e) { if (QuestBazaarPanel.this.selectedStall == e.getSource()) { QuestBazaarPanel.this.selectedStall.setSelected(true); @@ -101,12 +118,11 @@ public class QuestBazaarPanel extends QuestAbstractPanel { button.setMinimumSize(max); } - buttonPanel.add(buttonPanelMain, BorderLayout.NORTH); JButton quitButton = new JButton("Leave Bazaar"); quitButton.setSize(max); quitButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { + public void actionPerformed(final ActionEvent e) { QuestBazaarPanel.this.mainFrame.showMainPane(); } }); @@ -119,11 +135,14 @@ public class QuestBazaarPanel extends QuestAbstractPanel { } /** - *

showStall.

- * - * @param source a {@link java.lang.String} object. + *

+ * showStall. + *

+ * + * @param source + * a {@link java.lang.String} object. */ - private void showStall(String source) { + private void showStall(final String source) { stallLayout.show(stallPanel, source); } @@ -138,7 +157,7 @@ public class QuestBazaarPanel extends QuestAbstractPanel { /** {@inheritDoc} */ @Override - public void refreshState() { + public final void refreshState() { refreshLastInstance(); } } diff --git a/src/main/java/forge/quest/gui/bazaar/QuestBazaarStall.java b/src/main/java/forge/quest/gui/bazaar/QuestBazaarStall.java index 8d1517d1bf8..0ac1a264b8b 100644 --- a/src/main/java/forge/quest/gui/bazaar/QuestBazaarStall.java +++ b/src/main/java/forge/quest/gui/bazaar/QuestBazaarStall.java @@ -13,6 +13,7 @@ import javax.swing.border.EmptyBorder; import java.awt.*; import java.util.ArrayList; +// TODO: Auto-generated Javadoc /** *

QuestBazaarStall class.

* @@ -22,15 +23,24 @@ import java.util.ArrayList; public class QuestBazaarStall extends JPanel implements NewConstants { /** Constant serialVersionUID=-4147745071116906043L */ private static final long serialVersionUID = -4147745071116906043L; + + /** The name. */ String name; + + /** The stall name. */ String stallName; + + /** The fluff. */ String fluff; + + /** The icon. */ ImageIcon icon; private JLabel creditLabel = new JLabel(); private JPanel inventoryPanel = new JPanel(); + /** The quest data. */ protected QuestData questData = AllZone.getQuestData(); /** diff --git a/src/main/java/forge/quest/gui/bazaar/package-info.java b/src/main/java/forge/quest/gui/bazaar/package-info.java index 006dbcf549d..867b4e06828 100644 --- a/src/main/java/forge/quest/gui/bazaar/package-info.java +++ b/src/main/java/forge/quest/gui/bazaar/package-info.java @@ -1,2 +1,2 @@ -/** Forge Card Game */ +/** Forge Card Game. */ package forge.quest.gui.bazaar;