mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 20:58:03 +00:00
checkstyle
This commit is contained in:
@@ -6,17 +6,28 @@
|
|||||||
|
|
||||||
package forge.gui.game;
|
package forge.gui.game;
|
||||||
|
|
||||||
|
|
||||||
import forge.*;
|
|
||||||
import forge.Constant.Zone;
|
|
||||||
|
|
||||||
import javax.swing.*;
|
|
||||||
import javax.swing.border.EtchedBorder;
|
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.*;
|
import java.awt.GridBagConstraints;
|
||||||
|
import java.awt.GridBagLayout;
|
||||||
|
import java.awt.GridLayout;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
import javax.swing.BorderFactory;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JScrollPane;
|
||||||
|
import javax.swing.JTextArea;
|
||||||
|
import javax.swing.SwingConstants;
|
||||||
|
import javax.swing.border.EtchedBorder;
|
||||||
|
|
||||||
|
import forge.AllZone;
|
||||||
|
import forge.Card;
|
||||||
|
import forge.CardContainer;
|
||||||
|
import forge.Constant.Zone;
|
||||||
|
import forge.Counters;
|
||||||
|
import forge.GameEntity;
|
||||||
|
import forge.GuiDisplayUtil;
|
||||||
|
import forge.Singletons;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The class CardDetailPanel. Shows the details of a card.
|
* The class CardDetailPanel. Shows the details of a card.
|
||||||
@@ -25,7 +36,7 @@ import java.util.Iterator;
|
|||||||
* @version V0.0 17.02.2010
|
* @version V0.0 17.02.2010
|
||||||
*/
|
*/
|
||||||
public class CardDetailPanel extends JPanel implements CardContainer {
|
public class CardDetailPanel extends JPanel implements CardContainer {
|
||||||
/** Constant <code>serialVersionUID=-8461473263764812323L</code> */
|
/** Constant <code>serialVersionUID=-8461473263764812323L</code>. */
|
||||||
private static final long serialVersionUID = -8461473263764812323L;
|
private static final long serialVersionUID = -8461473263764812323L;
|
||||||
|
|
||||||
private static Color PURPLE = new Color(14381203);
|
private static Color PURPLE = new Color(14381203);
|
||||||
@@ -41,11 +52,14 @@ public class CardDetailPanel extends JPanel implements CardContainer {
|
|||||||
private JTextArea cdArea;
|
private JTextArea cdArea;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Constructor for CardDetailPanel.</p>
|
* <p>
|
||||||
|
* Constructor for CardDetailPanel.
|
||||||
|
* </p>
|
||||||
*
|
*
|
||||||
* @param card a {@link forge.Card} object.
|
* @param card
|
||||||
|
* a {@link forge.Card} object.
|
||||||
*/
|
*/
|
||||||
public CardDetailPanel(Card card) {
|
public CardDetailPanel(final Card card) {
|
||||||
setLayout(new GridLayout(2, 0, 0, 5));
|
setLayout(new GridLayout(2, 0, 0, 5));
|
||||||
setBorder(new EtchedBorder());
|
setBorder(new EtchedBorder());
|
||||||
|
|
||||||
@@ -89,7 +103,6 @@ public class CardDetailPanel extends JPanel implements CardContainer {
|
|||||||
damageLabel.setFont(new java.awt.Font("Dialog", 0, 14));
|
damageLabel.setFont(new java.awt.Font("Dialog", 0, 14));
|
||||||
idLabel.setFont(new java.awt.Font("Dialog", 0, 14));
|
idLabel.setFont(new java.awt.Font("Dialog", 0, 14));
|
||||||
|
|
||||||
|
|
||||||
java.awt.Font f = new java.awt.Font("Dialog", 0, 14);
|
java.awt.Font f = new java.awt.Font("Dialog", 0, 14);
|
||||||
f = f.deriveFont(java.awt.Font.BOLD);
|
f = f.deriveFont(java.awt.Font.BOLD);
|
||||||
setInfoLabel.setFont(f);
|
setInfoLabel.setFont(f);
|
||||||
@@ -101,7 +114,7 @@ public class CardDetailPanel extends JPanel implements CardContainer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
public void setCard(Card card) {
|
public final void setCard(final Card card) {
|
||||||
nameCostLabel.setText("");
|
nameCostLabel.setText("");
|
||||||
typeLabel.setText("");
|
typeLabel.setText("");
|
||||||
powerToughnessLabel.setText("");
|
powerToughnessLabel.setText("");
|
||||||
@@ -114,27 +127,42 @@ public class CardDetailPanel extends JPanel implements CardContainer {
|
|||||||
setBorder(GuiDisplayUtil.getBorder(card));
|
setBorder(GuiDisplayUtil.getBorder(card));
|
||||||
|
|
||||||
this.card = card;
|
this.card = card;
|
||||||
if (card == null) return;
|
if (card == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
boolean faceDown = card.isFaceDown() && card.getController() != AllZone.getHumanPlayer();
|
boolean faceDown = card.isFaceDown() && card.getController() != AllZone.getHumanPlayer();
|
||||||
if (!faceDown) {
|
if (!faceDown) {
|
||||||
if (card.getManaCost().equals("") || card.isLand()) nameCostLabel.setText(card.getName());
|
if (card.getManaCost().equals("") || card.isLand()) {
|
||||||
else nameCostLabel.setText(card.getName() + " - " + card.getManaCost());
|
nameCostLabel.setText(card.getName());
|
||||||
} else nameCostLabel.setText("Morph");
|
} else {
|
||||||
|
nameCostLabel.setText(card.getName() + " - " + card.getManaCost());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
nameCostLabel.setText("Morph");
|
||||||
|
}
|
||||||
|
|
||||||
if (!faceDown) typeLabel.setText(GuiDisplayUtil.formatCardType(card));
|
if (!faceDown) {
|
||||||
else typeLabel.setText("Creature");
|
typeLabel.setText(GuiDisplayUtil.formatCardType(card));
|
||||||
|
} else {
|
||||||
|
typeLabel.setText("Creature");
|
||||||
|
}
|
||||||
|
|
||||||
if (card.isCreature()) {
|
if (card.isCreature()) {
|
||||||
powerToughnessLabel.setText(card.getNetAttack() + " / " + card.getNetDefense());
|
powerToughnessLabel.setText(card.getNetAttack() + " / " + card.getNetDefense());
|
||||||
damageLabel.setText("Damage: " + card.getDamage() + " Assigned Damage: " + card.getTotalAssignedDamage());
|
damageLabel.setText("Damage: " + card.getDamage() + " Assigned Damage: " + card.getTotalAssignedDamage());
|
||||||
}
|
}
|
||||||
if (card.isPlaneswalker()) damageLabel.setText("Assigned Damage: " + card.getTotalAssignedDamage());
|
if (card.isPlaneswalker()) {
|
||||||
|
damageLabel.setText("Assigned Damage: " + card.getTotalAssignedDamage());
|
||||||
|
}
|
||||||
|
|
||||||
idLabel.setText("Card ID " + card.getUniqueNumber());
|
idLabel.setText("Card ID " + card.getUniqueNumber());
|
||||||
|
|
||||||
//rarity and set of a face down card should not be visible to the opponent
|
// rarity and set of a face down card should not be visible to the
|
||||||
if (!card.isFaceDown() || card.getController().isHuman()) setInfoLabel.setText(card.getCurSetCode());
|
// opponent
|
||||||
|
if (!card.isFaceDown() || card.getController().isHuman()) {
|
||||||
|
setInfoLabel.setText(card.getCurSetCode());
|
||||||
|
}
|
||||||
|
|
||||||
if (!setInfoLabel.getText().equals("")) {
|
if (!setInfoLabel.getText().equals("")) {
|
||||||
setInfoLabel.setOpaque(true);
|
setInfoLabel.setOpaque(true);
|
||||||
@@ -169,11 +197,15 @@ public class CardDetailPanel extends JPanel implements CardContainer {
|
|||||||
StringBuilder area = new StringBuilder();
|
StringBuilder area = new StringBuilder();
|
||||||
|
|
||||||
// Token
|
// Token
|
||||||
if (card.isToken()) area.append("Token");
|
if (card.isToken()) {
|
||||||
|
area.append("Token");
|
||||||
|
}
|
||||||
|
|
||||||
if (!faceDown) {
|
if (!faceDown) {
|
||||||
// card text
|
// card text
|
||||||
if (area.length() != 0) area.append("\n");
|
if (area.length() != 0) {
|
||||||
|
area.append("\n");
|
||||||
|
}
|
||||||
String text = card.getText();
|
String text = card.getText();
|
||||||
// LEVEL [0-9]+-[0-9]+
|
// LEVEL [0-9]+-[0-9]+
|
||||||
// LEVEL [0-9]+\+
|
// LEVEL [0-9]+\+
|
||||||
@@ -192,7 +224,9 @@ public class CardDetailPanel extends JPanel implements CardContainer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (card.isPhasedOut()) {
|
if (card.isPhasedOut()) {
|
||||||
if (area.length() != 0) area.append("\n");
|
if (area.length() != 0) {
|
||||||
|
area.append("\n");
|
||||||
|
}
|
||||||
area.append("Phased Out");
|
area.append("Phased Out");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -200,7 +234,9 @@ public class CardDetailPanel extends JPanel implements CardContainer {
|
|||||||
Counters[] counters = Counters.values();
|
Counters[] counters = Counters.values();
|
||||||
for (Counters counter : counters) {
|
for (Counters counter : counters) {
|
||||||
if (card.getCounters(counter) != 0) {
|
if (card.getCounters(counter) != 0) {
|
||||||
if (area.length() != 0) area.append("\n");
|
if (area.length() != 0) {
|
||||||
|
area.append("\n");
|
||||||
|
}
|
||||||
area.append(counter.getName() + " counters: ");
|
area.append(counter.getName() + " counters: ");
|
||||||
area.append(card.getCounters(counter));
|
area.append(card.getCounters(counter));
|
||||||
}
|
}
|
||||||
@@ -209,7 +245,9 @@ public class CardDetailPanel extends JPanel implements CardContainer {
|
|||||||
// Regeneration Shields
|
// Regeneration Shields
|
||||||
int regenShields = card.getShield();
|
int regenShields = card.getShield();
|
||||||
if (regenShields > 0) {
|
if (regenShields > 0) {
|
||||||
if (area.length() != 0) area.append("\n");
|
if (area.length() != 0) {
|
||||||
|
area.append("\n");
|
||||||
|
}
|
||||||
area.append("Regeneration Shield(s): ").append(regenShields);
|
area.append("Regeneration Shield(s): ").append(regenShields);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -230,7 +268,9 @@ public class CardDetailPanel extends JPanel implements CardContainer {
|
|||||||
|
|
||||||
// chosen type
|
// chosen type
|
||||||
if (card.getChosenType() != "") {
|
if (card.getChosenType() != "") {
|
||||||
if (area.length() != 0) area.append("\n");
|
if (area.length() != 0) {
|
||||||
|
area.append("\n");
|
||||||
|
}
|
||||||
area.append("(chosen type: ");
|
area.append("(chosen type: ");
|
||||||
area.append(card.getChosenType());
|
area.append(card.getChosenType());
|
||||||
area.append(")");
|
area.append(")");
|
||||||
@@ -238,7 +278,9 @@ public class CardDetailPanel extends JPanel implements CardContainer {
|
|||||||
|
|
||||||
// chosen color
|
// chosen color
|
||||||
if (!card.getChosenColor().isEmpty()) {
|
if (!card.getChosenColor().isEmpty()) {
|
||||||
if (area.length() != 0) area.append("\n");
|
if (area.length() != 0) {
|
||||||
|
area.append("\n");
|
||||||
|
}
|
||||||
area.append("(chosen colors: ");
|
area.append("(chosen colors: ");
|
||||||
area.append(card.getChosenColor());
|
area.append(card.getChosenColor());
|
||||||
area.append(")");
|
area.append(")");
|
||||||
@@ -246,7 +288,9 @@ public class CardDetailPanel extends JPanel implements CardContainer {
|
|||||||
|
|
||||||
// named card
|
// named card
|
||||||
if (card.getNamedCard() != "") {
|
if (card.getNamedCard() != "") {
|
||||||
if (area.length() != 0) area.append("\n");
|
if (area.length() != 0) {
|
||||||
|
area.append("\n");
|
||||||
|
}
|
||||||
area.append("(named card: ");
|
area.append("(named card: ");
|
||||||
area.append(card.getNamedCard());
|
area.append(card.getNamedCard());
|
||||||
area.append(")");
|
area.append(")");
|
||||||
@@ -254,7 +298,9 @@ public class CardDetailPanel extends JPanel implements CardContainer {
|
|||||||
|
|
||||||
// equipping
|
// equipping
|
||||||
if (card.getEquipping().size() > 0) {
|
if (card.getEquipping().size() > 0) {
|
||||||
if (area.length() != 0) area.append("\n");
|
if (area.length() != 0) {
|
||||||
|
area.append("\n");
|
||||||
|
}
|
||||||
area.append("=Equipping ");
|
area.append("=Equipping ");
|
||||||
area.append(card.getEquipping().get(0));
|
area.append(card.getEquipping().get(0));
|
||||||
area.append("=");
|
area.append("=");
|
||||||
@@ -262,11 +308,15 @@ public class CardDetailPanel extends JPanel implements CardContainer {
|
|||||||
|
|
||||||
// equipped by
|
// equipped by
|
||||||
if (card.getEquippedBy().size() > 0) {
|
if (card.getEquippedBy().size() > 0) {
|
||||||
if (area.length() != 0) area.append("\n");
|
if (area.length() != 0) {
|
||||||
|
area.append("\n");
|
||||||
|
}
|
||||||
area.append("=Equipped by ");
|
area.append("=Equipped by ");
|
||||||
for (Iterator<Card> it = card.getEquippedBy().iterator(); it.hasNext();) {
|
for (Iterator<Card> it = card.getEquippedBy().iterator(); it.hasNext();) {
|
||||||
area.append(it.next());
|
area.append(it.next());
|
||||||
if (it.hasNext()) area.append(", ");
|
if (it.hasNext()) {
|
||||||
|
area.append(", ");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
area.append("=");
|
area.append("=");
|
||||||
}
|
}
|
||||||
@@ -274,7 +324,9 @@ public class CardDetailPanel extends JPanel implements CardContainer {
|
|||||||
// enchanting
|
// enchanting
|
||||||
GameEntity entity = card.getEnchanting();
|
GameEntity entity = card.getEnchanting();
|
||||||
if (entity != null) {
|
if (entity != null) {
|
||||||
if (area.length() != 0) area.append("\n");
|
if (area.length() != 0) {
|
||||||
|
area.append("\n");
|
||||||
|
}
|
||||||
area.append("*Enchanting ");
|
area.append("*Enchanting ");
|
||||||
|
|
||||||
if (entity instanceof Card) {
|
if (entity instanceof Card) {
|
||||||
@@ -283,12 +335,10 @@ public class CardDetailPanel extends JPanel implements CardContainer {
|
|||||||
area.append("Morph (");
|
area.append("Morph (");
|
||||||
area.append(card.getUniqueNumber());
|
area.append(card.getUniqueNumber());
|
||||||
area.append(")");
|
area.append(")");
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
area.append(entity);
|
area.append(entity);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
area.append(entity);
|
area.append(entity);
|
||||||
}
|
}
|
||||||
area.append("*");
|
area.append("*");
|
||||||
@@ -296,29 +346,39 @@ public class CardDetailPanel extends JPanel implements CardContainer {
|
|||||||
|
|
||||||
// enchanted by
|
// enchanted by
|
||||||
if (card.getEnchantedBy().size() > 0) {
|
if (card.getEnchantedBy().size() > 0) {
|
||||||
if (area.length() != 0) area.append("\n");
|
if (area.length() != 0) {
|
||||||
|
area.append("\n");
|
||||||
|
}
|
||||||
area.append("*Enchanted by ");
|
area.append("*Enchanted by ");
|
||||||
for (Iterator<Card> it = card.getEnchantedBy().iterator(); it.hasNext();) {
|
for (Iterator<Card> it = card.getEnchantedBy().iterator(); it.hasNext();) {
|
||||||
area.append(it.next());
|
area.append(it.next());
|
||||||
if (it.hasNext()) area.append(", ");
|
if (it.hasNext()) {
|
||||||
|
area.append(", ");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
area.append("*");
|
area.append("*");
|
||||||
}
|
}
|
||||||
|
|
||||||
// controlling
|
// controlling
|
||||||
if (card.getGainControlTargets().size() > 0) {
|
if (card.getGainControlTargets().size() > 0) {
|
||||||
if (area.length() != 0) area.append("\n");
|
if (area.length() != 0) {
|
||||||
|
area.append("\n");
|
||||||
|
}
|
||||||
area.append("+Controlling: ");
|
area.append("+Controlling: ");
|
||||||
for (Iterator<Card> it = card.getGainControlTargets().iterator(); it.hasNext();) {
|
for (Iterator<Card> it = card.getGainControlTargets().iterator(); it.hasNext();) {
|
||||||
area.append(it.next());
|
area.append(it.next());
|
||||||
if (it.hasNext()) area.append(", ");
|
if (it.hasNext()) {
|
||||||
|
area.append(", ");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
area.append("+");
|
area.append("+");
|
||||||
}
|
}
|
||||||
|
|
||||||
// cloned via
|
// cloned via
|
||||||
if (card.getCloneOrigin() != null) {
|
if (card.getCloneOrigin() != null) {
|
||||||
if (area.length() != 0) area.append("\n");
|
if (area.length() != 0) {
|
||||||
|
area.append("\n");
|
||||||
|
}
|
||||||
area.append("^Cloned via: ");
|
area.append("^Cloned via: ");
|
||||||
area.append(card.getCloneOrigin().getName());
|
area.append(card.getCloneOrigin().getName());
|
||||||
area.append("^");
|
area.append("^");
|
||||||
@@ -326,29 +386,39 @@ public class CardDetailPanel extends JPanel implements CardContainer {
|
|||||||
|
|
||||||
// Imprint
|
// Imprint
|
||||||
if (!card.getImprinted().isEmpty()) {
|
if (!card.getImprinted().isEmpty()) {
|
||||||
if (area.length() != 0) area.append("\n");
|
if (area.length() != 0) {
|
||||||
|
area.append("\n");
|
||||||
|
}
|
||||||
area.append("^Imprinting: ");
|
area.append("^Imprinting: ");
|
||||||
for (Iterator<Card> it = card.getImprinted().iterator(); it.hasNext();) {
|
for (Iterator<Card> it = card.getImprinted().iterator(); it.hasNext();) {
|
||||||
area.append(it.next());
|
area.append(it.next());
|
||||||
if (it.hasNext()) area.append(", ");
|
if (it.hasNext()) {
|
||||||
|
area.append(", ");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
area.append("^");
|
area.append("^");
|
||||||
}
|
}
|
||||||
|
|
||||||
// uncastable
|
// uncastable
|
||||||
if (card.isUnCastable()) {
|
if (card.isUnCastable()) {
|
||||||
if (area.length() != 0) area.append("\n");
|
if (area.length() != 0) {
|
||||||
|
area.append("\n");
|
||||||
|
}
|
||||||
area.append("This card can't be cast.");
|
area.append("This card can't be cast.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// must block
|
// must block
|
||||||
if (!card.getMustBlockCards().isEmpty()) {
|
if (!card.getMustBlockCards().isEmpty()) {
|
||||||
if (area.length() != 0) area.append("\n");
|
if (area.length() != 0) {
|
||||||
|
area.append("\n");
|
||||||
|
}
|
||||||
area.append("Must block an attacker");
|
area.append("Must block an attacker");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (card.hasAttachedCardsByMindsDesire()) {
|
if (card.hasAttachedCardsByMindsDesire()) {
|
||||||
if (area.length() != 0) area.append("\n");
|
if (area.length() != 0) {
|
||||||
|
area.append("\n");
|
||||||
|
}
|
||||||
Card[] cards = card.getAttachedCardsByMindsDesire();
|
Card[] cards = card.getAttachedCardsByMindsDesire();
|
||||||
area.append("=Attached: ");
|
area.append("=Attached: ");
|
||||||
for (Card c : cards) {
|
for (Card c : cards) {
|
||||||
@@ -362,11 +432,13 @@ public class CardDetailPanel extends JPanel implements CardContainer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Getter for the field <code>card</code>.</p>
|
* <p>
|
||||||
|
* Getter for the field <code>card</code>.
|
||||||
|
* </p>
|
||||||
*
|
*
|
||||||
* @return a {@link forge.Card} object.
|
* @return a {@link forge.Card} object.
|
||||||
*/
|
*/
|
||||||
public Card getCard() {
|
public final Card getCard() {
|
||||||
return card;
|
return card;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,37 +1,46 @@
|
|||||||
package forge.gui.game;
|
package forge.gui.game;
|
||||||
|
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.awt.GridLayout;
|
||||||
|
import java.awt.Image;
|
||||||
|
|
||||||
|
import javax.swing.ImageIcon;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
|
||||||
import forge.Card;
|
import forge.Card;
|
||||||
import forge.CardContainer;
|
import forge.CardContainer;
|
||||||
import forge.GuiDisplayUtil;
|
import forge.GuiDisplayUtil;
|
||||||
import forge.ImageCache;
|
import forge.ImageCache;
|
||||||
|
|
||||||
import javax.swing.*;
|
|
||||||
import java.awt.*;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The class CardPanel. A card panel stores a card to display it on the battlefield. An image is used if available.
|
* The class CardPanel. A card panel stores a card to display it on the
|
||||||
|
* battlefield. An image is used if available.
|
||||||
*
|
*
|
||||||
* @author Forge
|
* @author Forge
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
*/
|
*/
|
||||||
public class CardPanel extends JPanel implements CardContainer {
|
public class CardPanel extends JPanel implements CardContainer {
|
||||||
/** Constant <code>serialVersionUID=509877513760665415L</code> */
|
/** Constant <code>serialVersionUID=509877513760665415L</code>. */
|
||||||
private static final long serialVersionUID = 509877513760665415L;
|
private static final long serialVersionUID = 509877513760665415L;
|
||||||
private Card card;
|
private Card card;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Constructor for CardPanel.</p>
|
* <p>
|
||||||
|
* Constructor for CardPanel.
|
||||||
|
* </p>
|
||||||
*
|
*
|
||||||
* @param card a {@link forge.Card} object.
|
* @param card
|
||||||
|
* a {@link forge.Card} object.
|
||||||
*/
|
*/
|
||||||
public CardPanel(Card card) {
|
public CardPanel(final Card card) {
|
||||||
setCard(card);
|
setCard(card);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>addComponents.</p>
|
* <p>
|
||||||
|
* addComponents.
|
||||||
|
* </p>
|
||||||
*/
|
*/
|
||||||
private void addComponents() {
|
private void addComponents() {
|
||||||
Card c = getCard();
|
Card c = getCard();
|
||||||
@@ -51,7 +60,9 @@ public class CardPanel extends JPanel implements CardContainer {
|
|||||||
add(tapLabel);
|
add(tapLabel);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (c.isCreature()) add(new JLabel(c.getNetAttack() + " / " + c.getNetDefense()));
|
if (c.isCreature()) {
|
||||||
|
add(new JLabel(c.getNetAttack() + " / " + c.getNetDefense()));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// show the card image
|
// show the card image
|
||||||
setLayout(new GridLayout(1, 1));
|
setLayout(new GridLayout(1, 1));
|
||||||
@@ -60,22 +71,25 @@ public class CardPanel extends JPanel implements CardContainer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
public void setCard(Card card) {
|
public final void setCard(final Card card) {
|
||||||
this.card = card;
|
this.card = card;
|
||||||
setBorder(GuiDisplayUtil.getBorder(card));
|
setBorder(GuiDisplayUtil.getBorder(card));
|
||||||
addComponents();
|
addComponents();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Getter for the field <code>card</code>.</p>
|
* <p>
|
||||||
|
* Getter for the field <code>card</code>.
|
||||||
|
* </p>
|
||||||
*
|
*
|
||||||
* @return a {@link forge.Card} object.
|
* @return a {@link forge.Card} object.
|
||||||
*/
|
*/
|
||||||
public Card getCard() {
|
public final Card getCard() {
|
||||||
return card;
|
return card;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ~
|
// ~
|
||||||
|
/** The connected card. */
|
||||||
public CardPanel connectedCard;
|
public CardPanel connectedCard;
|
||||||
// ~
|
// ~
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,13 @@
|
|||||||
|
|
||||||
package forge.gui.game;
|
package forge.gui.game;
|
||||||
|
|
||||||
|
import java.awt.BorderLayout;
|
||||||
|
import java.awt.Image;
|
||||||
|
import java.awt.Insets;
|
||||||
|
import java.awt.event.ComponentAdapter;
|
||||||
|
import java.awt.event.ComponentEvent;
|
||||||
|
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
|
||||||
import arcane.ui.ScaledImagePanel;
|
import arcane.ui.ScaledImagePanel;
|
||||||
import arcane.ui.ScaledImagePanel.MultipassType;
|
import arcane.ui.ScaledImagePanel.MultipassType;
|
||||||
@@ -16,21 +23,15 @@ import forge.ImageCache;
|
|||||||
import forge.item.CardPrinted;
|
import forge.item.CardPrinted;
|
||||||
import forge.item.InventoryItem;
|
import forge.item.InventoryItem;
|
||||||
|
|
||||||
import javax.swing.*;
|
|
||||||
import java.awt.*;
|
|
||||||
import java.awt.event.ComponentAdapter;
|
|
||||||
import java.awt.event.ComponentEvent;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The class CardPicturePanel. Shows the full-sized image in a label. if there's no picture, the cardname is
|
* The class CardPicturePanel. Shows the full-sized image in a label. if there's
|
||||||
* displayed instead.
|
* no picture, the cardname is displayed instead.
|
||||||
*
|
*
|
||||||
* @author Clemens Koza
|
* @author Clemens Koza
|
||||||
* @version V0.0 17.02.2010
|
* @version V0.0 17.02.2010
|
||||||
*/
|
*/
|
||||||
public final class CardPicturePanel extends JPanel implements CardContainer {
|
public final class CardPicturePanel extends JPanel implements CardContainer {
|
||||||
/** Constant <code>serialVersionUID=-3160874016387273383L</code> */
|
/** Constant <code>serialVersionUID=-3160874016387273383L</code>. */
|
||||||
private static final long serialVersionUID = -3160874016387273383L;
|
private static final long serialVersionUID = -3160874016387273383L;
|
||||||
|
|
||||||
private Card card;
|
private Card card;
|
||||||
@@ -42,9 +43,12 @@ public final class CardPicturePanel extends JPanel implements CardContainer {
|
|||||||
private Image currentImange;
|
private Image currentImange;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Constructor for CardPicturePanel.</p>
|
* <p>
|
||||||
|
* Constructor for CardPicturePanel.
|
||||||
|
* </p>
|
||||||
*
|
*
|
||||||
* @param c a {@link forge.Card} object.
|
* @param c
|
||||||
|
* a {@link forge.Card} object.
|
||||||
*/
|
*/
|
||||||
public CardPicturePanel(final Card c) {
|
public CardPicturePanel(final Card c) {
|
||||||
super(new BorderLayout());
|
super(new BorderLayout());
|
||||||
@@ -70,14 +74,26 @@ public final class CardPicturePanel extends JPanel implements CardContainer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>update.</p>
|
* <p>
|
||||||
|
* update.
|
||||||
|
* </p>
|
||||||
*/
|
*/
|
||||||
public void update() { setCard(getCard()); }
|
public void update() {
|
||||||
|
setCard(getCard());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the card.
|
||||||
|
*
|
||||||
|
* @param cp
|
||||||
|
* the new card
|
||||||
|
*/
|
||||||
public void setCard(final InventoryItem cp) {
|
public void setCard(final InventoryItem cp) {
|
||||||
card = null;
|
card = null;
|
||||||
inventoryItem = cp;
|
inventoryItem = cp;
|
||||||
if (!isShowing()) { return; }
|
if (!isShowing()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
setImage();
|
setImage();
|
||||||
}
|
}
|
||||||
@@ -86,7 +102,9 @@ public final class CardPicturePanel extends JPanel implements CardContainer {
|
|||||||
public void setCard(final Card c) {
|
public void setCard(final Card c) {
|
||||||
card = c;
|
card = c;
|
||||||
inventoryItem = null;
|
inventoryItem = null;
|
||||||
if (!isShowing()) { return; }
|
if (!isShowing()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
setImage();
|
setImage();
|
||||||
}
|
}
|
||||||
@@ -95,9 +113,11 @@ public final class CardPicturePanel extends JPanel implements CardContainer {
|
|||||||
Insets i = getInsets();
|
Insets i = getInsets();
|
||||||
Image image = null;
|
Image image = null;
|
||||||
if (inventoryItem != null) {
|
if (inventoryItem != null) {
|
||||||
image = ImageCache.getImage(inventoryItem, getWidth() - i.left - i.right, getHeight() - i.top - i.bottom); }
|
image = ImageCache.getImage(inventoryItem, getWidth() - i.left - i.right, getHeight() - i.top - i.bottom);
|
||||||
|
}
|
||||||
if (card != null && image == null) {
|
if (card != null && image == null) {
|
||||||
image = ImageCache.getImage(card, getWidth() - i.left - i.right, getHeight() - i.top - i.bottom); }
|
image = ImageCache.getImage(card, getWidth() - i.left - i.right, getHeight() - i.top - i.bottom);
|
||||||
|
}
|
||||||
|
|
||||||
if (image != currentImange) {
|
if (image != currentImange) {
|
||||||
currentImange = image;
|
currentImange = image;
|
||||||
@@ -116,7 +136,9 @@ public final class CardPicturePanel extends JPanel implements CardContainer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Getter for the field <code>card</code>.</p>
|
* <p>
|
||||||
|
* Getter for the field <code>card</code>.
|
||||||
|
* </p>
|
||||||
*
|
*
|
||||||
* @return a {@link forge.Card} object.
|
* @return a {@link forge.Card} object.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
/** Forge Card Game */
|
/** Forge Card Game. */
|
||||||
package forge.gui.game;
|
package forge.gui.game;
|
||||||
|
|||||||
Reference in New Issue
Block a user