diff --git a/Mage.Client/src/main/java/mage/client/MageFrame.java b/Mage.Client/src/main/java/mage/client/MageFrame.java index bec3728b3d..22bcd2c147 100644 --- a/Mage.Client/src/main/java/mage/client/MageFrame.java +++ b/Mage.Client/src/main/java/mage/client/MageFrame.java @@ -55,6 +55,7 @@ import mage.client.util.gui.ArrowBuilder; import mage.client.util.gui.countryBox.CountryUtil; import mage.client.util.stats.UpdateMemUsageTask; import mage.components.ImagePanel; +import mage.components.ImagePanelStyle; import mage.constants.PlayerAction; import mage.interfaces.MageClient; import mage.interfaces.callback.CallbackClient; @@ -426,7 +427,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient { } else { InputStream is = this.getClass().getResourceAsStream(filename); BufferedImage background = ImageIO.read(is); - backgroundPane = new ImagePanel(background, ImagePanel.SCALED); + backgroundPane = new ImagePanel(background, ImagePanelStyle.SCALED); } backgroundPane.setSize(1024, 768); desktopPane.add(backgroundPane, JLayeredPane.DEFAULT_LAYER); diff --git a/Mage.Client/src/main/java/mage/client/deckeditor/collection/viewer/MageBook.java b/Mage.Client/src/main/java/mage/client/deckeditor/collection/viewer/MageBook.java index 53283cffab..5bbb699088 100644 --- a/Mage.Client/src/main/java/mage/client/deckeditor/collection/viewer/MageBook.java +++ b/Mage.Client/src/main/java/mage/client/deckeditor/collection/viewer/MageBook.java @@ -44,6 +44,7 @@ import mage.client.util.NaturalOrderCardNumberComparator; import mage.client.util.audio.AudioManager; import mage.client.util.sets.ConstructedFormats; import mage.components.ImagePanel; +import mage.components.ImagePanelStyle; import mage.constants.Rarity; import mage.view.CardView; import org.apache.log4j.Logger; @@ -89,12 +90,12 @@ public class MageBook extends JComponent { setMinimumSize(new Dimension(conf.WIDTH, conf.HEIGHT)); //setBorder(BorderFactory.createLineBorder(Color.green)); - jPanelLeft = getImagePanel(LEFT_PANEL_IMAGE_PATH, ImagePanel.TILED); + jPanelLeft = getImagePanel(LEFT_PANEL_IMAGE_PATH, ImagePanelStyle.TILED); jPanelLeft.setPreferredSize(new Dimension(LEFT_RIGHT_PAGES_WIDTH, 0)); jPanelLeft.setLayout(null); - jPanelCenter = getImagePanel(CENTER_PANEL_IMAGE_PATH, ImagePanel.SCALED); + jPanelCenter = getImagePanel(CENTER_PANEL_IMAGE_PATH, ImagePanelStyle.SCALED); jPanelCenter.setLayout(new BorderLayout()); - jPanelRight = getImagePanel(RIGHT_PANEL_IMAGE_PATH, ImagePanel.TILED); + jPanelRight = getImagePanel(RIGHT_PANEL_IMAGE_PATH, ImagePanelStyle.TILED); jPanelRight.setPreferredSize(new Dimension(LEFT_RIGHT_PAGES_WIDTH, 0)); jPanelRight.setLayout(null); @@ -267,7 +268,7 @@ public class MageBook extends JComponent { return cards.subList(start, end); } - private ImagePanel getImagePanel(String filename, int type) { + private ImagePanel getImagePanel(String filename, ImagePanelStyle type) { try { InputStream is = this.getClass().getResourceAsStream(filename); diff --git a/Mage.Client/src/main/java/mage/client/game/PlayerPanelExt.java b/Mage.Client/src/main/java/mage/client/game/PlayerPanelExt.java index 3fea196ba7..f8cd746698 100644 --- a/Mage.Client/src/main/java/mage/client/game/PlayerPanelExt.java +++ b/Mage.Client/src/main/java/mage/client/game/PlayerPanelExt.java @@ -70,6 +70,7 @@ import mage.client.util.ImageHelper; import mage.client.util.gui.BufferedImageBuilder; import mage.client.util.gui.countryBox.CountryUtil; import mage.components.ImagePanel; +import mage.components.ImagePanelStyle; import mage.constants.CardType; import static mage.constants.Constants.DEFAULT_AVATAR_ID; import static mage.constants.Constants.MAX_AVATAR_ID; @@ -417,7 +418,7 @@ public class PlayerPanelExt extends javax.swing.JPanel { lifeLabel.setToolTipText("Life"); Image imageLife = ImageHelper.getImageFromResources("/info/life.png"); BufferedImage resizedLife = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(imageLife, BufferedImage.TYPE_INT_ARGB), r); - life = new ImagePanel(resizedLife, ImagePanel.ACTUAL); + life = new ImagePanel(resizedLife, ImagePanelStyle.ACTUAL); life.setToolTipText("Life"); life.setOpaque(false); // hand area @@ -425,7 +426,7 @@ public class PlayerPanelExt extends javax.swing.JPanel { handLabel.setToolTipText("Hand"); Image imageHand = ImageHelper.getImageFromResources("/info/hand.png"); BufferedImage resizedHand = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(imageHand, BufferedImage.TYPE_INT_ARGB), r); - hand = new ImagePanel(resizedHand, ImagePanel.ACTUAL); + hand = new ImagePanel(resizedHand, ImagePanelStyle.ACTUAL); hand.setToolTipText("Hand"); hand.setOpaque(false); @@ -435,7 +436,7 @@ public class PlayerPanelExt extends javax.swing.JPanel { poisonLabel.setToolTipText("Poison"); Image imagePoison = ImageHelper.getImageFromResources("/info/poison.png"); BufferedImage resizedPoison = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(imagePoison, BufferedImage.TYPE_INT_ARGB), r); - poison = new ImagePanel(resizedPoison, ImagePanel.ACTUAL); + poison = new ImagePanel(resizedPoison, ImagePanelStyle.ACTUAL); poison.setToolTipText("Poison"); poison.setOpaque(false); @@ -512,7 +513,7 @@ public class PlayerPanelExt extends javax.swing.JPanel { energyLabel.setToolTipText("Energy"); Image imageEnergy = ImageHelper.getImageFromResources("/info/energy.png"); BufferedImage resizedEnergy = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(imageEnergy, BufferedImage.TYPE_INT_ARGB), r); - energy = new ImagePanel(resizedEnergy, ImagePanel.ACTUAL); + energy = new ImagePanel(resizedEnergy, ImagePanelStyle.ACTUAL); energy.setToolTipText("Energy"); energy.setOpaque(false); @@ -522,7 +523,7 @@ public class PlayerPanelExt extends javax.swing.JPanel { experienceLabel.setToolTipText("Experience"); Image imageExperience = ImageHelper.getImageFromResources("/info/experience.png"); BufferedImage resizedExperience = ImageHelper.getResizedImage(BufferedImageBuilder.bufferImage(imageExperience, BufferedImage.TYPE_INT_ARGB), r); - experience = new ImagePanel(resizedExperience, ImagePanel.ACTUAL); + experience = new ImagePanel(resizedExperience, ImagePanelStyle.ACTUAL); experience.setToolTipText("Experience"); experience.setOpaque(false); diff --git a/Mage.Client/src/main/java/org/mage/card/arcane/CardPanelComponentImpl.java b/Mage.Client/src/main/java/org/mage/card/arcane/CardPanelComponentImpl.java index cbd208feab..1e9e227f62 100644 --- a/Mage.Client/src/main/java/org/mage/card/arcane/CardPanelComponentImpl.java +++ b/Mage.Client/src/main/java/org/mage/card/arcane/CardPanelComponentImpl.java @@ -7,6 +7,7 @@ import mage.client.dialog.PreferencesDialog; import mage.client.util.ImageCaches; import mage.client.util.ImageHelper; import mage.components.ImagePanel; +import mage.components.ImagePanelStyle; import mage.constants.AbilityType; import mage.utils.CardUtil; import mage.view.CardView; @@ -243,7 +244,7 @@ public class CardPanelComponentImpl extends CardPanel { // Sickness overlay BufferedImage sickness = ImageManagerImpl.getInstance().getSicknessImage(); - overlayPanel = new ImagePanel(sickness, ImagePanel.SCALED); + overlayPanel = new ImagePanel(sickness, ImagePanelStyle.SCALED); overlayPanel.setOpaque(false); add(overlayPanel); diff --git a/Mage.Client/src/main/java/org/mage/plugins/theme/ThemePluginImpl.java b/Mage.Client/src/main/java/org/mage/plugins/theme/ThemePluginImpl.java index f51fe8b54f..f5a6a60138 100644 --- a/Mage.Client/src/main/java/org/mage/plugins/theme/ThemePluginImpl.java +++ b/Mage.Client/src/main/java/org/mage/plugins/theme/ThemePluginImpl.java @@ -8,6 +8,7 @@ import javax.imageio.ImageIO; import javax.swing.*; import mage.client.dialog.PreferencesDialog; import mage.components.ImagePanel; +import mage.components.ImagePanelStyle; import mage.interfaces.plugin.ThemePlugin; import net.xeoh.plugins.base.annotations.PluginImplementation; import net.xeoh.plugins.base.annotations.events.Init; @@ -82,7 +83,7 @@ public class ThemePluginImpl implements ThemePlugin { } if (ui.containsKey("gamePanel") && ui.containsKey("jLayeredPane")) { - ImagePanel bgPanel = new ImagePanel(backgroundImage, ImagePanel.TILED); + ImagePanel bgPanel = new ImagePanel(backgroundImage, ImagePanelStyle.TILED); unsetOpaque(ui.get("jSplitPane1")); unsetOpaque(ui.get("pnlBattlefield")); @@ -190,7 +191,7 @@ public class ThemePluginImpl implements ThemePlugin { } } } - return new ImagePanel(background, ImagePanel.SCALED); + return new ImagePanel(background, ImagePanelStyle.SCALED); } private void unsetOpaque(JComponent c) { diff --git a/Mage.Common/src/mage/cards/CardDimensions.java b/Mage.Common/src/mage/cards/CardDimensions.java index 746f6a0042..f1d2e29b5f 100644 --- a/Mage.Common/src/mage/cards/CardDimensions.java +++ b/Mage.Common/src/mage/cards/CardDimensions.java @@ -31,7 +31,6 @@ package mage.cards; import static mage.constants.Constants.*; /** - * * @author BetaSteward_at_googlemail.com */ public class CardDimensions { @@ -51,19 +50,19 @@ public class CardDimensions { public int nameFontSize; public CardDimensions(double scaleFactor) { - frameHeight = (int)(FRAME_MAX_HEIGHT * scaleFactor); - frameWidth = (int)(FRAME_MAX_WIDTH * scaleFactor); - symbolHeight = (int)(SYMBOL_MAX_HEIGHT * scaleFactor); - symbolWidth = (int)(SYMBOL_MAX_WIDTH * scaleFactor); - contentXOffset = (int)(CONTENT_MAX_XOFFSET * scaleFactor); - nameYOffset = (int)(NAME_MAX_YOFFSET * scaleFactor); - typeYOffset = (int)(TYPE_MAX_YOFFSET * scaleFactor); - textYOffset = (int)(TEXT_MAX_YOFFSET * scaleFactor); - textWidth = (int)(TEXT_MAX_WIDTH * scaleFactor); - textHeight = (int)(TEXT_MAX_HEIGHT * scaleFactor); - powBoxTextTop = (int)(POWBOX_TEXT_MAX_TOP * scaleFactor); - powBoxTextLeft = (int)(POWBOX_TEXT_MAX_LEFT * scaleFactor); - nameFontSize = Math.max(9, (int)(NAME_FONT_MAX_SIZE * scaleFactor)); + frameHeight = (int) (FRAME_MAX_HEIGHT * scaleFactor); + frameWidth = (int) (FRAME_MAX_WIDTH * scaleFactor); + symbolHeight = (int) (SYMBOL_MAX_HEIGHT * scaleFactor); + symbolWidth = (int) (SYMBOL_MAX_WIDTH * scaleFactor); + contentXOffset = (int) (CONTENT_MAX_XOFFSET * scaleFactor); + nameYOffset = (int) (NAME_MAX_YOFFSET * scaleFactor); + typeYOffset = (int) (TYPE_MAX_YOFFSET * scaleFactor); + textYOffset = (int) (TEXT_MAX_YOFFSET * scaleFactor); + textWidth = (int) (TEXT_MAX_WIDTH * scaleFactor); + textHeight = (int) (TEXT_MAX_HEIGHT * scaleFactor); + powBoxTextTop = (int) (POWBOX_TEXT_MAX_TOP * scaleFactor); + powBoxTextLeft = (int) (POWBOX_TEXT_MAX_LEFT * scaleFactor); + nameFontSize = Math.max(9, (int) (NAME_FONT_MAX_SIZE * scaleFactor)); } } diff --git a/Mage.Common/src/mage/components/ImagePanel.java b/Mage.Common/src/mage/components/ImagePanel.java index f6263e6c04..c71e0dd654 100644 --- a/Mage.Common/src/mage/components/ImagePanel.java +++ b/Mage.Common/src/mage/components/ImagePanel.java @@ -9,20 +9,18 @@ import javax.swing.JViewport; @SuppressWarnings("serial") public class ImagePanel extends JPanel { - public static final int TILED = 0; - public static final int SCALED = 1; - public static final int ACTUAL = 2; + private BufferedImage image; - private int style; + private ImagePanelStyle style; private float alignmentX = 0.5f; private float alignmentY = 0.5f; public ImagePanel(BufferedImage image) { - this(image, TILED); + this(image, ImagePanelStyle.TILED); } - public ImagePanel(BufferedImage image, int style) { + public ImagePanel(BufferedImage image, ImagePanelStyle style) { this.image = image; this.style = style; setLayout(new BorderLayout()); @@ -65,18 +63,16 @@ public class ImagePanel extends JPanel { return; switch (style) { - case TILED: - drawTiled(g); - break; - - case SCALED: - Dimension d = getSize(); - g.drawImage(image, 0, 0, d.width, d.height, null); - break; - - case ACTUAL: - drawActual(g); - break; + case TILED: + drawTiled(g); + break; + case SCALED: + Dimension d = getSize(); + g.drawImage(image, 0, 0, d.width, d.height, null); + break; + case ACTUAL: + drawActual(g); + break; } } diff --git a/Mage.Common/src/mage/components/ImagePanelStyle.java b/Mage.Common/src/mage/components/ImagePanelStyle.java new file mode 100644 index 0000000000..01e1b4557b --- /dev/null +++ b/Mage.Common/src/mage/components/ImagePanelStyle.java @@ -0,0 +1,8 @@ +package mage.components; + +/** + * Created by IGOUDT on 7-3-2017. + */ +public enum ImagePanelStyle { + TILED, SCALED, ACTUAL +} diff --git a/Mage.Common/src/mage/interfaces/ServerState.java b/Mage.Common/src/mage/interfaces/ServerState.java index 83e0ddbbf4..8208b44f03 100644 --- a/Mage.Common/src/mage/interfaces/ServerState.java +++ b/Mage.Common/src/mage/interfaces/ServerState.java @@ -31,12 +31,13 @@ package mage.interfaces; import java.io.Serializable; import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; + import mage.utils.MageVersion; import mage.view.GameTypeView; import mage.view.TournamentTypeView; /** - * * @author BetaSteward_at_googlemail.com */ public class ServerState implements Serializable { @@ -52,8 +53,8 @@ public class ServerState implements Serializable { private final long expansionsContentVersion; public ServerState(List gameTypes, List tournamentTypes, - String[] playerTypes, String[] deckTypes, String[] draftCubes, boolean testMode, - MageVersion version, long cardsContentVersion, long expansionsContentVersion) { + String[] playerTypes, String[] deckTypes, String[] draftCubes, boolean testMode, + MageVersion version, long cardsContentVersion, long expansionsContentVersion) { this.gameTypes = gameTypes; this.tournamentTypes = tournamentTypes; this.playerTypes = playerTypes; @@ -71,13 +72,9 @@ public class ServerState implements Serializable { } public List getTournamentGameTypes() { - List tournamentGameTypes = new ArrayList<>(); - for(GameTypeView gameTypeView: gameTypes) { - if (gameTypeView.getMinPlayers() == 2 && gameTypeView.getMaxPlayers() == 2) { - tournamentGameTypes.add(gameTypeView); - } - } - return tournamentGameTypes; + return gameTypes.stream() + .filter(gameTypeView -> gameTypeView.getMinPlayers() == 2 && gameTypeView.getMaxPlayers() == 2) + .collect(Collectors.toList()); } public List getTournamentTypes() { @@ -111,5 +108,5 @@ public class ServerState implements Serializable { public long getExpansionsContentVersion() { return expansionsContentVersion; } - + }