* Improved handling of enlarged images. Added mode to show other side of flip and transform cards. Added icon for copied cards and possibility to show enlarged original or copied card.

This commit is contained in:
LevelX2 2014-03-06 21:51:51 +01:00
parent 0babf49392
commit 59d907c981
24 changed files with 490 additions and 233 deletions

View file

@ -62,7 +62,7 @@ public class CardPluginImpl implements CardPlugin {
private int cardWidth, cardHeight;
private int extraCardSpacingX, cardSpacingX, cardSpacingY;
private int stackSpacingX, stackSpacingY;
private List<Row> rows = new ArrayList<Row>();
private List<Row> rows = new ArrayList<>();
@Init
public void init() {
@ -183,7 +183,7 @@ public class CardPluginImpl implements CardPlugin {
int afterCreaturesIndex = rows.size();
wrap(lands, rows, afterCreaturesIndex);
// Store the current rows and others.
List<Row> storedRows = new ArrayList<Row>(rows.size());
List<Row> storedRows = new ArrayList<>(rows.size());
for (Row row : rows) {
storedRows.add((Row) row.clone());
}

View file

@ -7,21 +7,21 @@ import com.mortennobel.imagescaling.ResampleOp;
import de.schlichtherle.truezip.file.TFile;
import de.schlichtherle.truezip.file.TFileInputStream;
import de.schlichtherle.truezip.file.TFileOutputStream;
import mage.client.dialog.PreferencesDialog;
import mage.view.CardView;
import org.apache.log4j.Logger;
import org.mage.plugins.card.constants.Constants;
import org.mage.plugins.card.dl.sources.DirectLinksForDownload;
import org.mage.plugins.card.utils.CardImageUtils;
import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.Graphics2D;
import java.awt.Rectangle;
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.dialog.PreferencesDialog;
import mage.view.CardView;
import org.apache.log4j.Logger;
import org.mage.plugins.card.constants.Constants;
import org.mage.plugins.card.dl.sources.DirectLinksForDownload;
import org.mage.plugins.card.utils.CardImageUtils;
/**
* This class stores ALL card images in a cache with soft values. this means
@ -167,10 +167,20 @@ public class ImageCache {
if (card.getUsesVariousArt()) {
key += "#usesVariousArt";
}
// log.debug("#key: " + key);
// log.warn("#key: " + key);
return getImage(key);
}
public static BufferedImage getImageOriginalAlternateName(CardView card) {
String key = getKeyAlternateName(card, card.getAlternateName());
if (card.getUsesVariousArt()) {
key += "#usesVariousArt";
}
// log.warn("#key: " + key);
return getImage(key);
}
/**
* Returns the Image corresponding to the key
*/
@ -205,6 +215,18 @@ public class ImageCache {
return sb.toString();
}
/**
* Returns the map key for the flip image of a card, without any suffixes for the image size.
*/
private static String getKeyAlternateName(CardView card, String alternateName) {
StringBuilder sb = new StringBuilder(alternateName).append("#");
sb.append(card.getExpansionSetCode()).append("#");
sb.append(card.getType()).append("#");
sb.append(card.getCardNumber()).append("#");
sb.append(card.getTokenSetCode() == null ? "":card.getTokenSetCode());
return sb.toString();
}
/**
* Load image from file
*
@ -251,6 +273,7 @@ public class ImageCache {
/**
* Returns an image scaled to the size given
* @param original
* @return
*/
public static BufferedImage getNormalSizeImage(BufferedImage original) {
@ -289,6 +312,9 @@ public class ImageCache {
/**
* Returns an image scaled to the size appropriate for the card picture
* panel
* @param original
* @param sizeNeed
* @return
*/
public static BufferedImage getResizedImage(BufferedImage original, Rectangle sizeNeed) {
ResampleOp resampleOp = new ResampleOp(sizeNeed.width, sizeNeed.height);
@ -298,6 +324,10 @@ public class ImageCache {
/**
* Returns the image appropriate to display the card in the picture panel
* @param card
* @param width
* @param height
* @return
*/
public static BufferedImage getImage(CardView card, int width, int height) {
if (Constants.THUMBNAIL_SIZE_FULL.width + 10 > width) {

View file

@ -13,6 +13,7 @@ public interface ImageManager {
Image getNightImage();
Image getTokenIconImage();
Image getCopyInformIconImage();
Image getDlgAcceptButtonImage();
Image getDlgActiveAcceptButtonImage();

View file

@ -106,6 +106,15 @@ public class ImageManagerImpl implements ImageManager {
return imageTokenIcon;
}
@Override
public BufferedImage getCopyInformIconImage() {
if (imageCopyIcon == null) {
Image image = getImageFromResourceTransparent("/card/copy.png", Color.WHITE, new Rectangle(20, 20));
imageCopyIcon = BufferedImageBuilder.bufferImage(image, BufferedImage.TYPE_INT_ARGB);
}
return imageCopyIcon;
}
@Override
public Image getDlgCancelButtonImage() {
if (imageDlgCancelButton == null) {
@ -226,6 +235,7 @@ public class ImageManagerImpl implements ImageManager {
private static BufferedImage imageNight;
private static BufferedImage imageTokenIcon;
private static BufferedImage imageCopyIcon;
private static BufferedImage imageDlgAcceptButton;
private static BufferedImage imageDlgActiveAcceptButton;