mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 11:18:01 +00:00
checkstyle
This commit is contained in:
@@ -1122,7 +1122,7 @@ public final class GuiDisplayUtil implements NewConstants {
|
|||||||
for (int i = connectedCards.size() - 1; i > 0; i--) {
|
for (int i = connectedCards.size() - 1; i > 0; i--) {
|
||||||
// System.out.println("We should have a stack");
|
// System.out.println("We should have a stack");
|
||||||
final CardPanel cp = connectedCards.get(i);
|
final CardPanel cp = connectedCards.get(i);
|
||||||
cp.connectedCard = connectedCards.get(i - 1);
|
cp.setConnectedCard(connectedCards.get(i - 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,17 +39,17 @@ 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);
|
||||||
|
|
||||||
private Card card;
|
private Card card;
|
||||||
|
|
||||||
private JLabel nameCostLabel;
|
private final JLabel nameCostLabel;
|
||||||
private JLabel typeLabel;
|
private final JLabel typeLabel;
|
||||||
private JLabel powerToughnessLabel;
|
private final JLabel powerToughnessLabel;
|
||||||
private JLabel damageLabel;
|
private final JLabel damageLabel;
|
||||||
private JLabel idLabel;
|
private final JLabel idLabel;
|
||||||
private JLabel setInfoLabel;
|
private final JLabel setInfoLabel;
|
||||||
private JTextArea cdArea;
|
private final JTextArea cdArea;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@@ -60,141 +60,150 @@ public class CardDetailPanel extends JPanel implements CardContainer {
|
|||||||
* a {@link forge.Card} object.
|
* a {@link forge.Card} object.
|
||||||
*/
|
*/
|
||||||
public CardDetailPanel(final Card card) {
|
public CardDetailPanel(final Card card) {
|
||||||
setLayout(new GridLayout(2, 0, 0, 5));
|
this.setLayout(new GridLayout(2, 0, 0, 5));
|
||||||
setBorder(new EtchedBorder());
|
this.setBorder(new EtchedBorder());
|
||||||
|
|
||||||
JPanel cdLabels = new JPanel(new GridLayout(0, 1, 0, 5));
|
final JPanel cdLabels = new JPanel(new GridLayout(0, 1, 0, 5));
|
||||||
cdLabels.add(nameCostLabel = new JLabel());
|
this.nameCostLabel = new JLabel();
|
||||||
cdLabels.add(typeLabel = new JLabel());
|
this.typeLabel = new JLabel();
|
||||||
cdLabels.add(powerToughnessLabel = new JLabel());
|
this.powerToughnessLabel = new JLabel();
|
||||||
cdLabels.add(damageLabel = new JLabel());
|
this.damageLabel = new JLabel();
|
||||||
|
cdLabels.add(this.nameCostLabel);
|
||||||
|
cdLabels.add(this.typeLabel);
|
||||||
|
cdLabels.add(this.powerToughnessLabel);
|
||||||
|
cdLabels.add(this.damageLabel);
|
||||||
|
|
||||||
JPanel IDR = new JPanel(new GridBagLayout());
|
final JPanel idr = new JPanel(new GridBagLayout());
|
||||||
GridBagConstraints c = new GridBagConstraints();
|
final GridBagConstraints c = new GridBagConstraints();
|
||||||
|
|
||||||
c.fill = GridBagConstraints.HORIZONTAL;
|
c.fill = GridBagConstraints.HORIZONTAL;
|
||||||
|
|
||||||
c.gridwidth = 2;
|
c.gridwidth = 2;
|
||||||
c.weightx = 1.0;
|
c.weightx = 1.0;
|
||||||
IDR.add(idLabel = new JLabel(), c);
|
this.idLabel = new JLabel();
|
||||||
|
idr.add(this.idLabel, c);
|
||||||
|
|
||||||
c.gridwidth = 1;
|
c.gridwidth = 1;
|
||||||
c.weightx = 0.3;
|
c.weightx = 0.3;
|
||||||
IDR.add(setInfoLabel = new JLabel(), c);
|
this.setInfoLabel = new JLabel();
|
||||||
|
idr.add(this.setInfoLabel, c);
|
||||||
|
|
||||||
cdLabels.add(IDR);
|
cdLabels.add(idr);
|
||||||
|
|
||||||
add(cdLabels);
|
this.add(cdLabels);
|
||||||
nameCostLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
this.nameCostLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
||||||
typeLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
this.typeLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
||||||
powerToughnessLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
this.powerToughnessLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
||||||
// cdLabel7.setSize(100, cdLabel7.getHeight());
|
// cdLabel7.setSize(100, cdLabel7.getHeight());
|
||||||
|
|
||||||
setInfoLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
this.setInfoLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
||||||
|
|
||||||
add(new JScrollPane(cdArea = new JTextArea(4, 12)));
|
this.cdArea = new JTextArea(4, 12);
|
||||||
cdArea.setLineWrap(true);
|
this.add(new JScrollPane(this.cdArea));
|
||||||
cdArea.setWrapStyleWord(true);
|
this.cdArea.setLineWrap(true);
|
||||||
|
this.cdArea.setWrapStyleWord(true);
|
||||||
|
|
||||||
if (!Singletons.getModel().getPreferences().lafFonts) {
|
if (!Singletons.getModel().getPreferences().lafFonts) {
|
||||||
nameCostLabel.setFont(new java.awt.Font("Dialog", 0, 14));
|
this.nameCostLabel.setFont(new java.awt.Font("Dialog", 0, 14));
|
||||||
typeLabel.setFont(new java.awt.Font("Dialog", 0, 14));
|
this.typeLabel.setFont(new java.awt.Font("Dialog", 0, 14));
|
||||||
powerToughnessLabel.setFont(new java.awt.Font("Dialog", 0, 14));
|
this.powerToughnessLabel.setFont(new java.awt.Font("Dialog", 0, 14));
|
||||||
damageLabel.setFont(new java.awt.Font("Dialog", 0, 14));
|
this.damageLabel.setFont(new java.awt.Font("Dialog", 0, 14));
|
||||||
idLabel.setFont(new java.awt.Font("Dialog", 0, 14));
|
this.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);
|
this.setInfoLabel.setFont(f);
|
||||||
|
|
||||||
cdArea.setFont(new java.awt.Font("Dialog", 0, 14));
|
this.cdArea.setFont(new java.awt.Font("Dialog", 0, 14));
|
||||||
}
|
}
|
||||||
|
|
||||||
setCard(card);
|
this.setCard(card);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
|
@Override
|
||||||
public final void setCard(final Card card) {
|
public final void setCard(final Card card) {
|
||||||
nameCostLabel.setText("");
|
this.nameCostLabel.setText("");
|
||||||
typeLabel.setText("");
|
this.typeLabel.setText("");
|
||||||
powerToughnessLabel.setText("");
|
this.powerToughnessLabel.setText("");
|
||||||
damageLabel.setText("");
|
this.damageLabel.setText("");
|
||||||
idLabel.setText("");
|
this.idLabel.setText("");
|
||||||
setInfoLabel.setText("");
|
this.setInfoLabel.setText("");
|
||||||
setInfoLabel.setOpaque(false);
|
this.setInfoLabel.setOpaque(false);
|
||||||
setInfoLabel.setBorder(null);
|
this.setInfoLabel.setBorder(null);
|
||||||
cdArea.setText("");
|
this.cdArea.setText("");
|
||||||
setBorder(GuiDisplayUtil.getBorder(card));
|
this.setBorder(GuiDisplayUtil.getBorder(card));
|
||||||
|
|
||||||
this.card = card;
|
this.card = card;
|
||||||
if (card == null) {
|
if (card == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean faceDown = card.isFaceDown() && card.getController() != AllZone.getHumanPlayer();
|
final boolean faceDown = card.isFaceDown() && (card.getController() != AllZone.getHumanPlayer());
|
||||||
if (!faceDown) {
|
if (!faceDown) {
|
||||||
if (card.getManaCost().equals("") || card.isLand()) {
|
if (card.getManaCost().equals("") || card.isLand()) {
|
||||||
nameCostLabel.setText(card.getName());
|
this.nameCostLabel.setText(card.getName());
|
||||||
} else {
|
} else {
|
||||||
nameCostLabel.setText(card.getName() + " - " + card.getManaCost());
|
this.nameCostLabel.setText(card.getName() + " - " + card.getManaCost());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
nameCostLabel.setText("Morph");
|
this.nameCostLabel.setText("Morph");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!faceDown) {
|
if (!faceDown) {
|
||||||
typeLabel.setText(GuiDisplayUtil.formatCardType(card));
|
this.typeLabel.setText(GuiDisplayUtil.formatCardType(card));
|
||||||
} else {
|
} else {
|
||||||
typeLabel.setText("Creature");
|
this.typeLabel.setText("Creature");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (card.isCreature()) {
|
if (card.isCreature()) {
|
||||||
powerToughnessLabel.setText(card.getNetAttack() + " / " + card.getNetDefense());
|
this.powerToughnessLabel.setText(card.getNetAttack() + " / " + card.getNetDefense());
|
||||||
damageLabel.setText("Damage: " + card.getDamage() + " Assigned Damage: " + card.getTotalAssignedDamage());
|
this.damageLabel.setText("Damage: " + card.getDamage() + " Assigned Damage: "
|
||||||
|
+ card.getTotalAssignedDamage());
|
||||||
}
|
}
|
||||||
if (card.isPlaneswalker()) {
|
if (card.isPlaneswalker()) {
|
||||||
damageLabel.setText("Assigned Damage: " + card.getTotalAssignedDamage());
|
this.damageLabel.setText("Assigned Damage: " + card.getTotalAssignedDamage());
|
||||||
}
|
}
|
||||||
|
|
||||||
idLabel.setText("Card ID " + card.getUniqueNumber());
|
this.idLabel.setText("Card ID " + card.getUniqueNumber());
|
||||||
|
|
||||||
// rarity and set of a face down card should not be visible to the
|
// rarity and set of a face down card should not be visible to the
|
||||||
// opponent
|
// opponent
|
||||||
if (!card.isFaceDown() || card.getController().isHuman()) {
|
if (!card.isFaceDown() || card.getController().isHuman()) {
|
||||||
setInfoLabel.setText(card.getCurSetCode());
|
this.setInfoLabel.setText(card.getCurSetCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!setInfoLabel.getText().equals("")) {
|
if (!this.setInfoLabel.getText().equals("")) {
|
||||||
setInfoLabel.setOpaque(true);
|
this.setInfoLabel.setOpaque(true);
|
||||||
String csr = card.getCurSetRarity();
|
final String csr = card.getCurSetRarity();
|
||||||
if (csr.equals("Common") || csr.equals("Land")) {
|
if (csr.equals("Common") || csr.equals("Land")) {
|
||||||
setInfoLabel.setBackground(Color.BLACK);
|
this.setInfoLabel.setBackground(Color.BLACK);
|
||||||
setInfoLabel.setForeground(Color.WHITE);
|
this.setInfoLabel.setForeground(Color.WHITE);
|
||||||
setInfoLabel.setBorder(BorderFactory.createLineBorder(Color.WHITE));
|
this.setInfoLabel.setBorder(BorderFactory.createLineBorder(Color.WHITE));
|
||||||
} else if (csr.equals("Uncommon")) {
|
} else if (csr.equals("Uncommon")) {
|
||||||
setInfoLabel.setBackground(Color.LIGHT_GRAY);
|
this.setInfoLabel.setBackground(Color.LIGHT_GRAY);
|
||||||
setInfoLabel.setForeground(Color.BLACK);
|
this.setInfoLabel.setForeground(Color.BLACK);
|
||||||
setInfoLabel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
|
this.setInfoLabel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
|
||||||
} else if (csr.equals("Rare")) {
|
} else if (csr.equals("Rare")) {
|
||||||
setInfoLabel.setBackground(Color.YELLOW);
|
this.setInfoLabel.setBackground(Color.YELLOW);
|
||||||
setInfoLabel.setForeground(Color.BLACK);
|
this.setInfoLabel.setForeground(Color.BLACK);
|
||||||
setInfoLabel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
|
this.setInfoLabel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
|
||||||
} else if (csr.equals("Mythic")) {
|
} else if (csr.equals("Mythic")) {
|
||||||
setInfoLabel.setBackground(Color.RED);
|
this.setInfoLabel.setBackground(Color.RED);
|
||||||
setInfoLabel.setForeground(Color.BLACK);
|
this.setInfoLabel.setForeground(Color.BLACK);
|
||||||
setInfoLabel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
|
this.setInfoLabel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
|
||||||
} else if (csr.equals("Special")) {
|
} else if (csr.equals("Special")) {
|
||||||
// "Timeshifted" or other Special Rarity Cards
|
// "Timeshifted" or other Special Rarity Cards
|
||||||
setInfoLabel.setBackground(PURPLE);
|
this.setInfoLabel.setBackground(CardDetailPanel.purple);
|
||||||
setInfoLabel.setForeground(Color.BLACK);
|
this.setInfoLabel.setForeground(Color.BLACK);
|
||||||
setInfoLabel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
|
this.setInfoLabel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
|
||||||
}
|
}
|
||||||
// cdLabel7.setText(card.getCurSetCode());
|
// cdLabel7.setText(card.getCurSetCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
// fill the card text
|
// fill the card text
|
||||||
|
|
||||||
StringBuilder area = new StringBuilder();
|
final StringBuilder area = new StringBuilder();
|
||||||
|
|
||||||
// Token
|
// Token
|
||||||
if (card.isToken()) {
|
if (card.isToken()) {
|
||||||
@@ -231,8 +240,8 @@ public class CardDetailPanel extends JPanel implements CardContainer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// counter text
|
// counter text
|
||||||
Counters[] counters = Counters.values();
|
final Counters[] counters = Counters.values();
|
||||||
for (Counters counter : counters) {
|
for (final Counters counter : counters) {
|
||||||
if (card.getCounters(counter) != 0) {
|
if (card.getCounters(counter) != 0) {
|
||||||
if (area.length() != 0) {
|
if (area.length() != 0) {
|
||||||
area.append("\n");
|
area.append("\n");
|
||||||
@@ -243,7 +252,7 @@ public class CardDetailPanel extends JPanel implements CardContainer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Regeneration Shields
|
// Regeneration Shields
|
||||||
int regenShields = card.getShield();
|
final int regenShields = card.getShield();
|
||||||
if (regenShields > 0) {
|
if (regenShields > 0) {
|
||||||
if (area.length() != 0) {
|
if (area.length() != 0) {
|
||||||
area.append("\n");
|
area.append("\n");
|
||||||
@@ -252,7 +261,7 @@ public class CardDetailPanel extends JPanel implements CardContainer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Damage Prevention
|
// Damage Prevention
|
||||||
int preventNextDamage = card.getPreventNextDamage();
|
final int preventNextDamage = card.getPreventNextDamage();
|
||||||
if (preventNextDamage > 0) {
|
if (preventNextDamage > 0) {
|
||||||
area.append("\n");
|
area.append("\n");
|
||||||
area.append("Prevent the next ").append(preventNextDamage).append(" damage that would be dealt to ");
|
area.append("Prevent the next ").append(preventNextDamage).append(" damage that would be dealt to ");
|
||||||
@@ -260,7 +269,7 @@ public class CardDetailPanel extends JPanel implements CardContainer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// top revealed
|
// top revealed
|
||||||
if (card.hasKeyword("Play with the top card of your library revealed.") && card.getController() != null
|
if (card.hasKeyword("Play with the top card of your library revealed.") && (card.getController() != null)
|
||||||
&& !card.getController().getZone(Zone.Library).isEmpty()) {
|
&& !card.getController().getZone(Zone.Library).isEmpty()) {
|
||||||
area.append("\r\nTop card: ");
|
area.append("\r\nTop card: ");
|
||||||
area.append(card.getController().getCardsIn(Zone.Library, 1));
|
area.append(card.getController().getCardsIn(Zone.Library, 1));
|
||||||
@@ -312,7 +321,7 @@ public class CardDetailPanel extends JPanel implements CardContainer {
|
|||||||
area.append("\n");
|
area.append("\n");
|
||||||
}
|
}
|
||||||
area.append("=Equipped by ");
|
area.append("=Equipped by ");
|
||||||
for (Iterator<Card> it = card.getEquippedBy().iterator(); it.hasNext();) {
|
for (final Iterator<Card> it = card.getEquippedBy().iterator(); it.hasNext();) {
|
||||||
area.append(it.next());
|
area.append(it.next());
|
||||||
if (it.hasNext()) {
|
if (it.hasNext()) {
|
||||||
area.append(", ");
|
area.append(", ");
|
||||||
@@ -322,7 +331,7 @@ public class CardDetailPanel extends JPanel implements CardContainer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// enchanting
|
// enchanting
|
||||||
GameEntity entity = card.getEnchanting();
|
final GameEntity entity = card.getEnchanting();
|
||||||
if (entity != null) {
|
if (entity != null) {
|
||||||
if (area.length() != 0) {
|
if (area.length() != 0) {
|
||||||
area.append("\n");
|
area.append("\n");
|
||||||
@@ -330,7 +339,7 @@ public class CardDetailPanel extends JPanel implements CardContainer {
|
|||||||
area.append("*Enchanting ");
|
area.append("*Enchanting ");
|
||||||
|
|
||||||
if (entity instanceof Card) {
|
if (entity instanceof Card) {
|
||||||
Card c = (Card) entity;
|
final Card c = (Card) entity;
|
||||||
if (c.isFaceDown() && c.getController().isComputer()) {
|
if (c.isFaceDown() && c.getController().isComputer()) {
|
||||||
area.append("Morph (");
|
area.append("Morph (");
|
||||||
area.append(card.getUniqueNumber());
|
area.append(card.getUniqueNumber());
|
||||||
@@ -350,7 +359,7 @@ public class CardDetailPanel extends JPanel implements CardContainer {
|
|||||||
area.append("\n");
|
area.append("\n");
|
||||||
}
|
}
|
||||||
area.append("*Enchanted by ");
|
area.append("*Enchanted by ");
|
||||||
for (Iterator<Card> it = card.getEnchantedBy().iterator(); it.hasNext();) {
|
for (final Iterator<Card> it = card.getEnchantedBy().iterator(); it.hasNext();) {
|
||||||
area.append(it.next());
|
area.append(it.next());
|
||||||
if (it.hasNext()) {
|
if (it.hasNext()) {
|
||||||
area.append(", ");
|
area.append(", ");
|
||||||
@@ -365,7 +374,7 @@ public class CardDetailPanel extends JPanel implements CardContainer {
|
|||||||
area.append("\n");
|
area.append("\n");
|
||||||
}
|
}
|
||||||
area.append("+Controlling: ");
|
area.append("+Controlling: ");
|
||||||
for (Iterator<Card> it = card.getGainControlTargets().iterator(); it.hasNext();) {
|
for (final Iterator<Card> it = card.getGainControlTargets().iterator(); it.hasNext();) {
|
||||||
area.append(it.next());
|
area.append(it.next());
|
||||||
if (it.hasNext()) {
|
if (it.hasNext()) {
|
||||||
area.append(", ");
|
area.append(", ");
|
||||||
@@ -390,7 +399,7 @@ public class CardDetailPanel extends JPanel implements CardContainer {
|
|||||||
area.append("\n");
|
area.append("\n");
|
||||||
}
|
}
|
||||||
area.append("^Imprinting: ");
|
area.append("^Imprinting: ");
|
||||||
for (Iterator<Card> it = card.getImprinted().iterator(); it.hasNext();) {
|
for (final Iterator<Card> it = card.getImprinted().iterator(); it.hasNext();) {
|
||||||
area.append(it.next());
|
area.append(it.next());
|
||||||
if (it.hasNext()) {
|
if (it.hasNext()) {
|
||||||
area.append(", ");
|
area.append(", ");
|
||||||
@@ -419,16 +428,16 @@ public class CardDetailPanel extends JPanel implements CardContainer {
|
|||||||
if (area.length() != 0) {
|
if (area.length() != 0) {
|
||||||
area.append("\n");
|
area.append("\n");
|
||||||
}
|
}
|
||||||
Card[] cards = card.getAttachedCardsByMindsDesire();
|
final Card[] cards = card.getAttachedCardsByMindsDesire();
|
||||||
area.append("=Attached: ");
|
area.append("=Attached: ");
|
||||||
for (Card c : cards) {
|
for (final Card c : cards) {
|
||||||
area.append(c.getName());
|
area.append(c.getName());
|
||||||
area.append(" ");
|
area.append(" ");
|
||||||
}
|
}
|
||||||
area.append("=");
|
area.append("=");
|
||||||
}
|
}
|
||||||
|
|
||||||
cdArea.setText(area.toString());
|
this.cdArea.setText(area.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -438,7 +447,8 @@ public class CardDetailPanel extends JPanel implements CardContainer {
|
|||||||
*
|
*
|
||||||
* @return a {@link forge.Card} object.
|
* @return a {@link forge.Card} object.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public final Card getCard() {
|
public final Card getCard() {
|
||||||
return card;
|
return this.card;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ public class CardPanel extends JPanel implements CardContainer {
|
|||||||
* a {@link forge.Card} object.
|
* a {@link forge.Card} object.
|
||||||
*/
|
*/
|
||||||
public CardPanel(final Card card) {
|
public CardPanel(final Card card) {
|
||||||
setCard(card);
|
this.setCard(card);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -43,38 +43,39 @@ public class CardPanel extends JPanel implements CardContainer {
|
|||||||
* </p>
|
* </p>
|
||||||
*/
|
*/
|
||||||
private void addComponents() {
|
private void addComponents() {
|
||||||
Card c = getCard();
|
final Card c = this.getCard();
|
||||||
Image cardImage = ImageCache.getImage(c);
|
final Image cardImage = ImageCache.getImage(c);
|
||||||
if (cardImage == null) {
|
if (cardImage == null) {
|
||||||
// show the card as text
|
// show the card as text
|
||||||
setLayout(new GridLayout(0, 1));
|
this.setLayout(new GridLayout(0, 1));
|
||||||
|
|
||||||
add(new JLabel(c.isFaceDown() ? "Morph" : c.getName() + " " + c.getManaCost()));
|
this.add(new JLabel(c.isFaceDown() ? "Morph" : c.getName() + " " + c.getManaCost()));
|
||||||
add(new JLabel(GuiDisplayUtil.formatCardType(c)));
|
this.add(new JLabel(GuiDisplayUtil.formatCardType(c)));
|
||||||
|
|
||||||
JLabel tapLabel = new JLabel("Tapped");
|
final JLabel tapLabel = new JLabel("Tapped");
|
||||||
tapLabel.setBackground(Color.white);
|
tapLabel.setBackground(Color.white);
|
||||||
tapLabel.setOpaque(true);
|
tapLabel.setOpaque(true);
|
||||||
|
|
||||||
if (c.isTapped()) {
|
if (c.isTapped()) {
|
||||||
add(tapLabel);
|
this.add(tapLabel);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (c.isCreature()) {
|
if (c.isCreature()) {
|
||||||
add(new JLabel(c.getNetAttack() + " / " + c.getNetDefense()));
|
this.add(new JLabel(c.getNetAttack() + " / " + c.getNetDefense()));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// show the card image
|
// show the card image
|
||||||
setLayout(new GridLayout(1, 1));
|
this.setLayout(new GridLayout(1, 1));
|
||||||
add(new JLabel(new ImageIcon(cardImage)));
|
this.add(new JLabel(new ImageIcon(cardImage)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
|
@Override
|
||||||
public final void setCard(final Card card) {
|
public final void setCard(final Card card) {
|
||||||
this.card = card;
|
this.card = card;
|
||||||
setBorder(GuiDisplayUtil.getBorder(card));
|
this.setBorder(GuiDisplayUtil.getBorder(card));
|
||||||
addComponents();
|
this.addComponents();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -84,12 +85,28 @@ public class CardPanel extends JPanel implements CardContainer {
|
|||||||
*
|
*
|
||||||
* @return a {@link forge.Card} object.
|
* @return a {@link forge.Card} object.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public final Card getCard() {
|
public final Card getCard() {
|
||||||
return card;
|
return this.card;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the connectedCard
|
||||||
|
*/
|
||||||
|
public CardPanel getConnectedCard() {
|
||||||
|
return connectedCard;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param connectedCard
|
||||||
|
* the connectedCard to set
|
||||||
|
*/
|
||||||
|
public void setConnectedCard(CardPanel connectedCard) {
|
||||||
|
this.connectedCard = connectedCard; // TODO: Add 0 to parameter's name.
|
||||||
}
|
}
|
||||||
|
|
||||||
// ~
|
// ~
|
||||||
/** The connected card. */
|
/** The connected card. */
|
||||||
public CardPanel connectedCard;
|
private CardPanel connectedCard;
|
||||||
// ~
|
// ~
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,24 +53,25 @@ public final class CardPicturePanel extends JPanel implements CardContainer {
|
|||||||
public CardPicturePanel(final Card c) {
|
public CardPicturePanel(final Card c) {
|
||||||
super(new BorderLayout());
|
super(new BorderLayout());
|
||||||
// add(label = new JLabel(icon = new ImageIcon()));
|
// add(label = new JLabel(icon = new ImageIcon()));
|
||||||
add(panel = new ScaledImagePanel());
|
this.panel = new ScaledImagePanel();
|
||||||
panel.setScalingBlur(false);
|
this.add(this.panel);
|
||||||
panel.setScalingType(ScalingType.bicubic);
|
this.panel.setScalingBlur(false);
|
||||||
panel.setScalingMultiPassType(MultipassType.none);
|
this.panel.setScalingType(ScalingType.bicubic);
|
||||||
|
this.panel.setScalingMultiPassType(MultipassType.none);
|
||||||
|
|
||||||
addComponentListener(new ComponentAdapter() {
|
this.addComponentListener(new ComponentAdapter() {
|
||||||
@Override
|
@Override
|
||||||
public void componentShown(final ComponentEvent e) {
|
public void componentShown(final ComponentEvent e) {
|
||||||
update();
|
CardPicturePanel.this.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void componentResized(final ComponentEvent e) {
|
public void componentResized(final ComponentEvent e) {
|
||||||
update();
|
CardPicturePanel.this.update();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
setCard(c);
|
this.setCard(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -79,7 +80,7 @@ public final class CardPicturePanel extends JPanel implements CardContainer {
|
|||||||
* </p>
|
* </p>
|
||||||
*/
|
*/
|
||||||
public void update() {
|
public void update() {
|
||||||
setCard(getCard());
|
this.setCard(this.getCard());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -89,40 +90,43 @@ public final class CardPicturePanel extends JPanel implements CardContainer {
|
|||||||
* the new card
|
* the new card
|
||||||
*/
|
*/
|
||||||
public void setCard(final InventoryItem cp) {
|
public void setCard(final InventoryItem cp) {
|
||||||
card = null;
|
this.card = null;
|
||||||
inventoryItem = cp;
|
this.inventoryItem = cp;
|
||||||
if (!isShowing()) {
|
if (!this.isShowing()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
setImage();
|
this.setImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
|
@Override
|
||||||
public void setCard(final Card c) {
|
public void setCard(final Card c) {
|
||||||
card = c;
|
this.card = c;
|
||||||
inventoryItem = null;
|
this.inventoryItem = null;
|
||||||
if (!isShowing()) {
|
if (!this.isShowing()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
setImage();
|
this.setImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setImage() {
|
private void setImage() {
|
||||||
Insets i = getInsets();
|
final Insets i = this.getInsets();
|
||||||
Image image = null;
|
Image image = null;
|
||||||
if (inventoryItem != null) {
|
if (this.inventoryItem != null) {
|
||||||
image = ImageCache.getImage(inventoryItem, getWidth() - i.left - i.right, getHeight() - i.top - i.bottom);
|
image = ImageCache.getImage(this.inventoryItem, this.getWidth() - i.left - i.right, this.getHeight()
|
||||||
|
- i.top - i.bottom);
|
||||||
}
|
}
|
||||||
if (card != null && image == null) {
|
if ((this.card != null) && (image == null)) {
|
||||||
image = ImageCache.getImage(card, getWidth() - i.left - i.right, getHeight() - i.top - i.bottom);
|
image = ImageCache.getImage(this.card, this.getWidth() - i.left - i.right, this.getHeight() - i.top
|
||||||
|
- i.bottom);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (image != currentImange) {
|
if (image != this.currentImange) {
|
||||||
currentImange = image;
|
this.currentImange = image;
|
||||||
panel.setImage(image, null);
|
this.panel.setImage(image, null);
|
||||||
panel.repaint();
|
this.panel.repaint();
|
||||||
}
|
}
|
||||||
// if(image == null) {
|
// if(image == null) {
|
||||||
// label.setIcon(null);
|
// label.setIcon(null);
|
||||||
@@ -142,10 +146,11 @@ public final class CardPicturePanel extends JPanel implements CardContainer {
|
|||||||
*
|
*
|
||||||
* @return a {@link forge.Card} object.
|
* @return a {@link forge.Card} object.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public Card getCard() {
|
public Card getCard() {
|
||||||
if (card == null && inventoryItem != null && inventoryItem instanceof CardPrinted) {
|
if ((this.card == null) && (this.inventoryItem != null) && (this.inventoryItem instanceof CardPrinted)) {
|
||||||
card = ((CardPrinted) inventoryItem).toForgeCard();
|
this.card = ((CardPrinted) this.inventoryItem).toForgeCard();
|
||||||
}
|
}
|
||||||
return card;
|
return this.card;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,2 +1,3 @@
|
|||||||
/** Forge Card Game. */
|
/** Forge Card Game. */
|
||||||
package forge.gui.game;
|
package forge.gui.game;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user