diff --git a/Mage.Client/plugins/mage-card-plugin.jar b/Mage.Client/plugins/mage-card-plugin.jar index 9c662a1e05..6e2643fe0f 100644 Binary files a/Mage.Client/plugins/mage-card-plugin.jar and b/Mage.Client/plugins/mage-card-plugin.jar differ diff --git a/Mage.Client/src/main/java/mage/client/MageFrame.java b/Mage.Client/src/main/java/mage/client/MageFrame.java index 91c5bb73ed..bf4a607f9b 100644 --- a/Mage.Client/src/main/java/mage/client/MageFrame.java +++ b/Mage.Client/src/main/java/mage/client/MageFrame.java @@ -34,26 +34,6 @@ package mage.client; -import java.awt.*; -import java.awt.event.ComponentAdapter; -import java.awt.event.ComponentEvent; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -import java.awt.image.BufferedImage; -import java.io.IOException; -import java.io.InputStream; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; -import java.util.logging.Level; -import java.util.logging.Logger; -import java.util.prefs.Preferences; - -import javax.imageio.ImageIO; -import javax.swing.*; -import javax.swing.JToolBar.Separator; - -import com.sun.java.swing.Painter; import mage.cards.decks.Deck; import mage.client.cards.CardsStorage; import mage.client.components.MageComponents; @@ -69,151 +49,168 @@ import mage.client.util.gui.ArrowBuilder; import mage.components.ImagePanel; import mage.util.Logging; +import javax.imageio.ImageIO; +import javax.swing.*; +import javax.swing.JToolBar.Separator; +import java.awt.*; +import java.awt.event.ComponentAdapter; +import java.awt.event.ComponentEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.awt.image.BufferedImage; +import java.io.IOException; +import java.io.InputStream; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; +import java.util.logging.Level; +import java.util.logging.Logger; +import java.util.prefs.Preferences; + /** - * * @author BetaSteward_at_googlemail.com */ public class MageFrame extends javax.swing.JFrame { - private final static Logger logger = Logging.getLogger(MageFrame.class.getName()); + private final static Logger logger = Logging.getLogger(MageFrame.class.getName()); - private static Session session; - private ConnectDialog connectDialog; - private static CombatDialog combat; - private static PickNumberDialog pickNumber; - private static Preferences prefs = Preferences.userNodeForPackage(MageFrame.class); - private JLabel title; - private Rectangle titleRectangle; - - /** - * @return the session - */ - public static Session getSession() { - return session; - } + private static Session session; + private ConnectDialog connectDialog; + private static CombatDialog combat; + private static PickNumberDialog pickNumber; + private static Preferences prefs = Preferences.userNodeForPackage(MageFrame.class); + private JLabel title; + private Rectangle titleRectangle; - public static JDesktopPane getDesktop() { - return desktopPane; - } + /** + * @return the session + */ + public static Session getSession() { + return session; + } - public static Preferences getPreferences() { - return prefs; - } + public static JDesktopPane getDesktop() { + return desktopPane; + } - /** Creates new form MageFrame */ + public static Preferences getPreferences() { + return prefs; + } + + /** + * Creates new form MageFrame + */ public MageFrame() { - setTitle("Mage, version 0.5.1"); - - EDTExceptionHandler.registerExceptionHandler(); - addWindowListener(new WindowAdapter() - { - @Override - public void windowClosing(WindowEvent e) - { - exitApp(); - } - }); + setTitle("Mage, version 0.5.1"); - try { - UIManager.put("desktop", new Color(0,0,0,0)); + EDTExceptionHandler.registerExceptionHandler(); + addWindowListener(new WindowAdapter() { + @Override + public void windowClosing(WindowEvent e) { + exitApp(); + } + }); + + try { + UIManager.put("desktop", new Color(0, 0, 0, 0)); UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel"); - //MageSynthStyleFactory f = new MageSynthStyleFactory(SynthLookAndFeel.getStyleFactory()); - //SynthLookAndFeel.setStyleFactory(f); - } catch (Exception ex) { - logger.log(Level.SEVERE, null, ex); - } + //MageSynthStyleFactory f = new MageSynthStyleFactory(SynthLookAndFeel.getStyleFactory()); + //SynthLookAndFeel.setStyleFactory(f); + } catch (Exception ex) { + logger.log(Level.SEVERE, null, ex); + } - Plugins.getInstance().loadPlugins(); + Plugins.getInstance().loadPlugins(); - initComponents(); - setSize(1024,768); - this.setExtendedState(JFrame.MAXIMIZED_BOTH); + initComponents(); + setSize(1024, 768); + this.setExtendedState(JFrame.MAXIMIZED_BOTH); - session = new Session(this); - connectDialog = new ConnectDialog(); - combat = new CombatDialog(); - pickNumber = new PickNumberDialog(); - desktopPane.add(connectDialog, JLayeredPane.POPUP_LAYER); - desktopPane.add(combat, JLayeredPane.POPUP_LAYER); - combat.hideDialog(); - desktopPane.add(pickNumber, JLayeredPane.POPUP_LAYER); - session.getUI().addComponent(MageComponents.DESKTOP_PANE, desktopPane); + session = new Session(this); + connectDialog = new ConnectDialog(); + combat = new CombatDialog(); + pickNumber = new PickNumberDialog(); + desktopPane.add(connectDialog, JLayeredPane.POPUP_LAYER); + desktopPane.add(combat, JLayeredPane.POPUP_LAYER); + combat.hideDialog(); + desktopPane.add(pickNumber, JLayeredPane.POPUP_LAYER); + session.getUI().addComponent(MageComponents.DESKTOP_PANE, desktopPane); ManaSymbols.loadImages(); addTooltipContainer(); setBackground(); - addMageLabel(); - setAppIcon(); + addMageLabel(); + setAppIcon(); - desktopPane.add(ArrowBuilder.getArrowsPanel(), JLayeredPane.DRAG_LAYER); - - desktopPane.addComponentListener(new ComponentAdapter(){ - @Override - public void componentResized(ComponentEvent e) { - int width = ((JComponent)e.getSource()).getWidth(); - int height = ((JComponent)e.getSource()).getHeight(); - backgroundPane.setSize(width, height); - JPanel arrowsPanel = ArrowBuilder.getArrowsPanelRef(); - if (arrowsPanel != null) arrowsPanel.setSize(width, height); - if (title != null) { - //title.setBorder(BorderFactory.createLineBorder(Color.red)); - title.setBounds((int)(width - titleRectangle.getWidth())/2, (int)(height - titleRectangle.getHeight())/2, titleRectangle.width, titleRectangle.height); - } - } + desktopPane.add(ArrowBuilder.getArrowsPanel(), JLayeredPane.DRAG_LAYER); + + desktopPane.addComponentListener(new ComponentAdapter() { + @Override + public void componentResized(ComponentEvent e) { + int width = ((JComponent) e.getSource()).getWidth(); + int height = ((JComponent) e.getSource()).getHeight(); + backgroundPane.setSize(width, height); + JPanel arrowsPanel = ArrowBuilder.getArrowsPanelRef(); + if (arrowsPanel != null) arrowsPanel.setSize(width, height); + if (title != null) { + //title.setBorder(BorderFactory.createLineBorder(Color.red)); + title.setBounds((int) (width - titleRectangle.getWidth()) / 2, (int) (height - titleRectangle.getHeight()) / 2, titleRectangle.width, titleRectangle.height); + } + } }); - - //TODO: move to plugin impl - if (Plugins.getInstance().isCardPluginLoaded()) { - Separator separator = new javax.swing.JToolBar.Separator(); - mageToolbar.add(separator); - - JButton btnDownloadSymbols = new JButton("Symbols"); - btnDownloadSymbols.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1)); - btnDownloadSymbols.setFocusable(false); - btnDownloadSymbols.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); - btnDownloadSymbols.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); - btnDownloadSymbols.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - btnSymbolsActionPerformed(evt); - } - }); - mageToolbar.add(btnDownloadSymbols); - - separator = new javax.swing.JToolBar.Separator(); - mageToolbar.add(separator); - - JButton btnDownload = new JButton("Images"); - btnDownload.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1)); - btnDownload.setFocusable(false); - btnDownload.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); - btnDownload.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); - btnDownload.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - btnImagesActionPerformed(evt); - } - }); - mageToolbar.add(btnDownload); - } - - if (Plugins.getInstance().isCounterPluginLoaded()) { - int i = Plugins.getInstance().getGamesPlayed(); - JLabel label = new JLabel(" Games played: " + String.valueOf(i)); - desktopPane.add(label, JLayeredPane.DEFAULT_LAYER + 1); - label.setVisible(true); - label.setForeground(Color.white); - label.setBounds(0, 0, 180, 30); - } - - session.getUI().addButton(MageComponents.TABLES_MENU_BUTTON, btnGames); - - SwingUtilities.invokeLater(new Runnable() { + + //TODO: move to plugin impl + if (Plugins.getInstance().isCardPluginLoaded()) { + Separator separator = new javax.swing.JToolBar.Separator(); + mageToolbar.add(separator); + + JButton btnDownloadSymbols = new JButton("Symbols"); + btnDownloadSymbols.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1)); + btnDownloadSymbols.setFocusable(false); + btnDownloadSymbols.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); + btnDownloadSymbols.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); + btnDownloadSymbols.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnSymbolsActionPerformed(evt); + } + }); + mageToolbar.add(btnDownloadSymbols); + + separator = new javax.swing.JToolBar.Separator(); + mageToolbar.add(separator); + + JButton btnDownload = new JButton("Images"); + btnDownload.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1)); + btnDownload.setFocusable(false); + btnDownload.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); + btnDownload.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); + btnDownload.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnImagesActionPerformed(evt); + } + }); + mageToolbar.add(btnDownload); + } + + if (Plugins.getInstance().isCounterPluginLoaded()) { + int i = Plugins.getInstance().getGamesPlayed(); + JLabel label = new JLabel(" Games played: " + String.valueOf(i)); + desktopPane.add(label, JLayeredPane.DEFAULT_LAYER + 1); + label.setVisible(true); + label.setForeground(Color.white); + label.setBounds(0, 0, 180, 30); + } + + session.getUI().addButton(MageComponents.TABLES_MENU_BUTTON, btnGames); + + SwingUtilities.invokeLater(new Runnable() { public void run() { - if (autoConnect()) - enableButtons(); - else - disableButtons(); + if (autoConnect()) + enableButtons(); + else + disableButtons(); } }); } @@ -222,7 +219,7 @@ public class MageFrame extends javax.swing.JFrame { final JEditorPane cardInfoPane = (JEditorPane) Plugins.getInstance().getCardInfoPane(); cardInfoPane.setSize(320, 201); cardInfoPane.setLocation(40, 40); - cardInfoPane.setBackground(new Color(0,0,0,0)); + cardInfoPane.setBackground(new Color(0, 0, 0, 0)); MageRoundPane popupContainer = new MageRoundPane(); popupContainer.setLayout(null); @@ -257,96 +254,95 @@ public class MageFrame extends javax.swing.JFrame { private void addMageLabel() { String filename = "/label-mage.png"; - try { - InputStream is = this.getClass().getResourceAsStream(filename); + try { + InputStream is = this.getClass().getResourceAsStream(filename); - float ratio = 1179.0f / 678.0f; - titleRectangle = new Rectangle(640, (int)(640 / ratio)); - if (is != null) { - BufferedImage image = ImageIO.read(is); - //ImageIcon resized = new ImageIcon(image.getScaledInstance(titleRectangle.width, titleRectangle.height, java.awt.Image.SCALE_SMOOTH)); - title = new JLabel(); - title.setIcon(new ImageIcon(image)); - backgroundPane.setLayout(null); - backgroundPane.add(title); - } - } catch (IOException e) { - e.printStackTrace(); - } + float ratio = 1179.0f / 678.0f; + titleRectangle = new Rectangle(640, (int) (640 / ratio)); + if (is != null) { + BufferedImage image = ImageIO.read(is); + //ImageIcon resized = new ImageIcon(image.getScaledInstance(titleRectangle.width, titleRectangle.height, java.awt.Image.SCALE_SMOOTH)); + title = new JLabel(); + title.setIcon(new ImageIcon(image)); + backgroundPane.setLayout(null); + backgroundPane.add(title); + } + } catch (IOException e) { + e.printStackTrace(); + } } private void setAppIcon() { String filename = "/icon-mage.png"; - try { - InputStream is = this.getClass().getResourceAsStream(filename); + try { + InputStream is = this.getClass().getResourceAsStream(filename); - if (is != null) { - BufferedImage image = ImageIO.read(is); - setIconImage(image); - } - } catch (IOException e) { - e.printStackTrace(); - } + if (is != null) { + BufferedImage image = ImageIO.read(is); + setIconImage(image); + } + } catch (IOException e) { + e.printStackTrace(); + } } - - private void btnImagesActionPerformed(java.awt.event.ActionEvent evt) { - Plugins.getInstance().downloadImage(CardsStorage.getAllCards()); - } - - private void btnSymbolsActionPerformed(java.awt.event.ActionEvent evt) { - if (JOptionPane.showConfirmDialog(null, "Do you want to download mana symbols?") == JOptionPane.OK_OPTION) { - Plugins.getInstance().downloadSymbols(); - } - } - public void showGame(UUID gameId, UUID playerId) { - this.tablesPane.hideTables(); - this.tablesPane.setVisible(false); - this.gamePane.setVisible(true); - this.gamePane.showGame(gameId, playerId); - } + private void btnImagesActionPerformed(java.awt.event.ActionEvent evt) { + Plugins.getInstance().downloadImage(CardsStorage.getAllCards()); + } - public void watchGame(UUID gameId) { - this.tablesPane.hideTables(); - this.tablesPane.setVisible(false); - this.gamePane.setVisible(true); - this.gamePane.watchGame(gameId); - } + private void btnSymbolsActionPerformed(java.awt.event.ActionEvent evt) { + if (JOptionPane.showConfirmDialog(null, "Do you want to download mana symbols?") == JOptionPane.OK_OPTION) { + Plugins.getInstance().downloadSymbols(); + } + } - public void replayGame() { - this.tablesPane.hideTables(); - this.tablesPane.setVisible(false); - this.gamePane.setVisible(true); - this.gamePane.replayGame(); - } + public void showGame(UUID gameId, UUID playerId) { + this.tablesPane.hideTables(); + this.tablesPane.setVisible(false); + this.gamePane.setVisible(true); + this.gamePane.showGame(gameId, playerId); + } - public static boolean connect(String userName, String serverName, int port) { - return session.connect(userName, serverName, port); - } + public void watchGame(UUID gameId) { + this.tablesPane.hideTables(); + this.tablesPane.setVisible(false); + this.gamePane.setVisible(true); + this.gamePane.watchGame(gameId); + } - public boolean autoConnect() { - boolean autoConnect = Boolean.parseBoolean(prefs.get("autoConnect", "false")); - if (autoConnect) { - String userName = prefs.get("userName", ""); - String server = prefs.get("serverAddress", ""); - int port = Integer.parseInt(prefs.get("serverPort", "")); - try { - setCursor(new Cursor(Cursor.WAIT_CURSOR)); - if (MageFrame.connect(userName, server, port)) { - return true; - } - else { - JOptionPane.showMessageDialog(rootPane, "Unable to connect to server"); - } - } - finally { - setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); - } - } - return false; - } + public void replayGame() { + this.tablesPane.hideTables(); + this.tablesPane.setVisible(false); + this.gamePane.setVisible(true); + this.gamePane.replayGame(); + } - /** This method is called from within the constructor to + public static boolean connect(String userName, String serverName, int port) { + return session.connect(userName, serverName, port); + } + + public boolean autoConnect() { + boolean autoConnect = Boolean.parseBoolean(prefs.get("autoConnect", "false")); + if (autoConnect) { + String userName = prefs.get("userName", ""); + String server = prefs.get("serverAddress", ""); + int port = Integer.parseInt(prefs.get("serverPort", "")); + try { + setCursor(new Cursor(Cursor.WAIT_CURSOR)); + if (MageFrame.connect(userName, server, port)) { + return true; + } else { + JOptionPane.showMessageDialog(rootPane, "Unable to connect to server"); + } + } finally { + setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); + } + } + return false; + } + + /** + * This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. @@ -440,7 +436,7 @@ public class MageFrame extends javax.swing.JFrame { }); mageToolbar.add(btnDeckEditor); mageToolbar.add(jSeparator2); - + btnPreferences.setText("Preferences"); btnPreferences.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1)); btnPreferences.setFocusable(false); @@ -486,122 +482,121 @@ public class MageFrame extends javax.swing.JFrame { javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(desktopPane, javax.swing.GroupLayout.DEFAULT_SIZE, 1144, Short.MAX_VALUE) - .addComponent(mageToolbar, javax.swing.GroupLayout.DEFAULT_SIZE, 1144, Short.MAX_VALUE) + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(desktopPane, javax.swing.GroupLayout.DEFAULT_SIZE, 1144, Short.MAX_VALUE) + .addComponent(mageToolbar, javax.swing.GroupLayout.DEFAULT_SIZE, 1144, Short.MAX_VALUE) ); layout.setVerticalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addComponent(mageToolbar, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE) - .addGap(0, 0, 0) - .addComponent(desktopPane, javax.swing.GroupLayout.DEFAULT_SIZE, 880, Short.MAX_VALUE)) + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(mageToolbar, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(0, 0, 0) + .addComponent(desktopPane, javax.swing.GroupLayout.DEFAULT_SIZE, 880, Short.MAX_VALUE)) ); pack(); }// //GEN-END:initComponents - private void btnDeckEditorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDeckEditorActionPerformed - this.gamePane.setVisible(false); - this.tablesPane.setVisible(false); - showDeckEditor(DeckEditorMode.Constructed, null, null); - }//GEN-LAST:event_btnDeckEditorActionPerformed + private void btnDeckEditorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDeckEditorActionPerformed + this.gamePane.setVisible(false); + this.tablesPane.setVisible(false); + showDeckEditor(DeckEditorMode.Constructed, null, null); + }//GEN-LAST:event_btnDeckEditorActionPerformed - private void btnPreferencesActionPerformed(java.awt.event.ActionEvent evt) { + private void btnPreferencesActionPerformed(java.awt.event.ActionEvent evt) { PhasesDialog.main(new String[]{}); - } - - private void btnGamesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGamesActionPerformed - this.gamePane.setVisible(false); - this.deckEditorPane.setVisible(false); - this.tablesPane.setVisible(true); - this.tablesPane.showTables(); - }//GEN-LAST:event_btnGamesActionPerformed + } - private void btnExitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnExitActionPerformed - exitApp(); - }//GEN-LAST:event_btnExitActionPerformed + private void btnGamesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGamesActionPerformed + this.gamePane.setVisible(false); + this.deckEditorPane.setVisible(false); + this.tablesPane.setVisible(true); + this.tablesPane.showTables(); + }//GEN-LAST:event_btnGamesActionPerformed - private void btnConnectActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnConnectActionPerformed - if (session.isConnected()) { - if (JOptionPane.showConfirmDialog(this, "Are you sure you want to disconnect?", "Confirm disconnect", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { - session.disconnect(); - } - } - else { - connectDialog.showDialog(); - } - }//GEN-LAST:event_btnConnectActionPerformed + private void btnExitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnExitActionPerformed + exitApp(); + }//GEN-LAST:event_btnExitActionPerformed - private void btnAboutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAboutActionPerformed - AboutDialog aboutDialog = new AboutDialog(); - desktopPane.add(aboutDialog); - aboutDialog.showDialog(); - }//GEN-LAST:event_btnAboutActionPerformed + private void btnConnectActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnConnectActionPerformed + if (session.isConnected()) { + if (JOptionPane.showConfirmDialog(this, "Are you sure you want to disconnect?", "Confirm disconnect", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { + session.disconnect(); + } + } else { + connectDialog.showDialog(); + } + }//GEN-LAST:event_btnConnectActionPerformed - public void exitApp() { - session.disconnect(); - Plugins.getInstance().shutdown(); - dispose(); - System.exit(0); - } + private void btnAboutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAboutActionPerformed + AboutDialog aboutDialog = new AboutDialog(); + desktopPane.add(aboutDialog); + aboutDialog.showDialog(); + }//GEN-LAST:event_btnAboutActionPerformed - public void enableButtons() { - btnConnect.setEnabled(true); - btnConnect.setText("Disconnect"); - btnGames.setEnabled(true); - btnDeckEditor.setEnabled(true); - } + public void exitApp() { + session.disconnect(); + Plugins.getInstance().shutdown(); + dispose(); + System.exit(0); + } - public void disableButtons() { - btnConnect.setEnabled(true); - btnConnect.setText("Connect"); - btnGames.setEnabled(false); - btnDeckEditor.setEnabled(true); - this.tablesPane.setVisible(false); - this.gamePane.setVisible(false); - this.deckEditorPane.setVisible(false); - } + public void enableButtons() { + btnConnect.setEnabled(true); + btnConnect.setText("Disconnect"); + btnGames.setEnabled(true); + btnDeckEditor.setEnabled(true); + } - public void showDeckEditor(DeckEditorMode mode, Deck deck, UUID tableId) { - this.deckEditorPane.setVisible(true); - this.deckEditorPane.show(mode, deck, tableId); - } + public void disableButtons() { + btnConnect.setEnabled(true); + btnConnect.setText("Connect"); + btnGames.setEnabled(false); + btnDeckEditor.setEnabled(true); + this.tablesPane.setVisible(false); + this.gamePane.setVisible(false); + this.deckEditorPane.setVisible(false); + } - public static CombatDialog getCombatDialog() { - return combat; - } + public void showDeckEditor(DeckEditorMode mode, Deck deck, UUID tableId) { + this.deckEditorPane.setVisible(true); + this.deckEditorPane.show(mode, deck, tableId); + } - public static PickNumberDialog getPickNumberDialog() { - return pickNumber; - } + public static CombatDialog getCombatDialog() { + return combat; + } - static void renderSplashFrame(Graphics2D g) { + public static PickNumberDialog getPickNumberDialog() { + return pickNumber; + } + + static void renderSplashFrame(Graphics2D g) { g.setComposite(AlphaComposite.Clear); - g.fillRect(120,140,200,40); + g.fillRect(120, 140, 200, 40); g.setPaintMode(); g.setColor(Color.white); g.drawString("Version 0.5.1", 560, 460); } - + /** - * @param args the command line arguments - */ + * @param args the command line arguments + */ public static void main(String args[]) { - final SplashScreen splash = SplashScreen.getSplashScreen(); - if (splash != null) { - Graphics2D g = splash.createGraphics(); - if (g != null) { - renderSplashFrame(g); - } - splash.update(); - } - - Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { - public void uncaughtException(Thread t, Throwable e) { - logger.log(Level.SEVERE, null, e); - } - }); + final SplashScreen splash = SplashScreen.getSplashScreen(); + if (splash != null) { + Graphics2D g = splash.createGraphics(); + if (g != null) { + renderSplashFrame(g); + } + splash.update(); + } + + Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + public void uncaughtException(Thread t, Throwable e) { + logger.log(Level.SEVERE, null, e); + } + }); SwingUtilities.invokeLater(new Runnable() { public void run() { new MageFrame().setVisible(true); @@ -628,11 +623,11 @@ public class MageFrame extends javax.swing.JFrame { private javax.swing.JToolBar mageToolbar; private mage.client.table.TablesPane tablesPane; // End of variables declaration//GEN-END:variables - - private static final long serialVersionUID = -9104885239063142218L; + + private static final long serialVersionUID = -9104885239063142218L; private ImagePanel backgroundPane; - public void setStatusText(String status) { - this.lblStatus.setText(status); - } + public void setStatusText(String status) { + this.lblStatus.setText(status); + } } diff --git a/Mage.Client/src/main/java/mage/client/cards/BigCard.java b/Mage.Client/src/main/java/mage/client/cards/BigCard.java index 6d13f4a0b1..a574ce8752 100644 --- a/Mage.Client/src/main/java/mage/client/cards/BigCard.java +++ b/Mage.Client/src/main/java/mage/client/cards/BigCard.java @@ -34,105 +34,199 @@ 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 mage.client.plugins.impl.Plugins; +import mage.client.util.gui.BufferedImageBuilder; +import mage.filters.FilterFactory; +import mage.filters.impl.HueFilter; +import mage.utils.ThreadUtils; +import org.jdesktop.swingx.JXPanel; -import java.awt.Dimension; -import java.awt.Graphics; -import java.awt.Image; -import java.awt.Rectangle; +import javax.imageio.ImageIO; +import javax.swing.*; +import javax.swing.text.BadLocationException; +import javax.swing.text.StyledDocument; +import java.awt.*; +import java.awt.image.BufferedImage; +import java.io.File; import java.util.List; import java.util.UUID; -import javax.swing.text.BadLocationException; -import javax.swing.text.StyledDocument; - -import mage.client.plugins.impl.Plugins; - -import org.jdesktop.swingx.JXPanel; +import static mage.constants.Constants.*; /** + * Class for displaying big image of the card * - * @author BetaSteward_at_googlemail.com + * @author BetaSteward_at_googlemail.com, nantuko */ -public class BigCard extends javax.swing.JPanel { +public class BigCard extends JComponent { - protected Image bigImage; - protected UUID cardId; - protected JXPanel panel; - protected boolean initState; + protected Image bigImage; + protected BufferedImage source; + protected volatile BufferedImage foil; + protected UUID cardId; + protected JXPanel panel; + protected boolean initState; + protected boolean foilState; + protected Thread foilThread; + protected float hue = 0.005f; - public BigCard() { + static private final int DEFAULT_DELAY_PERIOD = 25; + + public BigCard() { initComponents(); if (!Plugins.getInstance().isCardPluginLoaded()) { - initBounds(); + initBounds(); } + setDoubleBuffered(true); + setOpaque(true); } - - protected void initBounds() { - initState = true; + + protected void initBounds() { + initState = true; scrollPane.setBounds(20, 230, 210, 120); scrollPane.setBounds(new Rectangle(CONTENT_MAX_XOFFSET, TEXT_MAX_YOFFSET, TEXT_MAX_WIDTH, TEXT_MAX_HEIGHT)); - } - - public void setCard(UUID cardId, Image image, List strings) { - if (this.cardId == null || !this.cardId.equals(cardId)) { - if (this.panel != null) remove(this.panel); - this.cardId = cardId; - bigImage = image; - this.repaint(); - drawText(strings); - } - } + } + + public void setCard(UUID cardId, Image image, List strings, boolean foil) { + if (this.cardId == null || !this.cardId.equals(cardId)) { + if (this.panel != null) remove(this.panel); + this.cardId = cardId; + bigImage = image; + synchronized (this) { + source = null; + hue = 0.000f; + } + drawText(strings); + setFoil(foil); + } + } public UUID getCardId() { - return cardId; - } - - private void drawText(java.util.List strings) { - text.setText(""); - StyledDocument doc = text.getStyledDocument(); + return cardId; + } - try { - for (String line: strings) { - doc.insertString(doc.getLength(), line + "\n", doc.getStyle("regular")); - } - } catch (BadLocationException ble) { } - text.setCaretPosition(0); - } + private void drawText(java.util.List strings) { + text.setText(""); + StyledDocument doc = text.getStyledDocument(); - @Override - public void paintComponent(Graphics graphics) { - if (bigImage != null) - graphics.drawImage(bigImage, 0, 0, this); - super.paintComponent(graphics); - } + try { + for (String line : strings) { + doc.insertString(doc.getLength(), line + "\n", doc.getStyle("regular")); + } + } catch (BadLocationException ble) { + } + text.setCaretPosition(0); + } + + @Override + public void paintComponent(Graphics graphics) { + + if (foilState) { + if (source != null) { + synchronized (BigCard.class) { + if (source != null) { + graphics.drawImage(foil, 0, 0, this); + } + } + } + } else { + if (bigImage != null) { + graphics.drawImage(bigImage, 0, 0, this); + } + } + super.paintComponent(graphics); + } public void hideTextComponent() { - this.scrollPane.setVisible(false); + this.scrollPane.setVisible(false); } public void showTextComponent() { - if (!initState) {initBounds();} - this.scrollPane.setVisible(true); + if (!initState) { + initBounds(); + } + this.scrollPane.setVisible(true); + } + + public void setFoil(boolean foil) { + if (foil) { + if (foilThread == null) { + synchronized (this) { + if (foilThread == null) { + foilThread = getFoilThread(); + foilThread.setDaemon(true); + foilThread.start(); + } + } + } + if (foil != foilState) { + synchronized (this) { + if (foil != foilState) { + hue = 0.005f; + foilState = foil; + } + } + } + } + repaint(); + } + + private Thread getFoilThread() { + return new Thread(new Runnable() { + @Override + public void run() { + if (bigImage == null) { + return; + } + final HueFilter filter = FilterFactory.getHueFilter(); + while (true) { + boolean prevState = foilState; + while (!foilState) { + ThreadUtils.sleep(10); + } + if (prevState == foilState) { + ThreadUtils.sleep(DEFAULT_DELAY_PERIOD); + } + hue += 0.005F; + if (hue >= 1.0D) { + hue = 0.000F; + } + filter.setHue(hue); + BufferedImage f = null; + synchronized (BigCard.this) { + if (source == null) { + source = BufferedImageBuilder.bufferImage(bigImage); + } + f = filter.filter(source, null); + } + synchronized (BigCard.class) { + foil = f; + } + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + BigCard.this.repaint(); + } + }); + + } + } + }); } 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(); + 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 + + /** + * This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. diff --git a/Mage.Client/src/main/java/mage/client/cards/Card.java b/Mage.Client/src/main/java/mage/client/cards/Card.java index fd2772068a..7e080ed16c 100644 --- a/Mage.Client/src/main/java/mage/client/cards/Card.java +++ b/Mage.Client/src/main/java/mage/client/cards/Card.java @@ -135,12 +135,12 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis Style s = doc.addStyle("small", regular); StyleConstants.setFontSize(s, 9); - addMouseListener(this); - text.addMouseListener(this); - addFocusListener(this); - addMouseMotionListener(this); - text.addMouseMotionListener(this); - addComponentListener(this); + //addMouseListener(this); + //text.addMouseListener(this); + //addFocusListener(this); + //addMouseMotionListener(this); + //text.addMouseMotionListener(this); + //addComponentListener(this); } public UUID getCardId() { @@ -347,7 +347,7 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis @Override public void mouseMoved(MouseEvent arg0) { this.bigCard.showTextComponent(); - this.bigCard.setCard(card.getId(), image, getRules()); + this.bigCard.setCard(card.getId(), image, getRules(), false); } @Override @@ -480,7 +480,16 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis return image; } - @Override + @Override + public void setFoil(boolean foil) { + } + + @Override + public boolean isFoil() { + return false; + } + + @Override public PermanentView getOriginalPermanent() { return null; } diff --git a/Mage.Client/src/main/java/mage/client/components/arcane/ManaSymbols.java b/Mage.Client/src/main/java/mage/client/components/arcane/ManaSymbols.java index 80dff70037..9526ad1e2d 100644 --- a/Mage.Client/src/main/java/mage/client/components/arcane/ManaSymbols.java +++ b/Mage.Client/src/main/java/mage/client/components/arcane/ManaSymbols.java @@ -26,11 +26,10 @@ public class ManaSymbols { "BR", "G", "GU", "GW", "R", "RG", "RW", "S", "T", "U", "UB", "UR", "W", "WB", "WU", "X" /*, "Y", "Z", "slash"*/}; for (String symbol : symbols) { File file = new File(Constants.RESOURCE_PATH_MANA_LARGE + "/" + symbol + ".jpg"); - BufferedImageBuilder builder = new BufferedImageBuilder(); Rectangle r = new Rectangle(11, 11); try { Image image = UI.getImageIcon(file.getAbsolutePath()).getImage(); - BufferedImage resized = ImageResizeUtil.getResizedImage(builder.bufferImage(image, BufferedImage.TYPE_INT_ARGB), r); + BufferedImage resized = ImageResizeUtil.getResizedImage(BufferedImageBuilder.bufferImage(image, BufferedImage.TYPE_INT_ARGB), r); manaImages.put(symbol, resized); } catch (Exception e) { noManaSymbols = true; diff --git a/Mage.Client/src/main/java/mage/client/deckeditor/DeckEditorPanel.java b/Mage.Client/src/main/java/mage/client/deckeditor/DeckEditorPanel.java index dc571f9ef3..6c5c9720f0 100644 --- a/Mage.Client/src/main/java/mage/client/deckeditor/DeckEditorPanel.java +++ b/Mage.Client/src/main/java/mage/client/deckeditor/DeckEditorPanel.java @@ -37,6 +37,7 @@ package mage.client.deckeditor; import mage.cards.Card; import mage.cards.decks.Deck; import mage.client.MageFrame; +import mage.client.deckeditor.collection.viewer.Huerotator2; import mage.client.plugins.impl.Plugins; import mage.client.util.Event; import mage.client.util.Listener; diff --git a/Mage.Client/src/main/java/mage/client/plugins/adapters/MageActionCallback.java b/Mage.Client/src/main/java/mage/client/plugins/adapters/MageActionCallback.java index d1cabb2ffd..3562a45824 100644 --- a/Mage.Client/src/main/java/mage/client/plugins/adapters/MageActionCallback.java +++ b/Mage.Client/src/main/java/mage/client/plugins/adapters/MageActionCallback.java @@ -184,14 +184,13 @@ public class MageActionCallback implements ActionCallback { Image image = card.getImage(); if (image != null && image instanceof BufferedImage) { image = ImageHelper.getResizedImage((BufferedImage) image, bigCard.getWidth(), bigCard.getHeight()); - bigCard.setCard(card.getOriginal().getId(), image, card.getOriginal().getRules()); + bigCard.setCard(card.getOriginal().getId(), image, card.getOriginal().getRules(), card.isFoil()); bigCard.showTextComponent(); if (card.getOriginal().isAbility()) { bigCard.showTextComponent(); } else { bigCard.hideTextComponent(); } - ; } else { JXPanel panel = GuiDisplayUtil.getDescription(card.getOriginal(), bigCard.getWidth(), bigCard.getHeight()); panel.setVisible(true); diff --git a/Mage.Client/src/main/java/mage/client/util/gui/BufferedImageBuilder.java b/Mage.Client/src/main/java/mage/client/util/gui/BufferedImageBuilder.java index f10dea97ac..cea78531ba 100644 --- a/Mage.Client/src/main/java/mage/client/util/gui/BufferedImageBuilder.java +++ b/Mage.Client/src/main/java/mage/client/util/gui/BufferedImageBuilder.java @@ -4,15 +4,27 @@ import java.awt.*; import java.awt.image.BufferedImage; import java.awt.image.ImageObserver; +/** + * Utility class for creating BufferedImage object from Image instance. + * + * @author nantuko + */ public class BufferedImageBuilder { private static final int DEFAULT_IMAGE_TYPE = BufferedImage.TYPE_INT_RGB; - public BufferedImage bufferImage(Image image) { + /** + * Hide constructor + */ + private BufferedImageBuilder() { + + } + + public static BufferedImage bufferImage(Image image) { return bufferImage(image, DEFAULT_IMAGE_TYPE); } - public BufferedImage bufferImage(Image image, int type) { + public static BufferedImage bufferImage(Image image, int type) { BufferedImage bufferedImage = new BufferedImage(image.getWidth(null), image.getHeight(null), type); Graphics2D g = bufferedImage.createGraphics(); g.drawImage(image, null, null); @@ -50,7 +62,6 @@ public class BufferedImageBuilder { } class ImageLoadStatus { - public boolean widthDone = false; public boolean heightDone = false; } diff --git a/Mage.Common/src/mage/cards/MageCard.java b/Mage.Common/src/mage/cards/MageCard.java index 5b94121360..674697b73e 100644 --- a/Mage.Common/src/mage/cards/MageCard.java +++ b/Mage.Common/src/mage/cards/MageCard.java @@ -19,4 +19,6 @@ public abstract class MageCard extends JPanel { abstract public void setCardBounds(int x, int y, int width, int height); abstract public void update(CardView card); abstract public Image getImage(); + abstract public void setFoil(boolean foil); + abstract public boolean isFoil(); } diff --git a/Mage.Common/src/mage/filters/FilterFactory.java b/Mage.Common/src/mage/filters/FilterFactory.java new file mode 100644 index 0000000000..64153ce628 --- /dev/null +++ b/Mage.Common/src/mage/filters/FilterFactory.java @@ -0,0 +1,17 @@ +package mage.filters; + +import mage.filters.impl.HueFilter; + +/** + * Creates filter instances. + * + * @author nantuko + */ +public class FilterFactory { + + private static final HueFilter hueFilter = new HueFilter(); + + public static HueFilter getHueFilter() { + return hueFilter; + } +} diff --git a/Mage.Common/src/mage/filters/MageBufferedImageOp.java b/Mage.Common/src/mage/filters/MageBufferedImageOp.java new file mode 100644 index 0000000000..08c587cd5b --- /dev/null +++ b/Mage.Common/src/mage/filters/MageBufferedImageOp.java @@ -0,0 +1,68 @@ +package mage.filters; + +import java.awt.*; +import java.awt.geom.Point2D; +import java.awt.geom.Rectangle2D; +import java.awt.image.BufferedImage; +import java.awt.image.BufferedImageOp; +import java.awt.image.ColorModel; + +/** + * Mage abstract class that implements single-input/single-output + * operations performed on {@link java.awt.image.BufferedImage}. + * + * @author nantuko + */ +public abstract class MageBufferedImageOp implements BufferedImageOp { + + /** + * Creates compatible image for @param src image. + */ + public BufferedImage createCompatibleDestImage(BufferedImage src, ColorModel dest) { + if (dest == null) { + dest = src.getColorModel(); + } + return new BufferedImage(dest, dest.createCompatibleWritableRaster(src.getWidth(), src.getHeight()), dest.isAlphaPremultiplied(), null); + } + + public RenderingHints getRenderingHints() { + return null; + } + + public Rectangle2D getBounds2D(BufferedImage src) { + return new Rectangle(0, 0, src.getWidth(), src.getHeight()); + } + + public Point2D getPoint2D(Point2D srcPt, Point2D destPt) { + if (destPt == null) { + destPt = new Point2D.Double(); + } + destPt.setLocation(srcPt.getX(), srcPt.getY()); + return destPt; + } + + /** + * Gets ARGB pixels from image. Solves the performance + * issue of BufferedImage.getRGB method. + */ + public int[] getRGB(BufferedImage image, int x, int y, int width, int height, int[] pixels) { + int type = image.getType(); + if (type == BufferedImage.TYPE_INT_ARGB || type == BufferedImage.TYPE_INT_RGB) { + return (int[]) image.getRaster().getDataElements(x, y, width, height, pixels); + } + return image.getRGB(x, y, width, height, pixels, 0, width); + } + + /** + * Sets ARGB pixels in image. Solves the performance + * issue of BufferedImage.setRGB method. + */ + public void setRGB(BufferedImage image, int x, int y, int width, int height, int[] pixels) { + int type = image.getType(); + if (type == BufferedImage.TYPE_INT_ARGB || type == BufferedImage.TYPE_INT_RGB) { + image.getRaster().setDataElements(x, y, width, height, pixels); + } else { + image.setRGB(x, y, width, height, pixels, 0, width); + } + } +} diff --git a/Mage.Common/src/mage/filters/PointFilter.java b/Mage.Common/src/mage/filters/PointFilter.java new file mode 100644 index 0000000000..f1aeb8f3a1 --- /dev/null +++ b/Mage.Common/src/mage/filters/PointFilter.java @@ -0,0 +1,69 @@ +/* +Copyright 2006 Jerry Huxtable + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package mage.filters; + +import java.awt.image.BufferedImage; +import java.awt.image.WritableRaster; + +/** + * An abstract super class for filters that work with points. + * Takes into account image type to avoid performance issue with getRGB and setRGB methods of BufferedImage. + * + * @author nantuko + */ +public abstract class PointFilter extends MageBufferedImageOp { + + protected boolean canFilterIndexColorModel = false; + + public BufferedImage filter(BufferedImage src, BufferedImage dst) { + int width = src.getWidth(); + int height = src.getHeight(); + int type = src.getType(); + WritableRaster srcRaster = src.getRaster(); + + if (dst == null) { + dst = createCompatibleDestImage(src, null); + } + WritableRaster dstRaster = dst.getRaster(); + + setDimensions(width, height); + + int[] inPixels = new int[width]; + for (int y = 0; y < height; y++) { + if (type == BufferedImage.TYPE_INT_ARGB || type == BufferedImage.TYPE_INT_RGB) { + srcRaster.getDataElements(0, y, width, 1, inPixels); + for (int x = 0; x < width; x++) { + inPixels[x] = filterRGB(x, y, inPixels[x]); + } + dstRaster.setDataElements(0, y, width, 1, inPixels); + } else { + src.getRGB(0, y, width, 1, inPixels, 0, width); + for (int x = 0; x < width; x++) { + inPixels[x] = filterRGB(x, y, inPixels[x]); + } + dst.setRGB(0, y, width, 1, inPixels, 0, width); + } + } + + return dst; + } + + public void setDimensions(int width, int height) { + } + + public abstract int filterRGB(int x, int y, int rgb); +} diff --git a/Mage.Common/src/mage/filters/impl/HueFilter.java b/Mage.Common/src/mage/filters/impl/HueFilter.java new file mode 100644 index 0000000000..2057ea0301 --- /dev/null +++ b/Mage.Common/src/mage/filters/impl/HueFilter.java @@ -0,0 +1,68 @@ +/* +Copyright 2006 Jerry Huxtable + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package mage.filters.impl; + +import mage.filters.PointFilter; + +import java.awt.*; + +/** + * Point filter that changes hue of the image. + * + * @author nantuko + */ +public class HueFilter extends PointFilter { + + public float hue; + private float[] hsb = new float[3]; + + public HueFilter() { + this(0); + } + + public HueFilter(float hue) { + this.hue = hue; + canFilterIndexColorModel = true; + } + + public void setHue(float hue) { + this.hue = hue; + } + + public float getHue() { + return hue; + } + + public int filterRGB(int x, int y, int rgb) { + int a = rgb & 0xff000000; + int r = (rgb >> 16) & 0xff; + int g = (rgb >> 8) & 0xff; + int b = rgb & 0xff; + Color.RGBtoHSB(r, g, b, hsb); + hsb[0] += hue; + while (hsb[0] < 0) { + hsb[0] += Math.PI*2; + } + rgb = Color.HSBtoRGB(hsb[0], hsb[1], hsb[2]); + return a | (rgb & 0xffffff); + } + + public String toString() { + return "Change HUE filter"; + } +} + diff --git a/Mage.Plugins/Mage.Card.Plugin/src/main/java/org/mage/card/arcane/CardPanel.java b/Mage.Plugins/Mage.Card.Plugin/src/main/java/org/mage/card/arcane/CardPanel.java index aeed536334..3c9d4bd0ee 100644 --- a/Mage.Plugins/Mage.Card.Plugin/src/main/java/org/mage/card/arcane/CardPanel.java +++ b/Mage.Plugins/Mage.Card.Plugin/src/main/java/org/mage/card/arcane/CardPanel.java @@ -1,15 +1,27 @@ package org.mage.card.arcane; -import java.awt.AlphaComposite; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Font; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.Image; -import java.awt.Point; -import java.awt.Rectangle; -import java.awt.RenderingHints; +import mage.Constants.CardType; +import mage.cards.MagePermanent; +import mage.cards.TextPopup; +import mage.cards.action.ActionCallback; +import mage.cards.action.TransferData; +import mage.components.ImagePanel; +import mage.filters.FilterFactory; +import mage.filters.impl.HueFilter; +import mage.utils.CardUtil; +import mage.view.AbilityView; +import mage.view.CardView; +import mage.view.PermanentView; +import mage.view.StackAbilityView; +import org.apache.log4j.Logger; +import org.mage.card.arcane.ScaledImagePanel.MultipassType; +import org.mage.card.arcane.ScaledImagePanel.ScalingType; +import org.mage.plugins.card.images.ImageCache; +import org.mage.plugins.card.utils.BufferedImageBuilder; +import org.mage.plugins.card.utils.impl.ImageManagerImpl; + +import javax.swing.*; +import java.awt.*; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.awt.event.MouseMotionListener; @@ -18,402 +30,431 @@ import java.util.ArrayList; import java.util.List; import java.util.UUID; -import javax.swing.BorderFactory; -import javax.swing.JRootPane; -import javax.swing.SwingUtilities; - -import mage.Constants.CardType; -import mage.cards.MagePermanent; -import mage.cards.TextPopup; -import mage.cards.action.ActionCallback; -import mage.cards.action.TransferData; -import mage.components.ImagePanel; -import mage.utils.CardUtil; -import mage.view.AbilityView; -import mage.view.CardView; -import mage.view.PermanentView; -import mage.view.StackAbilityView; - -import org.apache.log4j.Logger; -import org.mage.card.arcane.ScaledImagePanel.MultipassType; -import org.mage.card.arcane.ScaledImagePanel.ScalingType; -import org.mage.plugins.card.images.ImageCache; -import org.mage.plugins.card.utils.impl.ImageManagerImpl; - - -@SuppressWarnings({"unchecked","rawtypes"}) +/** + * Main class for drawing Mage card object. + * + * @author arcane, nantuko + */ +@SuppressWarnings({"unchecked", "rawtypes"}) public class CardPanel extends MagePermanent implements MouseListener, MouseMotionListener { - private static final long serialVersionUID = -3272134219262184410L; - - private static final Logger log = Logger.getLogger(CardPanel.class); - - static public final double TAPPED_ANGLE = Math.PI / 2; - static public final float ASPECT_RATIO = 3.5f / 2.5f; - static public final int POPUP_X_GAP = 1; // prevent popup window from blinking - //static public final float ASPECT_RATIO = 1.0f; + private static final long serialVersionUID = -3272134219262184410L; - static public CardPanel dragAnimationPanel; + private static final Logger log = Logger.getLogger(CardPanel.class); - public static final Rectangle CARD_SIZE_FULL = new Rectangle(101, 149); - - static private final float ROUNDED_CORNER_SIZE = 0.1f; - //static private final float SELECTED_BORDER_SIZE = 0.01f; - static private final float BLACK_BORDER_SIZE = 0.03f; - static private final int TEXT_GLOW_SIZE = 6; - static private final float TEXT_GLOW_INTENSITY = 3f; - static private final float rotCenterToTopCorner = 1.0295630140987000315797369464196f; - static private final float rotCenterToBottomCorner = 0.7071067811865475244008443621048f; + static public final double TAPPED_ANGLE = Math.PI / 2; + static public final float ASPECT_RATIO = 3.5f / 2.5f; + static public final int POPUP_X_GAP = 1; // prevent popup window from blinking + //static public final float ASPECT_RATIO = 1.0f; - public CardView gameCard; - //public List attachedPanels = new ArrayList(); + static public CardPanel dragAnimationPanel; + + public static final Rectangle CARD_SIZE_FULL = new Rectangle(101, 149); + + static private final float ROUNDED_CORNER_SIZE = 0.1f; + //static private final float SELECTED_BORDER_SIZE = 0.01f; + static private final float BLACK_BORDER_SIZE = 0.03f; + static private final int TEXT_GLOW_SIZE = 6; + static private final float TEXT_GLOW_INTENSITY = 3f; + static private final float rotCenterToTopCorner = 1.0295630140987000315797369464196f; + static private final float rotCenterToBottomCorner = 0.7071067811865475244008443621048f; + + static private final int DEFAULT_DELAY_PERIOD = 300; + + public CardView gameCard; + //public List attachedPanels = new ArrayList(); private List links = new ArrayList(); - public double tappedAngle = 0; - public ScaledImagePanel imagePanel; - public ImagePanel overlayPanel; + public double tappedAngle = 0; + public ScaledImagePanel imagePanel; + public ImagePanel overlayPanel; - private GlowText titleText; - private GlowText ptText; - private List imageLoadListeners = new ArrayList(2); - private boolean displayEnabled = true; - private boolean isAnimationPanel; - private int cardXOffset, cardYOffset, cardWidth, cardHeight; + private GlowText titleText; + private GlowText ptText; + private boolean displayEnabled = true; + private boolean isAnimationPanel; + private int cardXOffset, cardYOffset, cardWidth, cardHeight; - private boolean isSelected; - private boolean showCastingCost; - private boolean hasImage = false; - private float alpha = 1.0f; - - private ActionCallback callback; - - protected boolean popupShowing; - protected TextPopup popupText = new TextPopup(); - protected UUID gameId; - private TransferData data = new TransferData(); - - private boolean isPermanent; - private boolean hasSickness; - - public CardPanel(CardView newGameCard, UUID gameId, boolean loadImage, ActionCallback callback) { - this.gameCard = newGameCard; - this.callback = callback; - this.gameId = gameId; - this.isPermanent = this.gameCard instanceof PermanentView; - - if (isPermanent) { - this.hasSickness = ((PermanentView) this.gameCard).hasSummoningSickness(); - } - - //for container debug (don't remove) - //setBorder(BorderFactory.createLineBorder(Color.green)); + private boolean isSelected; + private boolean showCastingCost; + private boolean hasImage = false; + private float alpha = 1.0f; - setBackground(Color.black); - setOpaque(false); - - addMouseListener(this); - addMouseMotionListener(this); - - titleText = new GlowText(); - setText(gameCard); - titleText.setFont(getFont().deriveFont(Font.BOLD, 13f)); - titleText.setForeground(Color.white); - titleText.setGlow(Color.black, TEXT_GLOW_SIZE, TEXT_GLOW_INTENSITY); - titleText.setWrap(true); - add(titleText); + private ActionCallback callback; - ptText = new GlowText(); - if (CardUtil.isCreature(gameCard)) { - ptText.setText(gameCard.getPower() + "/" + gameCard.getToughness()); - } else if (CardUtil.isPlaneswalker(gameCard)) { - ptText.setText(gameCard.getLoyalty()); - } - ptText.setFont(getFont().deriveFont(Font.BOLD, 13f)); - ptText.setForeground(Color.white); - ptText.setGlow(Color.black, TEXT_GLOW_SIZE, TEXT_GLOW_INTENSITY); - add(ptText); - - BufferedImage sickness = ImageManagerImpl.getInstance().getSicknessImage(); - overlayPanel = new ImagePanel(sickness, ImagePanel.SCALED); - overlayPanel.setOpaque(false); - add(overlayPanel); + protected boolean popupShowing; + protected TextPopup popupText = new TextPopup(); + protected UUID gameId; + private TransferData data = new TransferData(); - imagePanel = new ScaledImagePanel(); - imagePanel.setBorder(BorderFactory.createLineBorder(Color.white)); - add(imagePanel); - imagePanel.setScaleLarger(true); - imagePanel.setScalingType(ScalingType.nearestNeighbor); - imagePanel.setScalingBlur(true); - imagePanel.setScalingMultiPassType(MultipassType.none); - - String cardType = getType(newGameCard); - popupText.setText(getText(cardType, newGameCard)); - - if (!loadImage) return; - - Util.threadPool.submit(new Runnable() { - public void run () { - try { - tappedAngle = isTapped() ? CardPanel.TAPPED_ANGLE : 0; - BufferedImage srcImage = ImageCache.getImageOriginal(gameCard); - srcImage = ImageCache.getNormalSizeImage(srcImage); - if (srcImage != null) { - hasImage = true; - setText(gameCard); - setImage(srcImage, srcImage); - } else { - log.warn("image wasn't found, card=" + gameCard.getName() + ", set=" + gameCard.getExpansionSetCode() + ", cid=" + gameCard.getCardNumber()); - } - } catch (Exception e) { - e.printStackTrace(); - } catch (Error err) { - err.printStackTrace(); - } - } - }); - } - - private void setText(CardView card) { - if (hasImage) { - titleText.setText(""); - } else { - titleText.setText(card.getName()); - } - } + private boolean isPermanent; + private boolean hasSickness; + private boolean isFoil; - private void setImage (Image srcImage, Image srcImageBlurred) { - synchronized (imagePanel) { - imagePanel.setImage(srcImage, srcImageBlurred); - repaint(); - for (CardPanel cardPanel : imageLoadListeners) { - cardPanel.setImage(srcImage, srcImageBlurred); - cardPanel.repaint(); - } - imageLoadListeners.clear(); - } - layout(); - } + public CardPanel(CardView newGameCard, UUID gameId, boolean loadImage, ActionCallback callback, final boolean foil) { + this.gameCard = newGameCard; + this.callback = callback; + this.gameId = gameId; + this.isPermanent = this.gameCard instanceof PermanentView; - public void setImage (final CardPanel panel) { - synchronized (panel.imagePanel) { - if (panel.imagePanel.hasImage()) - setImage(panel.imagePanel.srcImage, panel.imagePanel.srcImageBlurred); - else - panel.imageLoadListeners.add(this); - } - } + if (isPermanent) { + this.hasSickness = ((PermanentView) this.gameCard).hasSummoningSickness(); + } - public void setScalingType (ScalingType scalingType) { - imagePanel.setScalingType(scalingType); - } + //for container debug (don't remove) + //setBorder(BorderFactory.createLineBorder(Color.green)); - public void setDisplayEnabled (boolean displayEnabled) { - this.displayEnabled = displayEnabled; - } + setBackground(Color.black); + setOpaque(false); - public boolean isDisplayEnabled () { - return displayEnabled; - } + addMouseListener(this); + addMouseMotionListener(this); - public void setAnimationPanel (boolean isAnimationPanel) { - this.isAnimationPanel = isAnimationPanel; - } + titleText = new GlowText(); + setText(gameCard); + titleText.setFont(getFont().deriveFont(Font.BOLD, 13f)); + titleText.setForeground(Color.white); + titleText.setGlow(Color.black, TEXT_GLOW_SIZE, TEXT_GLOW_INTENSITY); + titleText.setWrap(true); + add(titleText); - public void setSelected (boolean isSelected) { - this.isSelected = isSelected; - repaint(); - } - - public void setAttacking (boolean isAttacking) { - //TODO:uncomment - //this.gameCard.setAttacking(isAttacking); - repaint(); - } - - public boolean getSelected() { - return this.isSelected; - } - - public void setShowCastingCost (boolean showCastingCost) { - this.showCastingCost = showCastingCost; - } + ptText = new GlowText(); + if (CardUtil.isCreature(gameCard)) { + ptText.setText(gameCard.getPower() + "/" + gameCard.getToughness()); + } else if (CardUtil.isPlaneswalker(gameCard)) { + ptText.setText(gameCard.getLoyalty()); + } + ptText.setFont(getFont().deriveFont(Font.BOLD, 13f)); + ptText.setForeground(Color.white); + ptText.setGlow(Color.black, TEXT_GLOW_SIZE, TEXT_GLOW_INTENSITY); + add(ptText); - public void paint (Graphics g) { - if (!displayEnabled) return; - if (!isValid()) super.validate(); - Graphics2D g2d = (Graphics2D)g; - if (tappedAngle > 0) { - g2d = (Graphics2D)g2d.create(); - float edgeOffset = cardWidth / 2f; - g2d.rotate(tappedAngle, cardXOffset + edgeOffset, cardYOffset + cardHeight - edgeOffset); - } - super.paint(g2d); - } + BufferedImage sickness = ImageManagerImpl.getInstance().getSicknessImage(); + overlayPanel = new ImagePanel(sickness, ImagePanel.SCALED); + overlayPanel.setOpaque(false); + add(overlayPanel); - protected void paintComponent (Graphics g) { - Graphics2D g2d = (Graphics2D)g; - g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - - if (alpha != 1.0f) { - AlphaComposite composite = AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, alpha); - g2d.setComposite(composite); - } - - //TODO:uncomment - if (!hasImage /*&& gameCard.getTableID() > 0*/) { - g2d.setColor(new Color(30,200,200,120)); - } else { - g2d.setColor(new Color(0,0,0,200)); - } - - //for debug repainting - //g2d.setColor(new Color(MyRandom.random.nextInt(255),MyRandom.random.nextInt(255),MyRandom.random.nextInt(255),150)); - int cornerSize = Math.max(4, Math.round(cardWidth * ROUNDED_CORNER_SIZE)); - g2d.fillRoundRect(cardXOffset, cardYOffset, cardWidth, cardHeight, cornerSize, cornerSize); - if (isSelected) { - //g2d.setColor(new Color(0,250,0,200)); - g2d.setColor(new Color(200,120,40,200)); - g2d.fillRoundRect(cardXOffset+1, cardYOffset+1, cardWidth-2, cardHeight-2, cornerSize, cornerSize); - } - - //TODO:uncomment - /* - if (gameCard.isAttacking()) { - g2d.setColor(new Color(200,10,10,200)); - g2d.fillRoundRect(cardXOffset+1, cardYOffset+1, cardWidth-2, cardHeight-2, cornerSize, cornerSize); - }*/ - - /*if (isSelected) { - g2d.setColor(Color.green); - int offset = gameCard.isTapped() ? 1 : 0; - for (int i = 1, n = Math.max(1, Math.round(cardWidth * SELECTED_BORDER_SIZE)); i <= n; i++) - g2d.drawRoundRect(cardXOffset - i, cardYOffset - i + offset, cardWidth + i * 2 - 1, cardHeight + i * 2 - 1, - cornerSize, cornerSize); - }*/ - - - //for debugging - // REMOVEME - /* - Point component = getLocation(); - - int cx = getCardX() + component.x; - int cy = getCardY() + component.y; - int cw = getCardWidth(); - int ch = getCardHeight(); - - g2d.setColor(Color.white); - g2d.drawRect(getCardX() - component.x, getCardY() - component.y, cw, ch); - */ - } + imagePanel = new ScaledImagePanel(); + imagePanel.setBorder(BorderFactory.createLineBorder(Color.white)); + add(imagePanel); + imagePanel.setScaleLarger(true); + imagePanel.setScalingType(ScalingType.nearestNeighbor); + imagePanel.setScalingBlur(true); + imagePanel.setScalingMultiPassType(MultipassType.none); - protected void paintChildren (Graphics g) { - super.paintChildren(g); + String cardType = getType(newGameCard); + popupText.setText(getText(cardType, newGameCard)); - if (showCastingCost && !isAnimationPanel && cardWidth < 200 && cardWidth > 60) { - String manaCost = ManaSymbols.getStringManaCost(gameCard.getManaCost()); - int width = ManaSymbols.getWidth(manaCost); - if (hasImage) { + if (!loadImage) return; + + Util.threadPool.submit(new Runnable() { + public void run() { + try { + tappedAngle = isTapped() ? CardPanel.TAPPED_ANGLE : 0; + BufferedImage srcImage = ImageCache.getImageOriginal(gameCard); + srcImage = ImageCache.getNormalSizeImage(srcImage); + if (srcImage != null) { + hasImage = true; + setText(gameCard); + setImage(srcImage); + setFoil(foil); + } else { + //log.warn("image wasn't found, card=" + gameCard.getName() + ", set=" + gameCard.getExpansionSetCode() + ", cid=" + gameCard.getCardNumber()); + } + } catch (Exception e) { + e.printStackTrace(); + } catch (Error err) { + err.printStackTrace(); + } + } + }); + } + + private void setText(CardView card) { + if (hasImage) { + titleText.setText(""); + } else { + titleText.setText(card.getName()); + } + } + + private void setImage(Image srcImage) { + synchronized (imagePanel) { + imagePanel.setImage(srcImage); + repaint(); + } + layout(); + } + + public void setImage(final CardPanel panel) { + synchronized (panel.imagePanel) { + if (panel.imagePanel.hasImage()) { + setImage(panel.imagePanel.srcImage); + } + } + } + + public boolean isFoil() { + return this.isFoil; + } + + public void setFoil(boolean foil) { + this.isFoil = foil; + if (foil) { + /*BufferedImage source = BufferedImageBuilder.bufferImage(imagePanel.getSrcImage()); + HueFilter filter = FilterFactory.getHueFilter(); + filter.setHue(0.1sf); + BufferedImage dest = filter.filter(source, null); + imagePanel.setImage(dest); + imagePanel.repaint();*/ + + Thread thread = new Thread(new Runnable() { + @Override + public void run() { + if (imagePanel.getSrcImage() == null) { + return; + } + BufferedImage source = BufferedImageBuilder.bufferImage(imagePanel.getSrcImage()); + HueFilter filter = FilterFactory.getHueFilter(); + float hue = 0.005f; + while (true) { + try { + Thread.sleep(DEFAULT_DELAY_PERIOD); + } catch (InterruptedException e) { + } + hue += 0.015F; + if (hue >= 1.0D) { + hue = 0.005F; + } + filter.setHue(hue); + final BufferedImage dest = filter.filter(source, null); + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + imagePanel.setImage(dest); + imagePanel.repaint(); + } + }); + } + } + }); + thread.setDaemon(false); + thread.start(); + + } + } + + public void setScalingType(ScalingType scalingType) { + imagePanel.setScalingType(scalingType); + } + + public void setDisplayEnabled(boolean displayEnabled) { + this.displayEnabled = displayEnabled; + } + + public boolean isDisplayEnabled() { + return displayEnabled; + } + + public void setAnimationPanel(boolean isAnimationPanel) { + this.isAnimationPanel = isAnimationPanel; + } + + public void setSelected(boolean isSelected) { + this.isSelected = isSelected; + repaint(); + } + + public void setAttacking(boolean isAttacking) { + //TODO:uncomment + //this.gameCard.setAttacking(isAttacking); + repaint(); + } + + public boolean getSelected() { + return this.isSelected; + } + + public void setShowCastingCost(boolean showCastingCost) { + this.showCastingCost = showCastingCost; + } + + public void paint(Graphics g) { + if (!displayEnabled) return; + if (!isValid()) super.validate(); + Graphics2D g2d = (Graphics2D) g; + if (tappedAngle > 0) { + g2d = (Graphics2D) g2d.create(); + float edgeOffset = cardWidth / 2f; + g2d.rotate(tappedAngle, cardXOffset + edgeOffset, cardYOffset + cardHeight - edgeOffset); + } + super.paint(g2d); + } + + protected void paintComponent(Graphics g) { + Graphics2D g2d = (Graphics2D) g; + g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + + if (alpha != 1.0f) { + AlphaComposite composite = AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, alpha); + g2d.setComposite(composite); + } + + //TODO:uncomment + if (!hasImage /*&& gameCard.getTableID() > 0*/) { + g2d.setColor(new Color(30, 200, 200, 120)); + } else { + g2d.setColor(new Color(0, 0, 0, 200)); + } + + //for debug repainting + //g2d.setColor(new Color(MyRandom.random.nextInt(255),MyRandom.random.nextInt(255),MyRandom.random.nextInt(255),150)); + int cornerSize = Math.max(4, Math.round(cardWidth * ROUNDED_CORNER_SIZE)); + g2d.fillRoundRect(cardXOffset, cardYOffset, cardWidth, cardHeight, cornerSize, cornerSize); + if (isSelected) { + //g2d.setColor(new Color(0,250,0,200)); + g2d.setColor(new Color(200, 120, 40, 200)); + g2d.fillRoundRect(cardXOffset + 1, cardYOffset + 1, cardWidth - 2, cardHeight - 2, cornerSize, cornerSize); + } + + //TODO:uncomment + /* + if (gameCard.isAttacking()) { + g2d.setColor(new Color(200,10,10,200)); + g2d.fillRoundRect(cardXOffset+1, cardYOffset+1, cardWidth-2, cardHeight-2, cornerSize, cornerSize); + }*/ + + /*if (isSelected) { + g2d.setColor(Color.green); + int offset = gameCard.isTapped() ? 1 : 0; + for (int i = 1, n = Math.max(1, Math.round(cardWidth * SELECTED_BORDER_SIZE)); i <= n; i++) + g2d.drawRoundRect(cardXOffset - i, cardYOffset - i + offset, cardWidth + i * 2 - 1, cardHeight + i * 2 - 1, + cornerSize, cornerSize); + }*/ + + + //for debugging + // REMOVEME + /* + Point component = getLocation(); + + int cx = getCardX() + component.x; + int cy = getCardY() + component.y; + int cw = getCardWidth(); + int ch = getCardHeight(); + + g2d.setColor(Color.white); + g2d.drawRect(getCardX() - component.x, getCardY() - component.y, cw, ch); + */ + } + + protected void paintChildren(Graphics g) { + super.paintChildren(g); + + if (showCastingCost && !isAnimationPanel && cardWidth < 200 && cardWidth > 60) { + String manaCost = ManaSymbols.getStringManaCost(gameCard.getManaCost()); + int width = ManaSymbols.getWidth(manaCost); + if (hasImage) { ManaSymbols.draw(g, manaCost, cardXOffset + cardWidth - width - 5, cardYOffset + 5); - } else { + } else { ManaSymbols.draw(g, manaCost, cardXOffset + 8, cardHeight - 9); - } - } - } + } + } + } - public void layout() { - int borderSize = Math.round(cardWidth * BLACK_BORDER_SIZE); - imagePanel.setLocation(cardXOffset + borderSize, cardYOffset + borderSize); - imagePanel.setSize(cardWidth - borderSize * 2, cardHeight - borderSize * 2); - - if (hasSickness && CardUtil.isCreature(gameCard) && isPermanent) { - overlayPanel.setLocation(cardXOffset + borderSize, cardYOffset + borderSize); - overlayPanel.setSize(cardWidth - borderSize * 2, cardHeight - borderSize * 2); - } else { - overlayPanel.setVisible(false); - } - - int fontHeight = Math.round(cardHeight * (27f / 680)); - boolean showText = (!isAnimationPanel && fontHeight < 12); - titleText.setVisible(showText); - ptText.setVisible(showText); + public void layout() { + int borderSize = Math.round(cardWidth * BLACK_BORDER_SIZE); + imagePanel.setLocation(cardXOffset + borderSize, cardYOffset + borderSize); + imagePanel.setSize(cardWidth - borderSize * 2, cardHeight - borderSize * 2); - int titleX = Math.round(cardWidth * (20f / 480)); - int titleY = Math.round(cardHeight * (9f / 680)); - titleText.setBounds(cardXOffset + titleX, cardYOffset + titleY, cardWidth - titleX, cardHeight); + if (hasSickness && CardUtil.isCreature(gameCard) && isPermanent) { + overlayPanel.setLocation(cardXOffset + borderSize, cardYOffset + borderSize); + overlayPanel.setSize(cardWidth - borderSize * 2, cardHeight - borderSize * 2); + } else { + overlayPanel.setVisible(false); + } - Dimension ptSize = ptText.getPreferredSize(); - ptText.setSize(ptSize.width, ptSize.height); - int ptX = Math.round(cardWidth * (420f / 480)) - ptSize.width / 2; - int ptY = Math.round(cardHeight * (675f / 680)) - ptSize.height; - - int offsetX = Math.round((CARD_SIZE_FULL.width - cardWidth) / 10.0f); - - ptText.setLocation(cardXOffset + ptX - TEXT_GLOW_SIZE / 2 - offsetX, cardYOffset + ptY - TEXT_GLOW_SIZE / 2); + int fontHeight = Math.round(cardHeight * (27f / 680)); + boolean showText = (!isAnimationPanel && fontHeight < 12); + titleText.setVisible(showText); + ptText.setVisible(showText); - if (isAnimationPanel || cardWidth < 200) - imagePanel.setScalingType(ScalingType.nearestNeighbor); - else - imagePanel.setScalingType(ScalingType.bilinear); - } + int titleX = Math.round(cardWidth * (20f / 480)); + int titleY = Math.round(cardHeight * (9f / 680)); + titleText.setBounds(cardXOffset + titleX, cardYOffset + titleY, cardWidth - titleX, cardHeight); - public String toString () { - return gameCard.toString(); - } + Dimension ptSize = ptText.getPreferredSize(); + ptText.setSize(ptSize.width, ptSize.height); + int ptX = Math.round(cardWidth * (420f / 480)) - ptSize.width / 2; + int ptY = Math.round(cardHeight * (675f / 680)) - ptSize.height; - @Override - public void setCardBounds (int x, int y, int width, int height) { - cardWidth = width; - cardHeight = height; - int rotCenterX = Math.round(width / 2f); - int rotCenterY = height - rotCenterX; - int rotCenterToTopCorner = Math.round(width * CardPanel.rotCenterToTopCorner); - int rotCenterToBottomCorner = Math.round(width * CardPanel.rotCenterToBottomCorner); - int xOffset = rotCenterX - rotCenterToBottomCorner; - int yOffset = rotCenterY - rotCenterToTopCorner; - cardXOffset = -xOffset; - cardYOffset = -yOffset; - width = -xOffset + rotCenterX + rotCenterToTopCorner; - height = -yOffset + rotCenterY + rotCenterToBottomCorner; - setBounds(x + xOffset, y + yOffset, width, height); - } + int offsetX = Math.round((CARD_SIZE_FULL.width - cardWidth) / 10.0f); - public void repaint () { - Rectangle b = getBounds(); - JRootPane rootPane = SwingUtilities.getRootPane(this); - if (rootPane == null) return; - Point p = SwingUtilities.convertPoint(getParent(), b.x, b.y, rootPane); - rootPane.repaint(p.x, p.y, b.width, b.height); - } + ptText.setLocation(cardXOffset + ptX - TEXT_GLOW_SIZE / 2 - offsetX, cardYOffset + ptY - TEXT_GLOW_SIZE / 2); - public int getCardX () { - return getX() + cardXOffset; - } + if (isAnimationPanel || cardWidth < 200) + imagePanel.setScalingType(ScalingType.nearestNeighbor); + else + imagePanel.setScalingType(ScalingType.bilinear); + } - public int getCardY () { - return getY() + cardYOffset; - } + public String toString() { + return gameCard.toString(); + } - public int getCardWidth () { - return cardWidth; - } + @Override + public void setCardBounds(int x, int y, int width, int height) { + cardWidth = width; + cardHeight = height; + int rotCenterX = Math.round(width / 2f); + int rotCenterY = height - rotCenterX; + int rotCenterToTopCorner = Math.round(width * CardPanel.rotCenterToTopCorner); + int rotCenterToBottomCorner = Math.round(width * CardPanel.rotCenterToBottomCorner); + int xOffset = rotCenterX - rotCenterToBottomCorner; + int yOffset = rotCenterY - rotCenterToTopCorner; + cardXOffset = -xOffset; + cardYOffset = -yOffset; + width = -xOffset + rotCenterX + rotCenterToTopCorner; + height = -yOffset + rotCenterY + rotCenterToBottomCorner; + setBounds(x + xOffset, y + yOffset, width, height); + } - public int getCardHeight () { - return cardHeight; - } + public void repaint() { + Rectangle b = getBounds(); + JRootPane rootPane = SwingUtilities.getRootPane(this); + if (rootPane == null) return; + Point p = SwingUtilities.convertPoint(getParent(), b.x, b.y, rootPane); + rootPane.repaint(p.x, p.y, b.width, b.height); + } - public Point getCardLocation () { - Point p = getLocation(); - p.x += cardXOffset; - p.y += cardYOffset; - return p; - } + public int getCardX() { + return getX() + cardXOffset; + } - public CardView getCard() { - return this.gameCard; - } - - @Override - public void setAlpha(float alpha) { - this.alpha = alpha; + public int getCardY() { + return getY() + cardYOffset; + } + + public int getCardWidth() { + return cardWidth; + } + + public int getCardHeight() { + return cardHeight; + } + + public Point getCardLocation() { + Point p = getLocation(); + p.x += cardXOffset; + p.y += cardYOffset; + return p; + } + + public CardView getCard() { + return this.gameCard; + } + + @Override + public void setAlpha(float alpha) { + this.alpha = alpha; if (alpha == 0) { this.ptText.setVisible(false); this.titleText.setVisible(false); @@ -421,272 +462,274 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti this.ptText.setVisible(true); this.titleText.setVisible(true); } - } - - public float getAlpha() { - return alpha; - } - - public int getCardXOffset() { - return cardXOffset; - } - - public int getCardYOffset() { - return cardYOffset; - } - - public void updateImage() { - if (!hasImage) { - Util.threadPool.submit(new Runnable() { - public void run () { - //TODO: BufferedImage srcImage = ImageCache.getImageOriginal(gameCard); - //BufferedImage srcImage = null; - //tappedAngle = isTapped() ? CardPanel.TAPPED_ANGLE : 0; - /*if (srcImage != null) { - hasImage = true; - setText(gameCard); - setImage(srcImage, srcImage); - }*/ - } - }); - } - } - - @Override - public List getLinks() { - return links; - } - - @Override - public boolean isTapped() { - if (isPermanent) { - return ((PermanentView)gameCard).isTapped(); - } - return false; - } - - @Override - public void onBeginAnimation() { - } - - @Override - public void onEndAnimation() { - } - - @Override - public void update(CardView card) { - if (isPermanent) { - if (isTapped() != ((PermanentView)card).isTapped()) { - Animation.tapCardToggle(this, this); - } - } - if (CardUtil.isCreature(card) && CardUtil.isPlaneswalker(card)) { - ptText.setText(card.getPower() + "/" + card.getToughness() + " (" + card.getLoyalty() + ")"); - } else if (CardUtil.isCreature(card)) { - ptText.setText(card.getPower() + "/" + card.getToughness()); - } else if (CardUtil.isPlaneswalker(card)) { - ptText.setText(card.getLoyalty()); - } else { - ptText.setText(""); - } - setText(card); - this.gameCard = card; - - String cardType = getType(card); - popupText.setText(getText(cardType, card)); - - if (hasSickness && CardUtil.isCreature(gameCard) && isPermanent) { - overlayPanel.setVisible(true); - } else { - overlayPanel.setVisible(false); - } - - repaint(); - } - - @Override - public boolean contains(int x, int y) { - if (containsThis(x, y, true)) return true; - - /* - * if (attachedCount > 0) { for (MWCardImpl card : - * mwAttachedCards.keySet()) { if (card.contains(x, y)) return true; } } - */ - - return false; - } - - public boolean containsThis(int x, int y, boolean root) { - //log.info("x="+x+", y="+y); - Point component = getLocation(); - - //int dy = component.y; - //if (root) dy = 0; - - int cx = getCardX() - component.x; - int cy = getCardY() - component.y; - int cw = getCardWidth(); - int ch = getCardHeight(); - if (isTapped()) { - cy = ch - cw + cx /*+ attachedDy*attachedCount*/; - ch = cw; - cw = getCardHeight(); - } - //int dx = drawIcons ? 19 : 0; - //int dx = 0; - - if (x >= cx && x <= cx + cw && y >= cy && y <= cy + ch) { - //log.info("!cx="+cx+", cy="+cy+", dx="+cw +", ch="+ch); - //log.info(getOriginal().getId()); - return true; - } else { - //log.info("cx="+cx+", cy="+cy+", dx="+cw +", ch="+ch); - } - return false; } - - @Override - public CardView getOriginal() { - return this.gameCard; - } - @Override - public Image getImage() { - return ImageCache.getImageOriginal(gameCard); - } + public float getAlpha() { + return alpha; + } - @Override - public void mouseClicked(MouseEvent e) { - } + public int getCardXOffset() { + return cardXOffset; + } - @Override - public void mouseEntered(MouseEvent e) { - if (!popupShowing) { - synchronized (this) { - if (!popupShowing) { - popupShowing = true; - callback.mouseEntered(e, getTransferDataForMouseEntered()); - } - } - } - } - - @Override - public void mouseDragged(MouseEvent e) {} + public int getCardYOffset() { + return cardYOffset; + } - @Override - public void mouseMoved(MouseEvent e) { - data.component = this; - callback.mouseMoved(e, data); - } + public void updateImage() { + if (!hasImage) { + throw new IllegalStateException("Not implemented"); + //TODO: + /*Util.threadPool.submit(new Runnable() { + public void run () { + //BufferedImage srcImage = ImageCache.getImageOriginal(gameCard); + //BufferedImage srcImage = null; + //tappedAngle = isTapped() ? CardPanel.TAPPED_ANGLE : 0; + if (srcImage != null) { + hasImage = true; + setText(gameCard); + setImage(srcImage, srcImage); + } + } + });*/ + } + } - @Override - public void mouseExited(MouseEvent e) { - if(getMousePosition(true) != null) return; - if (popupShowing) { - synchronized (this) { - if (popupShowing) { - popupShowing = false; - data.component = this; - data.card = this.gameCard; - data.popupText = popupText; - callback.mouseExited(e, data); - } - } - } - } + @Override + public List getLinks() { + return links; + } - @Override - public void mousePressed(MouseEvent e) { - data.component = this; - data.card = this.gameCard; - data.gameId = this.gameId; - callback.mousePressed(e, data); - } + @Override + public boolean isTapped() { + if (isPermanent) { + return ((PermanentView) gameCard).isTapped(); + } + return false; + } - @Override - public void mouseReleased(MouseEvent e) {} + @Override + public void onBeginAnimation() { + } - /** - * Prepares data to be sent to action callback on client side. - * - * @return - */ - private TransferData getTransferDataForMouseEntered() { - data.component = this; - data.card = this.gameCard; - data.popupText = popupText; - data.popupOffsetX = isTapped() ? cardHeight + cardXOffset + POPUP_X_GAP : cardWidth + cardXOffset + POPUP_X_GAP; - data.popupOffsetY = 40; - data.locationOnScreen = this.getLocationOnScreen(); - return data; - } - - protected String getType(CardView card) { - StringBuilder sbType = new StringBuilder(); + @Override + public void onEndAnimation() { + } - for (String superType: card.getSuperTypes()) { - sbType.append(superType).append(" "); - } + @Override + public void update(CardView card) { + if (isPermanent) { + if (isTapped() != ((PermanentView) card).isTapped()) { + Animation.tapCardToggle(this, this); + } + } + if (CardUtil.isCreature(card) && CardUtil.isPlaneswalker(card)) { + ptText.setText(card.getPower() + "/" + card.getToughness() + " (" + card.getLoyalty() + ")"); + } else if (CardUtil.isCreature(card)) { + ptText.setText(card.getPower() + "/" + card.getToughness()); + } else if (CardUtil.isPlaneswalker(card)) { + ptText.setText(card.getLoyalty()); + } else { + ptText.setText(""); + } + setText(card); + this.gameCard = card; - for (mage.Constants.CardType cardType: card.getCardTypes()) { - sbType.append(cardType.toString()).append(" "); - } + String cardType = getType(card); + popupText.setText(getText(cardType, card)); - if (card.getSubTypes().size() > 0) { - sbType.append("- "); - for (String subType: card.getSubTypes()) { - sbType.append(subType).append(" "); - } - } + if (hasSickness && CardUtil.isCreature(gameCard) && isPermanent) { + overlayPanel.setVisible(true); + } else { + overlayPanel.setVisible(false); + } - return sbType.toString(); - } - - protected String getText(String cardType, CardView card) { - StringBuilder sb = new StringBuilder(); - if (card instanceof StackAbilityView || card instanceof AbilityView) { - for (String rule: card.getRules()) { - sb.append("\n").append(rule); - } - } - else { - sb.append(card.getName()); - if (card.getManaCost().size() > 0) { - sb.append("\n").append(card.getManaCost()); - } - sb.append("\n").append(cardType); - if (card.getColor().hasColor()) { - sb.append("\n").append(card.getColor().toString()); - } - if (card.getCardTypes().contains(CardType.CREATURE)) { - sb.append("\n").append(card.getPower()).append("/").append(card.getToughness()); - } - else if (card.getCardTypes().contains(CardType.PLANESWALKER)) { - sb.append("\n").append(card.getLoyalty()); - } - for (String rule: card.getRules()) { - sb.append("\n").append(rule); - } - if (card.getExpansionSetCode() != null && card.getExpansionSetCode().length() > 0) { - sb.append("\n").append(card.getCardNumber()).append(" - "); - //sb.append(Sets.getInstance().get(card.getExpansionSetCode()).getName()).append(" - "); - sb.append(card.getExpansionSetCode()).append(" - "); - sb.append(card.getRarity().toString()); - } - } + repaint(); + } + + @Override + public boolean contains(int x, int y) { + if (containsThis(x, y, true)) return true; + + /* + * if (attachedCount > 0) { for (MWCardImpl card : + * mwAttachedCards.keySet()) { if (card.contains(x, y)) return true; } } + */ + + return false; + } + + public boolean containsThis(int x, int y, boolean root) { + //log.info("x="+x+", y="+y); + Point component = getLocation(); + + //int dy = component.y; + //if (root) dy = 0; + + int cx = getCardX() - component.x; + int cy = getCardY() - component.y; + int cw = getCardWidth(); + int ch = getCardHeight(); + if (isTapped()) { + cy = ch - cw + cx /*+ attachedDy*attachedCount*/; + ch = cw; + cw = getCardHeight(); + } + //int dx = drawIcons ? 19 : 0; + //int dx = 0; + + if (x >= cx && x <= cx + cw && y >= cy && y <= cy + ch) { + //log.info("!cx="+cx+", cy="+cy+", dx="+cw +", ch="+ch); + //log.info(getOriginal().getId()); + return true; + } else { + //log.info("cx="+cx+", cy="+cy+", dx="+cw +", ch="+ch); + } + return false; + } + + @Override + public CardView getOriginal() { + return this.gameCard; + } + + @Override + public Image getImage() { + return ImageCache.getImageOriginal(gameCard); + } + + @Override + public void mouseClicked(MouseEvent e) { + } + + @Override + public void mouseEntered(MouseEvent e) { + if (!popupShowing) { + synchronized (this) { + if (!popupShowing) { + popupShowing = true; + callback.mouseEntered(e, getTransferDataForMouseEntered()); + } + } + } + } + + @Override + public void mouseDragged(MouseEvent e) { + } + + @Override + public void mouseMoved(MouseEvent e) { + data.component = this; + callback.mouseMoved(e, data); + } + + @Override + public void mouseExited(MouseEvent e) { + if (getMousePosition(true) != null) return; + if (popupShowing) { + synchronized (this) { + if (popupShowing) { + popupShowing = false; + data.component = this; + data.card = this.gameCard; + data.popupText = popupText; + callback.mouseExited(e, data); + } + } + } + } + + @Override + public void mousePressed(MouseEvent e) { + data.component = this; + data.card = this.gameCard; + data.gameId = this.gameId; + callback.mousePressed(e, data); + } + + @Override + public void mouseReleased(MouseEvent e) { + } + + /** + * Prepares data to be sent to action callback on client side. + * + * @return + */ + private TransferData getTransferDataForMouseEntered() { + data.component = this; + data.card = this.gameCard; + data.popupText = popupText; + data.popupOffsetX = isTapped() ? cardHeight + cardXOffset + POPUP_X_GAP : cardWidth + cardXOffset + POPUP_X_GAP; + data.popupOffsetY = 40; + data.locationOnScreen = this.getLocationOnScreen(); + return data; + } + + protected String getType(CardView card) { + StringBuilder sbType = new StringBuilder(); + + for (String superType : card.getSuperTypes()) { + sbType.append(superType).append(" "); + } + + for (mage.Constants.CardType cardType : card.getCardTypes()) { + sbType.append(cardType.toString()).append(" "); + } + + if (card.getSubTypes().size() > 0) { + sbType.append("- "); + for (String subType : card.getSubTypes()) { + sbType.append(subType).append(" "); + } + } + + return sbType.toString(); + } + + protected String getText(String cardType, CardView card) { + StringBuilder sb = new StringBuilder(); + if (card instanceof StackAbilityView || card instanceof AbilityView) { + for (String rule : card.getRules()) { + sb.append("\n").append(rule); + } + } else { + sb.append(card.getName()); + if (card.getManaCost().size() > 0) { + sb.append("\n").append(card.getManaCost()); + } + sb.append("\n").append(cardType); + if (card.getColor().hasColor()) { + sb.append("\n").append(card.getColor().toString()); + } + if (card.getCardTypes().contains(CardType.CREATURE)) { + sb.append("\n").append(card.getPower()).append("/").append(card.getToughness()); + } else if (card.getCardTypes().contains(CardType.PLANESWALKER)) { + sb.append("\n").append(card.getLoyalty()); + } + for (String rule : card.getRules()) { + sb.append("\n").append(rule); + } + if (card.getExpansionSetCode() != null && card.getExpansionSetCode().length() > 0) { + sb.append("\n").append(card.getCardNumber()).append(" - "); + //sb.append(Sets.getInstance().get(card.getExpansionSetCode()).getName()).append(" - "); + sb.append(card.getExpansionSetCode()).append(" - "); + sb.append(card.getRarity().toString()); + } + } // sb.append("\n").append(card.getId()); - return sb.toString(); - } + return sb.toString(); + } - @Override - public void update(PermanentView card) { - update((CardView)card); - this.hasSickness = card.hasSummoningSickness(); - } + @Override + public void update(PermanentView card) { + update((CardView) card); + this.hasSickness = card.hasSummoningSickness(); + } - @Override - public PermanentView getOriginalPermanent() { - throw new IllegalStateException("Is not permanent."); - } + @Override + public PermanentView getOriginalPermanent() { + throw new IllegalStateException("Is not permanent."); + } } diff --git a/Mage.Plugins/Mage.Card.Plugin/src/main/java/org/mage/card/arcane/ManaSymbols.java b/Mage.Plugins/Mage.Card.Plugin/src/main/java/org/mage/card/arcane/ManaSymbols.java index 9ca2ca45bf..fea218b638 100644 --- a/Mage.Plugins/Mage.Card.Plugin/src/main/java/org/mage/card/arcane/ManaSymbols.java +++ b/Mage.Plugins/Mage.Card.Plugin/src/main/java/org/mage/card/arcane/ManaSymbols.java @@ -27,11 +27,10 @@ public class ManaSymbols { "BR", "G", "GU", "GW", "R", "RG", "RW", "S", "T", "U", "UB", "UR", "W", "WB", "WU", "X", "Y", "Z", "slash"}; for (String symbol : symbols) { File file = new File(Constants.RESOURCE_PATH_MANA_LARGE + "/" + symbol + ".jpg"); - BufferedImageBuilder builder = new BufferedImageBuilder(); Rectangle r = new Rectangle(11, 11); try { Image image = UI.getImageIcon(file.getAbsolutePath()).getImage(); - BufferedImage resized = ImageCache.getResizedImage(builder.bufferImage(image, BufferedImage.TYPE_INT_ARGB), r); + BufferedImage resized = ImageCache.getResizedImage(BufferedImageBuilder.bufferImage(image, BufferedImage.TYPE_INT_ARGB), r); manaImages.put(symbol, resized); } catch (Exception e) {} file = new File(Constants.RESOURCE_PATH_MANA_MEDIUM + "/" + symbol + ".jpg"); diff --git a/Mage.Plugins/Mage.Card.Plugin/src/main/java/org/mage/card/arcane/ScaledImagePanel.java b/Mage.Plugins/Mage.Card.Plugin/src/main/java/org/mage/card/arcane/ScaledImagePanel.java index 7f7656c7e3..0e6093141f 100644 --- a/Mage.Plugins/Mage.Card.Plugin/src/main/java/org/mage/card/arcane/ScaledImagePanel.java +++ b/Mage.Plugins/Mage.Card.Plugin/src/main/java/org/mage/card/arcane/ScaledImagePanel.java @@ -11,7 +11,7 @@ import javax.swing.JPanel; public class ScaledImagePanel extends JPanel { private static final long serialVersionUID = -1523279873208605664L; public volatile Image srcImage; - public volatile Image srcImageBlurred; + //public volatile Image srcImageBlurred; private ScalingType scalingType = ScalingType.bilinear; private boolean scaleLarger; @@ -23,9 +23,8 @@ public class ScaledImagePanel extends JPanel { setOpaque(false); } - public void setImage (Image srcImage, Image srcImageBlurred) { + public void setImage(Image srcImage) { this.srcImage = srcImage; - this.srcImageBlurred = srcImageBlurred; } public void clearImage () { @@ -168,9 +167,10 @@ public class ScaledImagePanel extends JPanel { } private Image getSourceImage (ScalingInfo info) { - if (!blur || srcImageBlurred == null) return srcImage; - if (info.srcWidth / 2 < info.targetWidth || info.srcHeight / 2 < info.targetHeight) return srcImage; - return srcImageBlurred; + return srcImage; + //if (!blur || srcImageBlurred == null) return srcImage; + //if (info.srcWidth / 2 < info.targetWidth || info.srcHeight / 2 < info.targetHeight) return srcImage; + //return srcImageBlurred; } public Image getSrcImage() { diff --git a/Mage.Plugins/Mage.Card.Plugin/src/main/java/org/mage/plugins/card/CardPluginImpl.java b/Mage.Plugins/Mage.Card.Plugin/src/main/java/org/mage/plugins/card/CardPluginImpl.java index 9fec2f9d2c..e1cf3a8e6b 100644 --- a/Mage.Plugins/Mage.Card.Plugin/src/main/java/org/mage/plugins/card/CardPluginImpl.java +++ b/Mage.Plugins/Mage.Card.Plugin/src/main/java/org/mage/plugins/card/CardPluginImpl.java @@ -6,12 +6,7 @@ import java.awt.Image; import java.awt.Rectangle; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.UUID; +import java.util.*; import javax.swing.JComponent; import javax.swing.JDialog; @@ -92,7 +87,8 @@ public class CardPluginImpl implements CardPlugin { @Override public MagePermanent getMagePermanent(PermanentView permanent, CardDimensions dimension, UUID gameId, ActionCallback callback) { - CardPanel cardPanel = new CardPanel(permanent, gameId, true, callback); + boolean foil = (new Random()).nextInt(5) == 0; + CardPanel cardPanel = new CardPanel(permanent, gameId, true, callback, foil); cardPanel.setShowCastingCost(true); cardPanel.setCardBounds(0, 0, dimension.frameWidth, dimension.frameHeight); cardPanel.setShowCastingCost(true); @@ -101,10 +97,12 @@ public class CardPluginImpl implements CardPlugin { @Override public MagePermanent getMageCard(CardView permanent, CardDimensions dimension, UUID gameId, ActionCallback callback) { - CardPanel cardPanel = new CardPanel(permanent, gameId, true, callback); + boolean foil = (new Random()).nextInt(5) == 0; + CardPanel cardPanel = new CardPanel(permanent, gameId, true, callback, foil); cardPanel.setShowCastingCost(true); cardPanel.setCardBounds(0, 0, dimension.frameWidth, dimension.frameHeight); cardPanel.setShowCastingCost(true); + return cardPanel; } diff --git a/Mage.Plugins/Mage.Card.Plugin/src/main/java/org/mage/plugins/card/utils/BufferedImageBuilder.java b/Mage.Plugins/Mage.Card.Plugin/src/main/java/org/mage/plugins/card/utils/BufferedImageBuilder.java index cc0890cdc5..bf254d5768 100644 --- a/Mage.Plugins/Mage.Card.Plugin/src/main/java/org/mage/plugins/card/utils/BufferedImageBuilder.java +++ b/Mage.Plugins/Mage.Card.Plugin/src/main/java/org/mage/plugins/card/utils/BufferedImageBuilder.java @@ -5,15 +5,27 @@ import java.awt.Image; import java.awt.image.BufferedImage; import java.awt.image.ImageObserver; +/** + * Utility class for creating BufferedImage object from Image instance. + * + * @author nantuko + */ public class BufferedImageBuilder { private static final int DEFAULT_IMAGE_TYPE = BufferedImage.TYPE_INT_RGB; - public BufferedImage bufferImage(Image image) { + /** + * Hide constructor + */ + private BufferedImageBuilder() { + + } + + public static BufferedImage bufferImage(Image image) { return bufferImage(image, DEFAULT_IMAGE_TYPE); } - public BufferedImage bufferImage(Image image, int type) { + public static BufferedImage bufferImage(Image image, int type) { BufferedImage bufferedImage = new BufferedImage(image.getWidth(null), image.getHeight(null), type); Graphics2D g = bufferedImage.createGraphics(); g.drawImage(image, null, null); diff --git a/Mage.Plugins/Mage.Card.Plugin/src/main/java/org/mage/plugins/card/utils/impl/ImageManagerImpl.java b/Mage.Plugins/Mage.Card.Plugin/src/main/java/org/mage/plugins/card/utils/impl/ImageManagerImpl.java index 4c8bff7620..ba66868468 100644 --- a/Mage.Plugins/Mage.Card.Plugin/src/main/java/org/mage/plugins/card/utils/impl/ImageManagerImpl.java +++ b/Mage.Plugins/Mage.Card.Plugin/src/main/java/org/mage/plugins/card/utils/impl/ImageManagerImpl.java @@ -29,8 +29,7 @@ public class ImageManagerImpl implements ImageManager { Image image = getImageFromResourceTransparent("/sickness.png", Color.WHITE, new Rectangle(296, 265)); Toolkit tk = Toolkit.getDefaultToolkit(); image = tk.createImage(new FilteredImageSource(image.getSource(), new CropImageFilter(0, 0, 200, 285))); - BufferedImageBuilder builder = new BufferedImageBuilder(); - imageSickness = builder.bufferImage(image, BufferedImage.TYPE_INT_ARGB); + imageSickness = BufferedImageBuilder.bufferImage(image, BufferedImage.TYPE_INT_ARGB); } return imageSickness; }