diff --git a/Mage.Client/pom.xml b/Mage.Client/pom.xml
index 818f319f92..bf98878f84 100644
--- a/Mage.Client/pom.xml
+++ b/Mage.Client/pom.xml
@@ -6,7 +6,7 @@
org.mage
mage-root
- 1.4.20
+ 1.4.21
org.mage
diff --git a/Mage.Client/src/main/java/mage/client/MageFrame.java b/Mage.Client/src/main/java/mage/client/MageFrame.java
index ae3f7ab1d6..01274af98d 100644
--- a/Mage.Client/src/main/java/mage/client/MageFrame.java
+++ b/Mage.Client/src/main/java/mage/client/MageFrame.java
@@ -39,13 +39,9 @@ import java.awt.Image;
import java.awt.Rectangle;
import java.awt.SplashScreen;
import java.awt.Toolkit;
-import java.awt.event.AWTEventListener;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import java.awt.event.ItemEvent;
-import java.awt.event.ItemListener;
import java.awt.event.KeyEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
@@ -163,7 +159,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
private static MageFrame instance;
- private ConnectDialog connectDialog;
+ private final ConnectDialog connectDialog;
private final ErrorDialog errorDialog;
private static CallbackClient callbackClient;
private static final Preferences PREFS = Preferences.userNodeForPackage(MageFrame.class);
@@ -254,12 +250,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
}
});
- Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() {
- @Override
- public void eventDispatched(AWTEvent event) {
- handleEvent(event);
- }
- }, AWTEvent.KEY_EVENT_MASK | AWTEvent.MOUSE_EVENT_MASK);
+ Toolkit.getDefaultToolkit().addAWTEventListener(event -> handleEvent(event), AWTEvent.KEY_EVENT_MASK | AWTEvent.MOUSE_EVENT_MASK);
TConfig config = TConfig.current();
config.setArchiveDetector(new TArchiveDetector("zip"));
@@ -307,12 +298,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
desktopPane.add(errorDialog, JLayeredPane.POPUP_LAYER);
UI.addComponent(MageComponents.DESKTOP_PANE, desktopPane);
- PING_TASK_EXECUTOR.scheduleAtFixedRate(new Runnable() {
- @Override
- public void run() {
- SessionHandler.ping();
- }
- }, 60, 60, TimeUnit.SECONDS);
+ PING_TASK_EXECUTOR.scheduleAtFixedRate(() -> SessionHandler.ping(), 60, 60, TimeUnit.SECONDS);
updateMemUsageTask = new UpdateMemUsageTask(jMemUsageLabel);
@@ -369,24 +355,21 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
setGUISize();
- SwingUtilities.invokeLater(new Runnable() {
- @Override
- public void run() {
- disableButtons();
- if (PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CARD_IMAGES_CHECK, "false").equals("true")) {
- checkForNewImages();
- }
-
- updateMemUsageTask.execute();
- LOGGER.info("Client start up time: " + ((System.currentTimeMillis() - startTime) / 1000 + " seconds"));
- if (autoConnect()) {
- enableButtons();
- } else {
- connectDialog.showDialog();
- }
- setWindowTitle();
-
+ SwingUtilities.invokeLater(() -> {
+ disableButtons();
+ if (PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CARD_IMAGES_CHECK, "false").equals("true")) {
+ checkForNewImages();
}
+
+ updateMemUsageTask.execute();
+ LOGGER.info("Client start up time: " + ((System.currentTimeMillis() - startTime) / 1000 + " seconds"));
+ if (autoConnect()) {
+ enableButtons();
+ } else {
+ connectDialog.showDialog();
+ }
+ setWindowTitle();
+
});
if (SystemUtil.isMacOSX()) {
@@ -532,12 +515,9 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
private AbstractButton createSwitchPanelsButton() {
final JToggleButton switchPanelsButton = new JToggleButton("Switch panels");
- switchPanelsButton.addItemListener(new ItemListener() {
- @Override
- public void itemStateChanged(ItemEvent e) {
- if (e.getStateChange() == ItemEvent.SELECTED) {
- createAndShowSwitchPanelsMenu((JComponent) e.getSource(), switchPanelsButton);
- }
+ switchPanelsButton.addItemListener(e -> {
+ if (e.getStateChange() == ItemEvent.SELECTED) {
+ createAndShowSwitchPanelsMenu((JComponent) e.getSource(), switchPanelsButton);
}
});
switchPanelsButton.setFocusable(false);
@@ -557,12 +537,9 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
menuItem = new MagePaneMenuItem(window);
menuItem.setFont(GUISizeHelper.menuFont);
menuItem.setState(i == 0);
- menuItem.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent ae) {
- MagePane frame = ((MagePaneMenuItem) ae.getSource()).getFrame();
- setActive(frame);
- }
+ menuItem.addActionListener(ae -> {
+ MagePane frame = ((MagePaneMenuItem) ae.getSource()).getFrame();
+ setActive(frame);
});
menuItem.setIcon(window.getFrameIcon());
menu.add(menuItem);
@@ -883,11 +860,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
btnPreferences.setFocusable(false);
btnPreferences.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
btnPreferences.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
- btnPreferences.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- btnPreferencesActionPerformed(evt);
- }
- });
+ btnPreferences.addActionListener(evt -> btnPreferencesActionPerformed(evt));
mageToolbar.add(btnPreferences);
mageToolbar.add(jSeparator4);
@@ -896,11 +869,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
btnConnect.setFocusable(false);
btnConnect.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
btnConnect.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
- btnConnect.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- btnConnectActionPerformed(evt);
- }
- });
+ btnConnect.addActionListener(evt -> btnConnectActionPerformed(evt));
mageToolbar.add(btnConnect);
lblStatus.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
@@ -916,11 +885,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
btnDeckEditor.setFocusable(false);
btnDeckEditor.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
btnDeckEditor.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
- btnDeckEditor.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- btnDeckEditorActionPerformed(evt);
- }
- });
+ btnDeckEditor.addActionListener(evt -> btnDeckEditorActionPerformed(evt));
mageToolbar.add(btnDeckEditor);
mageToolbar.add(jSeparator2);
@@ -930,11 +895,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
btnCollectionViewer.setFocusable(false);
btnCollectionViewer.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
btnCollectionViewer.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
- btnCollectionViewer.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- btnCollectionViewerActionPerformed(evt);
- }
- });
+ btnCollectionViewer.addActionListener(evt -> btnCollectionViewerActionPerformed(evt));
mageToolbar.add(btnCollectionViewer);
mageToolbar.add(jSeparator5);
@@ -944,11 +905,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
btnSendFeedback.setFocusable(false);
btnSendFeedback.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
btnSendFeedback.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
- btnSendFeedback.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- btnSendFeedbackActionPerformed(evt);
- }
- });
+ btnSendFeedback.addActionListener(evt -> btnSendFeedbackActionPerformed(evt));
mageToolbar.add(btnSendFeedback);
mageToolbar.add(jSeparator6);
@@ -958,11 +915,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
btnSymbols.setFocusable(false);
btnSymbols.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
btnSymbols.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
- btnSymbols.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- btnSymbolsActionPerformed(evt);
- }
- });
+ btnSymbols.addActionListener(evt -> btnSymbolsActionPerformed(evt));
mageToolbar.add(btnSymbols);
mageToolbar.add(jSeparatorSymbols);
@@ -972,11 +925,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
btnImages.setFocusable(false);
btnImages.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
btnImages.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
- btnImages.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- btnImagesActionPerformed(evt);
- }
- });
+ btnImages.addActionListener(evt -> btnImagesActionPerformed(evt));
mageToolbar.add(btnImages);
mageToolbar.add(jSeparatorImages);
@@ -986,11 +935,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
btnAbout.setFocusable(false);
btnAbout.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
btnAbout.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
- btnAbout.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- btnAboutActionPerformed(evt);
- }
- });
+ btnAbout.addActionListener(evt -> btnAboutActionPerformed(evt));
mageToolbar.add(btnAbout);
mageToolbar.add(jSeparator7);
@@ -1192,12 +1137,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
if (SwingUtilities.isEventDispatchThread()) {
userRequestDialog.showDialog(userRequestMessage);
} else {
- SwingUtilities.invokeLater(new Runnable() {
- @Override
- public void run() {
- userRequestDialog.showDialog(userRequestMessage);
- }
- });
+ SwingUtilities.invokeLater(() -> userRequestDialog.showDialog(userRequestMessage));
}
}
@@ -1206,12 +1146,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
if (SwingUtilities.isEventDispatchThread()) {
errorDialog.showDialog(title, message);
} else {
- SwingUtilities.invokeLater(new Runnable() {
- @Override
- public void run() {
- errorDialog.showDialog(title, message);
- }
- });
+ SwingUtilities.invokeLater(() -> errorDialog.showDialog(title, message));
}
}
@@ -1253,40 +1188,32 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
LOGGER.info("Logging level: " + LOGGER.getEffectiveLevel());
startTime = System.currentTimeMillis();
- Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
- @Override
- public void uncaughtException(Thread t, Throwable e) {
- LOGGER.fatal(null, e);
+ Thread.setDefaultUncaughtExceptionHandler((t, e) -> LOGGER.fatal(null, e));
+ SwingUtilities.invokeLater(() -> {
+ for (String arg : args) {
+ if (arg.startsWith(LITE_MODE_ARG)) {
+ liteMode = true;
+ }
+ if (arg.startsWith(GRAY_MODE_ARG)) {
+ grayMode = true;
+ }
+ if (arg.startsWith(FILL_SCREEN_ARG)) {
+ fullscreenMode = true;
+ }
}
- });
- SwingUtilities.invokeLater(new Runnable() {
- @Override
- public void run() {
- for (String arg : args) {
- if (arg.startsWith(LITE_MODE_ARG)) {
- liteMode = true;
- }
- if (arg.startsWith(GRAY_MODE_ARG)) {
- grayMode = true;
- }
- if (arg.startsWith(FILL_SCREEN_ARG)) {
- fullscreenMode = true;
+ if (!liteMode) {
+ final SplashScreen splash = SplashScreen.getSplashScreen();
+ if (splash != null) {
+ Graphics2D g = splash.createGraphics();
+ if (g != null) {
+ renderSplashFrame(g);
}
+ splash.update();
}
- if (!liteMode) {
- final SplashScreen splash = SplashScreen.getSplashScreen();
- if (splash != null) {
- Graphics2D g = splash.createGraphics();
- if (g != null) {
- renderSplashFrame(g);
- }
- splash.update();
- }
- }
- instance = new MageFrame();
- instance.setVisible(true);
+ }
+ instance = new MageFrame();
+ instance.setVisible(true);
- }
});
}
@@ -1383,12 +1310,9 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
setStatusText(message);
enableButtons();
} else {
- SwingUtilities.invokeLater(new Runnable() {
- @Override
- public void run() {
- setStatusText(message);
- enableButtons();
- }
+ SwingUtilities.invokeLater(() -> {
+ setStatusText(message);
+ enableButtons();
});
}
}
@@ -1403,20 +1327,17 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
hideTables();
} else {
LOGGER.info("DISCONNECTED (NO Event Dispatch Thread)");
- SwingUtilities.invokeLater(new Runnable() {
- @Override
- public void run() {
- setStatusText("Not connected");
- disableButtons();
- hideGames();
- hideTables();
- SessionHandler.disconnect(false);
- if (errorCall) {
- UserRequestMessage message = new UserRequestMessage("Connection lost", "The connection to server was lost. Reconnect to " + currentConnection.getHost() + "?");
- message.setButton1("No", null);
- message.setButton2("Yes", PlayerAction.CLIENT_RECONNECT);
- showUserRequestDialog(message);
- }
+ SwingUtilities.invokeLater(() -> {
+ setStatusText("Not connected");
+ disableButtons();
+ hideGames();
+ hideTables();
+ SessionHandler.disconnect(false);
+ if (errorCall) {
+ UserRequestMessage message = new UserRequestMessage("Connection lost", "The connection to server was lost. Reconnect to " + currentConnection.getHost() + "?");
+ message.setButton1("No", null);
+ message.setButton2("Yes", PlayerAction.CLIENT_RECONNECT);
+ showUserRequestDialog(message);
}
}
);
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 f87c03bbeb..f8d974caf6 100644
--- a/Mage.Client/src/main/java/mage/client/cards/Card.java
+++ b/Mage.Client/src/main/java/mage/client/cards/Card.java
@@ -86,7 +86,6 @@ import mage.client.util.ImageHelper;
import mage.client.util.gui.ArrowBuilder;
import mage.constants.CardType;
import mage.constants.EnlargeMode;
-import mage.remote.Session;
import mage.view.AbilityView;
import mage.view.CardView;
import mage.view.CounterView;
@@ -101,10 +100,10 @@ import org.apache.log4j.Logger;
@SuppressWarnings("serial")
public class Card extends MagePermanent implements MouseMotionListener, MouseListener, FocusListener, ComponentListener {
- protected static DefaultActionCallback callback = DefaultActionCallback.getInstance();
+ protected static final DefaultActionCallback callback = DefaultActionCallback.getInstance();
protected Point p;
- protected CardDimensions dimension;
+ protected final CardDimensions dimension;
protected final UUID gameId;
protected final BigCard bigCard;
@@ -112,10 +111,10 @@ public class Card extends MagePermanent implements MouseMotionListener, MouseLis
protected Popup tooltipPopup;
protected boolean tooltipShowing;
- protected TextPopup tooltipText = new TextPopup();
+ protected final TextPopup tooltipText = new TextPopup();
protected BufferedImage background;
- protected BufferedImage image = new BufferedImage(FRAME_MAX_WIDTH, FRAME_MAX_HEIGHT, BufferedImage.TYPE_INT_RGB);
- protected BufferedImage small;
+ protected final BufferedImage image = new BufferedImage(FRAME_MAX_WIDTH, FRAME_MAX_HEIGHT, BufferedImage.TYPE_INT_RGB);
+ protected final BufferedImage small;
protected String backgroundName;
// if this is set, it's opened if the user right clicks on the card panel
diff --git a/Mage.Client/src/main/java/mage/client/cards/CardArea.java b/Mage.Client/src/main/java/mage/client/cards/CardArea.java
index 8ebd826c3e..531cf10eb2 100644
--- a/Mage.Client/src/main/java/mage/client/cards/CardArea.java
+++ b/Mage.Client/src/main/java/mage/client/cards/CardArea.java
@@ -52,7 +52,7 @@ import org.mage.card.arcane.CardPanel;
public class CardArea extends JPanel implements MouseListener {
- protected CardEventSource cardEventSource = new CardEventSource();
+ protected final CardEventSource cardEventSource = new CardEventSource();
private boolean reloaded = false;
private final javax.swing.JLayeredPane cardArea;
@@ -89,7 +89,7 @@ public class CardArea extends JPanel implements MouseListener {
setGUISize();
for (Component component : cardArea.getComponents()) {
if (component instanceof CardPanel) {
- ((CardPanel) component).setBounds(0, 0, cardDimension.width, cardDimension.height);
+ component.setBounds(0, 0, cardDimension.width, cardDimension.height);
}
}
}
diff --git a/Mage.Client/src/main/java/mage/client/cards/CardDraggerGlassPane.java b/Mage.Client/src/main/java/mage/client/cards/CardDraggerGlassPane.java
index 2ca0586348..b813b53bfe 100644
--- a/Mage.Client/src/main/java/mage/client/cards/CardDraggerGlassPane.java
+++ b/Mage.Client/src/main/java/mage/client/cards/CardDraggerGlassPane.java
@@ -3,7 +3,6 @@ package mage.client.cards;
import mage.cards.MageCard;
import mage.client.plugins.impl.Plugins;
import mage.view.CardView;
-import org.apache.log4j.Logger;
import javax.swing.*;
import java.awt.*;
@@ -11,13 +10,12 @@ import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.util.ArrayList;
-import java.util.Collection;
/**
* Created by StravantUser on 2016-09-22.
*/
public class CardDraggerGlassPane implements MouseListener, MouseMotionListener {
- private DragCardSource source;
+ private final DragCardSource source;
private Component dragComponent;
private JRootPane currentRoot;
private JComponent glassPane;
diff --git a/Mage.Client/src/main/java/mage/client/cards/CardEventSource.java b/Mage.Client/src/main/java/mage/client/cards/CardEventSource.java
index 0327dc887d..81e29d83db 100644
--- a/Mage.Client/src/main/java/mage/client/cards/CardEventSource.java
+++ b/Mage.Client/src/main/java/mage/client/cards/CardEventSource.java
@@ -33,7 +33,6 @@ import mage.client.util.Event;
import mage.client.util.EventDispatcher;
import mage.client.util.EventSource;
import mage.client.util.Listener;
-import mage.view.CardView;
import mage.view.SimpleCardView;
/**
diff --git a/Mage.Client/src/main/java/mage/client/cards/CardGrid.java b/Mage.Client/src/main/java/mage/client/cards/CardGrid.java
index 618f604a45..1180ccab47 100644
--- a/Mage.Client/src/main/java/mage/client/cards/CardGrid.java
+++ b/Mage.Client/src/main/java/mage/client/cards/CardGrid.java
@@ -39,7 +39,6 @@ import java.awt.Rectangle;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
@@ -64,7 +63,7 @@ import org.mage.card.arcane.CardPanel;
*/
public class CardGrid extends javax.swing.JLayeredPane implements MouseListener, ICardGrid {
- protected CardEventSource cardEventSource = new CardEventSource();
+ protected final CardEventSource cardEventSource = new CardEventSource();
protected BigCard bigCard;
protected UUID gameId;
private final Map cards = new HashMap<>();
@@ -154,22 +153,22 @@ public class CardGrid extends javax.swing.JLayeredPane implements MouseListener,
List sortedCards = new ArrayList<>(cards.values());
switch (sortSetting.getSortBy()) {
case NAME:
- Collections.sort(sortedCards, new CardNameComparator());
+ sortedCards.sort(new CardNameComparator());
break;
case CARD_TYPE:
- Collections.sort(sortedCards, new CardTypeComparator());
+ sortedCards.sort(new CardTypeComparator());
break;
case RARITY:
- Collections.sort(sortedCards, new CardRarityComparator());
+ sortedCards.sort(new CardRarityComparator());
break;
case COLOR:
- Collections.sort(sortedCards, new CardColorComparator());
+ sortedCards.sort(new CardColorComparator());
break;
case COLOR_IDENTITY:
- Collections.sort(sortedCards, new CardColorDetailedIdentity());
+ sortedCards.sort(new CardColorDetailedIdentity());
break;
case CASTING_COST:
- Collections.sort(sortedCards, new CardCostComparator());
+ sortedCards.sort(new CardCostComparator());
break;
}
@@ -409,7 +408,7 @@ class CardCostComparator implements Comparator {
@Override
public int compare(MageCard o1, MageCard o2) {
- int val = Integer.valueOf(o1.getOriginal().getConvertedManaCost()).compareTo(Integer.valueOf(o2.getOriginal().getConvertedManaCost()));
+ int val = Integer.valueOf(o1.getOriginal().getConvertedManaCost()).compareTo(o2.getOriginal().getConvertedManaCost());
if (val == 0) {
return o1.getOriginal().getName().compareTo(o2.getOriginal().getName());
} else {
diff --git a/Mage.Client/src/main/java/mage/client/cards/Cards.java b/Mage.Client/src/main/java/mage/client/cards/Cards.java
index 8cd01f78ac..d6a3363db7 100644
--- a/Mage.Client/src/main/java/mage/client/cards/Cards.java
+++ b/Mage.Client/src/main/java/mage/client/cards/Cards.java
@@ -37,8 +37,6 @@ import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
@@ -210,7 +208,7 @@ public class Cards extends javax.swing.JPanel {
tmp.setIsAbility(true);
tmp.overrideTargets(card.getTargets());
tmp.overrideId(card.getId());
- tmp.setAbilityType(((StackAbilityView) card).getAbilityType());
+ tmp.setAbilityType(card.getAbilityType());
card = tmp;
} else {
card.setAbilityType(null);
@@ -258,7 +256,7 @@ public class Cards extends javax.swing.JPanel {
this.cardDimension = dimension;
for (Component component : cardArea.getComponents()) {
if (component instanceof CardPanel) {
- ((CardPanel) component).setBounds(0, 0, dimension.width, dimension.height);
+ component.setBounds(0, 0, dimension.width, dimension.height);
}
}
layoutCards();
@@ -358,12 +356,7 @@ public class Cards extends javax.swing.JPanel {
}
}
// sort the cards
- Collections.sort(cardsToLayout, new Comparator() {
- @Override
- public int compare(CardPanel cp1, CardPanel cp2) {
- return Integer.valueOf(cp1.getLocation().x).compareTo(cp2.getLocation().x);
- }
- });
+ cardsToLayout.sort((cp1, cp2) -> Integer.valueOf(cp1.getLocation().x).compareTo(cp2.getLocation().x));
// relocate the cards
int dx = 0;
for (Component component : cardsToLayout) {
diff --git a/Mage.Client/src/main/java/mage/client/cards/CardsList.java b/Mage.Client/src/main/java/mage/client/cards/CardsList.java
index bfc3658f30..bec809a416 100644
--- a/Mage.Client/src/main/java/mage/client/cards/CardsList.java
+++ b/Mage.Client/src/main/java/mage/client/cards/CardsList.java
@@ -83,7 +83,7 @@ import org.mage.card.arcane.CardPanel;
*/
public class CardsList extends javax.swing.JPanel implements MouseListener, ICardGrid {
- protected CardEventSource cardEventSource = new CardEventSource();
+ protected final CardEventSource cardEventSource = new CardEventSource();
private Dimension cardDimension;
private int rowHeight;
private CardsView cards;
@@ -346,8 +346,8 @@ public class CardsList extends javax.swing.JPanel implements MouseListener, ICar
break;
}
if (comparator != null) {
- Collections.sort(sortedCards, new CardViewNameComparator());
- Collections.sort(sortedCards, comparator);
+ sortedCards.sort(new CardViewNameComparator());
+ sortedCards.sort(comparator);
}
CardView lastCard = null;
for (CardView card : sortedCards) {
@@ -536,11 +536,7 @@ public class CardsList extends javax.swing.JPanel implements MouseListener, ICar
chkPiles.setText("Piles");
chkPiles.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
chkPiles.setMargin(new java.awt.Insets(3, 2, 2, 2));
- chkPiles.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- chkPilesActionPerformed(evt);
- }
- });
+ chkPiles.addActionListener(evt -> chkPilesActionPerformed(evt));
cbSortBy.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "SortBy" }));
cbSortBy.setToolTipText("Sort the cards if card view is active.");
@@ -549,11 +545,7 @@ public class CardsList extends javax.swing.JPanel implements MouseListener, ICar
cbSortBy.setName("SortBy"); // NOI18N
cbSortBy.setOpaque(false);
cbSortBy.setPreferredSize(new java.awt.Dimension(120, 20));
- cbSortBy.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- cbSortByActionPerformed(evt);
- }
- });
+ cbSortBy.addActionListener(evt -> cbSortByActionPerformed(evt));
bgView.add(jToggleListView);
jToggleListView.setIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/list_panel.png"))); // NOI18N
@@ -564,11 +556,7 @@ public class CardsList extends javax.swing.JPanel implements MouseListener, ICar
jToggleListView.setMaximumSize(new java.awt.Dimension(37, 25));
jToggleListView.setMinimumSize(new java.awt.Dimension(37, 25));
jToggleListView.setPreferredSize(new java.awt.Dimension(44, 22));
- jToggleListView.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jToggleListViewActionPerformed(evt);
- }
- });
+ jToggleListView.addActionListener(evt -> jToggleListViewActionPerformed(evt));
bgView.add(jToggleCardView);
jToggleCardView.setIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/card_panel.png"))); // NOI18N
@@ -576,11 +564,7 @@ public class CardsList extends javax.swing.JPanel implements MouseListener, ICar
jToggleCardView.setHorizontalTextPosition(javax.swing.SwingConstants.LEADING);
jToggleCardView.setMargin(new java.awt.Insets(2, 6, 2, 6));
jToggleCardView.setPreferredSize(new java.awt.Dimension(40, 22));
- jToggleCardView.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jToggleCardViewActionPerformed(evt);
- }
- });
+ jToggleCardView.addActionListener(evt -> jToggleCardViewActionPerformed(evt));
javax.swing.GroupLayout panelControlLayout = new javax.swing.GroupLayout(panelControl);
panelControl.setLayout(panelControlLayout);
diff --git a/Mage.Client/src/main/java/mage/client/cards/DraftGrid.java b/Mage.Client/src/main/java/mage/client/cards/DraftGrid.java
index 4dc525154a..89c8149d09 100644
--- a/Mage.Client/src/main/java/mage/client/cards/DraftGrid.java
+++ b/Mage.Client/src/main/java/mage/client/cards/DraftGrid.java
@@ -40,7 +40,6 @@ import java.awt.Rectangle;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
import mage.cards.CardDimensions;
import mage.cards.MageCard;
@@ -62,7 +61,7 @@ public class DraftGrid extends javax.swing.JPanel implements MouseListener {
private static final Logger logger = Logger.getLogger(DraftGrid.class);
- protected CardEventSource cardEventSource = new CardEventSource();
+ protected final CardEventSource cardEventSource = new CardEventSource();
protected BigCard bigCard;
protected MageCard markedCard;
protected boolean emptyGrid;
@@ -126,7 +125,7 @@ public class DraftGrid extends javax.swing.JPanel implements MouseListener {
Dimension dimension = new Dimension(cardDimension.frameWidth, cardDimension.frameHeight);
List sortedCards = new ArrayList<>(booster.values());
- Collections.sort(sortedCards, new CardViewRarityComparator());
+ sortedCards.sort(new CardViewRarityComparator());
for (CardView card: sortedCards) {
MageCard cardImg = Plugins.getInstance().getMageCard(card, bigCard, dimension, null, true, true);
cardImg.addMouseListener(this);
diff --git a/Mage.Client/src/main/java/mage/client/cards/DragCardGrid.java b/Mage.Client/src/main/java/mage/client/cards/DragCardGrid.java
index a362c619bb..e352c154e6 100644
--- a/Mage.Client/src/main/java/mage/client/cards/DragCardGrid.java
+++ b/Mage.Client/src/main/java/mage/client/cards/DragCardGrid.java
@@ -7,15 +7,12 @@ import java.awt.Graphics;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.GridLayout;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
@@ -40,9 +37,11 @@ import javax.swing.JLabel;
import javax.swing.JLayeredPane;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
+import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JScrollPane;
+import mage.cards.Card;
import javax.swing.JSlider;
import javax.swing.JTextField;
import javax.swing.JToggleButton;
@@ -52,6 +51,9 @@ import javax.swing.SwingUtilities;
import mage.cards.MageCard;
import mage.cards.decks.DeckCardInfo;
import mage.cards.decks.DeckCardLayout;
+import mage.cards.repository.CardCriteria;
+import mage.cards.repository.CardInfo;
+import mage.cards.repository.CardRepository;
import mage.client.MageFrame;
import mage.client.constants.Constants;
import mage.client.dialog.PreferencesDialog;
@@ -66,6 +68,7 @@ import mage.client.util.Event;
import mage.client.util.GUISizeHelper;
import mage.client.util.Listener;
import mage.constants.CardType;
+import mage.util.RandomUtil;
import mage.view.CardView;
import mage.view.CardsView;
import org.apache.log4j.Logger;
@@ -455,12 +458,9 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
}
public enum Sort {
- NONE("No Sort", new Comparator() {
- @Override
- public int compare(CardView o1, CardView o2) {
- // Always equal, sort into the first row
- return 0;
- }
+ NONE("No Sort", (o1, o2) -> {
+ // Always equal, sort into the first row
+ return 0;
}),
CARD_TYPE("Card Type", new CardViewCardTypeComparator()),
CMC("Converted Mana Cost", new CardViewCostComparator()),
@@ -508,44 +508,44 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
}
// Counters we use
- private CardTypeCounter creatureCounter = new CardTypeCounter() {
+ private final CardTypeCounter creatureCounter = new CardTypeCounter() {
@Override
protected boolean is(CardView card) {
return card.getCardTypes().contains(CardType.CREATURE);
}
};
- private CardTypeCounter landCounter = new CardTypeCounter() {
+ private final CardTypeCounter landCounter = new CardTypeCounter() {
@Override
protected boolean is(CardView card) {
return card.getCardTypes().contains(CardType.LAND);
}
};
- private CardTypeCounter artifactCounter = new CardTypeCounter() {
+ private final CardTypeCounter artifactCounter = new CardTypeCounter() {
@Override
protected boolean is(CardView card) {
return card.getCardTypes().contains(CardType.ARTIFACT);
}
};
- private CardTypeCounter enchantmentCounter = new CardTypeCounter() {
+ private final CardTypeCounter enchantmentCounter = new CardTypeCounter() {
@Override
protected boolean is(CardView card) {
return card.getCardTypes().contains(CardType.ENCHANTMENT);
}
};
- private CardTypeCounter instantCounter = new CardTypeCounter() {
+ private final CardTypeCounter instantCounter = new CardTypeCounter() {
@Override
protected boolean is(CardView card) {
return card.getCardTypes().contains(CardType.INSTANT);
}
};
- private CardTypeCounter sorceryCounter = new CardTypeCounter() {
+ private final CardTypeCounter sorceryCounter = new CardTypeCounter() {
@Override
protected boolean is(CardView card) {
return card.getCardTypes().contains(CardType.SORCERY);
}
};
- private CardTypeCounter planeswalkerCounter = new CardTypeCounter() {
+ private final CardTypeCounter planeswalkerCounter = new CardTypeCounter() {
@Override
protected boolean is(CardView card) {
return card.getCardTypes().contains(CardType.PLANESWALKER);
@@ -577,15 +577,15 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
void hideCards(Collection card);
void duplicateCards(Collection cards);
-
+
void invertCardSelection(Collection cards);
void showAll();
- };
+ }
// Constants
- public static int COUNT_LABEL_HEIGHT = 20;
- public static int GRID_PADDING = 10;
+ public static final int COUNT_LABEL_HEIGHT = 20;
+ public static final int GRID_PADDING = 10;
private final static ImageIcon INSERT_ROW_ICON = new ImageIcon(DragCardGrid.class.getClassLoader().getResource("editor_insert_row.png"));
private final static ImageIcon INSERT_COL_ICON = new ImageIcon(DragCardGrid.class.getClassLoader().getResource("editor_insert_col.png"));
@@ -606,36 +606,38 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
JButton visibilityButton;
JButton selectByButton;
JButton analyseButton;
+ JButton blingButton;
+
// Popup for toolbar
- JPopupMenu filterPopup;
+ final JPopupMenu filterPopup;
JPopupMenu selectByTypePopup;
- JPopupMenu sortPopup;
- JPopupMenu selectByPopup;
- JCheckBox separateCreaturesCb;
- JTextField searchByTextField;
+ final JPopupMenu sortPopup;
+ final JPopupMenu selectByPopup;
+ final JCheckBox separateCreaturesCb;
+ final JTextField searchByTextField;
JToggleButton multiplesButton;
- JSlider cardSizeSlider;
- JLabel cardSizeSliderLabel;
+ final JSlider cardSizeSlider;
+ final JLabel cardSizeSliderLabel;
- Map sortButtons = new HashMap<>();
- HashMap selectByTypeButtons = new HashMap<>();
+ final Map sortButtons = new HashMap<>();
+ final HashMap selectByTypeButtons = new HashMap<>();
- JLabel deckNameAndCountLabel;
- JLabel landCountLabel;
- JLabel creatureCountLabel;
+ final JLabel deckNameAndCountLabel;
+ final JLabel landCountLabel;
+ final JLabel creatureCountLabel;
// Main two controls holding the scrollable card grid
- JScrollPane cardScroll;
+ final JScrollPane cardScroll;
JLayeredPane cardContent;
// Drag onto insert arrow
- JLabel insertArrow;
+ final JLabel insertArrow;
// Card area selection panel
- SelectionBox selectionPanel;
+ final SelectionBox selectionPanel;
Set selectionDragStartCards;
int selectionDragStartX;
int selectionDragStartY;
@@ -672,7 +674,7 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
return name;
}
- private String name;
+ private final String name;
}
public static class Settings {
@@ -756,9 +758,10 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
// Toolbar
sortButton = new JButton("Sort");
filterButton = new JButton("Filter");
- visibilityButton = new JButton("Visibility");
+ visibilityButton = new JButton("V"); // "Visibility" button
selectByButton = new JButton("Select By");
- analyseButton = new JButton("Mana");
+ analyseButton = new JButton("M"); // "Mana" button
+ blingButton = new JButton("B"); // "Bling" button
// Name and count label
deckNameAndCountLabel = new JLabel();
@@ -779,9 +782,10 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
toolbarInner.add(creatureCountLabel);
toolbarInner.add(sortButton);
toolbarInner.add(filterButton);
- toolbarInner.add(visibilityButton);
toolbarInner.add(selectByButton);
+ toolbarInner.add(visibilityButton);
toolbarInner.add(analyseButton);
+ toolbarInner.add(blingButton);
toolbar.add(toolbarInner, BorderLayout.WEST);
JPanel sliderPanel = new JPanel(new GridBagLayout());
sliderPanel.setOpaque(false);
@@ -929,6 +933,7 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
JMenuItem showAll = new JMenuItem("Show all");
showAll.addActionListener(e -> showAll());
visPopup.add(showAll);
+ visibilityButton.setToolTipText("Visibility of cards. Right click to get the same options this provides");
visibilityButton.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
@@ -956,15 +961,15 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
ButtonGroup selectByTypeModeGroup = new ButtonGroup();
for (final CardType cardType : CardType.values()) {
- if (cardType == cardType.CONSPIRACY) {
+ if (cardType == cardType.CONSPIRACY) {
multiplesButton = new JToggleButton("Multiples");
selectByTypeButtons.put(cardType, multiplesButton);
selectByTypeMode.add(multiplesButton);
selectByTypeModeGroup.add(multiplesButton);
multiplesButton.addActionListener(e -> {
- multiplesButton.setSelected(!multiplesButton.isSelected());
- reselectBy();
- });
+ multiplesButton.setSelected(!multiplesButton.isSelected());
+ reselectBy();
+ });
continue;
}
@@ -1011,13 +1016,14 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
}
// Analyse Mana (aka #blue pips, #islands, #white pips, #plains etc.)
- analyseButton.setToolTipText("Counts coloured/colourless mana costs. Counts land types.");
+ analyseButton.setToolTipText("Mana Analyser! Counts coloured/colourless mana costs. Counts land types.");
- analyseButton.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent evt) {
- analyseDeck();
- }
- });
+ analyseButton.addActionListener(evt -> analyseDeck());
+
+ // Bling button - aka Add in a premium 'JR', 'MBP', 'CS' etc card
+ blingButton.setToolTipText("Bling your deck! Select the original and added cards by selecting 'Multiples' in the selection options");
+
+ blingButton.addActionListener(evt -> blingDeck());
// Filter popup
filterPopup = new JPopupMenu();
@@ -1108,7 +1114,7 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
l.duplicateCards(toDuplicate);
}
}
-
+
private void invertSelection() {
Collection toInvert = allCards;
for (DragCardGridListener l : listeners) {
@@ -1229,7 +1235,7 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
trimGrid();
// First sort all cards by name
- Collections.sort(allCards, new CardViewNameComparator());
+ allCards.sort(new CardViewNameComparator());
// Now re-insert all of the cards using the current sort
for (CardView card : allCards) {
@@ -1478,6 +1484,84 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
MageFrame.getInstance().showMessage(finalInfo);
}
+ public void blingDeck() {
+ if (!(this.mode == Constants.DeckEditorMode.FREE_BUILDING)) {
+ return;
+ }
+
+ if (JOptionPane.showConfirmDialog(null, "Are you sure you want to bling your deck? This process will add cards!", "WARNING",
+ JOptionPane.YES_NO_OPTION) == JOptionPane.NO_OPTION) {
+ return;
+ }
+
+ HashMap pimpedSets = new HashMap<>();
+ HashMap pimpedCards = new HashMap<>();
+ pimpedSets.put("CP", 1);
+ pimpedSets.put("JR", 1);
+ pimpedSets.put("MPS", 1);
+ pimpedSets.put("CLASH", 1);
+ pimpedSets.put("ARENA", 1);
+ pimpedSets.put("UGIN", 1);
+ pimpedSets.put("WMCQ", 1);
+ pimpedSets.put("APAC", 1);
+ pimpedSets.put("EURO", 1);
+ pimpedSets.put("FNMP", 1);
+ pimpedSets.put("MGDC", 1);
+ pimpedSets.put("MPRP", 1);
+ pimpedSets.put("EXP", 1);
+ pimpedSets.put("GPX", 1);
+ pimpedSets.put("GRC", 1);
+ pimpedSets.put("MBP", 1);
+ pimpedSets.put("MLP", 1);
+ pimpedSets.put("PLS", 1);
+ pimpedSets.put("PTC", 1);
+ pimpedSets.put("SUS", 1);
+
+ String[] sets = pimpedSets.keySet().toArray(new String[pimpedSets.keySet().size()]);
+ Boolean didModify = false;
+
+ for (ArrayList> gridRow : cardGrid) {
+ for (ArrayList stack : gridRow) {
+ for (CardView card : stack) {
+ if (card.getSuperTypes().contains("Basic")) {
+ continue;
+ }
+
+ if (!pimpedSets.containsKey(card.getExpansionSetCode())) {
+ final CardCriteria cardCriteria = new CardCriteria();
+ cardCriteria.setCodes(sets);
+ cardCriteria.name(card.getName());
+
+ List cardPool = CardRepository.instance.findCards(cardCriteria);
+
+ if (cardPool.size() > 0) {
+ Card acard = cardPool.get(RandomUtil.nextInt(cardPool.size())).getMockCard();
+
+ if (acard.getName().equals(card.getName())) {
+ CardView pimpedCard = new CardView(acard);
+ addCardView(pimpedCard, false);
+ eventSource.addSpecificCard(pimpedCard, "add-specific-card");
+ pimpedCards.put(pimpedCard, 1);
+ didModify = true;
+ }
+ }
+ }
+ }
+ }
+
+ if (didModify) {
+ for (CardView c : pimpedCards.keySet()) {
+ sortIntoGrid(c);
+ }
+
+ layoutGrid();
+ cardScroll.revalidate();
+ repaint();
+ JOptionPane.showMessageDialog(null, "Added " + pimpedCards.size() + " cards. You can select them and the originals by choosing 'Multiples'");
+ }
+ }
+ }
+
// Update the contents of the card grid
public void setCards(CardsView cardsView, DeckCardLayout layout, BigCard bigCard) {
if (bigCard != null) {
@@ -1640,10 +1724,10 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
AbstractButton button = selectByTypeButtons.get(cardType);
String text = cardType.toString();
int numCards = getCount(cardType);
- if (cardType == cardType.CONSPIRACY) {
+ if (cardType == cardType.CONSPIRACY) {
continue;
}
-
+
if (numCards > 0) {
button.setForeground(Color.BLACK);
text = text + " - " + numCards;
@@ -1659,7 +1743,7 @@ public class DragCardGrid extends JPanel implements DragCardSource, DragCardTarg
JMenuItem hide = new JMenuItem("Hide");
hide.addActionListener(e2 -> hideSelection());
menu.add(hide);
-
+
JMenuItem invertSelection = new JMenuItem("Invert Selection");
invertSelection.addActionListener(e2 -> invertSelection());
menu.add(invertSelection);
diff --git a/Mage.Client/src/main/java/mage/client/cards/DragCardTarget.java b/Mage.Client/src/main/java/mage/client/cards/DragCardTarget.java
index 70138889c4..a656a4bc93 100644
--- a/Mage.Client/src/main/java/mage/client/cards/DragCardTarget.java
+++ b/Mage.Client/src/main/java/mage/client/cards/DragCardTarget.java
@@ -2,7 +2,6 @@ package mage.client.cards;
import mage.view.CardView;
-import java.awt.*;
import java.awt.event.MouseEvent;
import java.util.Collection;
diff --git a/Mage.Client/src/main/java/mage/client/cards/Permanent.java b/Mage.Client/src/main/java/mage/client/cards/Permanent.java
index 0db10e5887..f5b3dd2494 100644
--- a/Mage.Client/src/main/java/mage/client/cards/Permanent.java
+++ b/Mage.Client/src/main/java/mage/client/cards/Permanent.java
@@ -52,11 +52,9 @@ import mage.cards.Sets;
import static mage.client.constants.Constants.DAMAGE_MAX_LEFT;
import static mage.client.constants.Constants.POWBOX_TEXT_MAX_TOP;
import mage.client.util.Config;
-import mage.client.util.ImageHelper;
import mage.constants.CardType;
import mage.view.CounterView;
import mage.view.PermanentView;
-import org.mage.plugins.card.images.ImageCache;
import mage.client.util.TransformedImageCache;
/**
@@ -67,9 +65,9 @@ public class Permanent extends Card {
protected PermanentView permanent;
- protected List links = new ArrayList<>();
+ protected final List links = new ArrayList<>();
protected boolean linked;
- protected BufferedImage tappedImage;
+ protected final BufferedImage tappedImage;
protected BufferedImage flippedImage;
/** Creates new form Permanent
diff --git a/Mage.Client/src/main/java/mage/client/components/ColorPane.java b/Mage.Client/src/main/java/mage/client/components/ColorPane.java
index 8fc39aa5be..79851a659d 100644
--- a/Mage.Client/src/main/java/mage/client/components/ColorPane.java
+++ b/Mage.Client/src/main/java/mage/client/components/ColorPane.java
@@ -13,9 +13,7 @@ import javax.swing.JEditorPane;
import javax.swing.JPanel;
import javax.swing.JTextPane;
import javax.swing.SwingUtilities;
-import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkEvent.EventType;
-import javax.swing.event.HyperlinkListener;
import javax.swing.text.html.HTMLDocument;
import javax.swing.text.html.HTMLEditorKit;
@@ -35,8 +33,8 @@ import mage.view.CardView;
*/
public class ColorPane extends JEditorPane {
- HTMLEditorKit kit = new HTMLEditorKit();
- HTMLDocument doc = new HTMLDocument();
+ final HTMLEditorKit kit = new HTMLEditorKit();
+ final HTMLDocument doc = new HTMLDocument();
private int tooltipDelay;
private int tooltipCounter;
private boolean hyperlinkEnabled = false;
@@ -47,39 +45,28 @@ public class ColorPane extends JEditorPane {
}
private void addHyperlinkHandlers() {
- addHyperlinkListener(new HyperlinkListener() {
-
- @Override
- public void hyperlinkUpdate(final HyperlinkEvent e) {
- ThreadUtils.threadPool2.submit(new Runnable() {
-
- @Override
- public void run() {
- tooltipDelay = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_SHOW_TOOLTIPS_DELAY, 300);
- if (tooltipDelay == 0) {
- return;
- }
- String name = e.getDescription().substring(1);
- CardInfo card = CardRepository.instance.findCard(name);
- try {
- final Component container = MageFrame.getUI().getComponent(MageComponents.POPUP_CONTAINER);
- if (e.getEventType() == EventType.EXITED) {
- setPopupVisibility(container, false);
- }
- if (e.getEventType() == EventType.ENTERED && card != null) {
- CardInfoPane cardInfoPane = (CardInfoPane) MageFrame.getUI().getComponent(MageComponents.CARD_INFO_PANE);
- cardInfoPane.setCard(new CardView(card.getMockCard()), container);
- setPopupVisibility(container, true);
- }
- } catch (InterruptedException e1) {
- e1.printStackTrace();
- }
-
- }
- });
+ addHyperlinkListener(e -> ThreadUtils.threadPool2.submit(() -> {
+ tooltipDelay = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_SHOW_TOOLTIPS_DELAY, 300);
+ if (tooltipDelay == 0) {
+ return;
+ }
+ String name = e.getDescription().substring(1);
+ CardInfo card = CardRepository.instance.findCard(name);
+ try {
+ final Component container = MageFrame.getUI().getComponent(MageComponents.POPUP_CONTAINER);
+ if (e.getEventType() == EventType.EXITED) {
+ setPopupVisibility(container, false);
+ }
+ if (e.getEventType() == EventType.ENTERED && card != null) {
+ CardInfoPane cardInfoPane = (CardInfoPane) MageFrame.getUI().getComponent(MageComponents.CARD_INFO_PANE);
+ cardInfoPane.setCard(new CardView(card.getMockCard()), container);
+ setPopupVisibility(container, true);
+ }
+ } catch (InterruptedException e1) {
+ e1.printStackTrace();
}
- });
+ }));
addMouseListener(new MouseAdapter() {
@Override
@@ -96,22 +83,19 @@ public class ColorPane extends JEditorPane {
private void setPopupVisibility(final Component container, final boolean show) throws InterruptedException {
final Component c = MageFrame.getUI().getComponent(MageComponents.DESKTOP_PANE);
- SwingUtilities.invokeLater(new Runnable() {
- @Override
- public void run() {
- tooltipCounter += show ? 1 : -1;
- if (tooltipCounter < 0) {
- tooltipCounter = 0;
- }
- if (tooltipCounter > 0) {
- Point location = new Point(getLocationOnScreen().x - container.getWidth(), MouseInfo.getPointerInfo().getLocation().y);
- Component parentComponent = MageFrame.getInstance();
- location = GuiDisplayUtil.keepComponentInsideParent(location, parentComponent.getLocationOnScreen(), container, parentComponent);
- container.setLocation(location);
- }
- container.setVisible(tooltipCounter > 0);
- c.repaint();
+ SwingUtilities.invokeLater(() -> {
+ tooltipCounter += show ? 1 : -1;
+ if (tooltipCounter < 0) {
+ tooltipCounter = 0;
}
+ if (tooltipCounter > 0) {
+ Point location = new Point(getLocationOnScreen().x - container.getWidth(), MouseInfo.getPointerInfo().getLocation().y);
+ Component parentComponent = MageFrame.getInstance();
+ location = GuiDisplayUtil.keepComponentInsideParent(location, parentComponent.getLocationOnScreen(), container, parentComponent);
+ container.setLocation(location);
+ }
+ container.setVisible(tooltipCounter > 0);
+ c.repaint();
});
}
diff --git a/Mage.Client/src/main/java/mage/client/components/MageDesktopManager.java b/Mage.Client/src/main/java/mage/client/components/MageDesktopManager.java
index e2c704f2d5..146af3294b 100644
--- a/Mage.Client/src/main/java/mage/client/components/MageDesktopManager.java
+++ b/Mage.Client/src/main/java/mage/client/components/MageDesktopManager.java
@@ -6,12 +6,8 @@
package mage.client.components;
import java.awt.BorderLayout;
-import javax.swing.DefaultDesktopManager;
-import javax.swing.DesktopManager;
-import javax.swing.JDesktopPane;
-import javax.swing.JFrame;
-import javax.swing.JInternalFrame;
-import javax.swing.SwingUtilities;
+import javax.swing.*;
+
import mage.client.dialog.CardInfoWindowDialog;
/**
@@ -41,24 +37,21 @@ public class MageDesktopManager extends DefaultDesktopManager {
}
public static void main(String args[]) {
- SwingUtilities.invokeLater(new Runnable() {
- @Override
- public void run() {
- JFrame frame = new JFrame();
- frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ SwingUtilities.invokeLater(() -> {
+ JFrame frame = new JFrame();
+ frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
- JDesktopPane desktopPane = new JDesktopPane();
- DesktopManager dm = new MageDesktopManager();
- desktopPane.setDesktopManager(dm);
- JInternalFrame internalFrame = new JInternalFrame("Test Internal Frame", true, false, true, true);
- internalFrame.setSize(200, 150);
- internalFrame.setVisible(true);
- desktopPane.add(internalFrame);
+ JDesktopPane desktopPane = new JDesktopPane();
+ DesktopManager dm = new MageDesktopManager();
+ desktopPane.setDesktopManager(dm);
+ JInternalFrame internalFrame = new JInternalFrame("Test Internal Frame", true, false, true, true);
+ internalFrame.setSize(200, 150);
+ internalFrame.setVisible(true);
+ desktopPane.add(internalFrame);
- frame.add(desktopPane, BorderLayout.CENTER);
- frame.setSize(800, 600);
- frame.setVisible(true);
- }
+ frame.add(desktopPane, BorderLayout.CENTER);
+ frame.setSize(800, 600);
+ frame.setVisible(true);
});
}
}
diff --git a/Mage.Client/src/main/java/mage/client/components/MageJDesktop.java b/Mage.Client/src/main/java/mage/client/components/MageJDesktop.java
index f090861b2c..8c5052ce6d 100644
--- a/Mage.Client/src/main/java/mage/client/components/MageJDesktop.java
+++ b/Mage.Client/src/main/java/mage/client/components/MageJDesktop.java
@@ -24,7 +24,7 @@ public class MageJDesktop extends JDesktopPane {
UIDefaults map = new UIDefaults();
Painter painter = new Painter() {
- Color color = null;
+ final Color color = null;
@Override
public void paint(Graphics2D g, Object c, int w, int h) {
diff --git a/Mage.Client/src/main/java/mage/client/components/MageRoundPane.java b/Mage.Client/src/main/java/mage/client/components/MageRoundPane.java
index 53a2d1878e..4d318a7bed 100644
--- a/Mage.Client/src/main/java/mage/client/components/MageRoundPane.java
+++ b/Mage.Client/src/main/java/mage/client/components/MageRoundPane.java
@@ -27,23 +27,13 @@ public class MageRoundPane extends JPanel {
private final Color defaultBackgroundColor = new Color(141, 130, 112, 200);
private Color backgroundColor = defaultBackgroundColor;
private final int alpha = 0;
- private static Map SHADOW_IMAGE_CACHE;
+ private static final Map SHADOW_IMAGE_CACHE;
private static final Map IMAGE_CACHE;
static {
- SHADOW_IMAGE_CACHE = ImageCaches.register(new MapMaker().softValues().makeComputingMap(new Function() {
- @Override
- public BufferedImage apply(ShadowKey key) {
- return createShadowImage(key);
- }
- }));
+ SHADOW_IMAGE_CACHE = ImageCaches.register(new MapMaker().softValues().makeComputingMap((Function) key -> createShadowImage(key)));
- IMAGE_CACHE = ImageCaches.register(new MapMaker().softValues().makeComputingMap(new Function() {
- @Override
- public BufferedImage apply(Key key) {
- return createImage(key);
- }
- }));
+ IMAGE_CACHE = ImageCaches.register(new MapMaker().softValues().makeComputingMap((Function) key -> createImage(key)));
}
private final static class ShadowKey {
diff --git a/Mage.Client/src/main/java/mage/client/components/MageSynthStyleFactory.java b/Mage.Client/src/main/java/mage/client/components/MageSynthStyleFactory.java
index 73eb67b69c..375f7c60d5 100644
--- a/Mage.Client/src/main/java/mage/client/components/MageSynthStyleFactory.java
+++ b/Mage.Client/src/main/java/mage/client/components/MageSynthStyleFactory.java
@@ -14,7 +14,7 @@ import javax.swing.plaf.synth.SynthStyleFactory;
* @author nantuko
*/
public class MageSynthStyleFactory extends SynthStyleFactory {
- private SynthStyleFactory wrappedFactory;
+ private final SynthStyleFactory wrappedFactory;
public MageSynthStyleFactory(SynthStyleFactory factory) {
this.wrappedFactory = factory;
diff --git a/Mage.Client/src/main/java/mage/client/components/MageTextArea.java b/Mage.Client/src/main/java/mage/client/components/MageTextArea.java
index 219e0f72d7..9f2f6975df 100644
--- a/Mage.Client/src/main/java/mage/client/components/MageTextArea.java
+++ b/Mage.Client/src/main/java/mage/client/components/MageTextArea.java
@@ -57,22 +57,19 @@ public class MageTextArea extends JEditorPane {
buffer.append("