diff --git a/Mage.Client/pom.xml b/Mage.Client/pom.xml
index ae03ce324d..3a2612a36a 100644
--- a/Mage.Client/pom.xml
+++ b/Mage.Client/pom.xml
@@ -54,9 +54,9 @@
0.8.6
- com.google.collections
- google-collections
- 1.0
+ com.google.guava
+ guava
+ 20.0
org.swinglabs
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 7f7a774562..b5957413e7 100644
--- a/Mage.Client/src/main/java/mage/client/components/MageRoundPane.java
+++ b/Mage.Client/src/main/java/mage/client/components/MageRoundPane.java
@@ -1,20 +1,21 @@
package mage.client.components;
-import com.google.common.base.Function;
-import com.google.common.collect.MapMaker;
-import java.awt.BasicStroke;
-import java.awt.Color;
-import java.awt.Graphics;
-import java.awt.Graphics2D;
-import java.awt.RenderingHints;
+import java.awt.*;
import java.awt.image.BufferedImage;
-import java.util.Map;
import java.util.Objects;
-import javax.swing.JPanel;
-import mage.client.util.ImageCaches;
+
+import javax.swing.*;
+
import org.jdesktop.swingx.graphics.GraphicsUtilities;
import org.jdesktop.swingx.graphics.ShadowRenderer;
+import com.google.common.cache.CacheBuilder;
+import com.google.common.cache.CacheLoader;
+import com.google.common.cache.LoadingCache;
+
+import mage.client.util.ImageCaches;
+import mage.client.util.SoftValuesLoadingCache;
+
/**
* Mage round pane with transparency. Used for tooltips.
*
@@ -26,14 +27,12 @@ public class MageRoundPane extends JPanel {
private int Y_OFFSET = 30;
private final Color defaultBackgroundColor = new Color(141, 130, 112, 200); // color of the frame of the popup window
private Color backgroundColor = defaultBackgroundColor;
- private static final int ALPHA = 0;
- private static final Map SHADOW_IMAGE_CACHE;
- private static final Map IMAGE_CACHE;
+ private static final SoftValuesLoadingCache SHADOW_IMAGE_CACHE;
+ private static final SoftValuesLoadingCache IMAGE_CACHE;
static {
- SHADOW_IMAGE_CACHE = ImageCaches.register(new MapMaker().softValues().makeComputingMap((Function) key -> createShadowImage(key)));
-
- IMAGE_CACHE = ImageCaches.register(new MapMaker().softValues().makeComputingMap((Function) key -> createImage(key)));
+ SHADOW_IMAGE_CACHE = ImageCaches.register(SoftValuesLoadingCache.from(MageRoundPane::createShadowImage));
+ IMAGE_CACHE = ImageCaches.register(SoftValuesLoadingCache.from(MageRoundPane::createImage));
}
private static final class ShadowKey {
@@ -136,7 +135,7 @@ public class MageRoundPane extends JPanel {
@Override
protected void paintComponent(Graphics g) {
- g.drawImage(IMAGE_CACHE.get(new Key(getWidth(), getHeight(), X_OFFSET, Y_OFFSET, backgroundColor)), 0, 0, null);
+ g.drawImage(IMAGE_CACHE.getOrThrow(new Key(getWidth(), getHeight(), X_OFFSET, Y_OFFSET, backgroundColor)), 0, 0, null);
}
private static BufferedImage createImage(Key key) {
@@ -150,7 +149,7 @@ public class MageRoundPane extends JPanel {
Graphics2D g2 = image.createGraphics();
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
- BufferedImage shadow = SHADOW_IMAGE_CACHE.get(new ShadowKey(w, h));
+ BufferedImage shadow = SHADOW_IMAGE_CACHE.getOrThrow(new ShadowKey(w, h));
{
int xOffset = (shadow.getWidth() - w) / 2;
diff --git a/Mage.Client/src/main/java/mage/client/util/ImageCaches.java b/Mage.Client/src/main/java/mage/client/util/ImageCaches.java
index 2f5fe74345..479370288a 100644
--- a/Mage.Client/src/main/java/mage/client/util/ImageCaches.java
+++ b/Mage.Client/src/main/java/mage/client/util/ImageCaches.java
@@ -2,7 +2,8 @@
package mage.client.util;
import java.util.ArrayList;
-import java.util.Map;
+
+import com.google.common.cache.Cache;
/**
*
@@ -10,20 +11,20 @@ import java.util.Map;
*/
public final class ImageCaches {
- private static final ArrayList