diff --git a/Mage.Client/plugins/mage-theme-plugin.jar b/Mage.Client/plugins/mage-theme-plugin.jar index 7c8ad4dbe7..54a15502b1 100644 Binary files a/Mage.Client/plugins/mage-theme-plugin.jar and b/Mage.Client/plugins/mage-theme-plugin.jar differ diff --git a/Mage.Plugins/Mage.Theme.Plugin/src/main/java/org/mage/plugins/theme/ThemePluginImpl.java b/Mage.Plugins/Mage.Theme.Plugin/src/main/java/org/mage/plugins/theme/ThemePluginImpl.java index d557c97ac8..a6bb182ce8 100644 --- a/Mage.Plugins/Mage.Theme.Plugin/src/main/java/org/mage/plugins/theme/ThemePluginImpl.java +++ b/Mage.Plugins/Mage.Theme.Plugin/src/main/java/org/mage/plugins/theme/ThemePluginImpl.java @@ -1,6 +1,6 @@ package org.mage.plugins.theme; -import java.awt.Color; +import java.awt.*; import java.awt.image.BufferedImage; import java.io.FileNotFoundException; import java.io.InputStream; @@ -23,6 +23,7 @@ import org.apache.log4j.Logger; public class ThemePluginImpl implements ThemePlugin { private final static Logger log = Logger.getLogger(ThemePluginImpl.class); + private static BufferedImage background; @Init public void init() { @@ -73,33 +74,43 @@ public class ThemePluginImpl implements ThemePlugin { } } + public JComponent updateTable(Map ui) { - String filename = "/background.png"; - try { - InputStream is = this.getClass().getResourceAsStream(filename); + ImagePanel bgPanel = createImagePanelInstance(); - if (is == null) - throw new FileNotFoundException("Couldn't find " + filename + " in resources."); - - BufferedImage background = ImageIO.read(is); - - if (background == null) - throw new FileNotFoundException("Couldn't find " + filename + " in resources."); - - ImagePanel bgPanel = new ImagePanel(background, ImagePanel.SCALED); - - unsetOpaque(ui.get("jScrollPane1")); - unsetOpaque(ui.get("jPanel1")); - unsetOpaque(ui.get("tablesPanel")); - JComponent viewport = ui.get("jScrollPane1ViewPort"); - if (viewport != null) { - viewport.setBackground(new Color(255,255,255,50)); - } - return bgPanel; - } catch (Exception e) { - log.error(e.getMessage(), e); - return null; + unsetOpaque(ui.get("jScrollPane1")); + unsetOpaque(ui.get("jPanel1")); + unsetOpaque(ui.get("tablesPanel")); + JComponent viewport = ui.get("jScrollPane1ViewPort"); + if (viewport != null) { + viewport.setBackground(new Color(255,255,255,50)); } + return bgPanel; + } + + private ImagePanel createImagePanelInstance() { + if (background == null) { + synchronized (ThemePluginImpl.class) { + if (background == null) { + String filename = "/background.png"; + try { + InputStream is = this.getClass().getResourceAsStream(filename); + + if (is == null) + throw new FileNotFoundException("Couldn't find " + filename + " in resources."); + + background = ImageIO.read(is); + + if (background == null) + throw new FileNotFoundException("Couldn't find " + filename + " in resources."); + } catch (Exception e) { + log.error(e.getMessage(), e); + return null; + } + } + } + } + return new ImagePanel(background, ImagePanel.SCALED); } private void unsetOpaque(JComponent c) { diff --git a/Mage.Tests/plugins/mage-player-ai-ma.jar b/Mage.Tests/plugins/mage-player-ai-ma.jar index 3a85551f38..88a538f381 100644 Binary files a/Mage.Tests/plugins/mage-player-ai-ma.jar and b/Mage.Tests/plugins/mage-player-ai-ma.jar differ diff --git a/Mage.Tests/plugins/mage-player-aiminimax.jar b/Mage.Tests/plugins/mage-player-aiminimax.jar index 7db82c5297..0f40c73022 100644 Binary files a/Mage.Tests/plugins/mage-player-aiminimax.jar and b/Mage.Tests/plugins/mage-player-aiminimax.jar differ diff --git a/Mage.Tests/src/test/java/org/mage/test/serverside/PlayGameTest.java b/Mage.Tests/src/test/java/org/mage/test/serverside/PlayGameTest.java index 776ddd692c..4f89a832e1 100644 --- a/Mage.Tests/src/test/java/org/mage/test/serverside/PlayGameTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/serverside/PlayGameTest.java @@ -1,11 +1,14 @@ package org.mage.test.serverside; import mage.Constants; +import mage.Constants.ColoredManaSymbol; +import mage.cards.Card; import mage.cards.decks.Deck; import mage.game.Game; import mage.game.GameException; import mage.game.GameOptions; import mage.game.TwoPlayerDuel; +import mage.player.ai.ComputerPlayer; import mage.players.Player; import mage.sets.Sets; import org.junit.Test; @@ -16,16 +19,13 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Random; -import mage.Constants.ColoredManaSymbol; -import mage.cards.Card; -import mage.player.ai.ComputerPlayer; /** * @author ayratn */ public class PlayGameTest extends MageTestBase { - private static List colorChoices = Arrays.asList("bu","bg","br","bw","ug","ur","uw","gr","gw","rw","bur","buw","bug","brg","brw","bgw","wur","wug","wrg","rgu"); + private static List colorChoices = Arrays.asList("bu", "bg", "br", "bw", "ug", "ur", "uw", "gr", "gw", "rw", "bur", "buw", "bug", "brg", "brw", "bgw", "wur", "wug", "wrg", "rgu"); @Test public void playOneGame() throws GameException, FileNotFoundException, IllegalArgumentException { @@ -76,12 +76,12 @@ public class PlayGameTest extends MageTestBase { private Deck generateRandomDeck() { String selectedColors = colorChoices.get(new Random().nextInt(colorChoices.size())).toUpperCase(); - List allowedColors = new ArrayList(); + List allowedColors = new ArrayList(); logger.info("Building deck with colors: " + selectedColors); - for (int i = 0; i < selectedColors.length(); i++) { - char c = selectedColors.charAt(i); - allowedColors.add(ColoredManaSymbol.lookup(c)); - } + for (int i = 0; i < selectedColors.length(); i++) { + char c = selectedColors.charAt(i); + allowedColors.add(ColoredManaSymbol.lookup(c)); + } List cardPool = Sets.generateRandomCardPool(45, allowedColors); return ComputerPlayer.buildDeck(cardPool, allowedColors); }