From fb8cd79b5991d870e02b522b83e5cba44ca8d0d2 Mon Sep 17 00:00:00 2001 From: magenoxx Date: Fri, 1 Apr 2011 17:35:38 +0400 Subject: [PATCH] More efficient use of background image. Now Mage takes much less memory. Also updated plugins in Mage.Tests. --- Mage.Client/plugins/mage-theme-plugin.jar | Bin 3801495 -> 3801639 bytes .../mage/plugins/theme/ThemePluginImpl.java | 61 +++++++++++------- Mage.Tests/plugins/mage-player-ai-ma.jar | Bin 43117 -> 43117 bytes Mage.Tests/plugins/mage-player-aiminimax.jar | Bin 40051 -> 40051 bytes .../mage/test/serverside/PlayGameTest.java | 18 +++--- 5 files changed, 45 insertions(+), 34 deletions(-) diff --git a/Mage.Client/plugins/mage-theme-plugin.jar b/Mage.Client/plugins/mage-theme-plugin.jar index 7c8ad4dbe7b71b0b9cc080f51f3826ba7a754d66..54a15502b12fda8f6ff30cd2a67c62aca385111f 100644 GIT binary patch delta 2989 zcmZA3c|25m9|v#-S%)#!v9DztX4Q=Bq=>O6A(xqwEG4pC%(Y}2LW3z+N-;uq8FaN7 zgqmn^MY5GOd-m-)JkNce*Xud2*ZX|Gzw`V3Ua#{z=bsNPeu}*$VTv7WcZP$LkL}=E zr^IG~RXEmwg304J81>2@mKBwQLX~3II;@uLsDnlEG3-e(><2&q4ge>B3vdL$4d4Or z0{8&@0096PAP5iwKmfu3C_n@t3J?Q`10(>F02n|DAPtZK$O7a5@&E;ZB0veC3{U~6 z0*(TX0n`BM01bd9K#LK>4)+&5czMR07`zI6*xgr#XK)Jw2Q++X)bH?vhmGwCl%}r< zN0EzNw#lL{V*9N5qjg`bPxnIZz8eVy|pv=^%GC+p~g zhJk@ptBR|BZueJXD|A53u@6sDOeZi9qnjg%@F7LQFs#K%6GL|J4SmX8H1YHUV9JbA__CQ<6iK2A~i z1l91f?oouF1wvz*rhmIQN5K=EH=1!#W{c72WQn+qvyfrIu@f54rA@h6e7Os}iAi~$T=}w%tWITLBo-p--q|jG%Fmq^rpTo=O=nO{3OP z`Eom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;)0~qigCcV;82`YkP-4EcJamqXdUE#rg}l1xrs4rz4jqo4)l6csL7ar=7W@`M%;fmq_mqY>roM0N z7kpb@>$3-B3bJd9ljr|_QA_Xd)IFgl$WBTgtr5c+I>GbVbU(!@)bk7l)@+)6R!wlw zlw25^qqdlZd$P0}*}XKN;LlEQdYrlxRxAFA$c=Da+T2ai*6Oi|f`% zU4Yh@wYC9Uh1~?#sP8zTb;7uH;$~}W$*rgHj8`0R^7h(pE+v$SO2jQ+M*Gt!-%V00 z`E9$Owx`U@sDTrv&)<>bk8R%E?A!esg#1ye$Zb3B3A?hn>IB6VTfZwq)Li@VXOy1} zY4goq5B-A@m4dMO`wB8is53^WLwr`)*k8S*XLk-`gv*&)3G&}Z1cr21PS$W=F0P$P zt_$N&&AM`ef)S=pEI2kkd>AEuS^p`ic|Cx2imx+WVckwpI>ADY%!-e={MfkCQ7Pwk z-KzXp7-o+duUSx&_g&uYowt6^;?dt$Jt0Tkrbppl@@L~?l1g26`GTte%t zZ5-}>g!qBBv>{X{q0R0^Jm4KD9DMdY3385&MBOY7*Rt z?E2)ukJt%8r%iW7Zv;h-z__QSx&z_%O^=3_@1TuPq0VYO-Xfd6Oi2m^UjC=j{7-pr zii{fQ=;fN7X9+X_!_AvIuSkiSn+kCMAAl*$o;|?WIH8WJtc8T0i&Vqmis${ z7So-qa3!4u#~Vqwm(1WNATQ7eXC}dgEQFi=G)IwckEViId?65P@&&&7kR; ze!r=L^6v^Y&ydQsNM+MCwk>mV!U1GRJO1SWLLWCtWbQ) 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 3a85551f388a3133efe9010e476eda6cd5222488..88a538f3818439ac2a03987b61b5965b212a73b9 100644 GIT binary patch delta 475 zcmaERf$8l9Cf)#VW)?065LmLYVj`~!^I{-nG6hVXRsd7))R}>DlO-6nz_cr)E{NV- z%J`HCB)>V9%G%cUkym@78<|9lN@UeO+&wLCm)e9nkYHd+t_(l@z%feFa(llLvK z2k|E@Gyn@5FEj_!xeKkp^s0rnVEWZUFEDMsC=g6{L+SgA{K0&~#Srn<#Ss4W#qMBn z#U;UDx_n6#n7*L3D6OyzB3`r%qAqu#9(GKCq$JFNhw-l>DA$r6lOAbPVa<0B?8 zLyKi2gmI6}k(m!DWp}XRRM!-J28N62ll5(tHwSPn)d#EmVX4UsW~kWq%Yzx)V!p9} z8S4|hc)*N5xe*Z4!V7jm7$U_nVqmG_&SX|F<7VG%u+-%8iD0)(UNX@bEOBe%NhS`E z3$DDsQZ;$?lr%0Mk)ED4JiTjt&Pi6X^}#BCSZXqZ87j8@@?gfcm~Sj# z#`;7r9x&riZUn@%@Pb_shDdRY7+9*fGnp04xY;)wEH$}&BG@gHmrOJUOWc}xl8FQ4 zg2M-ueoS6HC5?+$w1;Oc56>DN-O18Z!$FEBmrgYS`EK%>srF$0yQv0XT5*~=m_9H| za&pNuMKF8DG*2-7WLhAYwwMl~d#3w?`S+lFqZtr>%M3TL_}LjjU|MNrFqp2G36Vbq irDbOMfyHxY1%T-Tv#h}M-&xLJ+IjXKgg@Bl7YFT 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); }