mirror of
https://github.com/magefree/mage.git
synced 2025-12-22 03:22:00 -08:00
UI: added images cache reset after downloads finish (no more xmage restart for new images);
This commit is contained in:
parent
97c9659f1e
commit
c3ea8ddd7a
2 changed files with 21 additions and 12 deletions
|
|
@ -653,6 +653,9 @@ public class DownloadPicturesService extends DefaultBoundedRangeModel implements
|
||||||
|
|
||||||
// stop
|
// stop
|
||||||
reloadCardsToDownload(uiDialog.getSetsCombo().getSelectedItem().toString());
|
reloadCardsToDownload(uiDialog.getSetsCombo().getSelectedItem().toString());
|
||||||
|
|
||||||
|
// reset images cache
|
||||||
|
ImageCache.clearCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
static String convertStreamToString(InputStream is) {
|
static String convertStreamToString(InputStream is) {
|
||||||
|
|
|
||||||
|
|
@ -3,15 +3,6 @@ package org.mage.plugins.card.images;
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.collect.ComputationException;
|
import com.google.common.collect.ComputationException;
|
||||||
import com.google.common.collect.MapMaker;
|
import com.google.common.collect.MapMaker;
|
||||||
import java.awt.*;
|
|
||||||
import java.awt.geom.RoundRectangle2D;
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
import javax.imageio.ImageIO;
|
|
||||||
import mage.client.constants.Constants;
|
import mage.client.constants.Constants;
|
||||||
import mage.client.dialog.PreferencesDialog;
|
import mage.client.dialog.PreferencesDialog;
|
||||||
import mage.client.util.TransformedImageCache;
|
import mage.client.util.TransformedImageCache;
|
||||||
|
|
@ -23,13 +14,23 @@ import org.apache.log4j.Logger;
|
||||||
import org.mage.plugins.card.dl.sources.DirectLinksForDownload;
|
import org.mage.plugins.card.dl.sources.DirectLinksForDownload;
|
||||||
import org.mage.plugins.card.utils.CardImageUtils;
|
import org.mage.plugins.card.utils.CardImageUtils;
|
||||||
|
|
||||||
|
import javax.imageio.ImageIO;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.geom.RoundRectangle2D;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class stores ALL card images in a cache with soft values. this means
|
* This class stores ALL card images in a cache with soft values. this means
|
||||||
* that the images may be garbage collected when they are not needed any more,
|
* that the images may be garbage collected when they are not needed any more,
|
||||||
* but will be kept as long as possible.
|
* but will be kept as long as possible.
|
||||||
*
|
* <p>
|
||||||
* Key format: "[cardname]#[setname]#[type]#[collectorID]#[param]"
|
* Key format: "[cardname]#[setname]#[type]#[collectorID]#[param]"
|
||||||
*
|
* <p>
|
||||||
* where param is:
|
* where param is:
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>size of image</li>
|
* <li>size of image</li>
|
||||||
|
|
@ -228,6 +229,10 @@ public final class ImageCache {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void clearCache() {
|
||||||
|
IMAGE_CACHE.clear();
|
||||||
|
}
|
||||||
|
|
||||||
public static String getFilePath(CardView card, int width) {
|
public static String getFilePath(CardView card, int width) {
|
||||||
String key = getKey(card, card.getName(), Integer.toString(width));
|
String key = getKey(card, card.getName(), Integer.toString(width));
|
||||||
boolean usesVariousArt = false;
|
boolean usesVariousArt = false;
|
||||||
|
|
@ -389,7 +394,7 @@ public final class ImageCache {
|
||||||
return getImage(getKey(card, card.getName(), ""));
|
return getImage(getKey(card, card.getName(), ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
// public static BufferedImage getImageFaceOriginal(CardView card) {
|
// public static BufferedImage getImageFaceOriginal(CardView card) {
|
||||||
// return getFaceImage(getFaceKey(card, card.getName(), card.getExpansionSetCode()));
|
// return getFaceImage(getFaceKey(card, card.getName(), card.getExpansionSetCode()));
|
||||||
// }
|
// }
|
||||||
public static BufferedImage getImageOriginalAlternateName(CardView card) {
|
public static BufferedImage getImageOriginalAlternateName(CardView card) {
|
||||||
|
|
@ -472,6 +477,7 @@ public final class ImageCache {
|
||||||
// return alternateName + "#" + card.getExpansionSetCode() + "#" +card.getType()+ "#" + card.getCardNumber() + "#"
|
// return alternateName + "#" + card.getExpansionSetCode() + "#" +card.getType()+ "#" + card.getCardNumber() + "#"
|
||||||
// + (card.getTokenSetCode() == null ? "":card.getTokenSetCode());
|
// + (card.getTokenSetCode() == null ? "":card.getTokenSetCode());
|
||||||
// }
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load image from file
|
* Load image from file
|
||||||
*
|
*
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue