mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 12:48:00 +00:00
checkstyle
This commit is contained in:
@@ -6,30 +6,41 @@
|
||||
|
||||
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.*;
|
||||
import java.awt.GridBagConstraints;
|
||||
import java.awt.GridBagLayout;
|
||||
import java.awt.GridLayout;
|
||||
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.
|
||||
*
|
||||
*
|
||||
* @author Clemens Koza
|
||||
* @version V0.0 17.02.2010
|
||||
*/
|
||||
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 Color PURPLE = new Color(14381203);
|
||||
|
||||
|
||||
private Card card;
|
||||
|
||||
private JLabel nameCostLabel;
|
||||
@@ -41,11 +52,14 @@ public class CardDetailPanel extends JPanel implements CardContainer {
|
||||
private JTextArea cdArea;
|
||||
|
||||
/**
|
||||
* <p>Constructor for CardDetailPanel.</p>
|
||||
*
|
||||
* @param card a {@link forge.Card} object.
|
||||
* <p>
|
||||
* Constructor for CardDetailPanel.
|
||||
* </p>
|
||||
*
|
||||
* @param card
|
||||
* a {@link forge.Card} object.
|
||||
*/
|
||||
public CardDetailPanel(Card card) {
|
||||
public CardDetailPanel(final Card card) {
|
||||
setLayout(new GridLayout(2, 0, 0, 5));
|
||||
setBorder(new EtchedBorder());
|
||||
|
||||
@@ -74,7 +88,7 @@ public class CardDetailPanel extends JPanel implements CardContainer {
|
||||
nameCostLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
typeLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
powerToughnessLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
//cdLabel7.setSize(100, cdLabel7.getHeight());
|
||||
// cdLabel7.setSize(100, cdLabel7.getHeight());
|
||||
|
||||
setInfoLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
|
||||
@@ -83,27 +97,26 @@ public class CardDetailPanel extends JPanel implements CardContainer {
|
||||
cdArea.setWrapStyleWord(true);
|
||||
|
||||
if (!Singletons.getModel().getPreferences().lafFonts) {
|
||||
nameCostLabel.setFont(new java.awt.Font("Dialog", 0, 14));
|
||||
typeLabel.setFont(new java.awt.Font("Dialog", 0, 14));
|
||||
nameCostLabel.setFont(new java.awt.Font("Dialog", 0, 14));
|
||||
typeLabel.setFont(new java.awt.Font("Dialog", 0, 14));
|
||||
powerToughnessLabel.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));
|
||||
|
||||
|
||||
java.awt.Font f = new java.awt.Font("Dialog", 0, 14);
|
||||
f = f.deriveFont(java.awt.Font.BOLD);
|
||||
setInfoLabel.setFont(f);
|
||||
f = f.deriveFont(java.awt.Font.BOLD);
|
||||
setInfoLabel.setFont(f);
|
||||
|
||||
cdArea.setFont(new java.awt.Font("Dialog", 0, 14));
|
||||
cdArea.setFont(new java.awt.Font("Dialog", 0, 14));
|
||||
}
|
||||
|
||||
setCard(card);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public void setCard(Card card) {
|
||||
nameCostLabel.setText("");
|
||||
typeLabel.setText("");
|
||||
public final void setCard(final Card card) {
|
||||
nameCostLabel.setText("");
|
||||
typeLabel.setText("");
|
||||
powerToughnessLabel.setText("");
|
||||
damageLabel.setText("");
|
||||
idLabel.setText("");
|
||||
@@ -114,69 +127,88 @@ public class CardDetailPanel extends JPanel implements CardContainer {
|
||||
setBorder(GuiDisplayUtil.getBorder(card));
|
||||
|
||||
this.card = card;
|
||||
if (card == null) return;
|
||||
if (card == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
boolean faceDown = card.isFaceDown() && card.getController() != AllZone.getHumanPlayer();
|
||||
if (!faceDown) {
|
||||
if (card.getManaCost().equals("") || card.isLand()) nameCostLabel.setText(card.getName());
|
||||
else nameCostLabel.setText(card.getName() + " - " + card.getManaCost());
|
||||
} else nameCostLabel.setText("Morph");
|
||||
if (card.getManaCost().equals("") || card.isLand()) {
|
||||
nameCostLabel.setText(card.getName());
|
||||
} else {
|
||||
nameCostLabel.setText(card.getName() + " - " + card.getManaCost());
|
||||
}
|
||||
} else {
|
||||
nameCostLabel.setText("Morph");
|
||||
}
|
||||
|
||||
if (!faceDown) typeLabel.setText(GuiDisplayUtil.formatCardType(card));
|
||||
else typeLabel.setText("Creature");
|
||||
if (!faceDown) {
|
||||
typeLabel.setText(GuiDisplayUtil.formatCardType(card));
|
||||
} else {
|
||||
typeLabel.setText("Creature");
|
||||
}
|
||||
|
||||
if (card.isCreature()) {
|
||||
powerToughnessLabel.setText(card.getNetAttack() + " / " + card.getNetDefense());
|
||||
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());
|
||||
|
||||
//rarity and set of a face down card should not be visible to the opponent
|
||||
if (!card.isFaceDown() || card.getController().isHuman()) setInfoLabel.setText(card.getCurSetCode());
|
||||
|
||||
if (!setInfoLabel.getText().equals("")) {
|
||||
setInfoLabel.setOpaque(true);
|
||||
String csr = card.getCurSetRarity();
|
||||
if (csr.equals("Common") || csr.equals("Land")) {
|
||||
setInfoLabel.setBackground(Color.BLACK);
|
||||
setInfoLabel.setForeground(Color.WHITE);
|
||||
setInfoLabel.setBorder(BorderFactory.createLineBorder(Color.WHITE));
|
||||
} else if (csr.equals("Uncommon")) {
|
||||
setInfoLabel.setBackground(Color.LIGHT_GRAY);
|
||||
setInfoLabel.setForeground(Color.BLACK);
|
||||
setInfoLabel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
|
||||
} else if (csr.equals("Rare")) {
|
||||
setInfoLabel.setBackground(Color.YELLOW);
|
||||
setInfoLabel.setForeground(Color.BLACK);
|
||||
setInfoLabel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
|
||||
} else if (csr.equals("Mythic")) {
|
||||
setInfoLabel.setBackground(Color.RED);
|
||||
setInfoLabel.setForeground(Color.BLACK);
|
||||
setInfoLabel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
|
||||
} else if (csr.equals("Special")) {
|
||||
// "Timeshifted" or other Special Rarity Cards
|
||||
setInfoLabel.setBackground(PURPLE);
|
||||
setInfoLabel.setForeground(Color.BLACK);
|
||||
setInfoLabel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
|
||||
}
|
||||
//cdLabel7.setText(card.getCurSetCode());
|
||||
// rarity and set of a face down card should not be visible to the
|
||||
// opponent
|
||||
if (!card.isFaceDown() || card.getController().isHuman()) {
|
||||
setInfoLabel.setText(card.getCurSetCode());
|
||||
}
|
||||
|
||||
//fill the card text
|
||||
if (!setInfoLabel.getText().equals("")) {
|
||||
setInfoLabel.setOpaque(true);
|
||||
String csr = card.getCurSetRarity();
|
||||
if (csr.equals("Common") || csr.equals("Land")) {
|
||||
setInfoLabel.setBackground(Color.BLACK);
|
||||
setInfoLabel.setForeground(Color.WHITE);
|
||||
setInfoLabel.setBorder(BorderFactory.createLineBorder(Color.WHITE));
|
||||
} else if (csr.equals("Uncommon")) {
|
||||
setInfoLabel.setBackground(Color.LIGHT_GRAY);
|
||||
setInfoLabel.setForeground(Color.BLACK);
|
||||
setInfoLabel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
|
||||
} else if (csr.equals("Rare")) {
|
||||
setInfoLabel.setBackground(Color.YELLOW);
|
||||
setInfoLabel.setForeground(Color.BLACK);
|
||||
setInfoLabel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
|
||||
} else if (csr.equals("Mythic")) {
|
||||
setInfoLabel.setBackground(Color.RED);
|
||||
setInfoLabel.setForeground(Color.BLACK);
|
||||
setInfoLabel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
|
||||
} else if (csr.equals("Special")) {
|
||||
// "Timeshifted" or other Special Rarity Cards
|
||||
setInfoLabel.setBackground(PURPLE);
|
||||
setInfoLabel.setForeground(Color.BLACK);
|
||||
setInfoLabel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
|
||||
}
|
||||
// cdLabel7.setText(card.getCurSetCode());
|
||||
}
|
||||
|
||||
// fill the card text
|
||||
|
||||
StringBuilder area = new StringBuilder();
|
||||
|
||||
//Token
|
||||
if (card.isToken()) area.append("Token");
|
||||
// Token
|
||||
if (card.isToken()) {
|
||||
area.append("Token");
|
||||
}
|
||||
|
||||
if (!faceDown) {
|
||||
//card text
|
||||
if (area.length() != 0) area.append("\n");
|
||||
// card text
|
||||
if (area.length() != 0) {
|
||||
area.append("\n");
|
||||
}
|
||||
String text = card.getText();
|
||||
//LEVEL [0-9]+-[0-9]+
|
||||
//LEVEL [0-9]+\+
|
||||
// LEVEL [0-9]+-[0-9]+
|
||||
// LEVEL [0-9]+\+
|
||||
|
||||
String regex = "LEVEL [0-9]+-[0-9]+ ";
|
||||
text = text.replaceAll(regex, "$0\r\n");
|
||||
@@ -184,23 +216,27 @@ public class CardDetailPanel extends JPanel implements CardContainer {
|
||||
regex = "LEVEL [0-9]+\\+ ";
|
||||
text = text.replaceAll(regex, "\r\n$0\r\n");
|
||||
|
||||
//displays keywords that have dots in them a little better:
|
||||
// displays keywords that have dots in them a little better:
|
||||
regex = "\\., ";
|
||||
text = text.replaceAll(regex, ".\r\n");
|
||||
|
||||
area.append(text);
|
||||
}
|
||||
|
||||
if (card.isPhasedOut()){
|
||||
if (area.length() != 0) area.append("\n");
|
||||
if (card.isPhasedOut()) {
|
||||
if (area.length() != 0) {
|
||||
area.append("\n");
|
||||
}
|
||||
area.append("Phased Out");
|
||||
}
|
||||
|
||||
//counter text
|
||||
// counter text
|
||||
Counters[] counters = Counters.values();
|
||||
for (Counters counter : counters) {
|
||||
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(card.getCounters(counter));
|
||||
}
|
||||
@@ -209,7 +245,9 @@ public class CardDetailPanel extends JPanel implements CardContainer {
|
||||
// Regeneration Shields
|
||||
int regenShields = card.getShield();
|
||||
if (regenShields > 0) {
|
||||
if (area.length() != 0) area.append("\n");
|
||||
if (area.length() != 0) {
|
||||
area.append("\n");
|
||||
}
|
||||
area.append("Regeneration Shield(s): ").append(regenShields);
|
||||
}
|
||||
|
||||
@@ -221,134 +259,166 @@ public class CardDetailPanel extends JPanel implements CardContainer {
|
||||
area.append(card.getName()).append(" it this turn.");
|
||||
}
|
||||
|
||||
//top revealed
|
||||
// top revealed
|
||||
if (card.hasKeyword("Play with the top card of your library revealed.") && card.getController() != null
|
||||
&& !card.getController().getZone(Zone.Library).isEmpty()) {
|
||||
area.append("\r\nTop card: ");
|
||||
area.append(card.getController().getCardsIn(Zone.Library, 1));
|
||||
}
|
||||
|
||||
//chosen type
|
||||
// chosen type
|
||||
if (card.getChosenType() != "") {
|
||||
if (area.length() != 0) area.append("\n");
|
||||
if (area.length() != 0) {
|
||||
area.append("\n");
|
||||
}
|
||||
area.append("(chosen type: ");
|
||||
area.append(card.getChosenType());
|
||||
area.append(")");
|
||||
}
|
||||
|
||||
//chosen color
|
||||
// chosen color
|
||||
if (!card.getChosenColor().isEmpty()) {
|
||||
if (area.length() != 0) area.append("\n");
|
||||
if (area.length() != 0) {
|
||||
area.append("\n");
|
||||
}
|
||||
area.append("(chosen colors: ");
|
||||
area.append(card.getChosenColor());
|
||||
area.append(")");
|
||||
}
|
||||
|
||||
//named card
|
||||
// named card
|
||||
if (card.getNamedCard() != "") {
|
||||
if (area.length() != 0) area.append("\n");
|
||||
if (area.length() != 0) {
|
||||
area.append("\n");
|
||||
}
|
||||
area.append("(named card: ");
|
||||
area.append(card.getNamedCard());
|
||||
area.append(")");
|
||||
}
|
||||
|
||||
//equipping
|
||||
// equipping
|
||||
if (card.getEquipping().size() > 0) {
|
||||
if (area.length() != 0) area.append("\n");
|
||||
if (area.length() != 0) {
|
||||
area.append("\n");
|
||||
}
|
||||
area.append("=Equipping ");
|
||||
area.append(card.getEquipping().get(0));
|
||||
area.append("=");
|
||||
}
|
||||
|
||||
//equipped by
|
||||
// equipped by
|
||||
if (card.getEquippedBy().size() > 0) {
|
||||
if (area.length() != 0) area.append("\n");
|
||||
if (area.length() != 0) {
|
||||
area.append("\n");
|
||||
}
|
||||
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());
|
||||
if (it.hasNext()) area.append(", ");
|
||||
if (it.hasNext()) {
|
||||
area.append(", ");
|
||||
}
|
||||
}
|
||||
area.append("=");
|
||||
}
|
||||
|
||||
//enchanting
|
||||
// enchanting
|
||||
GameEntity entity = card.getEnchanting();
|
||||
if (entity != null){
|
||||
if (area.length() != 0) area.append("\n");
|
||||
if (entity != null) {
|
||||
if (area.length() != 0) {
|
||||
area.append("\n");
|
||||
}
|
||||
area.append("*Enchanting ");
|
||||
|
||||
if (entity instanceof Card){
|
||||
Card c = (Card)entity;
|
||||
if (c.isFaceDown() && c.getController().isComputer()){
|
||||
|
||||
if (entity instanceof Card) {
|
||||
Card c = (Card) entity;
|
||||
if (c.isFaceDown() && c.getController().isComputer()) {
|
||||
area.append("Morph (");
|
||||
area.append(card.getUniqueNumber());
|
||||
area.append(")");
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
area.append(entity);
|
||||
}
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
area.append(entity);
|
||||
}
|
||||
area.append("*");
|
||||
}
|
||||
|
||||
//enchanted by
|
||||
// enchanted by
|
||||
if (card.getEnchantedBy().size() > 0) {
|
||||
if (area.length() != 0) area.append("\n");
|
||||
if (area.length() != 0) {
|
||||
area.append("\n");
|
||||
}
|
||||
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());
|
||||
if (it.hasNext()) area.append(", ");
|
||||
if (it.hasNext()) {
|
||||
area.append(", ");
|
||||
}
|
||||
}
|
||||
area.append("*");
|
||||
}
|
||||
|
||||
//controlling
|
||||
// controlling
|
||||
if (card.getGainControlTargets().size() > 0) {
|
||||
if (area.length() != 0) area.append("\n");
|
||||
if (area.length() != 0) {
|
||||
area.append("\n");
|
||||
}
|
||||
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());
|
||||
if (it.hasNext()) area.append(", ");
|
||||
if (it.hasNext()) {
|
||||
area.append(", ");
|
||||
}
|
||||
}
|
||||
area.append("+");
|
||||
}
|
||||
|
||||
//cloned via
|
||||
// cloned via
|
||||
if (card.getCloneOrigin() != null) {
|
||||
if (area.length() != 0) area.append("\n");
|
||||
if (area.length() != 0) {
|
||||
area.append("\n");
|
||||
}
|
||||
area.append("^Cloned via: ");
|
||||
area.append(card.getCloneOrigin().getName());
|
||||
area.append("^");
|
||||
}
|
||||
|
||||
//Imprint
|
||||
// Imprint
|
||||
if (!card.getImprinted().isEmpty()) {
|
||||
if (area.length() != 0) area.append("\n");
|
||||
if (area.length() != 0) {
|
||||
area.append("\n");
|
||||
}
|
||||
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());
|
||||
if (it.hasNext()) area.append(", ");
|
||||
if (it.hasNext()) {
|
||||
area.append(", ");
|
||||
}
|
||||
}
|
||||
area.append("^");
|
||||
}
|
||||
|
||||
//uncastable
|
||||
// uncastable
|
||||
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.");
|
||||
}
|
||||
|
||||
//must block
|
||||
|
||||
// must block
|
||||
if (!card.getMustBlockCards().isEmpty()) {
|
||||
if (area.length() != 0) area.append("\n");
|
||||
if (area.length() != 0) {
|
||||
area.append("\n");
|
||||
}
|
||||
area.append("Must block an attacker");
|
||||
}
|
||||
|
||||
if (card.hasAttachedCardsByMindsDesire()) {
|
||||
if (area.length() != 0) area.append("\n");
|
||||
if (area.length() != 0) {
|
||||
area.append("\n");
|
||||
}
|
||||
Card[] cards = card.getAttachedCardsByMindsDesire();
|
||||
area.append("=Attached: ");
|
||||
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.
|
||||
*/
|
||||
public Card getCard() {
|
||||
public final Card getCard() {
|
||||
return card;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,43 +1,52 @@
|
||||
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.CardContainer;
|
||||
import forge.GuiDisplayUtil;
|
||||
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
|
||||
* @version $Id$
|
||||
*/
|
||||
public class CardPanel extends JPanel implements CardContainer {
|
||||
/** Constant <code>serialVersionUID=509877513760665415L</code> */
|
||||
/** Constant <code>serialVersionUID=509877513760665415L</code>. */
|
||||
private static final long serialVersionUID = 509877513760665415L;
|
||||
private Card card;
|
||||
|
||||
/**
|
||||
* <p>Constructor for CardPanel.</p>
|
||||
*
|
||||
* @param card a {@link forge.Card} object.
|
||||
* <p>
|
||||
* Constructor for CardPanel.
|
||||
* </p>
|
||||
*
|
||||
* @param card
|
||||
* a {@link forge.Card} object.
|
||||
*/
|
||||
public CardPanel(Card card) {
|
||||
public CardPanel(final Card card) {
|
||||
setCard(card);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>addComponents.</p>
|
||||
* <p>
|
||||
* addComponents.
|
||||
* </p>
|
||||
*/
|
||||
private void addComponents() {
|
||||
Card c = getCard();
|
||||
Image cardImage = ImageCache.getImage(c);
|
||||
if (cardImage == null) {
|
||||
//show the card as text
|
||||
// show the card as text
|
||||
setLayout(new GridLayout(0, 1));
|
||||
|
||||
add(new JLabel(c.isFaceDown() ? "Morph" : c.getName() + " " + c.getManaCost()));
|
||||
@@ -51,31 +60,36 @@ public class CardPanel extends JPanel implements CardContainer {
|
||||
add(tapLabel);
|
||||
}
|
||||
|
||||
if (c.isCreature()) add(new JLabel(c.getNetAttack() + " / " + c.getNetDefense()));
|
||||
if (c.isCreature()) {
|
||||
add(new JLabel(c.getNetAttack() + " / " + c.getNetDefense()));
|
||||
}
|
||||
} else {
|
||||
//show the card image
|
||||
// show the card image
|
||||
setLayout(new GridLayout(1, 1));
|
||||
add(new JLabel(new ImageIcon(cardImage)));
|
||||
}
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public void setCard(Card card) {
|
||||
public final void setCard(final Card card) {
|
||||
this.card = card;
|
||||
setBorder(GuiDisplayUtil.getBorder(card));
|
||||
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.
|
||||
*/
|
||||
public Card getCard() {
|
||||
public final Card getCard() {
|
||||
return card;
|
||||
}
|
||||
|
||||
//~
|
||||
// ~
|
||||
/** The connected card. */
|
||||
public CardPanel connectedCard;
|
||||
//~
|
||||
// ~
|
||||
}
|
||||
|
||||
@@ -6,6 +6,13 @@
|
||||
|
||||
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.MultipassType;
|
||||
@@ -16,39 +23,36 @@ import forge.ImageCache;
|
||||
import forge.item.CardPrinted;
|
||||
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
|
||||
* displayed instead.
|
||||
*
|
||||
* The class CardPicturePanel. Shows the full-sized image in a label. if there's
|
||||
* no picture, the cardname is displayed instead.
|
||||
*
|
||||
* @author Clemens Koza
|
||||
* @version V0.0 17.02.2010
|
||||
*/
|
||||
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 Card card;
|
||||
private InventoryItem inventoryItem;
|
||||
|
||||
// private JLabel label;
|
||||
// private ImageIcon icon;
|
||||
// private JLabel label;
|
||||
// private ImageIcon icon;
|
||||
private ScaledImagePanel panel;
|
||||
private Image currentImange;
|
||||
|
||||
/**
|
||||
* <p>Constructor for CardPicturePanel.</p>
|
||||
*
|
||||
* @param c a {@link forge.Card} object.
|
||||
* <p>
|
||||
* Constructor for CardPicturePanel.
|
||||
* </p>
|
||||
*
|
||||
* @param c
|
||||
* a {@link forge.Card} object.
|
||||
*/
|
||||
public CardPicturePanel(final Card c) {
|
||||
super(new BorderLayout());
|
||||
// add(label = new JLabel(icon = new ImageIcon()));
|
||||
// add(label = new JLabel(icon = new ImageIcon()));
|
||||
add(panel = new ScaledImagePanel());
|
||||
panel.setScalingBlur(false);
|
||||
panel.setScalingType(ScalingType.bicubic);
|
||||
@@ -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) {
|
||||
card = null;
|
||||
inventoryItem = cp;
|
||||
if (!isShowing()) { return; }
|
||||
if (!isShowing()) {
|
||||
return;
|
||||
}
|
||||
|
||||
setImage();
|
||||
}
|
||||
@@ -86,7 +102,9 @@ public final class CardPicturePanel extends JPanel implements CardContainer {
|
||||
public void setCard(final Card c) {
|
||||
card = c;
|
||||
inventoryItem = null;
|
||||
if (!isShowing()) { return; }
|
||||
if (!isShowing()) {
|
||||
return;
|
||||
}
|
||||
|
||||
setImage();
|
||||
}
|
||||
@@ -95,33 +113,37 @@ public final class CardPicturePanel extends JPanel implements CardContainer {
|
||||
Insets i = getInsets();
|
||||
Image image = 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) {
|
||||
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) {
|
||||
currentImange = image;
|
||||
panel.setImage(image, null);
|
||||
panel.repaint();
|
||||
}
|
||||
// if(image == null) {
|
||||
// label.setIcon(null);
|
||||
// //avoid a hard reference to the image while not needed
|
||||
// icon.setImage(null);
|
||||
// label.setText(card.isFaceDown()? "Morph":card.getName());
|
||||
// } else if(image != icon.getImage()) {
|
||||
// icon.setImage(image);
|
||||
// label.setIcon(icon);
|
||||
// }
|
||||
// if(image == null) {
|
||||
// label.setIcon(null);
|
||||
// //avoid a hard reference to the image while not needed
|
||||
// icon.setImage(null);
|
||||
// label.setText(card.isFaceDown()? "Morph":card.getName());
|
||||
// } else if(image != icon.getImage()) {
|
||||
// icon.setImage(image);
|
||||
// label.setIcon(icon);
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Getter for the field <code>card</code>.</p>
|
||||
*
|
||||
* <p>
|
||||
* Getter for the field <code>card</code>.
|
||||
* </p>
|
||||
*
|
||||
* @return a {@link forge.Card} object.
|
||||
*/
|
||||
public Card getCard() {
|
||||
if ( card == null && inventoryItem != null && inventoryItem instanceof CardPrinted ) {
|
||||
if (card == null && inventoryItem != null && inventoryItem instanceof CardPrinted) {
|
||||
card = ((CardPrinted) inventoryItem).toForgeCard();
|
||||
}
|
||||
return card;
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
/** Forge Card Game */
|
||||
/** Forge Card Game. */
|
||||
package forge.gui.game;
|
||||
|
||||
Reference in New Issue
Block a user