rename GraphicsUtils to ImageHelper and relocate to helpers package.

master
lodici 2016-10-07 10:20:27 +01:00
parent d02cd037e0
commit 8602d5dd26
39 changed files with 131 additions and 127 deletions

View File

@ -10,7 +10,7 @@ import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import javax.imageio.ImageIO;
import magic.ui.utility.GraphicsUtils;
import magic.ui.helpers.ImageHelper;
public class ResourceManager {
@ -271,7 +271,7 @@ public class ResourceManager {
private static BufferedImage getComponent(String imageName) {
String fName = FRAMES_FOLDER + imageName;
try (final InputStream is = getJarResourceStream(fName)) {
return GraphicsUtils.getOptimizedImage(ImageIO.read(is));
return ImageHelper.getOptimizedImage(ImageIO.read(is));
} catch (IOException ex) {
throw new RuntimeException(ex);
}
@ -280,14 +280,14 @@ public class ResourceManager {
public static BufferedImage getImage(String name) {
String fName = "/cardbuilder/images/" + name;
try (final InputStream is = getJarResourceStream(fName)) {
return GraphicsUtils.getOptimizedImage(ImageIO.read(is));
return ImageHelper.getOptimizedImage(ImageIO.read(is));
} catch (IOException ex) {
throw new RuntimeException(ex);
}
}
public static BufferedImage newFrame(BufferedImage bi) {
return GraphicsUtils.getOptimizedImage(bi);
return ImageHelper.getOptimizedImage(bi);
}
}

View File

@ -13,7 +13,7 @@ import magic.ui.ImageFileIO;
import magic.ui.MagicImages;
import magic.model.IRenderableCard;
import magic.cardBuilder.ResourceManager;
import magic.ui.utility.GraphicsUtils;
import magic.ui.helpers.ImageHelper;
import magic.utility.MagicFileSystem;
public class ImageFrame {
@ -119,28 +119,28 @@ public class ImageFrame {
File cropFile = MagicFileSystem.getCroppedCardImageFile(cardDef);
if (cropFile.exists()) {
if (cardDef.isPlaneswalker()) {
BufferedImage crop = GraphicsUtils.scale(ImageFileIO.toImg(cropFile, MagicImages.MISSING_CARD), 320, 234);
BufferedImage crop = ImageHelper.scale(ImageFileIO.toImg(cropFile, MagicImages.MISSING_CARD), 320, 234);
if (OracleText.getPlaneswalkerAbilityCount(cardDef) <= 3) {
BufferedImage blend = ResourceManager.newFrame(ResourceManager.getPlaneswalkerImageBlend);
return Frame.getBlendedFrame(new BufferedImage(320, 234, BufferedImage.TYPE_INT_ARGB), blend, crop);
} else {
BufferedImage cropSmall = crop.getSubimage(0, 0, 320, 201);
BufferedImage blend = GraphicsUtils.scale(ResourceManager.newFrame(ResourceManager.getPlaneswalkerImageBlend), 320, 201);
BufferedImage blend = ImageHelper.scale(ResourceManager.newFrame(ResourceManager.getPlaneswalkerImageBlend), 320, 201);
return Frame.getBlendedFrame(new BufferedImage(320, 210, BufferedImage.TYPE_INT_ARGB), blend, cropSmall);
}
} else if (cardDef.isToken()) {
if (cardDef.hasText()) {
BufferedImage crop = GraphicsUtils.scale(ImageFileIO.toImg(cropFile, MagicImages.MISSING_CARD), 320, 289);
BufferedImage crop = ImageHelper.scale(ImageFileIO.toImg(cropFile, MagicImages.MISSING_CARD), 320, 289);
BufferedImage blend = ResourceManager.newFrame(ResourceManager.tokenImageMaskSmall);
return Frame.getBlendedFrame(new BufferedImage(320, 289, BufferedImage.TYPE_INT_ARGB), blend, crop);
} else {
BufferedImage crop = GraphicsUtils.scale(ImageFileIO.toImg(cropFile, MagicImages.MISSING_CARD), 320, 360);
BufferedImage crop = ImageHelper.scale(ImageFileIO.toImg(cropFile, MagicImages.MISSING_CARD), 320, 360);
BufferedImage blend =ResourceManager.newFrame(ResourceManager.tokenImageMaskLarge);
return Frame.getBlendedFrame(new BufferedImage(320, 360, BufferedImage.TYPE_INT_ARGB), blend, crop);
}
} else {
BufferedImage image = ImageFileIO.toImg(cropFile, MagicImages.MISSING_CARD);
return GraphicsUtils.scale(image, 316, 231);
return ImageHelper.scale(image, 316, 231);
}
}
if (cardDef.isPlaneswalker()) {
@ -166,10 +166,10 @@ public class ImageFrame {
blend = ResourceManager.newFrame(ResourceManager.getPlaneswalkerImageBlend);
} else {
HEIGHT = 201;
blend = GraphicsUtils.scale(ResourceManager.newFrame(ResourceManager.getPlaneswalkerImageBlend), WIDTH, HEIGHT);
blend = ImageHelper.scale(ResourceManager.newFrame(ResourceManager.getPlaneswalkerImageBlend), WIDTH, HEIGHT);
}
BufferedImage background = GraphicsUtils.scale(getDefaultBackground(cardDef), WIDTH, HEIGHT);
BufferedImage symbol = GraphicsUtils.scale(getDefaultSymbol(cardDef), WIDTH, HEIGHT);
BufferedImage background = ImageHelper.scale(getDefaultBackground(cardDef), WIDTH, HEIGHT);
BufferedImage symbol = ImageHelper.scale(getDefaultSymbol(cardDef), WIDTH, HEIGHT);
BufferedImage image = Frame.getBlendedFrame(new BufferedImage(WIDTH, HEIGHT, BufferedImage.TYPE_INT_ARGB), blend, background);
return getCompositeImage(image, symbol);
}
@ -185,8 +185,8 @@ public class ImageFrame {
HEIGHT = 360;
blend = ResourceManager.newFrame((ResourceManager.tokenImageMaskLarge));
}
BufferedImage background = GraphicsUtils.scale(getDefaultBackground(cardDef), WIDTH, HEIGHT);
BufferedImage symbol = GraphicsUtils.scale(getDefaultSymbol(cardDef), WIDTH, HEIGHT);
BufferedImage background = ImageHelper.scale(getDefaultBackground(cardDef), WIDTH, HEIGHT);
BufferedImage symbol = ImageHelper.scale(getDefaultSymbol(cardDef), WIDTH, HEIGHT);
BufferedImage image = Frame.getBlendedFrame(new BufferedImage(WIDTH, HEIGHT, BufferedImage.TYPE_INT_ARGB), blend, background);
return getCompositeImage(image,symbol);
}

View File

@ -28,7 +28,7 @@ import magic.model.MagicType;
import magic.ui.MagicImages;
import magic.model.IRenderableCard;
import magic.cardBuilder.ResourceManager;
import magic.ui.utility.GraphicsUtils;
import magic.ui.helpers.ImageHelper;
public class OracleText {
@ -336,7 +336,7 @@ public class OracleText {
) {
//setUp baseImage and Graphics2D
BufferedImage baseImage = GraphicsUtils.getCompatibleBufferedImage(
BufferedImage baseImage = ImageHelper.getCompatibleBufferedImage(
(int) box.getWidth(),
(int) box.getHeight(),
Transparency.TRANSLUCENT);

View File

@ -1,6 +1,6 @@
package magic.ui;
import magic.ui.utility.GraphicsUtils;
import magic.ui.helpers.ImageHelper;
import java.awt.image.BufferedImage;
import java.io.Closeable;
import java.io.File;
@ -36,7 +36,7 @@ public final class ImageFileIO {
return def.get();
} else {
final BufferedImage optimizedImage =
GraphicsUtils.getCompatibleBufferedImage(img.getWidth(), img.getHeight(), img.getTransparency());
ImageHelper.getCompatibleBufferedImage(img.getWidth(), img.getHeight(), img.getTransparency());
optimizedImage.getGraphics().drawImage(img, 0, 0 , null);
return optimizedImage;
}
@ -49,7 +49,7 @@ public final class ImageFileIO {
imageFile.delete();
return null;
}
BufferedImage optimizedImage = GraphicsUtils.getCompatibleBufferedImage(
BufferedImage optimizedImage = ImageHelper.getCompatibleBufferedImage(
sourceImage.getWidth(),
sourceImage.getHeight(),
sourceImage.getTransparency()

View File

@ -23,7 +23,7 @@ import magic.model.MagicGameLog;
import magic.ui.screen.ScreenHelper;
import magic.ui.theme.ThemeFactory;
import magic.ui.helpers.DesktopHelper;
import magic.ui.utility.GraphicsUtils;
import magic.ui.helpers.ImageHelper;
import magic.utility.MagicFileSystem.DataPath;
import magic.utility.MagicFileSystem;
import magic.utility.MagicSystem;
@ -215,7 +215,7 @@ public class MagicFrame extends MagicStickyFrame implements IDragDropListener {
private void doScreenshot() {
try {
final Path filePath = MagicFileSystem.getDataPath(DataPath.LOGS).resolve("screenshot.png");
final File imageFile = GraphicsUtils.doScreenshotToFile(this.getContentPane(), filePath);
final File imageFile = ImageHelper.doScreenshotToFile(this.getContentPane(), filePath);
DesktopHelper.openFileInDefaultOsEditor(imageFile);
} catch (IOException | DesktopNotSupportedException e) {
e.printStackTrace();
@ -259,7 +259,7 @@ public class MagicFrame extends MagicStickyFrame implements IDragDropListener {
private void doSetCustomBackgroundImage(File imageFile) {
if (!GraphicsUtils.isValidImageFile(imageFile)) {
if (!ImageHelper.isValidImageFile(imageFile)) {
ScreenController.showWarningMessage("Invalid image file.");
return;
}

View File

@ -9,7 +9,7 @@ import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import magic.data.GeneralConfig;
import magic.ui.theme.Theme;
import magic.ui.utility.GraphicsUtils;
import magic.ui.helpers.ImageHelper;
import magic.ui.utility.MagicStyle;
import net.miginfocom.swing.MigLayout;
@ -106,7 +106,7 @@ class MagicFramePanel extends JPanel {
private BufferedImage getBackgroundImage() {
return GeneralConfig.getInstance().isCustomBackground()
? GraphicsUtils.getCustomBackgroundImage()
? ImageHelper.getCustomBackgroundImage()
: activeTheme.getBackgroundImage();
}
@ -124,8 +124,8 @@ class MagicFramePanel extends JPanel {
imageRect = new Rectangle(0, (ih - ih2) / 2, iw, ih2);
}
final BufferedImage subImage = GraphicsUtils.getOptimizedSubimage(aImage, imageRect);
cachedImage = GraphicsUtils.scale(subImage, container.width, container.height);
final BufferedImage subImage = ImageHelper.getOptimizedSubimage(aImage, imageRect);
cachedImage = ImageHelper.scale(subImage, container.width, container.height);
g.drawImage(cachedImage, 0, 0, this);
}

View File

@ -27,7 +27,7 @@ import magic.model.MagicPermanent;
import magic.model.player.PlayerProfile;
import magic.ui.dialog.prefs.ImageSizePresets;
import magic.ui.theme.PlayerAvatar;
import magic.ui.utility.GraphicsUtils;
import magic.ui.helpers.ImageHelper;
import magic.utility.MagicFileSystem;
import magic.utility.MagicResources;
@ -39,7 +39,7 @@ public final class MagicImages {
static {
BufferedImage image = ImageFileIO.toImg(MagicResources.getImageUrl("card-back.jpg"), null);
Dimension size = getPreferredImageSize(image);
BACK_IMAGE = GraphicsUtils.scale(image, size.width, size.height);
BACK_IMAGE = ImageHelper.scale(image, size.width, size.height);
}
// when the preferred image or icon is missing.
@ -49,8 +49,8 @@ public final class MagicImages {
// "M" logo variations.
public static final BufferedImage LOGO = loadImage("logo.png");
public static final BufferedImage MENU_LOGO = GraphicsUtils.scale(LOGO, 40, 40);
public static final BufferedImage APP_LOGO = GraphicsUtils.scale(LOGO, 32, 32);
public static final BufferedImage MENU_LOGO = ImageHelper.scale(LOGO, 40, 40);
public static final BufferedImage APP_LOGO = ImageHelper.scale(LOGO, 32, 32);
// About
public static final BufferedImage ABOUT_LOGO = loadImage("magarena-logo.png");
@ -118,7 +118,7 @@ public final class MagicImages {
public static ImageIcon getSmallManaIcon(MagicIcon manaIcon) {
if (!smallManaIcons.containsKey(manaIcon)) {
Image image = GraphicsUtils.scale(loadManaImage(manaIcon), 15, 15);
Image image = ImageHelper.scale(loadManaImage(manaIcon), 15, 15);
smallManaIcons.put(manaIcon, new ImageIcon(image));
}
return smallManaIcons.get(manaIcon);
@ -126,7 +126,7 @@ public final class MagicImages {
public static ImageIcon getBigManaIcon(MagicIcon manaIcon) {
if (!bigManaIcons.containsKey(manaIcon)) {
Image image = GraphicsUtils.scale(loadManaImage(manaIcon), 25, 25);
Image image = ImageHelper.scale(loadManaImage(manaIcon), 25, 25);
bigManaIcons.put(manaIcon, new ImageIcon(image));
}
return bigManaIcons.get(manaIcon);

View File

@ -1,7 +1,7 @@
package magic.ui;
import magic.translate.UiString;
import magic.ui.utility.GraphicsUtils;
import magic.ui.helpers.ImageHelper;
import java.awt.Component;
import java.awt.Desktop;
import java.nio.file.Path;
@ -66,7 +66,7 @@ public class UiExceptionHandler extends FileExceptionHandler {
public void run() {
try {
final Path filePath = MagicFileSystem.getDataPath(MagicFileSystem.DataPath.LOGS).resolve("crash.png");
GraphicsUtils.doScreenshotToFile(container, filePath);
ImageHelper.doScreenshotToFile(container, filePath);
} catch (Exception e) {
System.err.println("ScreenShot failed : " + e.toString());
}

View File

@ -17,7 +17,7 @@ import magic.ui.MagicSound;
import magic.ui.helpers.UrlHelper;
import magic.ui.theme.ThemeFactory;
import magic.ui.helpers.DesktopHelper;
import magic.ui.utility.GraphicsUtils;
import magic.ui.helpers.ImageHelper;
import magic.utility.MagicFileSystem;
import net.miginfocom.swing.MigLayout;
@ -81,8 +81,8 @@ class ThemesActionPanel extends JPanel {
}
private ImageIcon getActionIcon(MagicIcon icon) {
final ImageIcon blackIcon = (ImageIcon) GraphicsUtils.getRecoloredIcon(MagicImages.getIcon(icon), Color.BLACK);
final BufferedImage scaledImage = GraphicsUtils.scale(GraphicsUtils.getConvertedIcon(blackIcon), 18, 18);
final ImageIcon blackIcon = (ImageIcon) ImageHelper.getRecoloredIcon(MagicImages.getIcon(icon), Color.BLACK);
final BufferedImage scaledImage = ImageHelper.scale(ImageHelper.getConvertedIcon(blackIcon), 18, 18);
return new ImageIcon(scaledImage);
}

View File

@ -1,4 +1,4 @@
package magic.ui.utility;
package magic.ui.helpers;
import java.awt.AlphaComposite;
import java.awt.Color;
@ -30,10 +30,11 @@ import javax.swing.JComponent;
import magic.ui.image.filter.GrayScaleImageFilter;
import magic.ui.image.filter.WhiteColorSwapImageFilter;
import magic.ui.theme.Theme;
import magic.ui.utility.MagicStyle;
import magic.utility.MagicFileSystem.DataPath;
import magic.utility.MagicFileSystem;
final public class GraphicsUtils {
final public class ImageHelper {
private static final GrayScaleImageFilter GRAYSCALE_FILTER = new GrayScaleImageFilter();
@ -44,7 +45,7 @@ final public class GraphicsUtils {
.getDefaultConfiguration() :
null;
private GraphicsUtils() {}
private ImageHelper() {}
public static BufferedImage scale(final BufferedImage img, final int targetWidth, final int targetHeight) {
if (img.getWidth() == targetWidth && img.getHeight() == targetHeight) {
@ -219,7 +220,7 @@ final public class GraphicsUtils {
}
return (image != null) ?
GraphicsUtils.getOptimizedImage(image) :
ImageHelper.getOptimizedImage(image) :
MagicStyle.getTheme().getTexture(Theme.TEXTURE_BACKGROUND);
}
@ -237,7 +238,7 @@ final public class GraphicsUtils {
public static BufferedImage getConvertedIcon(final ImageIcon icon) {
final BufferedImage bi =
GraphicsUtils.getCompatibleBufferedImage(
ImageHelper.getCompatibleBufferedImage(
icon.getIconWidth(), icon.getIconHeight(), Transparency.TRANSLUCENT);
final Graphics g = bi.createGraphics();
// paint the Icon to the BufferedImage.
@ -299,7 +300,7 @@ final public class GraphicsUtils {
}
public static BufferedImage getTranslucentImage(BufferedImage image, float opacity) {
final BufferedImage newImage = GraphicsUtils.getCompatibleBufferedImage(image);
final BufferedImage newImage = ImageHelper.getCompatibleBufferedImage(image);
final Graphics2D g2d = newImage.createGraphics();
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, opacity));
g2d.drawImage(image, 0, 0, null);
@ -326,7 +327,7 @@ final public class GraphicsUtils {
* (see <a href="http://www.jhlabs.com/ip/managed_images.html">external link</a>)
*/
public static BufferedImage getOptimizedSubimage(BufferedImage image, Rectangle rect) {
return GraphicsUtils.getOptimizedImage(image.getSubimage(rect.x, rect.y, rect.width, rect.height));
return ImageHelper.getOptimizedImage(image.getSubimage(rect.x, rect.y, rect.width, rect.height));
}
}

View File

@ -5,7 +5,7 @@ import java.awt.image.BufferedImage;
import javax.swing.JPanel;
import magic.ui.MagicImages;
import magic.ui.MagicSound;
import magic.ui.utility.GraphicsUtils;
import magic.ui.helpers.ImageHelper;
import net.miginfocom.swing.MigLayout;
import org.pushingpixels.trident.Timeline;
import org.pushingpixels.trident.callback.TimelineCallback;
@ -56,7 +56,7 @@ public class AboutContentPanel extends JPanel
BufferedImage image = MagicImages.ABOUT_LOGO;
int scaledW = (int) (image.getWidth() * imageScale);
int scaledH = (int) (image.getHeight() * imageScale);
BufferedImage scaled = GraphicsUtils.scale(image, scaledW, scaledH);
BufferedImage scaled = ImageHelper.scale(image, scaledW, scaledH);
int posX = (getWidth() - scaled.getWidth()) / 2;
int posY = (getHeight() - scaled.getHeight()) / 2;
g.drawImage(scaled, posX, posY, null);

View File

@ -6,7 +6,7 @@ import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.Transparency;
import java.awt.image.BufferedImage;
import magic.ui.utility.GraphicsUtils;
import magic.ui.helpers.ImageHelper;
public class BattlefieldTextOverlay {
@ -25,14 +25,14 @@ public class BattlefieldTextOverlay {
textOverlayImage.getWidth() != battlefieldWidth;
if (createNewImage) {
textOverlayImage = GraphicsUtils.getCompatibleBufferedImage(
textOverlayImage = ImageHelper.getCompatibleBufferedImage(
battlefieldWidth, batttlefieldHeight, Transparency.BITMASK
);
}
if (refreshOverlay) {
refreshOverlay = false;
GraphicsUtils.clearImage(textOverlayImage);
ImageHelper.clearImage(textOverlayImage);
final Graphics2D g2d = textOverlayImage.createGraphics();
g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
drawZoneName(g2d);
@ -47,7 +47,7 @@ public class BattlefieldTextOverlay {
final int textWidth = g2d.getFontMetrics(ZONE_FONT).stringWidth(zoneName);
final int textX = (textOverlayImage.getWidth() / 2) - (textWidth / 2);
final int textY = textOverlayImage.getHeight() - 4;
GraphicsUtils.drawStringWithOutline(g2d, zoneName, textX, textY, Color.YELLOW, Color.DARK_GRAY);
ImageHelper.drawStringWithOutline(g2d, zoneName, textX, textY, Color.YELLOW, Color.DARK_GRAY);
}
public void setPlayerZoneName(final String text) {

View File

@ -9,7 +9,7 @@ import java.awt.RenderingHints;
import java.awt.Transparency;
import java.awt.geom.Ellipse2D;
import java.awt.image.BufferedImage;
import magic.ui.utility.GraphicsUtils;
import magic.ui.helpers.ImageHelper;
public class CounterOverlay {
@ -21,7 +21,7 @@ public class CounterOverlay {
public CounterOverlay(final int width, final int height, final Color color) {
this.counterColor = color;
image = GraphicsUtils.getCompatibleBufferedImage(width, height, Transparency.TRANSLUCENT);
image = ImageHelper.getCompatibleBufferedImage(width, height, Transparency.TRANSLUCENT);
drawCounter();
}
@ -30,7 +30,7 @@ public class CounterOverlay {
}
private void drawCounter() {
GraphicsUtils.clearImage(image);
ImageHelper.clearImage(image);
final Graphics2D g2d = image.createGraphics();
// drawBorder(g2d);
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
@ -81,7 +81,7 @@ public class CounterOverlay {
final int textWidth = metrics.stringWidth(text);
final int textX = image.getWidth(null) / 2 - textWidth / 2;
final int textY = image.getHeight(null) / 2 + 4;
GraphicsUtils.drawStringWithOutline(g2d, text, textX, textY);
ImageHelper.drawStringWithOutline(g2d, text, textX, textY);
}
public void setCounterValue(final int value) {

View File

@ -14,11 +14,13 @@ import magic.model.MagicGame;
import magic.model.MagicGameLog;
import magic.ui.ScreenController;
import magic.ui.helpers.DesktopHelper;
import magic.ui.utility.GraphicsUtils;
import magic.ui.helpers.ImageHelper;
import magic.utility.MagicFileSystem;
import static magic.utility.MagicFileSystem.getDataPath;
import org.apache.commons.io.FileUtils;
import static magic.utility.MagicFileSystem.getDataPath;
import static magic.utility.MagicFileSystem.getDataPath;
import static magic.utility.MagicFileSystem.getDataPath;
final class GameplayReport {
private GameplayReport() {}
@ -42,7 +44,7 @@ final class GameplayReport {
private static void saveScreenshot() throws IOException {
final Path filePath = MagicFileSystem.getGameplayReportDirectory().resolve(SCREEN_FILE);
GraphicsUtils.doScreenshotToFile(ScreenController.getMainFrame().getContentPane(), filePath, IMAGE_TYPE);
ImageHelper.doScreenshotToFile(ScreenController.getMainFrame().getContentPane(), filePath, IMAGE_TYPE);
}
private static void saveGameState(MagicGame aGame) {

View File

@ -47,7 +47,7 @@ class AvatarImageSet {
final String filePath = itr.next().toAbsolutePath().toString();
final InputStream ins = new FileInputStream(new File(filePath));
final BufferedImage image = ImageFileIO.toImg(ins, MagicImages.MISSING_BIG);
this.sampleImage = new ImageIcon(magic.ui.utility.GraphicsUtils.scale(image, PlayerAvatar.MEDIUM_SIZE, PlayerAvatar.MEDIUM_SIZE));
this.sampleImage = new ImageIcon(magic.ui.helpers.ImageHelper.scale(image, PlayerAvatar.MEDIUM_SIZE, PlayerAvatar.MEDIUM_SIZE));
}
} catch (IOException e) {
e.printStackTrace();

View File

@ -48,7 +48,7 @@ import magic.ui.screen.widget.ActionBarButton;
import magic.ui.screen.widget.MenuButton;
import magic.ui.theme.PlayerAvatar;
import magic.ui.theme.Theme;
import magic.ui.utility.GraphicsUtils;
import magic.ui.helpers.ImageHelper;
import magic.ui.ImageFileIO;
import magic.translate.UiString;
import magic.ui.screen.AbstractScreen;
@ -115,7 +115,7 @@ public class AvatarImagesScreen extends AbstractScreen implements IStatusBar, IA
final String filePath = imagePath.toAbsolutePath().toString();
try (final InputStream ins = new FileInputStream(new File(filePath))) {
final BufferedImage image = ImageFileIO.toImg(ins, MagicImages.MISSING_BIG);
final ImageIcon icon = new ImageIcon(GraphicsUtils.scale(image, PlayerAvatar.LARGE_SIZE, PlayerAvatar.LARGE_SIZE));
final ImageIcon icon = new ImageIcon(ImageHelper.scale(image, PlayerAvatar.LARGE_SIZE, PlayerAvatar.LARGE_SIZE));
final JLabel iconLabel = new JLabel(icon);
imagePathMap.put(iconLabel, imagePath);
iconLabel.setBorder(FontsAndBorders.EMPTY_BORDER);
@ -160,7 +160,7 @@ public class AvatarImagesScreen extends AbstractScreen implements IStatusBar, IA
icon.paintIcon(null, g, 0,0);
g.dispose();
rightActionButton = new ActionBarButton(
new ImageIcon(GraphicsUtils.scale(bi, 46, 46)),
new ImageIcon(ImageHelper.scale(bi, 46, 46)),
UiString.get(_S1), UiString.get(_S2),
new AbstractAction() {
@Override

View File

@ -5,7 +5,7 @@ import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import javax.swing.JPanel;
import magic.ui.utility.GraphicsUtils;
import magic.ui.helpers.ImageHelper;
@SuppressWarnings("serial")
public class TestContentPanel extends JPanel {
@ -26,7 +26,7 @@ public class TestContentPanel extends JPanel {
g2d.fillRect(0, 0, getWidth(), getHeight());
g2d.setFont(getFont().deriveFont(48f));
int w = g2d.getFontMetrics(g2d.getFont()).stringWidth("TEST");
GraphicsUtils.drawStringWithOutline(g2d, "TEST", (getWidth() - w) / 2, (getHeight() - g2d.getFontMetrics().getHeight()) / 2);
ImageHelper.drawStringWithOutline(g2d, "TEST", (getWidth() - w) / 2, (getHeight() - g2d.getFontMetrics().getHeight()) / 2);
g2d.dispose();
}
}

View File

@ -6,7 +6,7 @@ import javax.swing.ImageIcon;
import java.awt.Point;
import java.awt.event.MouseEvent;
import javax.swing.Icon;
import magic.ui.utility.GraphicsUtils;
import magic.ui.helpers.ImageHelper;
import magic.ui.utility.MagicStyle;
@SuppressWarnings("serial")
@ -46,11 +46,11 @@ public class ActionBarButton extends MenuButton {
@Override
public void setIcon(Icon defaultIcon) {
super.setIcon(defaultIcon);
setRolloverIcon(GraphicsUtils.getRecoloredIcon(
setRolloverIcon(ImageHelper.getRecoloredIcon(
(ImageIcon) defaultIcon,
MagicStyle.getRolloverColor())
);
setPressedIcon(GraphicsUtils.getRecoloredIcon(
setPressedIcon(ImageHelper.getRecoloredIcon(
(ImageIcon) defaultIcon,
MagicStyle.getPressedColor())
);

View File

@ -9,7 +9,7 @@ import javax.swing.AbstractAction;
import javax.swing.ImageIcon;
import magic.data.MagicIcon;
import magic.ui.MagicImages;
import magic.ui.utility.GraphicsUtils;
import magic.ui.helpers.ImageHelper;
@SuppressWarnings("serial")
public class DialButton extends ActionBarButton {
@ -38,7 +38,7 @@ public class DialButton extends ActionBarButton {
}
private void rotateIconImage() {
final BufferedImage image = GraphicsUtils.getCompatibleBufferedImage(
final BufferedImage image = ImageHelper.getCompatibleBufferedImage(
DIAL_ICON.getIconWidth(), DIAL_ICON.getIconWidth(), BufferedImage.TRANSLUCENT
);
final Graphics2D g2d = image.createGraphics();

View File

@ -15,7 +15,7 @@ import magic.data.MagicIcon;
import magic.translate.UiString;
import magic.ui.MagicImages;
import magic.ui.ScreenController;
import magic.ui.utility.GraphicsUtils;
import magic.ui.helpers.ImageHelper;
import magic.ui.utility.MagicStyle;
import magic.ui.widget.FontsAndBorders;
@ -137,15 +137,15 @@ public class MenuButton extends JButton {
@Override
public void setIcon(final Icon defaultIcon) {
super.setIcon(defaultIcon);
setRolloverIcon(GraphicsUtils.getRecoloredIcon(
setRolloverIcon(ImageHelper.getRecoloredIcon(
(ImageIcon) defaultIcon,
MagicStyle.getRolloverColor())
);
setPressedIcon(GraphicsUtils.getRecoloredIcon(
setPressedIcon(ImageHelper.getRecoloredIcon(
(ImageIcon) defaultIcon,
MagicStyle.getPressedColor())
);
setDisabledIcon(GraphicsUtils.getRecoloredIcon(
setDisabledIcon(ImageHelper.getRecoloredIcon(
(ImageIcon) defaultIcon,
COLOR_DISABLED)
);

View File

@ -2,7 +2,7 @@ package magic.ui.theme;
import java.awt.image.BufferedImage;
import javax.swing.ImageIcon;
import magic.ui.utility.GraphicsUtils;
import magic.ui.helpers.ImageHelper;
public class PlayerAvatar {
@ -18,10 +18,10 @@ public class PlayerAvatar {
private int face = 0;
public PlayerAvatar(final BufferedImage image) {
largeIcon = new ImageIcon(GraphicsUtils.scale(image, LARGE_SIZE, LARGE_SIZE));
mediumIcon = new ImageIcon(GraphicsUtils.scale(image, MEDIUM_SIZE, MEDIUM_SIZE));
smallIcon = new ImageIcon(GraphicsUtils.scale(image, SMALL_SIZE, SMALL_SIZE));
turnIcon = new ImageIcon(GraphicsUtils.scale(image, CUSTOM_SIZE, CUSTOM_SIZE));
largeIcon = new ImageIcon(ImageHelper.scale(image, LARGE_SIZE, LARGE_SIZE));
mediumIcon = new ImageIcon(ImageHelper.scale(image, MEDIUM_SIZE, MEDIUM_SIZE));
smallIcon = new ImageIcon(ImageHelper.scale(image, SMALL_SIZE, SMALL_SIZE));
turnIcon = new ImageIcon(ImageHelper.scale(image, CUSTOM_SIZE, CUSTOM_SIZE));
}
/**

View File

@ -1,5 +1,6 @@
package magic.ui.utility;
import magic.ui.helpers.ImageHelper;
import java.awt.Color;
import java.awt.FontMetrics;
import java.awt.Graphics;
@ -169,7 +170,7 @@ public class ImageDrawingUtils {
public static void drawCardId(final Graphics g, long id, int x, int y) {
if (MagicSystem.isDevMode()) {
g.setFont(FontsAndBorders.FONT1.deriveFont(11f));
GraphicsUtils.drawStringWithOutline(g, Long.toString(id), x + 6, y + 13);
ImageHelper.drawStringWithOutline(g, Long.toString(id), x + 6, y + 13);
}
}

View File

@ -11,15 +11,15 @@ import javax.swing.JPopupMenu;
import javax.swing.SwingUtilities;
import magic.data.MagicIcon;
import magic.ui.MagicImages;
import magic.ui.utility.GraphicsUtils;
import magic.ui.helpers.ImageHelper;
import magic.ui.utility.MagicStyle;
@SuppressWarnings("serial")
public class MenuIconLabel extends JLabel {
private static final ImageIcon NORMAL_ICON = MagicImages.getIcon(MagicIcon.MENU);
private static final Icon HILITE_ICON = GraphicsUtils.getRecoloredIcon(NORMAL_ICON, MagicStyle.getRolloverColor());
private static final Icon PRESSED_ICON = GraphicsUtils.getRecoloredIcon(NORMAL_ICON, MagicStyle.getPressedColor());
private static final Icon HILITE_ICON = ImageHelper.getRecoloredIcon(NORMAL_ICON, MagicStyle.getRolloverColor());
private static final Icon PRESSED_ICON = ImageHelper.getRecoloredIcon(NORMAL_ICON, MagicStyle.getPressedColor());
private JPopupMenu menu;

View File

@ -11,7 +11,7 @@ import magic.ui.duel.resolution.ResolutionProfileResult;
import magic.ui.duel.resolution.ResolutionProfileType;
import magic.ui.screen.interfaces.IThemeStyle;
import magic.ui.theme.Theme;
import magic.ui.utility.GraphicsUtils;
import magic.ui.helpers.ImageHelper;
import magic.ui.utility.MagicStyle;
@SuppressWarnings("serial")
@ -158,7 +158,7 @@ public class ZoneBackgroundLabel extends JLabel implements IThemeStyle {
private void createBackgroundImage() {
cachedSize = new Dimension(getSize());
cachedImage = GraphicsUtils.getCompatibleBufferedImage(cachedSize.width, cachedSize.height);
cachedImage = ImageHelper.getCompatibleBufferedImage(cachedSize.width, cachedSize.height);
final Graphics2D g2d = cachedImage.createGraphics();
drawThemeBackground(g2d);
g2d.dispose();

View File

@ -41,7 +41,7 @@ import magic.ui.screen.duel.game.SwingGameController;
import magic.ui.widget.duel.animation.AnimationFx;
import magic.ui.widget.duel.animation.MagicAnimations;
import magic.ui.theme.AbilityIcon;
import magic.ui.utility.GraphicsUtils;
import magic.ui.helpers.ImageHelper;
import magic.ui.widget.FontsAndBorders;
import magic.utility.MagicSystem;
import org.pushingpixels.trident.Timeline;
@ -222,7 +222,7 @@ public class AnnotatedCardPanel extends JPanel {
private void setPopupImage() {
// create a blank canvas of the appropriate size.
popupImage = GraphicsUtils.getCompatibleBufferedImage(getWidth(), getHeight(), Transparency.TRANSLUCENT);
popupImage = ImageHelper.getCompatibleBufferedImage(getWidth(), getHeight(), Transparency.TRANSLUCENT);
final Graphics g = popupImage.getGraphics();
final Graphics2D g2d = (Graphics2D)g;
// don't overwrite original image with modified PT overlay, use a copy.
@ -232,7 +232,7 @@ public class AnnotatedCardPanel extends JPanel {
drawPowerToughnessOverlay(cardCanvas);
}
// scale card image if required.
final BufferedImage scaledImage = GraphicsUtils.scale(cardCanvas, imageOnlyPopupSize.width, imageOnlyPopupSize.height);
final BufferedImage scaledImage = ImageHelper.scale(cardCanvas, imageOnlyPopupSize.width, imageOnlyPopupSize.height);
//
// draw card image onto popup canvas, right-aligned.
g.drawImage(scaledImage, popupSize.width - imageOnlyPopupSize.width, 0, this);
@ -242,7 +242,7 @@ public class AnnotatedCardPanel extends JPanel {
if (MagicSystem.isDevMode() && magicObject != null && magicObject instanceof MagicPermanent) {
final MagicPermanent card = (MagicPermanent) magicObject;
g.setFont(FontsAndBorders.FONT1);
GraphicsUtils.drawStringWithOutline(g, Long.toString(card.getCard().getId()), 2, 14);
ImageHelper.drawStringWithOutline(g, Long.toString(card.getCard().getId()), 2, 14);
}
}
@ -257,7 +257,7 @@ public class AnnotatedCardPanel extends JPanel {
private BufferedImage getPTOverlay(Color maskColor) {
// create fixed size empty transparent image.
final BufferedImage overlay = GraphicsUtils.getCompatibleBufferedImage(312, 445, Transparency.TRANSLUCENT);
final BufferedImage overlay = ImageHelper.getCompatibleBufferedImage(312, 445, Transparency.TRANSLUCENT);
final Graphics2D g2d = overlay.createGraphics();
// use a rectangular opaque mask to hide original P/T.
@ -294,7 +294,7 @@ public class AnnotatedCardPanel extends JPanel {
);
// get transparent P/T overlay and size to card image.
final BufferedImage overlay = GraphicsUtils.scale(
final BufferedImage overlay = ImageHelper.scale(
getPTOverlay(maskColor),
cardImage.getWidth(),
cardImage.getHeight()

View File

@ -9,7 +9,7 @@ import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.JLabel;
import javax.swing.JWindow;
import magic.ui.utility.GraphicsUtils;
import magic.ui.helpers.ImageHelper;
import net.miginfocom.swing.MigLayout;
import org.pushingpixels.trident.Timeline;
import org.pushingpixels.trident.ease.Spline;
@ -101,7 +101,7 @@ public class MagicInfoWindow extends JWindow {
@Override
public void setVisible(boolean aFlag) {
super.setVisible(aFlag);
if (GraphicsUtils.isWindowTranslucencySupported()) {
if (ImageHelper.isWindowTranslucencySupported()) {
if (aFlag == false) {
setOpacity(0f);
} else {

View File

@ -17,7 +17,7 @@ import magic.model.MagicCard;
import magic.model.MagicCardDefinition;
import magic.ui.MagicImages;
import magic.ui.ScreenController;
import magic.ui.utility.GraphicsUtils;
import magic.ui.helpers.ImageHelper;
import magic.ui.utility.MagicStyle;
import magic.ui.widget.TexturedPanel;
@ -70,7 +70,7 @@ public class CardImageOverlay extends TexturedPanel {
Math.min(getWidth(), baseWidth) / (double) baseWidth,
Math.min(getHeight(), baseHeight) / (double) baseHeight
);
cardImage = GraphicsUtils.scale(baseImage, (int)(scale * baseWidth), (int)(scale * baseHeight));
cardImage = ImageHelper.scale(baseImage, (int)(scale * baseWidth), (int)(scale * baseHeight));
repaint();
}

View File

@ -25,7 +25,7 @@ import java.util.stream.Collectors;
import magic.model.MagicCard;
import magic.ui.dialog.prefs.ImageSizePresets;
import magic.ui.helpers.MouseHelper;
import magic.ui.utility.GraphicsUtils;
import magic.ui.helpers.ImageHelper;
import magic.ui.utility.MagicStyle;
@SuppressWarnings("serial")
@ -314,7 +314,7 @@ public class CardsCanvas extends JPanel {
final int W = canvasCard.getBounds().width;
final int H = canvasCard.getBounds().height;
g.drawImage(GraphicsUtils.scale(canvasCard.getFrontImage(), W, H), X, Y, null);
g.drawImage(ImageHelper.scale(canvasCard.getFrontImage(), W, H), X, Y, null);
if (stackDuplicateCards) {
drawCardCount(g, X, Y, W, H, canvasCard);

View File

@ -10,7 +10,7 @@ import java.awt.RenderingHints;
import java.awt.image.BufferedImage;
import java.awt.image.ImageObserver;
import java.io.IOException;
import magic.ui.utility.GraphicsUtils;
import magic.ui.helpers.ImageHelper;
public class ImageHandler {
@ -38,7 +38,7 @@ public class ImageHandler {
public BufferedImage getAnnotatedImage(final String id, final Image sourceImage) {
final BufferedImage pic
= GraphicsUtils.getCompatibleBufferedImage(
= ImageHelper.getCompatibleBufferedImage(
sourceImage.getWidth(observer),
sourceImage.getHeight(observer));
Graphics2D g2d = (Graphics2D) pic.getGraphics();
@ -67,7 +67,7 @@ public class ImageHandler {
final double aspectRatio = (double) sourceImage.getWidth() / sourceImage.getHeight();
final int newHeight = (int) (newWidth / aspectRatio);
final boolean useQualityScale = newWidth < sourceImage.getWidth();
scaledImage = GraphicsUtils.scale(
scaledImage = ImageHelper.scale(
sourceImage,
newWidth, newHeight,
RenderingHints.VALUE_INTERPOLATION_BILINEAR,
@ -88,7 +88,7 @@ public class ImageHandler {
*/
private BufferedImage loadImageResourceFromFile(final String filename) {
final BufferedImage source = loadImage(filename);
final BufferedImage buffImage = GraphicsUtils.getCompatibleBufferedImage(source.getWidth(), source.getHeight());
final BufferedImage buffImage = ImageHelper.getCompatibleBufferedImage(source.getWidth(), source.getHeight());
buffImage.getGraphics().drawImage(source, 0, 0, observer);
return buffImage;
}

View File

@ -13,7 +13,7 @@ import magic.model.MagicColor;
import magic.model.MagicManaType;
import magic.translate.UiString;
import magic.ui.MagicImages;
import magic.ui.utility.GraphicsUtils;
import magic.ui.helpers.ImageHelper;
import net.miginfocom.swing.MigLayout;
@SuppressWarnings("serial")
@ -49,15 +49,15 @@ class StatsTable extends JPanel {
for (MagicColor color : MagicColor.values()) {
final ImageIcon colorIcon = MagicImages.getIcon(color.getManaType());
manaIconOn[color.ordinal()] = colorIcon;
final Image gsImage = GraphicsUtils.getGreyScaleImage(colorIcon.getImage());
manaIconOff[color.ordinal()] = new ImageIcon(GraphicsUtils.getTranslucentImage(gsImage, 0.3f));
final Image gsImage = ImageHelper.getGreyScaleImage(colorIcon.getImage());
manaIconOff[color.ordinal()] = new ImageIcon(ImageHelper.getTranslucentImage(gsImage, 0.3f));
}
}
private static void setTypeOffIcons() {
for (MagicIcon icon : MagicIcon.TYPE_ICONS) {
final ImageIcon colorIcon = MagicImages.getIcon(icon);
final Image fadedImage = GraphicsUtils.getTranslucentImage(colorIcon.getImage(), 0.2f);
final Image fadedImage = ImageHelper.getTranslucentImage(colorIcon.getImage(), 0.2f);
typeIconOff.put(icon, new ImageIcon(fadedImage));
}
}

View File

@ -4,7 +4,7 @@ import java.awt.Dimension;
import java.awt.Image;
import java.awt.RenderingHints;
import java.awt.image.BufferedImage;
import magic.ui.utility.GraphicsUtils;
import magic.ui.helpers.ImageHelper;
class ImageScaler {
@ -26,7 +26,7 @@ class ImageScaler {
final double heightRatio = rect.getHeight() / origImage.getHeight();
final double aspectRatio = Math.min(widthRatio, heightRatio);
scaledImage = GraphicsUtils.scale(
scaledImage = ImageHelper.scale(
origImage,
(int) (origImage.getWidth() * aspectRatio),
(int) (origImage.getHeight() * aspectRatio),

View File

@ -17,7 +17,7 @@ import magic.ui.widget.duel.animation.AnimationFx;
import magic.ui.widget.duel.animation.MagicAnimations;
import magic.ui.duel.viewerinfo.PlayerViewerInfo;
import magic.ui.theme.ThemeFactory;
import magic.ui.utility.GraphicsUtils;
import magic.ui.helpers.ImageHelper;
import magic.ui.utility.MagicStyle;
import org.pushingpixels.trident.Timeline;
import org.pushingpixels.trident.ease.Spline;
@ -40,14 +40,14 @@ public class PlayerImagePanel extends AnimationPanel {
public PlayerImagePanel(final PlayerViewerInfo player) {
this.playerInfo = player;
activeImage = getPlayerAvatarImage();
inactiveImage = GraphicsUtils.getGreyScaleImage(activeImage);
inactiveImage = ImageHelper.getGreyScaleImage(activeImage);
poisonCounter = new CounterOverlay(20, 20, Color.GREEN);
damageCounter = new CounterOverlay(20, 20, Color.CYAN);
}
private BufferedImage getPlayerAvatarImage() {
final ImageIcon icon = MagicImages.getIconSize3(this.playerInfo.player.getPlayerDefinition());
return GraphicsUtils.scale(GraphicsUtils.getConvertedIcon(icon), 74, 74);
return ImageHelper.scale(ImageHelper.getConvertedIcon(icon), 74, 74);
}
@Override
@ -119,7 +119,7 @@ public class PlayerImagePanel extends AnimationPanel {
final String text = Integer.toString(playerInfo.life);
final int textX = x + 4;
final int textY = y + image.getHeight(null) - 6;
GraphicsUtils.drawStringWithOutline(g2d, text, textX, textY);
ImageHelper.drawStringWithOutline(g2d, text, textX, textY);
}
public void updateDisplay(final PlayerViewerInfo playerInfo) {

View File

@ -15,7 +15,7 @@ import java.awt.image.BufferedImage;
import javax.swing.JToggleButton;
import magic.data.MagicIcon;
import magic.model.MagicPlayerZone;
import magic.ui.utility.GraphicsUtils;
import magic.ui.helpers.ImageHelper;
import magic.ui.MagicImages;
import magic.ui.widget.duel.animation.AnimationFx;
import magic.ui.widget.duel.animation.MagicAnimations;
@ -129,10 +129,10 @@ public class ZoneToggleButton extends JToggleButton {
private BufferedImage getZoneIconAsImage() {
if (zoneIconImage == null) {
zoneIconImage = GraphicsUtils.getCompatibleBufferedImage(32, 32, Transparency.TRANSLUCENT);
zoneIconImage = ImageHelper.getCompatibleBufferedImage(32, 32, Transparency.TRANSLUCENT);
Graphics2D g2d = (Graphics2D) zoneIconImage.getGraphics();
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
final Image iconImage = GraphicsUtils.getConvertedIcon(MagicImages.getIcon(magicIcon));
final Image iconImage = ImageHelper.getConvertedIcon(MagicImages.getIcon(magicIcon));
g2d.drawImage(iconImage, 0, 0, this);
g2d.dispose();
}
@ -148,7 +148,7 @@ public class ZoneToggleButton extends JToggleButton {
int textX = x + ((iconImage.getWidth(null) / 2) - (textWidth / 2));
int textY = y - 6;
if (valueStyle == ValueStyle.OUTLINE) {
GraphicsUtils.drawStringWithOutline(g2d, text, textX, textY);
ImageHelper.drawStringWithOutline(g2d, text, textX, textY);
} else {
g2d.drawString(text, textX, textY);
}

View File

@ -21,7 +21,7 @@ import magic.model.MagicCardDefinition;
import magic.ui.MagicImages;
import magic.ui.widget.cards.table.ICardSelectionListener;
import magic.ui.dialog.prefs.ImageSizePresets;
import magic.ui.utility.GraphicsUtils;
import magic.ui.helpers.ImageHelper;
import magic.ui.utility.MagicStyle;
import magic.ui.widget.FontsAndBorders;
import magic.ui.widget.throbber.AbstractThrobber;
@ -171,7 +171,7 @@ public class CardViewer extends JPanel implements ICardSelectionListener {
} else {
thisImage = aImage;
gsImage = thisCard.isInvalid() && aImage != MagicImages.getMissingCardImage()
? GraphicsUtils.getGreyScaleImage(aImage)
? ImageHelper.getGreyScaleImage(aImage)
: null;
isImagePending = false;
throbber.setVisible(false);
@ -215,7 +215,7 @@ public class CardViewer extends JPanel implements ICardSelectionListener {
BufferedImage image = MagicImages.getCardImage(aCard);
if (image.getWidth() != prefSize.width || image.getHeight() != prefSize.height) {
image = GraphicsUtils.scale(image, prefSize.width, prefSize.height);
image = ImageHelper.scale(image, prefSize.width, prefSize.height);
}
return image;

View File

@ -31,7 +31,7 @@ import magic.model.MagicCard;
import magic.model.MagicCardDefinition;
import magic.model.MagicCardList;
import magic.ui.MagicImages;
import magic.ui.utility.GraphicsUtils;
import magic.ui.helpers.ImageHelper;
import magic.ui.screen.duel.game.SwingGameController;
import magic.ui.duel.viewerinfo.CardViewerInfo;
import magic.ui.theme.Theme;
@ -237,7 +237,7 @@ public class ImageCardListViewer extends JPanel implements IChoiceViewer {
final int x2=point.x+CARD_WIDTH;
final int y2=point.y+CARD_HEIGHT;
final BufferedImage image = GraphicsUtils.scale(
final BufferedImage image = ImageHelper.scale(
MagicImages.getCardImage(cardDefinition),
CARD_WIDTH,
CARD_HEIGHT

View File

@ -30,7 +30,7 @@ import magic.ui.duel.viewerinfo.PermanentViewerInfo;
import magic.ui.dialog.prefs.ImageSizePresets;
import magic.ui.theme.Theme;
import magic.ui.theme.ThemeFactory;
import magic.ui.utility.GraphicsUtils;
import magic.ui.helpers.ImageHelper;
import magic.ui.utility.ImageDrawingUtils;
import magic.ui.utility.MagicStyle;
import magic.ui.widget.FontsAndBorders;
@ -269,7 +269,7 @@ public class ImagePermanentViewer extends JPanel {
final int x2 = x1 + linkedRect.width - 1;
final int y2 = y1 + linkedRect.height - 1;
final BufferedImage image = GraphicsUtils.scale(
final BufferedImage image = ImageHelper.scale(
MagicImages.getCardImage(linkedInfo.permanent),
linkedInfo.tapped ? linkedRect.height : linkedRect.width,
linkedInfo.tapped ? linkedRect.width : linkedRect.height

View File

@ -21,7 +21,7 @@ import magic.ui.ScreenController;
import magic.translate.StringContext;
import magic.translate.UiString;
import magic.ui.MagicImages;
import magic.ui.utility.GraphicsUtils;
import magic.ui.helpers.ImageHelper;
@SuppressWarnings("serial")
public class PlayerZoneViewer extends JPanel implements ChangeListener {
@ -56,8 +56,8 @@ public class PlayerZoneViewer extends JPanel implements ChangeListener {
private static ImageIcon getTabIcon(MagicIcon icon) {
ImageIcon handIcon = MagicImages.getIcon(icon);
BufferedImage handImage = GraphicsUtils.getBufferedImage(handIcon);
BufferedImage scaledImage = GraphicsUtils.scale(handImage, 16, 16);
BufferedImage handImage = ImageHelper.getBufferedImage(handIcon);
BufferedImage scaledImage = ImageHelper.scale(handImage, 16, 16);
return new ImageIcon(scaledImage);
}

View File

@ -8,7 +8,7 @@ import java.awt.Transparency;
import java.awt.image.BufferedImage;
import javax.swing.JComponent;
import javax.swing.SwingUtilities;
import magic.ui.utility.GraphicsUtils;
import magic.ui.helpers.ImageHelper;
import org.pushingpixels.trident.Timeline;
import org.pushingpixels.trident.Timeline.RepeatBehavior;
@ -142,7 +142,7 @@ public abstract class AbstractThrobber extends JComponent {
return null;
}
final BufferedImage image = GraphicsUtils.getCompatibleBufferedImage(W, H, Transparency.TRANSLUCENT);
final BufferedImage image = ImageHelper.getCompatibleBufferedImage(W, H, Transparency.TRANSLUCENT);
final Graphics2D g2d = image.createGraphics();
if (isAntiAliasOn) {

View File

@ -8,7 +8,7 @@ import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import java.awt.event.HierarchyEvent;
import java.awt.image.BufferedImage;
import magic.ui.utility.GraphicsUtils;
import magic.ui.helpers.ImageHelper;
@SuppressWarnings("serial")
public class ImageThrobber extends AbstractThrobber {
@ -72,7 +72,7 @@ public class ImageThrobber extends AbstractThrobber {
final boolean isShowingChanged = (e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) == HierarchyEvent.SHOWING_CHANGED;
if (isShowingChanged) {
displayImage = isColorSet
? GraphicsUtils.getColoredImage(sourceImage, getForeground())
? ImageHelper.getColoredImage(sourceImage, getForeground())
: sourceImage;
}
});