mirror of
https://github.com/magefree/mage.git
synced 2025-12-24 20:41:58 -08:00
[card.plugin] Displaying JXPanel in case there is no image.
This commit is contained in:
parent
502b21fddb
commit
3a0fd73854
4 changed files with 40 additions and 2 deletions
|
|
@ -34,15 +34,24 @@
|
|||
|
||||
package mage.client.cards;
|
||||
|
||||
import static mage.constants.Constants.CONTENT_MAX_XOFFSET;
|
||||
import static mage.constants.Constants.FRAME_MAX_HEIGHT;
|
||||
import static mage.constants.Constants.FRAME_MAX_WIDTH;
|
||||
import static mage.constants.Constants.TEXT_MAX_HEIGHT;
|
||||
import static mage.constants.Constants.TEXT_MAX_WIDTH;
|
||||
import static mage.constants.Constants.TEXT_MAX_YOFFSET;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Image;
|
||||
import java.awt.Rectangle;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.swing.text.BadLocationException;
|
||||
import javax.swing.text.StyledDocument;
|
||||
import static mage.constants.Constants.*;
|
||||
|
||||
import org.jdesktop.swingx.JXPanel;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -52,6 +61,7 @@ public class BigCard extends javax.swing.JPanel {
|
|||
|
||||
protected Image bigImage;
|
||||
protected UUID cardId;
|
||||
protected JXPanel panel;
|
||||
|
||||
public BigCard() {
|
||||
initComponents();
|
||||
|
|
@ -59,6 +69,7 @@ public class BigCard extends javax.swing.JPanel {
|
|||
|
||||
public void setCard(UUID cardId, Image image, List<String> strings) {
|
||||
if (this.cardId == null || !this.cardId.equals(cardId)) {
|
||||
if (this.panel != null) remove(this.panel);
|
||||
this.cardId = cardId;
|
||||
bigImage = image;
|
||||
this.repaint();
|
||||
|
|
@ -101,6 +112,16 @@ public class BigCard extends javax.swing.JPanel {
|
|||
this.scrollPane.setVisible(true);
|
||||
}
|
||||
|
||||
public void addJXPanel(UUID cardId, JXPanel jxPanel) {
|
||||
bigImage = null;
|
||||
synchronized (this) {
|
||||
if (this.panel != null) remove(this.panel);
|
||||
this.panel = jxPanel;
|
||||
add(jxPanel);
|
||||
}
|
||||
this.repaint();
|
||||
}
|
||||
|
||||
|
||||
/** This method is called from within the constructor to
|
||||
* initialize the form.
|
||||
|
|
|
|||
|
|
@ -10,6 +10,9 @@ import mage.cards.MagePermanent;
|
|||
import mage.client.cards.BigCard;
|
||||
import mage.client.plugins.impl.Plugins;
|
||||
import mage.client.util.ImageHelper;
|
||||
import mage.client.util.gui.GuiDisplayUtil;
|
||||
|
||||
import org.jdesktop.swingx.JXPanel;
|
||||
|
||||
public class MageMouseMotionAdapter extends MouseMotionAdapter {
|
||||
|
||||
|
|
@ -35,7 +38,12 @@ public class MageMouseMotionAdapter extends MouseMotionAdapter {
|
|||
bigCard.setCard(card.getOriginal().getId(), image, card.getOriginal().getRules());
|
||||
bigCard.hideTextComponent();
|
||||
} else {
|
||||
//TODO: add description panel
|
||||
if (card.getOriginal().getId() != bigCard.getCardId()) {
|
||||
JXPanel panel = GuiDisplayUtil.getDescription(card.getOriginal(), bigCard.getWidth(), bigCard.getHeight());
|
||||
panel.setVisible(true);
|
||||
bigCard.hideTextComponent();
|
||||
bigCard.addJXPanel(card.getOriginal().getId(), panel);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue