mirror of
https://github.com/correl/mage.git
synced 2025-01-12 19:25:44 +00:00
* Split cards - The images of split cards are now rotated in the enlarged image view (moueswheel up/down).
This commit is contained in:
parent
4a2a40ae2d
commit
88aca77695
8 changed files with 160 additions and 46 deletions
|
@ -374,6 +374,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
||||||
ui.addComponent(MageComponents.CARD_INFO_PANE, cardInfoPane);
|
ui.addComponent(MageComponents.CARD_INFO_PANE, cardInfoPane);
|
||||||
ui.addComponent(MageComponents.POPUP_CONTAINER, popupContainer);
|
ui.addComponent(MageComponents.POPUP_CONTAINER, popupContainer);
|
||||||
|
|
||||||
|
// preview panel normal
|
||||||
JPanel cardPreviewContainer = new JPanel();
|
JPanel cardPreviewContainer = new JPanel();
|
||||||
cardPreviewContainer.setOpaque(false);
|
cardPreviewContainer.setOpaque(false);
|
||||||
cardPreviewContainer.setLayout(null);
|
cardPreviewContainer.setLayout(null);
|
||||||
|
@ -390,6 +391,24 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
|
||||||
ui.addComponent(MageComponents.CARD_PREVIEW_CONTAINER, cardPreviewContainer);
|
ui.addComponent(MageComponents.CARD_PREVIEW_CONTAINER, cardPreviewContainer);
|
||||||
|
|
||||||
desktopPane.add(cardPreviewContainer, JLayeredPane.POPUP_LAYER);
|
desktopPane.add(cardPreviewContainer, JLayeredPane.POPUP_LAYER);
|
||||||
|
|
||||||
|
// preview panel rotated
|
||||||
|
JPanel cardPreviewContainerRotated = new JPanel();
|
||||||
|
cardPreviewContainerRotated.setOpaque(false);
|
||||||
|
cardPreviewContainerRotated.setLayout(null);
|
||||||
|
bigCard = new BigCard(true);
|
||||||
|
bigCard.setSize(500, 350);
|
||||||
|
bigCard.setLocation(40, 40);
|
||||||
|
bigCard.setBackground(new Color(0, 0, 0, 0));
|
||||||
|
cardPreviewContainerRotated.add(bigCard);
|
||||||
|
cardPreviewContainerRotated.setVisible(false);
|
||||||
|
cardPreviewContainerRotated.setBounds(0, 0, 500 + 80, 420 + 30);
|
||||||
|
|
||||||
|
ui.addComponent(MageComponents.CARD_PREVIEW_PANE_ROTATED, bigCard);
|
||||||
|
ui.addComponent(MageComponents.CARD_PREVIEW_CONTAINER_ROTATED, cardPreviewContainerRotated);
|
||||||
|
|
||||||
|
desktopPane.add(cardPreviewContainerRotated, JLayeredPane.POPUP_LAYER);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setBackground() {
|
private void setBackground() {
|
||||||
|
|
|
@ -34,20 +34,26 @@
|
||||||
|
|
||||||
package mage.client.cards;
|
package mage.client.cards;
|
||||||
|
|
||||||
import mage.client.plugins.impl.Plugins;
|
import java.awt.Dimension;
|
||||||
import mage.client.util.ImageHelper;
|
import java.awt.Graphics;
|
||||||
import org.jdesktop.swingx.JXPanel;
|
import java.awt.Image;
|
||||||
|
import java.awt.Rectangle;
|
||||||
import javax.swing.*;
|
|
||||||
import javax.swing.text.BadLocationException;
|
|
||||||
import javax.swing.text.StyledDocument;
|
|
||||||
import java.awt.*;
|
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import javax.swing.JComponent;
|
||||||
import static mage.constants.Constants.*;
|
import javax.swing.text.BadLocationException;
|
||||||
|
import javax.swing.text.StyledDocument;
|
||||||
|
import static mage.client.constants.Constants.CONTENT_MAX_XOFFSET;
|
||||||
|
import static mage.client.constants.Constants.FRAME_MAX_HEIGHT;
|
||||||
|
import static mage.client.constants.Constants.FRAME_MAX_WIDTH;
|
||||||
|
import static mage.client.constants.Constants.TEXT_MAX_HEIGHT;
|
||||||
|
import static mage.client.constants.Constants.TEXT_MAX_WIDTH;
|
||||||
|
import static mage.client.constants.Constants.TEXT_MAX_YOFFSET;
|
||||||
|
import mage.client.plugins.impl.Plugins;
|
||||||
|
import mage.client.util.ImageHelper;
|
||||||
import mage.constants.EnlargeMode;
|
import mage.constants.EnlargeMode;
|
||||||
|
import org.jdesktop.swingx.JXPanel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class for displaying big image of the card
|
* Class for displaying big image of the card
|
||||||
|
@ -69,9 +75,13 @@ public class BigCard extends JComponent {
|
||||||
protected EnlargeMode enlargeMode;
|
protected EnlargeMode enlargeMode;
|
||||||
|
|
||||||
public BigCard() {
|
public BigCard() {
|
||||||
|
this(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigCard(boolean rotated) {
|
||||||
initComponents();
|
initComponents();
|
||||||
if (!Plugins.getInstance().isCardPluginLoaded()) {
|
if (!Plugins.getInstance().isCardPluginLoaded()) {
|
||||||
initBounds();
|
initBounds(rotated);
|
||||||
}
|
}
|
||||||
setDoubleBuffered(true);
|
setDoubleBuffered(true);
|
||||||
setOpaque(true);
|
setOpaque(true);
|
||||||
|
@ -79,11 +89,15 @@ public class BigCard extends JComponent {
|
||||||
this.scrollPane.setVisible(false);
|
this.scrollPane.setVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initBounds() {
|
private void initBounds(boolean rotated) {
|
||||||
oldWidth = this.getWidth();
|
oldWidth = this.getWidth();
|
||||||
|
if (rotated) {
|
||||||
|
scrollPane.setBounds(50, 50, 100, 100);
|
||||||
|
} else {
|
||||||
scrollPane.setBounds(this.getWidth()*1000/17777,this.getWidth()*1000/1100,
|
scrollPane.setBounds(this.getWidth()*1000/17777,this.getWidth()*1000/1100,
|
||||||
this.getWidth()*1000/1142,this.getWidth()*1000/2539);
|
this.getWidth()*1000/1142,this.getWidth()*1000/2539);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void clearUp() {
|
public void clearUp() {
|
||||||
|
|
||||||
|
@ -141,7 +155,7 @@ public class BigCard extends JComponent {
|
||||||
|
|
||||||
public void showTextComponent() {
|
public void showTextComponent() {
|
||||||
if (oldWidth != this.getWidth()) {
|
if (oldWidth != this.getWidth()) {
|
||||||
initBounds();
|
initBounds(false);
|
||||||
}
|
}
|
||||||
this.scrollPane.setVisible(true);
|
this.scrollPane.setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,13 +9,16 @@ public enum MageComponents {
|
||||||
CARD_INFO_PANE("cardInfoPane"),
|
CARD_INFO_PANE("cardInfoPane"),
|
||||||
POPUP_CONTAINER("popupContainer"),
|
POPUP_CONTAINER("popupContainer"),
|
||||||
CARD_PREVIEW_PANE("cardPreviewPane"),
|
CARD_PREVIEW_PANE("cardPreviewPane"),
|
||||||
CARD_PREVIEW_CONTAINER("cardPreviewContainer");
|
CARD_PREVIEW_CONTAINER("cardPreviewContainer"),
|
||||||
|
CARD_PREVIEW_PANE_ROTATED("cardPreviewPaneRotated"),
|
||||||
|
CARD_PREVIEW_CONTAINER_ROTATED("cardPreviewContainer");
|
||||||
|
|
||||||
private String name;
|
private final String name;
|
||||||
MageComponents(String name) {
|
MageComponents(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return this.name;
|
return this.name;
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,7 +64,11 @@ public class MageActionCallback implements ActionCallback {
|
||||||
private TransferData popupData;
|
private TransferData popupData;
|
||||||
private JComponent cardInfoPane;
|
private JComponent cardInfoPane;
|
||||||
private volatile boolean popupTextWindowOpen = false;
|
private volatile boolean popupTextWindowOpen = false;
|
||||||
private volatile boolean enlargedImageWindowOpen = false;
|
enum EnlargedWindowState {
|
||||||
|
CLOSED, NORMAL, ROTATED
|
||||||
|
}
|
||||||
|
private volatile EnlargedWindowState enlargedWindowState = EnlargedWindowState.CLOSED;
|
||||||
|
//private volatile boolean enlargedImageWindowOpen = false;
|
||||||
// shows the alternative card the normal card or the alternative card (copy source, other flip side, other transformed side)
|
// shows the alternative card the normal card or the alternative card (copy source, other flip side, other transformed side)
|
||||||
private volatile EnlargeMode enlargeMode;
|
private volatile EnlargeMode enlargeMode;
|
||||||
|
|
||||||
|
@ -239,7 +243,7 @@ public class MageActionCallback implements ActionCallback {
|
||||||
public void run() {
|
public void run() {
|
||||||
ThreadUtils.sleep(300);
|
ThreadUtils.sleep(300);
|
||||||
|
|
||||||
if (popupCard == null || !popupCard.equals(data.card) || session == null || !popupTextWindowOpen || enlargedImageWindowOpen) {
|
if (popupCard == null || !popupCard.equals(data.card) || session == null || !popupTextWindowOpen || !enlargedWindowState.equals(EnlargedWindowState.CLOSED)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -260,7 +264,7 @@ public class MageActionCallback implements ActionCallback {
|
||||||
SwingUtilities.invokeLater(new Runnable() {
|
SwingUtilities.invokeLater(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (!popupTextWindowOpen || enlargedImageWindowOpen) {
|
if (!popupTextWindowOpen || !enlargedWindowState.equals(EnlargedWindowState.CLOSED)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
popupContainer.setVisible(true);
|
popupContainer.setVisible(true);
|
||||||
|
@ -301,7 +305,7 @@ public class MageActionCallback implements ActionCallback {
|
||||||
} else {
|
} else {
|
||||||
popupTextWindowOpen = true;
|
popupTextWindowOpen = true;
|
||||||
}
|
}
|
||||||
if (enlargedImageWindowOpen) {
|
if (!enlargedWindowState.equals(EnlargedWindowState.CLOSED)) {
|
||||||
displayEnlargedCard(mageCard.getOriginal(), transferData);
|
displayEnlargedCard(mageCard.getOriginal(), transferData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -356,7 +360,7 @@ public class MageActionCallback implements ActionCallback {
|
||||||
@Override
|
@Override
|
||||||
public void mouseWheelMoved(MouseWheelEvent e, TransferData transferData) {
|
public void mouseWheelMoved(MouseWheelEvent e, TransferData transferData) {
|
||||||
int notches = e.getWheelRotation();
|
int notches = e.getWheelRotation();
|
||||||
if (enlargedImageWindowOpen) {
|
if (!enlargedWindowState.equals(EnlargedWindowState.CLOSED)) {
|
||||||
// same move direction will be ignored, opposite direction closes the enlarged window
|
// same move direction will be ignored, opposite direction closes the enlarged window
|
||||||
if (enlargeMode.equals(EnlargeMode.NORMAL)) {
|
if (enlargeMode.equals(EnlargeMode.NORMAL)) {
|
||||||
if (notches > 0) {
|
if (notches > 0) {
|
||||||
|
@ -384,7 +388,7 @@ public class MageActionCallback implements ActionCallback {
|
||||||
* @param showAlternative defines if the original image (if it's a copied card) or the opposite side of a transformable card will be shown
|
* @param showAlternative defines if the original image (if it's a copied card) or the opposite side of a transformable card will be shown
|
||||||
*/
|
*/
|
||||||
public void enlargeCard(EnlargeMode showAlternative) {
|
public void enlargeCard(EnlargeMode showAlternative) {
|
||||||
if (!enlargedImageWindowOpen) {
|
if (enlargedWindowState.equals(EnlargedWindowState.CLOSED)) {
|
||||||
this.enlargeMode = showAlternative;
|
this.enlargeMode = showAlternative;
|
||||||
CardView cardView = null;
|
CardView cardView = null;
|
||||||
if (popupData != null) {
|
if (popupData != null) {
|
||||||
|
@ -394,18 +398,25 @@ public class MageActionCallback implements ActionCallback {
|
||||||
hidePopup();
|
hidePopup();
|
||||||
}
|
}
|
||||||
if (cardView != null) {
|
if (cardView != null) {
|
||||||
enlargedImageWindowOpen = true;
|
if (cardView.isToRotate()) {
|
||||||
|
enlargedWindowState = EnlargedWindowState.ROTATED;
|
||||||
|
} else {
|
||||||
|
enlargedWindowState = EnlargedWindowState.NORMAL;
|
||||||
|
}
|
||||||
displayEnlargedCard(cardView, popupData);
|
displayEnlargedCard(cardView, popupData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void hideEnlargedCard() {
|
public void hideEnlargedCard() {
|
||||||
if (enlargedImageWindowOpen) {
|
if (!enlargedWindowState.equals(EnlargedWindowState.CLOSED)) {
|
||||||
enlargedImageWindowOpen = false;
|
enlargedWindowState = EnlargedWindowState.CLOSED;
|
||||||
try {
|
try {
|
||||||
Component cardPreviewContainer = MageFrame.getUI().getComponent(MageComponents.CARD_PREVIEW_CONTAINER);
|
Component cardPreviewContainer = MageFrame.getUI().getComponent(MageComponents.CARD_PREVIEW_CONTAINER);
|
||||||
cardPreviewContainer.setVisible(false);
|
cardPreviewContainer.setVisible(false);
|
||||||
|
cardPreviewContainer = MageFrame.getUI().getComponent(MageComponents.CARD_PREVIEW_CONTAINER_ROTATED);
|
||||||
|
cardPreviewContainer.setVisible(false);
|
||||||
|
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -422,14 +433,31 @@ public class MageActionCallback implements ActionCallback {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if (!enlargedImageWindowOpen) {
|
if (enlargedWindowState.equals(EnlargedWindowState.CLOSED)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Component parentComponent = SwingUtilities.getRoot(transferData.component);
|
Component parentComponent = SwingUtilities.getRoot(transferData.component);
|
||||||
Point parentPoint = parentComponent.getLocationOnScreen();
|
Point parentPoint = parentComponent.getLocationOnScreen();
|
||||||
|
|
||||||
final Component popupContainer = MageFrame.getUI().getComponent(MageComponents.CARD_PREVIEW_CONTAINER);
|
MageComponents mageComponentCardPreviewContainer;
|
||||||
Component cardPreviewPane = MageFrame.getUI().getComponent(MageComponents.CARD_PREVIEW_PANE);
|
MageComponents mageComponentCardPreviewPane;
|
||||||
|
if (cardView.isToRotate()) {
|
||||||
|
if(enlargedWindowState.equals(EnlargedWindowState.NORMAL)) {
|
||||||
|
hideEnlargedCard();
|
||||||
|
enlargedWindowState = EnlargedWindowState.ROTATED;
|
||||||
|
}
|
||||||
|
mageComponentCardPreviewContainer = MageComponents.CARD_PREVIEW_CONTAINER_ROTATED;
|
||||||
|
mageComponentCardPreviewPane = MageComponents.CARD_PREVIEW_PANE_ROTATED;
|
||||||
|
} else {
|
||||||
|
if(enlargedWindowState.equals(EnlargedWindowState.ROTATED)) {
|
||||||
|
hideEnlargedCard();
|
||||||
|
enlargedWindowState = EnlargedWindowState.NORMAL;
|
||||||
|
}
|
||||||
|
mageComponentCardPreviewContainer = MageComponents.CARD_PREVIEW_CONTAINER;
|
||||||
|
mageComponentCardPreviewPane = MageComponents.CARD_PREVIEW_PANE;
|
||||||
|
}
|
||||||
|
final Component popupContainer = MageFrame.getUI().getComponent(mageComponentCardPreviewContainer);
|
||||||
|
Component cardPreviewPane = MageFrame.getUI().getComponent(mageComponentCardPreviewPane);
|
||||||
if (cardPreviewPane != null) {
|
if (cardPreviewPane != null) {
|
||||||
Point location = new Point((int) transferData.locationOnScreen.getX() + transferData.popupOffsetX - 40, (int) transferData.locationOnScreen.getY() + transferData.popupOffsetY - 40);
|
Point location = new Point((int) transferData.locationOnScreen.getX() + transferData.popupOffsetX - 40, (int) transferData.locationOnScreen.getY() + transferData.popupOffsetY - 40);
|
||||||
location = GuiDisplayUtil.keepComponentInsideParent(location, parentPoint, cardPreviewPane, parentComponent);
|
location = GuiDisplayUtil.keepComponentInsideParent(location, parentPoint, cardPreviewPane, parentComponent);
|
||||||
|
@ -477,7 +505,12 @@ public class MageActionCallback implements ActionCallback {
|
||||||
private void displayCardInfo(MageCard mageCard, Image image, BigCard bigCard) {
|
private void displayCardInfo(MageCard mageCard, Image image, BigCard bigCard) {
|
||||||
if (image != null && image instanceof BufferedImage) {
|
if (image != null && image instanceof BufferedImage) {
|
||||||
// XXX: scaled to fit width
|
// XXX: scaled to fit width
|
||||||
|
if (mageCard.getOriginal().isToRotate() && bigCard.getWidth() > bigCard.getHeight()) {
|
||||||
|
image = ImageHelper.getResizedImage((BufferedImage) image, bigCard.getHeight());
|
||||||
|
image = ImageHelper.rotate((BufferedImage) image, Math.toRadians(90));
|
||||||
|
} else {
|
||||||
image = ImageHelper.getResizedImage((BufferedImage) image, bigCard.getWidth());
|
image = ImageHelper.getResizedImage((BufferedImage) image, bigCard.getWidth());
|
||||||
|
}
|
||||||
bigCard.setCard(mageCard.getOriginal().getId(), enlargeMode, image, mageCard.getOriginal().getRules());
|
bigCard.setCard(mageCard.getOriginal().getId(), enlargeMode, image, mageCard.getOriginal().getRules());
|
||||||
// if it's an ability, show only the ability text as overlay
|
// if it's an ability, show only the ability text as overlay
|
||||||
if (mageCard.getOriginal().isAbility()) {
|
if (mageCard.getOriginal().isAbility()) {
|
||||||
|
|
|
@ -28,11 +28,15 @@
|
||||||
|
|
||||||
package mage.client.util;
|
package mage.client.util;
|
||||||
|
|
||||||
import static mage.constants.Constants.*;
|
import com.mortennobel.imagescaling.ResampleOp;
|
||||||
|
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
|
import java.awt.GraphicsConfiguration;
|
||||||
|
import java.awt.GraphicsDevice;
|
||||||
|
import java.awt.GraphicsEnvironment;
|
||||||
import java.awt.Image;
|
import java.awt.Image;
|
||||||
|
import java.awt.Rectangle;
|
||||||
import java.awt.RenderingHints;
|
import java.awt.RenderingHints;
|
||||||
|
import java.awt.Transparency;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.awt.image.ImageObserver;
|
import java.awt.image.ImageObserver;
|
||||||
import java.awt.image.MemoryImageSource;
|
import java.awt.image.MemoryImageSource;
|
||||||
|
@ -41,28 +45,27 @@ import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
|
|
||||||
import mage.cards.CardDimensions;
|
import mage.cards.CardDimensions;
|
||||||
|
import static mage.client.constants.Constants.FRAME_MAX_HEIGHT;
|
||||||
|
import static mage.client.constants.Constants.FRAME_MAX_WIDTH;
|
||||||
|
import static mage.client.constants.Constants.SYMBOL_MAX_SPACE;
|
||||||
import mage.view.CardView;
|
import mage.view.CardView;
|
||||||
import org.mage.card.arcane.UI;
|
import org.mage.card.arcane.UI;
|
||||||
|
|
||||||
import com.mortennobel.imagescaling.ResampleOp;
|
|
||||||
import java.awt.Rectangle;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
*/
|
*/
|
||||||
public class ImageHelper {
|
public class ImageHelper {
|
||||||
protected static HashMap<String, BufferedImage> images = new HashMap<String, BufferedImage>();
|
protected static HashMap<String, BufferedImage> images = new HashMap<>();
|
||||||
protected static HashMap<String, BufferedImage> backgrounds = new HashMap<String, BufferedImage>();
|
protected static HashMap<String, BufferedImage> backgrounds = new HashMap<>();
|
||||||
|
|
||||||
public static BufferedImage loadImage(String ref, int width, int height) {
|
public static BufferedImage loadImage(String ref, int width, int height) {
|
||||||
BufferedImage image = loadImage(ref);
|
BufferedImage image = loadImage(ref);
|
||||||
if (image != null)
|
if (image != null) {
|
||||||
return scaleImage(image, width, height);
|
return scaleImage(image, width, height);
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,8 +77,9 @@ public class ImageHelper {
|
||||||
*/
|
*/
|
||||||
public static BufferedImage loadImage(String ref, int height) {
|
public static BufferedImage loadImage(String ref, int height) {
|
||||||
BufferedImage image = loadImage(ref);
|
BufferedImage image = loadImage(ref);
|
||||||
if (image != null)
|
if (image != null) {
|
||||||
return scaleImage(image, height);
|
return scaleImage(image, height);
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,6 +152,24 @@ public class ImageHelper {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static BufferedImage rotate(BufferedImage image, double angle) {
|
||||||
|
double sin = Math.abs(Math.sin(angle)), cos = Math.abs(Math.cos(angle));
|
||||||
|
int w = image.getWidth(), h = image.getHeight();
|
||||||
|
int neww = (int)Math.floor(w*cos+h*sin), newh = (int)Math.floor(h*cos+w*sin);
|
||||||
|
|
||||||
|
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
|
||||||
|
GraphicsDevice gs = ge.getDefaultScreenDevice();
|
||||||
|
GraphicsConfiguration gc = gs.getDefaultConfiguration();
|
||||||
|
|
||||||
|
BufferedImage result = gc.createCompatibleImage(neww, newh, Transparency.TRANSLUCENT);
|
||||||
|
Graphics2D g = result.createGraphics();
|
||||||
|
g.translate((neww-w)/2, (newh-h)/2);
|
||||||
|
g.rotate(angle, w/2, h/2);
|
||||||
|
g.drawRenderedImage(image, null);
|
||||||
|
g.dispose();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
public static void drawCosts(List<String> costs, Graphics2D g, int xOffset, int yOffset, ImageObserver o) {
|
public static void drawCosts(List<String> costs, Graphics2D g, int xOffset, int yOffset, ImageObserver o) {
|
||||||
if (costs.size() > 0) {
|
if (costs.size() > 0) {
|
||||||
int costLeft = xOffset;
|
int costLeft = xOffset;
|
||||||
|
@ -176,6 +198,9 @@ public class ImageHelper {
|
||||||
/**
|
/**
|
||||||
* Returns an image scaled to fit width
|
* Returns an image scaled to fit width
|
||||||
* panel
|
* panel
|
||||||
|
* @param original
|
||||||
|
* @param width
|
||||||
|
* @return
|
||||||
*/
|
*/
|
||||||
public static BufferedImage getResizedImage(BufferedImage original, int width) {
|
public static BufferedImage getResizedImage(BufferedImage original, int width) {
|
||||||
if (width != original.getWidth()) {
|
if (width != original.getWidth()) {
|
||||||
|
@ -189,6 +214,9 @@ public class ImageHelper {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an image scaled to the needed size
|
* Returns an image scaled to the needed size
|
||||||
|
* @param original
|
||||||
|
* @param sizeNeed
|
||||||
|
* @return
|
||||||
*/
|
*/
|
||||||
public static BufferedImage getResizedImage(BufferedImage original, Rectangle sizeNeed) {
|
public static BufferedImage getResizedImage(BufferedImage original, Rectangle sizeNeed) {
|
||||||
ResampleOp resampleOp = new ResampleOp(sizeNeed.width, sizeNeed.height);
|
ResampleOp resampleOp = new ResampleOp(sizeNeed.width, sizeNeed.height);
|
||||||
|
|
|
@ -337,10 +337,10 @@ public class ImageCache {
|
||||||
if (card.getUsesVariousArt()) {
|
if (card.getUsesVariousArt()) {
|
||||||
key += "#usesVariousArt";
|
key += "#usesVariousArt";
|
||||||
}
|
}
|
||||||
log.warn("getImage: " + key);
|
// log.warn("getImage: " + key);
|
||||||
BufferedImage original = getImage(key);
|
BufferedImage original = getImage(key);
|
||||||
if (original == null) {
|
if (original == null) {
|
||||||
log.warn(key + " not found");
|
log.debug(key + " not found");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -108,6 +108,8 @@ public class CardView extends SimpleCardView {
|
||||||
|
|
||||||
protected boolean controlledByOwner = true;
|
protected boolean controlledByOwner = true;
|
||||||
|
|
||||||
|
protected boolean rotate;
|
||||||
|
|
||||||
public CardView(Card card, UUID cardId) {
|
public CardView(Card card, UUID cardId) {
|
||||||
this(card);
|
this(card);
|
||||||
this.id = cardId;
|
this.id = cardId;
|
||||||
|
@ -125,9 +127,19 @@ public class CardView extends SimpleCardView {
|
||||||
SplitCard splitCard = null;
|
SplitCard splitCard = null;
|
||||||
if (card.isSplitCard()) {
|
if (card.isSplitCard()) {
|
||||||
splitCard = (SplitCard) card;
|
splitCard = (SplitCard) card;
|
||||||
|
rotate = true;
|
||||||
} else {
|
} else {
|
||||||
if (card instanceof Spell && ((Spell) card).getSpellAbility().getSpellAbilityType().equals(SpellAbilityType.SPLIT_FUSED)) {
|
if (card instanceof Spell) {
|
||||||
|
switch(((Spell) card).getSpellAbility().getSpellAbilityType()) {
|
||||||
|
case SPLIT_FUSED:
|
||||||
splitCard = (SplitCard) ((Spell) card).getCard();
|
splitCard = (SplitCard) ((Spell) card).getCard();
|
||||||
|
rotate = true;
|
||||||
|
break;
|
||||||
|
case SPLIT_LEFT:
|
||||||
|
case SPLIT_RIGHT:
|
||||||
|
rotate = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (splitCard != null) {
|
if (splitCard != null) {
|
||||||
|
@ -597,4 +609,8 @@ public class CardView extends SimpleCardView {
|
||||||
return flipCard;
|
return flipCard;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isToRotate() {
|
||||||
|
return rotate;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,6 +46,7 @@ import mage.watchers.Watcher;
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author LevelX2
|
* @author LevelX2
|
||||||
|
* @param <T>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public abstract class SplitCard<T extends SplitCard<T>> extends CardImpl<T> {
|
public abstract class SplitCard<T extends SplitCard<T>> extends CardImpl<T> {
|
||||||
|
|
Loading…
Reference in a new issue