minor changes (mostly code style)

This commit is contained in:
North 2012-12-24 18:43:54 +02:00
parent 895ee717dd
commit c0ad7812cd
22 changed files with 1170 additions and 1292 deletions

View file

@ -111,9 +111,9 @@ import java.util.prefs.Preferences;
*/
public class MageFrame extends javax.swing.JFrame implements MageClient {
private final static Logger logger = Logger.getLogger(MageFrame.class);
private final static String liteModeArg = "-lite";
private final static String grayModeArg = "-gray";
private static final Logger logger = Logger.getLogger(MageFrame.class);
private static final String liteModeArg = "-lite";
private static final String grayModeArg = "-gray";
private static MageFrame instance;
@ -124,7 +124,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
private static Preferences prefs = Preferences.userNodeForPackage(MageFrame.class);
private JLabel title;
private Rectangle titleRectangle;
private final static MageVersion version = new MageVersion(0, 10, 0, "dev");
private static final MageVersion version = new MageVersion(0, 10, 0, "dev");
private UUID clientId;
private static MagePane activeFrame;
private static boolean liteMode = false;
@ -196,14 +196,11 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
try {
UIManager.put("desktop", new Color(0, 0, 0, 0));
UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
//MageSynthStyleFactory f = new MageSynthStyleFactory(SynthLookAndFeel.getStyleFactory());
//SynthLookAndFeel.setStyleFactory(f);
} catch (Exception ex) {
logger.fatal(null, ex);
}
ManaSymbols.loadImages();
//ManaSymbols.loadImages();
Plugins.getInstance().loadPlugins();
initComponents();
@ -253,11 +250,6 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
setAppIcon();
MageTray.getInstance().install();
//PlayerPanelNew n = new PlayerPanelNew();
//n.setBounds(100,100,100,300);
//n.setVisible(true);
//backgroundPane.add(n);
desktopPane.add(ArrowBuilder.getArrowsPanel(), JLayeredPane.DRAG_LAYER);
desktopPane.addComponentListener(new ComponentAdapter() {
@ -270,9 +262,10 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
backgroundPane.setSize(width, height);
}
JPanel arrowsPanel = ArrowBuilder.getArrowsPanelRef();
if (arrowsPanel != null) arrowsPanel.setSize(width, height);
if (arrowsPanel != null) {
arrowsPanel.setSize(width, height);
}
if (title != null) {
//title.setBorder(BorderFactory.createLineBorder(Color.red));
title.setBounds((int) (width - titleRectangle.getWidth()) / 2, (int) (height - titleRectangle.getHeight()) / 2, titleRectangle.width, titleRectangle.height);
}
}
@ -292,6 +285,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
btnDownloadSymbols.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
btnDownloadSymbols.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
btnDownloadSymbols.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnSymbolsActionPerformed(evt);
}
@ -307,6 +301,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
btnDownload.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
btnDownload.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
btnDownload.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnImagesActionPerformed(evt);
}
@ -326,14 +321,16 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
ui.addButton(MageComponents.TABLES_MENU_BUTTON, btnGames);
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
disableButtons();
if (PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CARD_IMAGES_CHECK, "true").equals("true"))
if (PreferencesDialog.getCachedValue(PreferencesDialog.KEY_CARD_IMAGES_CHECK, "true").equals("true")) {
checkForNewImages();
}
logger.info("Client start up time: " + ((System.currentTimeMillis() - startTime) / 1000 + " seconds"));
if (autoConnect())
if (autoConnect()) {
enableButtons();
else {
} else {
connectDialog.showDialog();
}
}
@ -380,13 +377,13 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
}
private void setBackground() {
if (liteMode || grayMode)
if (liteMode || grayMode) {
return;
}
String filename = "/background.jpg";
try {
if (Plugins.getInstance().isThemePluginLoaded()) {
Map<String, JComponent> ui = new HashMap<String, JComponent>();
backgroundPane = (ImagePanel) Plugins.getInstance().updateTablePanel(ui);
backgroundPane = (ImagePanel) Plugins.getInstance().updateTablePanel(new HashMap<String, JComponent>());
} else {
InputStream is = this.getClass().getResourceAsStream(filename);
BufferedImage background = ImageIO.read(is);
@ -400,8 +397,9 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
}
private void addMageLabel() {
if (liteMode || grayMode)
if (liteMode || grayMode) {
return;
}
String filename = "/label-mage.png";
try {
InputStream is = this.getClass().getResourceAsStream(filename);
@ -429,6 +427,7 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
private AbstractButton createWindowsButton() {
final JToggleButton windowButton = new JToggleButton("Windows");
windowButton.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
createAndShowMenu((JComponent) e.getSource(), windowButton);
@ -465,13 +464,16 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
}
menu.addPopupMenuListener(new PopupMenuListener() {
@Override
public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
}
@Override
public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
windowButton.setSelected(false);
}
@Override
public void popupMenuCanceled(PopupMenuEvent e) {
windowButton.setSelected(false);
}
@ -519,11 +521,13 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
}
public static void setActive(MagePane frame) {
if (frame == null)
if (frame == null) {
return;
}
logger.debug("Setting " + frame.getTitle() + " active");
if (activeFrame != null)
if (activeFrame != null) {
activeFrame.deactivated();
}
activeFrame = frame;
activeFrame.setVisible(true);
activeFrame.toFront();
@ -538,8 +542,9 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
public static void deactivate(MagePane frame) {
frame.setVisible(false);
MagePane topmost = getTopMost(frame);
if (activeFrame != frame)
if (activeFrame != frame) {
frame.deactivated();
}
setActive(topmost);
}
@ -930,20 +935,19 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
public void showDeckEditor(DeckEditorMode mode, Deck deck, UUID tableId, int time) {
String name;
if (mode == DeckEditorMode.Sideboard || mode == DeckEditorMode.Limited)
if (mode == DeckEditorMode.Sideboard || mode == DeckEditorMode.Limited) {
name = "Deck Editor - " + tableId.toString();
else {
if (deck != null)
} else {
if (deck != null) {
name = "Deck Editor - " + deck.getName();
else
} else {
name = "Deck Editor";
}
JInternalFrame[] windows = desktopPane.getAllFramesInLayer(JLayeredPane.DEFAULT_LAYER);
for (JInternalFrame window : windows) {
if (window instanceof DeckEditorPane) {
if (window.getTitle().equals(name)) {
setActive((MagePane)window);
return;
}
if (window instanceof DeckEditorPane && window.getTitle().equals(name)) {
setActive((MagePane) window);
return;
}
}
}
@ -994,11 +998,13 @@ public class MageFrame extends javax.swing.JFrame implements MageClient {
startTime = System.currentTimeMillis();
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
@Override
public void uncaughtException(Thread t, Throwable e) {
logger.fatal(null, e);
}
});
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
CardScanner.scan();
for (String arg : args) {

View file

@ -66,10 +66,6 @@ public class BigCard extends JComponent {
protected float hue = 0.005f;
protected float dh = 0.005f;
static private final int DEFAULT_DELAY_PERIOD = 30;
static private final float LEFT_BOUNDARY = 0f;
static private final float RIGHT_BOUNDARY = 0.5f;
public BigCard() {
initComponents();
if (!Plugins.getInstance().isCardPluginLoaded()) {
@ -81,7 +77,7 @@ public class BigCard extends JComponent {
this.scrollPane.setVisible(false);
}
protected void initBounds() {
private void initBounds() {
oldWidth = this.getWidth();
scrollPane.setBounds(this.getWidth()*1000/17777,this.getWidth()*1000/1100,
this.getWidth()*1000/1142,this.getWidth()*1000/2539);
@ -89,7 +85,9 @@ public class BigCard extends JComponent {
public void setCard(UUID cardId, Image image, List<String> strings, boolean foil) {
if (this.cardId == null || !this.cardId.equals(cardId)) {
if (this.panel != null) remove(this.panel);
if (this.panel != null) {
remove(this.panel);
}
this.cardId = cardId;
bigImage = image;
synchronized (this) {
@ -124,20 +122,6 @@ public class BigCard extends JComponent {
@Override
public void paintComponent(Graphics graphics) {
/*if (foilState) {
if (source != null) {
synchronized (BigCard.class) {
if (source != null) {
graphics.drawImage(foil, 0, 0, this);
}
}
}
} else {
if (bigImage != null) {
graphics.drawImage(bigImage, 0, 0, this);
}
}*/
if (bigImage != null) {
graphics.drawImage(bigImage, 0, 0, this);
}
@ -156,81 +140,9 @@ public class BigCard extends JComponent {
}
public void setFoil(boolean foil) {
/*if (foilThread == null) {
synchronized (this) {
if (foilThread == null) {
foilThread = getFoilThread();
foilThread.setDaemon(true);
foilThread.start();
}
}
}
if (foil != foilState) {
synchronized (this) {
if (foil != foilState) {
hue = 0.005f;
foilState = foil;
}
}
}
*/
repaint();
}
// private Thread getFoilThread() {
// return new Thread(new Runnable() {
// @Override
// public void run() {
// if (bigImage == null) {
// return;
// }
// final HueFilter filter = FilterFactory.getHueFilter();
// int sign = 1;
// while (true) {
// boolean prevState = foilState;
// while (!foilState) {
// ThreadUtils.sleep(10);
// }
// if (prevState == foilState) {
// ThreadUtils.sleep(DEFAULT_DELAY_PERIOD);
// }
// hue += dh * sign;
// /*if (hue >= 1.0D) {
// hue = 0.000F;
// }*/
// if (hue < LEFT_BOUNDARY) {
// sign *= -1;
// hue = LEFT_BOUNDARY;
// } else if (hue > RIGHT_BOUNDARY) {
// sign *= -1;
// hue = RIGHT_BOUNDARY;
// }
// filter.setHue(hue);
// BufferedImage f = null;
// synchronized (BigCard.this) {
// if (source == null) {
// source = BufferedImageBuilder.bufferImage(bigImage);
// }
// if (source == null) {
// return;
// }
// f = filter.filter(source, null);
// }
// synchronized (BigCard.class) {
// foil = f;
// }
// SwingUtilities.invokeLater(new Runnable() {
// @Override
// public void run() {
// BigCard.this.repaint();
// }
// });
//
// }
// }
// });
// }
public void addJXPanel(UUID cardId, JXPanel jxPanel) {
bigImage = null;
synchronized (this) {

View file

@ -36,16 +36,17 @@ public class HoverButton extends JPanel implements MouseListener {
private Command onHover = null;
private Color textColor = Color.white;
final static Font textFont = new Font("Arial", Font.PLAIN, 12);
final static Font textFontMini = new Font("Arial", Font.PLAIN, 11);
final static Font textSetFontBoldMini = new Font("Arial", Font.BOLD, 12);
final static Font textSetFontBold = new Font("Arial", Font.BOLD, 14);
static final Font textFont = new Font("Arial", Font.PLAIN, 12);
static final Font textFontMini = new Font("Arial", Font.PLAIN, 11);
static final Font textSetFontBoldMini = new Font("Arial", Font.BOLD, 12);
static final Font textSetFontBold = new Font("Arial", Font.BOLD, 14);
private boolean useMiniFont = false;
public HoverButton(String text, Image image, Rectangle size) {
this(text, image, image, null, image, size);
if (image == null)
if (image == null) {
throw new IllegalArgumentException("Image can't be null");
}
}
public HoverButton(String text, Image image, Image hover, Image disabled, Rectangle size) {
@ -74,9 +75,14 @@ public class HoverButton extends JPanel implements MouseListener {
if (isHovered) {
g.drawImage(hoverImage, 0, 0, imageSize.width, imageSize.height, this);
if (text != null) {
if (textColor != null) g2d.setColor(textColor);
if (useMiniFont) g2d.setFont(textFontMini);
else g2d.setFont(textFont);
if (textColor != null) {
g2d.setColor(textColor);
}
if (useMiniFont) {
g2d.setFont(textFontMini);
} else {
g2d.setFont(textFont);
}
textOffsetX = calculateOffset(g2d);
g2d.drawString(text, textOffsetX, textOffsetY);
}
@ -124,7 +130,7 @@ public class HoverButton extends JPanel implements MouseListener {
frc = g2d.getFontRenderContext();
textWidth = (int) textFontMini.getStringBounds(text, frc).getWidth();
}
textOffsetX = (int) ((imageSize.width - textWidth) / 2);
textOffsetX = (imageSize.width - textWidth) / 2;
}
return textOffsetX;
}

View file

@ -71,6 +71,8 @@ import java.util.UUID;
*/
public class MageBook extends JComponent {
private static final long serialVersionUID = 1L;
public static final String LAYOUT_3x3 = "small";
public static final String LAYOUT_4x4 = "big";
@ -181,7 +183,7 @@ public class MageBook extends JComponent {
public void execute() {
if (!currentSet.equals(_set) || currentPage != 0) {
AudioManager.playAnotherTab();
synchronized (this) {
synchronized (MageBook.this) {
selectedTab = _index;
}
currentPage = 0;
@ -413,17 +415,17 @@ public class MageBook extends JComponent {
private java.util.List<HoverButton> tabs = new ArrayList<HoverButton>();
private int selectedTab;
static private final String CENTER_PANEL_IMAGE_PATH = "/book_bg.jpg";
static private final String RIGHT_PANEL_IMAGE_PATH = "/book_right.jpg";
static private final String LEFT_PANEL_IMAGE_PATH = "/book_left.jpg";
static private final String LEFT_PAGE_BUTTON_IMAGE_PATH = "/book_pager_left.png";
static private final String RIGHT_PAGE_BUTTON_IMAGE_PATH = "/book_pager_right.png";
static private final String LEFT_TAB_IMAGE_PATH = "/tab_left.png";
static private final String RIGHT_TAB_IMAGE_PATH = "/tab_right.png";
static private final int OFFSET_X = 25;
static private final int OFFSET_Y = 20;
static private final int LEFT_RIGHT_PAGES_WIDTH = 40;
static private final Color NOT_IMPLEMENTED = new Color(220, 220, 220, 150);
private static final String CENTER_PANEL_IMAGE_PATH = "/book_bg.jpg";
private static final String RIGHT_PANEL_IMAGE_PATH = "/book_right.jpg";
private static final String LEFT_PANEL_IMAGE_PATH = "/book_left.jpg";
private static final String LEFT_PAGE_BUTTON_IMAGE_PATH = "/book_pager_left.png";
private static final String RIGHT_PAGE_BUTTON_IMAGE_PATH = "/book_pager_right.png";
private static final String LEFT_TAB_IMAGE_PATH = "/tab_left.png";
private static final String RIGHT_TAB_IMAGE_PATH = "/tab_right.png";
private static final int OFFSET_X = 25;
private static final int OFFSET_Y = 20;
private static final int LEFT_RIGHT_PAGES_WIDTH = 40;
private static final Color NOT_IMPLEMENTED = new Color(220, 220, 220, 150);
private Configuration conf;
}

View file

@ -25,16 +25,8 @@
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
/*
* TablesPane.java
*
* Created on Dec 17, 2009, 9:21:42 AM
*/
package mage.client.table;
import java.util.Map;
import java.util.UUID;
import javax.swing.JComponent;
@ -54,8 +46,7 @@ public class TablesPane extends MagePane {
boolean initialized = false;
if (Plugins.getInstance().isThemePluginLoaded()) {
tablesPanel = new mage.client.table.TablesPanel();
Map<String, JComponent> ui = tablesPanel.getUIComponents();
JComponent container = Plugins.getInstance().updateTablePanel(ui);
JComponent container = Plugins.getInstance().updateTablePanel(tablesPanel.getUIComponents());
if (container != null) {
initComponents(container);
container.add(tablesPanel);

View file

@ -73,7 +73,7 @@ import java.util.concurrent.ExecutionException;
*/
public class TablesPanel extends javax.swing.JPanel {
private final static Logger logger = Logger.getLogger(TablesPanel.class);
private static final Logger logger = Logger.getLogger(TablesPanel.class);
private TableTableModel tableModel;
private MatchesTableModel matchesModel;
@ -674,7 +674,7 @@ class UpdateTablesTask extends SwingWorker<Void, Collection<TableView>> {
private UUID roomId;
private TablesPanel panel;
private final static Logger logger = Logger.getLogger(UpdateTablesTask.class);
private static final Logger logger = Logger.getLogger(UpdateTablesTask.class);
private int count = 0;
@ -723,7 +723,7 @@ class UpdatePlayersTask extends SwingWorker<Void, Collection<String>> {
private UUID roomId;
private ChatPanel chat;
private final static Logger logger = Logger.getLogger(UpdatePlayersTask.class);
private static final Logger logger = Logger.getLogger(UpdatePlayersTask.class);
UpdatePlayersTask(Session session, UUID roomId, ChatPanel chat) {
this.session = session;
@ -829,7 +829,7 @@ class UpdateMatchesTask extends SwingWorker<Void, Collection<MatchView>> {
private UUID roomId;
private TablesPanel panel;
private final static Logger logger = Logger.getLogger(UpdateTablesTask.class);
private static final Logger logger = Logger.getLogger(UpdateTablesTask.class);
UpdateMatchesTask(Session session, UUID roomId, TablesPanel panel) {
this.session = session;

View file

@ -8,16 +8,13 @@ import java.util.Timer;
import java.util.TimerTask;
abstract public class Animation {
static private final long TARGET_MILLIS_PER_FRAME = 30;
//static private final float HALF_PI = (float)(Math.PI / 2);
private static final long TARGET_MILLIS_PER_FRAME = 30;
static private Timer timer = new Timer("Animation", true);
private static Timer timer = new Timer("Animation", true);
//static private CardPanel delayedCardPanel;
//static private long delayedTime;
static private CardPanel enlargedCardPanel;
static private CardPanel enlargedAnimationPanel;
static private Object enlargeLock = new Object();
private static CardPanel enlargedCardPanel;
private static CardPanel enlargedAnimationPanel;
private static final Object enlargeLock = new Object();
private TimerTask timerTask;
private FrameTimer frameTimer;
@ -29,6 +26,7 @@ abstract public class Animation {
public Animation (final long duration, long delay) {
timerTask = new TimerTask() {
@Override
public void run () {
if (frameTimer == null) {
start();
@ -40,7 +38,9 @@ abstract public class Animation {
elapsed = duration;
}
update(elapsed / (float)duration);
if (elapsed == duration) end();
if (elapsed == duration) {
end();
}
}
};
timer.scheduleAtFixedRate(timerTask, delay, TARGET_MILLIS_PER_FRAME);
@ -62,32 +62,36 @@ abstract public class Animation {
/**
* Uses averaging of the time between the past few frames to provide smooth animation.
*/
private class FrameTimer {
static private final int SAMPLES = 6;
static private final long MAX_FRAME = 100; // Max time for one frame, to weed out spikes.
private static class FrameTimer {
private static final int SAMPLES = 6;
private static final long MAX_FRAME = 100; // Max time for one frame, to weed out spikes.
private long samples[] = new long[SAMPLES];
private int sampleIndex;
public FrameTimer () {
long currentTime = System.currentTimeMillis();
for (int i = SAMPLES - 1; i >= 0; i--)
for (int i = SAMPLES - 1; i >= 0; i--) {
samples[i] = currentTime - (SAMPLES - i) * TARGET_MILLIS_PER_FRAME;
}
}
public long getTimeSinceLastFrame () {
long currentTime = System.currentTimeMillis();
int id = sampleIndex - 1;
if (id < 0) id += SAMPLES;
if (id < 0) {
id += SAMPLES;
}
long timeSinceLastSample = currentTime - samples[id];
// If the slice was too big, advance all the previous times by the diff.
if (timeSinceLastSample > MAX_FRAME) {
long diff = timeSinceLastSample - MAX_FRAME;
for (int i = 0; i < SAMPLES; i++)
for (int i = 0; i < SAMPLES; i++) {
samples[i] += diff;
}
}
long timeSinceOldestSample = currentTime - samples[sampleIndex];
@ -100,26 +104,37 @@ abstract public class Animation {
static public void tapCardToggle (final CardPanel panel, final MagePermanent parent, final boolean tapped, final boolean flipped) {
new Animation(300) {
@Override
protected void start () {
parent.onBeginAnimation();
}
@Override
protected void update (float percentage) {
if (tapped) {
panel.tappedAngle = CardPanel.TAPPED_ANGLE * percentage;
// reverse movement if untapping
if (!panel.isTapped()) panel.tappedAngle = CardPanel.TAPPED_ANGLE - panel.tappedAngle;
if (!panel.isTapped()) {
panel.tappedAngle = CardPanel.TAPPED_ANGLE - panel.tappedAngle;
}
}
if (flipped) {
panel.flippedAngle = CardPanel.FLIPPED_ANGLE * percentage;
if (!panel.isFlipped()) panel.flippedAngle = CardPanel.FLIPPED_ANGLE - panel.flippedAngle;
panel.flippedAngle = CardPanel.FLIPPED_ANGLE * percentage;
if (!panel.isFlipped()) {
panel.flippedAngle = CardPanel.FLIPPED_ANGLE - panel.flippedAngle;
}
}
panel.repaint();
}
@Override
protected void end () {
if (tapped) panel.tappedAngle = panel.isTapped() ? CardPanel.TAPPED_ANGLE : 0;
if (flipped) panel.flippedAngle = panel.isFlipped() ? CardPanel.FLIPPED_ANGLE : 0;
if (tapped) {
panel.tappedAngle = panel.isTapped() ? CardPanel.TAPPED_ANGLE : 0;
}
if (flipped) {
panel.flippedAngle = panel.isFlipped() ? CardPanel.FLIPPED_ANGLE : 0;
}
parent.onEndAnimation();
parent.repaint();
}
@ -129,12 +144,14 @@ abstract public class Animation {
public static void transformCard (final CardPanel panel, final MagePermanent parent, final boolean transformed) {
new Animation(1200) {
boolean state = false;
private boolean state = false;
@Override
protected void start () {
parent.onBeginAnimation();
}
@Override
protected void update (float percentage) {
double p = percentage * 2;
if (percentage > 0.5) {
@ -152,6 +169,7 @@ abstract public class Animation {
panel.repaint();
}
@Override
protected void end () {
parent.onEndAnimation();
parent.repaint();
@ -159,11 +177,11 @@ abstract public class Animation {
};
}
// static public void moveCardToPlay (Component source, final CardPanel dest, final CardPanel animationPanel) {
static public void moveCardToPlay (final int startX, final int startY, final int startWidth, final int endX, final int endY,
final int endWidth, final CardPanel animationPanel, final CardPanel placeholder, final JLayeredPane layeredPane,
final int speed) {
UI.invokeLater(new Runnable() {
@Override
public void run () {
final int startHeight = Math.round(startWidth * CardPanel.ASPECT_RATIO);
final int endHeight = Math.round(endWidth * CardPanel.ASPECT_RATIO);
@ -173,42 +191,46 @@ abstract public class Animation {
animationPanel.setCardBounds(startX, startY, startWidth, startHeight);
animationPanel.setAnimationPanel(true);
Container parent = animationPanel.getParent();
if (parent != layeredPane) {
if (parent != null && !parent.equals(layeredPane)) {
layeredPane.add(animationPanel);
layeredPane.setLayer(animationPanel, JLayeredPane.MODAL_LAYER);
}
new Animation(700) {
@Override
protected void update (float percentage) {
float percent = percentage;
if (placeholder != null && !placeholder.isShowing()) {
cancel();
return;
}
int currentX = startX + Math.round((endX - startX + endWidth / 2f) * percentage);
int currentY = startY + Math.round((endY - startY + endHeight / 2f) * percentage);
int currentX = startX + Math.round((endX - startX + endWidth / 2f) * percent);
int currentY = startY + Math.round((endY - startY + endHeight / 2f) * percent);
int currentWidth, currentHeight;
int midWidth = Math.max(200, endWidth * 2);
int midHeight = Math.round(midWidth * CardPanel.ASPECT_RATIO);
if (percentage <= 0.5f) {
percentage = percentage * 2;
float pp = sqrta * (1 - percentage);
percentage = 1 - a * pp * pp;
currentWidth = startWidth + Math.round((midWidth - startWidth) * percentage);
currentHeight = startHeight + Math.round((midHeight - startHeight) * percentage);
if (percent <= 0.5f) {
percent = percent * 2;
float pp = sqrta * (1 - percent);
percent = 1 - a * pp * pp;
currentWidth = startWidth + Math.round((midWidth - startWidth) * percent);
currentHeight = startHeight + Math.round((midHeight - startHeight) * percent);
} else {
percentage = (percentage - 0.5f) * 2;
float pp = sqrta * percentage;
percentage = a * pp * pp;
currentWidth = midWidth + Math.round((endWidth - midWidth) * percentage);
currentHeight = midHeight + Math.round((endHeight - midHeight) * percentage);
percent = (percent - 0.5f) * 2;
float pp = sqrta * percent;
percent = a * pp * pp;
currentWidth = midWidth + Math.round((endWidth - midWidth) * percent);
currentHeight = midHeight + Math.round((endHeight - midHeight) * percent);
}
currentX -= Math.round(currentWidth / 2);
currentY -= Math.round(currentHeight / 2);
currentX -= currentWidth / 2;
currentY -= currentHeight / 2;
animationPanel.setCardBounds(currentX, currentY, currentWidth, currentHeight);
}
@Override
protected void end () {
EventQueue.invokeLater(new Runnable() {
@Override
public void run () {
if (placeholder != null) {
placeholder.setDisplayEnabled(true);
@ -229,6 +251,7 @@ abstract public class Animation {
final int endWidth, final CardPanel animationPanel, final CardPanel placeholder, final JLayeredPane layeredPane,
final int speed) {
UI.invokeLater(new Runnable() {
@Override
public void run () {
final int startHeight = Math.round(startWidth * CardPanel.ASPECT_RATIO);
final int endHeight = Math.round(endWidth * CardPanel.ASPECT_RATIO);
@ -236,12 +259,13 @@ abstract public class Animation {
animationPanel.setCardBounds(startX, startY, startWidth, startHeight);
animationPanel.setAnimationPanel(true);
Container parent = animationPanel.getParent();
if (parent != layeredPane) {
if (parent != null && !parent.equals(layeredPane)) {
layeredPane.add(animationPanel);
layeredPane.setLayer(animationPanel, JLayeredPane.MODAL_LAYER);
}
new Animation(speed) {
@Override
protected void update (float percentage) {
int currentX = startX + Math.round((endX - startX) * percentage);
int currentY = startY + Math.round((endY - startY) * percentage);
@ -250,8 +274,10 @@ abstract public class Animation {
animationPanel.setCardBounds(currentX, currentY, currentWidth, currentHeight);
}
@Override
protected void end () {
EventQueue.invokeLater(new Runnable() {
@Override
public void run () {
if (placeholder != null) {
placeholder.setDisplayEnabled(true);
@ -269,18 +295,19 @@ abstract public class Animation {
}
static public void shrinkCard () {
CardPanel enlargedCardPanel, enlargedAnimationPanel;
final CardPanel overPanel, animationPanel;
synchronized (enlargeLock) {
//delayedCardPanel = null;
//delayedTime = 0;
enlargedCardPanel = Animation.enlargedCardPanel;
enlargedAnimationPanel = Animation.enlargedAnimationPanel;
if (enlargedAnimationPanel == null) return;
overPanel = Animation.enlargedCardPanel;
animationPanel = Animation.enlargedAnimationPanel;
if (animationPanel == null) {
return;
}
Animation.enlargedCardPanel = null;
Animation.enlargedAnimationPanel = null;
}
final CardPanel overPanel = enlargedCardPanel, animationPanel = enlargedAnimationPanel;
animationPanel.setAnimationPanel(true);
final JLayeredPane layeredPane = SwingUtilities.getRootPane(overPanel).getLayeredPane();
@ -292,6 +319,7 @@ abstract public class Animation {
final int endHeight = Math.round(endWidth * CardPanel.ASPECT_RATIO);
new Animation(200) {
@Override
protected void update (float percentage) {
int currentWidth = startWidth + Math.round((endWidth - startWidth) * percentage);
int currentHeight = startHeight + Math.round((endHeight - startHeight) * percentage);
@ -306,10 +334,12 @@ abstract public class Animation {
animationPanel.setCardBounds(currentX, currentY, currentWidth, currentHeight);
}
@Override
protected void end () {
animationPanel.setVisible(false);
animationPanel.repaint();
EventQueue.invokeLater(new Runnable() {
@Override
public void run () {
layeredPane.remove(animationPanel);
}
@ -329,15 +359,18 @@ abstract public class Animation {
count = 1;
}
new Animation(600 / count) {
@Override
protected void start () {
}
@Override
protected void update (float percentage) {
float alpha = percentage;
card.setAlpha(alpha);
card.repaint();
}
@Override
protected void end () {
card.setAlpha(1.f);
}
@ -349,15 +382,18 @@ abstract public class Animation {
count = 1;
}
new Animation(600 / count) {
@Override
protected void start () {
}
@Override
protected void update (float percentage) {
float alpha = 1 - percentage;
card.setAlpha(alpha);
card.repaint();
}
@Override
protected void end () {
card.setAlpha(0f);
}

View file

@ -37,12 +37,12 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti
private static final Logger log = Logger.getLogger(CardPanel.class);
static public final double TAPPED_ANGLE = Math.PI / 2;
static public final double FLIPPED_ANGLE = Math.PI;
static public final float ASPECT_RATIO = 3.5f / 2.5f;
static public final int POPUP_X_GAP = 1; // prevent popup window from blinking
public static final double TAPPED_ANGLE = Math.PI / 2;
public static final double FLIPPED_ANGLE = Math.PI;
public static final float ASPECT_RATIO = 3.5f / 2.5f;
public static final int POPUP_X_GAP = 1; // prevent popup window from blinking
static public CardPanel dragAnimationPanel;
public static CardPanel dragAnimationPanel;
public static final Rectangle CARD_SIZE_FULL = new Rectangle(101, 149);
@ -62,7 +62,7 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti
public double tappedAngle = 0;
public double flippedAngle = 0;
public ScaledImagePanel imagePanel;
public final ScaledImagePanel imagePanel;
public ImagePanel overlayPanel;
public JPanel buttonPanel;
@ -178,7 +178,6 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti
add(imagePanel);
imagePanel.setScaleLarger(true);
imagePanel.setScalingType(ScalingType.nearestNeighbor);
imagePanel.setScalingBlur(true);
imagePanel.setScalingMultiPassType(MultipassType.none);
String cardType = getType(newGameCard);
@ -190,7 +189,9 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti
try {
tappedAngle = isTapped() ? CardPanel.TAPPED_ANGLE : 0;
flippedAngle = isFlipped() ? CardPanel.FLIPPED_ANGLE : 0;
if (!loadImage || gameCard.isFaceDown()) return;
if (!loadImage || gameCard.isFaceDown()) {
return;
}
BufferedImage srcImage = ImageCache.getThumbnail(gameCard);
if (srcImage != null) {
hasImage = true;
@ -255,51 +256,9 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti
return zone;
}
@Override
public void setFoil(boolean foil) {
this.isFoil = foil;
if (foil) {
/*BufferedImage source = BufferedImageBuilder.bufferImage(imagePanel.getSrcImage());
HueFilter filter = FilterFactory.getHueFilter();
filter.setHue(0.1f);
BufferedImage dest = filter.filter(source, null);
imagePanel.setImage(dest);
imagePanel.repaint();*/
/*
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
if (imagePanel.getSrcImage() == null) {
return;
}
BufferedImage source = BufferedImageBuilder.bufferImage(imagePanel.getSrcImage());
HueFilter filter = FilterFactory.getHueFilter();
float hue = 0.005f;
while (true) {
try {
Thread.sleep(DEFAULT_DELAY_PERIOD);
} catch (InterruptedException e) {
}
hue += 0.015F;
if (hue >= 1.0D) {
hue = 0.005F;
}
filter.setHue(hue);
final BufferedImage dest = filter.filter(source, null);
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
imagePanel.setImage(dest);
imagePanel.repaint();
}
});
}
}
});
thread.setDaemon(false);
thread.start();
*/
}
}
public void setScalingType(ScalingType scalingType) {
@ -341,8 +300,12 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti
@Override
public void paint(Graphics g) {
if (!displayEnabled) return;
if (!isValid()) super.validate();
if (!displayEnabled) {
return;
}
if (!isValid()) {
super.validate();
}
Graphics2D g2d = (Graphics2D) g;
if (transformAngle < 1) {
float edgeOffset = (cardWidth + cardXOffset) / 2f;
@ -466,10 +429,11 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti
ptText.setLocation(cardXOffset + ptX - TEXT_GLOW_SIZE / 2 - offsetX, cardYOffset + ptY - TEXT_GLOW_SIZE / 2);
dayNightButton.setLocation(0, cardHeight - 30);
if (isAnimationPanel || cardWidth < 200)
if (isAnimationPanel || cardWidth < 200) {
imagePanel.setScalingType(ScalingType.nearestNeighbor);
else
} else {
imagePanel.setScalingType(ScalingType.bilinear);
}
}
@Override
@ -494,15 +458,6 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti
setBounds(x + xOffset, y + yOffset, width, height);
}
/*@Override
public void repaint() {
Rectangle b = getBounds();
JRootPane rootPane = SwingUtilities.getRootPane(this);
if (rootPane == null) return;
Point p = SwingUtilities.convertPoint(getParent(), b.x, b.y, rootPane);
rootPane.repaint(p.x, p.y, b.width, b.height);
}*/
public int getCardX() {
return getX() + cardXOffset;
}
@ -563,7 +518,9 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti
try {
tappedAngle = isTapped() ? CardPanel.TAPPED_ANGLE : 0;
flippedAngle = isFlipped() ? CardPanel.FLIPPED_ANGLE : 0;
if (gameCard.isFaceDown()) return;
if (gameCard.isFaceDown()) {
return;
}
BufferedImage srcImage = ImageCache.getThumbnail(gameCard);
if (srcImage != null) {
hasImage = true;
@ -666,41 +623,28 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti
@Override
public boolean contains(int x, int y) {
if (containsThis(x, y, true)) return true;
/*
* if (attachedCount > 0) { for (MWCardImpl card :
* mwAttachedCards.keySet()) { if (card.contains(x, y)) return true; } }
*/
if (containsThis(x, y, true)) {
return true;
}
return false;
}
public boolean containsThis(int x, int y, boolean root) {
//log.info("x="+x+", y="+y);
Point component = getLocation();
//int dy = component.y;
//if (root) dy = 0;
int cx = getCardX() - component.x;
int cy = getCardY() - component.y;
int cw = getCardWidth();
int ch = getCardHeight();
if (isTapped()) {
cy = ch - cw + cx /*+ attachedDy*attachedCount*/;
cy = ch - cw + cx;
ch = cw;
cw = getCardHeight();
}
//int dx = drawIcons ? 19 : 0;
//int dx = 0;
if (x >= cx && x <= cx + cw && y >= cy && y <= cy + ch) {
//log.info("!cx="+cx+", cy="+cy+", dx="+cw +", ch="+ch);
//log.info(getOriginal().getId());
return true;
} else {
//log.info("cx="+cx+", cy="+cy+", dx="+cw +", ch="+ch);
}
return false;
}
@ -712,8 +656,9 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti
@Override
public Image getImage() {
if (this.hasImage)
if (this.hasImage) {
return ImageCache.getImageOriginal(gameCard);
}
return null;
}
@ -723,7 +668,9 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti
@Override
public void mouseEntered(MouseEvent e) {
if (gameCard.isFaceDown()) return;
if (gameCard.isFaceDown()) {
return;
}
if (!popupShowing) {
synchronized (this) {
if (!popupShowing) {
@ -740,15 +687,21 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti
@Override
public void mouseMoved(MouseEvent e) {
if (gameCard.isFaceDown()) return;
if (gameCard.isFaceDown()) {
return;
}
data.component = this;
callback.mouseMoved(e, data);
}
@Override
public void mouseExited(MouseEvent e) {
if (gameCard.isFaceDown()) return;
if (getMousePosition(true) != null) return;
if (gameCard.isFaceDown()) {
return;
}
if (getMousePosition(true) != null) {
return;
}
if (popupShowing) {
synchronized (this) {
if (popupShowing) {
@ -764,7 +717,9 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti
@Override
public void mousePressed(MouseEvent e) {
if (gameCard.isFaceDown()) return;
if (gameCard.isFaceDown()) {
return;
}
data.component = this;
data.card = this.gameCard;
data.gameId = this.gameId;
@ -840,12 +795,10 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti
}
if (card.getExpansionSetCode() != null && card.getExpansionSetCode().length() > 0) {
sb.append("\n").append(card.getCardNumber()).append(" - ");
//sb.append(Sets.getInstance().get(card.getExpansionSetCode()).getName()).append(" - ");
sb.append(card.getExpansionSetCode()).append(" - ");
sb.append(card.getRarity().toString());
}
}
// sb.append("\n").append(card.getId());
return sb.toString();
}
@ -899,7 +852,9 @@ public class CardPanel extends MagePermanent implements MouseListener, MouseMoti
@Override
public void mouseWheelMoved(MouseWheelEvent e) {
if (gameCard.isFaceDown()) return;
if (gameCard.isFaceDown()) {
return;
}
data.component = this;
callback.mouseWheelMoved(e, data);
}

View file

@ -19,13 +19,13 @@ import java.util.regex.Pattern;
public class ManaSymbols {
private static final Logger log = Logger.getLogger(ManaSymbols.class);
static private final Map<String, BufferedImage> manaImages = new HashMap<String, BufferedImage>();
static private final Map<String, Image> manaImagesOriginal = new HashMap<String, Image>();
static private final Map<String, Image> setImages = new HashMap<String, Image>();
static private final Map<String, Dimension> setImagesExist = new HashMap<String, Dimension>();
static private Pattern replaceSymbolsPattern = Pattern.compile("\\{([^}/]*)/?([^}]*)\\}");
private static final Map<String, BufferedImage> manaImages = new HashMap<String, BufferedImage>();
private static final Map<String, Image> manaImagesOriginal = new HashMap<String, Image>();
private static final Map<String, Image> setImages = new HashMap<String, Image>();
private static final Map<String, Dimension> setImagesExist = new HashMap<String, Dimension>();
private static Pattern replaceSymbolsPattern = Pattern.compile("\\{([^}/]*)/?([^}]*)\\}");
static public void loadImages() {
public static void loadImages() {
String[] symbols = new String[]{"0", "1", "10", "11", "12", "15", "16", "2", "3", "4", "5", "6", "7", "8", "9", "B", "BG",
"BR", "G", "GU", "GW", "R", "RG", "RW", "S", "T", "U", "UB", "UR", "W", "WB", "WU",
"WP", "UP", "BP", "RP", "GP", "X" /*, "Y", "Z", "slash"*/};
@ -38,7 +38,6 @@ public class ManaSymbols {
manaImages.put(symbol, resized);
} catch (Exception e) {
log.error("Error for symbol:" + symbol);
//e.printStackTrace();
}
file = new File(Constants.RESOURCE_PATH_MANA_MEDIUM + "/" + symbol + ".jpg");
try {
@ -121,11 +120,11 @@ public class ManaSymbols {
}
}
static public Image getManaSymbolImage(String symbol) {
public static Image getManaSymbolImage(String symbol) {
return manaImagesOriginal.get(symbol);
}
static public void draw(Graphics g, String manaCost, int x, int y) {
public static void draw(Graphics g, String manaCost, int x, int y) {
if (manaCost.length() == 0) {
return;
}
@ -144,7 +143,7 @@ public class ManaSymbols {
}
}
static public String getStringManaCost(List<String> manaCost) {
public static String getStringManaCost(List<String> manaCost) {
StringBuilder sb = new StringBuilder();
for (String s : manaCost) {
sb.append(s);
@ -152,7 +151,7 @@ public class ManaSymbols {
return sb.toString().replace("{", "").replace("}", " ").trim();
}
static public int getWidth(String manaCost) {
public static int getWidth(String manaCost) {
int width = 0;
manaCost = manaCost.replace("\\", "");
StringTokenizer tok = new StringTokenizer(manaCost, " ");
@ -169,7 +168,7 @@ public class ManaSymbols {
PAY
}
static public synchronized String replaceSymbolsWithHTML(String value, Type type) {
public static synchronized String replaceSymbolsWithHTML(String value, Type type) {
value = value.replace("{source}", "|source|");
value = value.replace("{this}", "|this|");
String replaced = value;
@ -189,7 +188,7 @@ public class ManaSymbols {
return replaced;
}
static public String replaceSetCodeWithHTML(String set, String rarity) {
public static String replaceSetCodeWithHTML(String set, String rarity) {
String _set = set;
if (_set.equals("CON")) {
_set = "CFX";
@ -203,11 +202,11 @@ public class ManaSymbols {
}
}
static public Image getSetSymbolImage(String set) {
public static Image getSetSymbolImage(String set) {
return setImages.get(set);
}
static public BufferedImage getManaSymbolImageSmall(String symbol) {
public static BufferedImage getManaSymbolImageSmall(String symbol) {
return manaImages.get(symbol);
}
}

View file

@ -11,12 +11,10 @@ import javax.swing.JPanel;
public class ScaledImagePanel extends JPanel {
private static final long serialVersionUID = -1523279873208605664L;
public volatile Image srcImage;
//public volatile Image srcImageBlurred;
private ScalingType scalingType = ScalingType.bilinear;
private boolean scaleLarger;
private MultipassType multiPassType = MultipassType.bilinear;
private boolean blur;
public ScaledImagePanel () {
super(false);
@ -40,10 +38,6 @@ public class ScaledImagePanel extends JPanel {
this.scalingType = scalingType;
}
public void setScalingBlur (boolean blur) {
this.blur = blur;
}
public void setScaleLarger (boolean scaleLarger) {
this.scaleLarger = scaleLarger;
}
@ -64,8 +58,9 @@ public class ScaledImagePanel extends JPanel {
if (targetWidth > panelWidth) {
targetHeight = Math.round(panelWidth * (srcHeight / (float)srcWidth));
targetWidth = panelWidth;
} else
} else {
targetHeight = panelHeight;
}
}
ScalingInfo info = new ScalingInfo();
info.targetWidth = targetWidth;
@ -77,8 +72,11 @@ public class ScaledImagePanel extends JPanel {
return info;
}
@Override
public void paint (Graphics g) {
if (srcImage == null) return;
if (srcImage == null) {
return;
}
Graphics2D g2 = (Graphics2D)g.create();
ScalingInfo info = getScalingInfo();
@ -112,8 +110,12 @@ public class ScaledImagePanel extends JPanel {
g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, hint);
int tempDestWidth = info.srcWidth / 2, tempDestHeight = info.srcHeight / 2;
if (tempDestWidth < info.targetWidth) tempDestWidth = info.targetWidth;
if (tempDestHeight < info.targetHeight) tempDestHeight = info.targetHeight;
if (tempDestWidth < info.targetWidth) {
tempDestWidth = info.targetWidth;
}
if (tempDestHeight < info.targetHeight) {
tempDestHeight = info.targetHeight;
}
Image srcImage = getSourceImage(info);
@ -144,15 +146,21 @@ public class ScaledImagePanel extends JPanel {
while (true) {
if (tempDestWidth > info.targetWidth) {
tempDestWidth = tempDestWidth / 2;
if (tempDestWidth < info.targetWidth) tempDestWidth = info.targetWidth;
if (tempDestWidth < info.targetWidth) {
tempDestWidth = info.targetWidth;
}
}
if (tempDestHeight > info.targetHeight) {
tempDestHeight = tempDestHeight / 2;
if (tempDestHeight < info.targetHeight) tempDestHeight = info.targetHeight;
if (tempDestHeight < info.targetHeight) {
tempDestHeight = info.targetHeight;
}
}
if (tempDestWidth == info.targetWidth && tempDestHeight == info.targetHeight) break;
if (tempDestWidth == info.targetWidth && tempDestHeight == info.targetHeight) {
break;
}
g2temp.drawImage(tempImage, 0, 0, tempDestWidth, tempDestHeight, 0, 0, tempSrcWidth, tempSrcHeight, null);
@ -168,9 +176,6 @@ public class ScaledImagePanel extends JPanel {
private Image getSourceImage (ScalingInfo info) {
return srcImage;
//if (!blur || srcImageBlurred == null) return srcImage;
//if (info.srcWidth / 2 < info.targetWidth || info.srcHeight / 2 < info.targetHeight) return srcImage;
//return srcImageBlurred;
}
public Image getSrcImage() {

View file

@ -17,7 +17,8 @@ import java.lang.reflect.InvocationTargetException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Collections;
import java.util.Hashtable;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
@ -44,31 +45,31 @@ import javax.swing.text.html.ImageView;
* UI utility functions.
*/
public class UI {
static private Hashtable<URL, Image> imageCache = new Hashtable<URL, Image>();
private static ConcurrentMap<URL, Image> imageCache = new ConcurrentHashMap<URL, Image>();
static public JToggleButton getToggleButton () {
public static JToggleButton getToggleButton () {
JToggleButton button = new JToggleButton();
button.setMargin(new Insets(2, 4, 2, 4));
return button;
}
static public JButton getButton () {
public static JButton getButton () {
JButton button = new JButton();
button.setMargin(new Insets(2, 4, 2, 4));
return button;
}
static public void setTitle (JPanel panel, String title) {
public static void setTitle (JPanel panel, String title) {
Border border = panel.getBorder();
if (border instanceof TitledBorder) {
((TitledBorder)panel.getBorder()).setTitle(title);
((TitledBorder) panel.getBorder()).setTitle(title);
panel.repaint();
} else
} else {
panel.setBorder(BorderFactory.createTitledBorder(title));
}
}
@SuppressWarnings("deprecation")
static public URL getFileURL (String path) {
public static URL getFileURL (String path) {
File file = new File(path);
if (file.exists()) {
try {
@ -79,12 +80,16 @@ public class UI {
return UI.class.getResource(path);
}
static public ImageIcon getImageIcon (String path) {
public static ImageIcon getImageIcon (String path) {
try {
InputStream stream;
stream = UI.class.getResourceAsStream(path);
if (stream == null && new File(path).exists()) stream = new FileInputStream(path);
if (stream == null) throw new RuntimeException("Image not found: " + path);
if (stream == null && new File(path).exists()) {
stream = new FileInputStream(path);
}
if (stream == null) {
throw new RuntimeException("Image not found: " + path);
}
byte[] data = new byte[stream.available()];
stream.read(data);
return new ImageIcon(data);
@ -93,27 +98,33 @@ public class UI {
}
}
static public void setHTMLEditorKit (JEditorPane editorPane) {
public static void setHTMLEditorKit (JEditorPane editorPane) {
editorPane.getDocument().putProperty("imageCache", imageCache); // Read internally by ImageView, but never written.
// Extend all this shit to cache images.
editorPane.setEditorKit(new HTMLEditorKit() {
private static final long serialVersionUID = -54602188235105448L;
@Override
public ViewFactory getViewFactory () {
return new HTMLFactory() {
public View create (Element elem) {
@Override
public View create(Element elem) {
Object o = elem.getAttributes().getAttribute(StyleConstants.NameAttribute);
if (o instanceof HTML.Tag) {
HTML.Tag kind = (HTML.Tag)o;
if (kind == HTML.Tag.IMG) return new ImageView(elem) {
public URL getImageURL () {
URL url = super.getImageURL();
// Put an image into the cache to be read by other ImageView methods.
if (url != null && imageCache.get(url) == null)
imageCache.put(url, Toolkit.getDefaultToolkit().createImage(url));
return url;
}
};
HTML.Tag kind = (HTML.Tag) o;
if (kind == HTML.Tag.IMG) {
return new ImageView(elem) {
@Override
public URL getImageURL() {
URL url = super.getImageURL();
// Put an image into the cache to be read by other ImageView methods.
if (url != null && imageCache.get(url) == null) {
imageCache.put(url, Toolkit.getDefaultToolkit().createImage(url));
}
return url;
}
};
}
}
return super.create(elem);
}
@ -122,10 +133,11 @@ public class UI {
});
}
static public void setVerticalScrollingView (JScrollPane scrollPane, final Component view) {
public static void setVerticalScrollingView (JScrollPane scrollPane, final Component view) {
final JViewport viewport = new JViewport();
viewport.setLayout(new ViewportLayout() {
private static final long serialVersionUID = 7701568740313788935L;
@Override
public void layoutContainer (Container parent) {
viewport.setViewPosition(new Point(0, 0));
Dimension viewportSize = viewport.getSize();
@ -139,19 +151,21 @@ public class UI {
scrollPane.setViewport(viewport);
}
static public String getDisplayManaCost (String manaCost) {
public static String getDisplayManaCost (String manaCost) {
manaCost = manaCost.replace("/", "");
// A pipe in the cost means "process left of the pipe as the card color, but display right of the pipe as the cost".
int pipePosition = manaCost.indexOf("{|}");
if (pipePosition != -1) manaCost = manaCost.substring(pipePosition + 3);
if (pipePosition != -1) {
manaCost = manaCost.substring(pipePosition + 3);
}
return manaCost;
}
static public void invokeLater (Runnable runnable) {
public static void invokeLater (Runnable runnable) {
EventQueue.invokeLater(runnable);
}
static public void invokeAndWait (Runnable runnable) {
public static void invokeAndWait (Runnable runnable) {
if (EventQueue.isDispatchThread()) {
runnable.run();
return;
@ -164,7 +178,7 @@ public class UI {
}
}
static public void setSystemLookAndFeel () {
public static void setSystemLookAndFeel () {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception ex) {
@ -173,10 +187,12 @@ public class UI {
}
}
static public void setDefaultFont (Font font) {
public static void setDefaultFont (Font font) {
for (Object key : Collections.list(UIManager.getDefaults().keys())) {
Object value = UIManager.get(key);
if (value instanceof javax.swing.plaf.FontUIResource) UIManager.put(key, font);
if (value instanceof javax.swing.plaf.FontUIResource) {
UIManager.put(key, font);
}
}
}
}

View file

@ -18,10 +18,10 @@ import javax.swing.SwingUtilities;
@SuppressWarnings({ "rawtypes", "unchecked" })
public class Util {
static public final boolean isMac = System.getProperty("os.name").toLowerCase().indexOf("mac") != -1;
static public final boolean isWindows = System.getProperty("os.name").toLowerCase().indexOf("windows") == -1;
public static final boolean isMac = System.getProperty("os.name").toLowerCase().indexOf("mac") != -1;
public static final boolean isWindows = System.getProperty("os.name").toLowerCase().indexOf("windows") == -1;
static public Robot robot;
public static Robot robot;
static {
try {
new Robot();
@ -30,10 +30,11 @@ public class Util {
}
}
static public ThreadPoolExecutor threadPool;
public static final ThreadPoolExecutor threadPool;
static private int threadCount;
static {
threadPool = new ThreadPoolExecutor(4, 4, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue(), new ThreadFactory() {
@Override
public Thread newThread (Runnable runnable) {
threadCount++;
Thread thread = new Thread(runnable, "Util" + threadCount);
@ -54,7 +55,9 @@ public class Util {
throws IOException {
for (NetworkInterface iface : Collections.list(ifaces)) {
for (InetAddress address : Collections.list(iface.getInetAddresses())) {
if (!address.isSiteLocalAddress()) continue;
if (!address.isSiteLocalAddress()) {
continue;
}
// Java 1.5 doesn't support getting the subnet mask, so try the two most common.
byte[] ip = address.getAddress();
ip[3] = -1; // 255.255.255.0
@ -65,14 +68,14 @@ public class Util {
}
}
static public void sleep (int millis) {
public static void sleep (int millis) {
try {
Thread.sleep(millis);
} catch (InterruptedException ignored) {
}
}
static public boolean classExists (String className) {
public static boolean classExists (String className) {
try {
Class.forName(className);
return true;
@ -81,7 +84,7 @@ public class Util {
}
}
static public void wait (Object lock) {
public static void wait (Object lock) {
synchronized (lock) {
try {
lock.wait();

View file

@ -43,15 +43,14 @@ import java.util.List;
@Author(name = "nantuko")
public class CardPluginImpl implements CardPlugin {
private final static Logger log = Logger.getLogger(CardPluginImpl.class);
private static final Logger log = Logger.getLogger(CardPluginImpl.class);
static private final int GUTTER_Y = 15;
static private final int GUTTER_X = 5;
private static final int GUTTER_Y = 15;
private static final int GUTTER_X = 5;
static final float EXTRA_CARD_SPACING_X = 0.04f;
static private final float CARD_SPACING_Y = 0.03f;
static private final float STACK_SPACING_X = 0.07f;
static private final float STACK_SPACING_Y = 0.13f;
//static private final int MW_GUIDE_HEIGHT = 30;
private static final float CARD_SPACING_Y = 0.03f;
private static final float STACK_SPACING_X = 0.07f;
private static final float STACK_SPACING_Y = 0.13f;
private int landStackMax = 5;
private int cardWidthMin = 50, cardWidthMax = Constants.CARD_SIZE_FULL.width;
@ -69,8 +68,6 @@ public class CardPluginImpl implements CardPlugin {
@PluginLoaded
public void newPlugin(CardPlugin plugin) {
//ManaSymbols.loadImages();
//log.info(plugin.toString() + " has been loaded.");
}
@Override
@ -104,21 +101,16 @@ public class CardPluginImpl implements CardPlugin {
//requires to find out is position have been changed that includes:
//adding/removing permanents, type change
if (ui == null)
if (ui == null) {
throw new RuntimeException("Error: no components");
//JComponent component = ui.get("jScrollPane");
JComponent component2 = ui.get("battlefieldPanel");
//if (component == null)
//throw new RuntimeException("Error: jScrollPane is missing");
if (component2 == null)
throw new RuntimeException("Error: battlefieldPanel is missing");
//if (!(component instanceof JScrollPane))
//throw new RuntimeException("Error: jScrollPane has wrong type.");
//if (!(component instanceof JScrollPane))
//throw new RuntimeException("Error: battlefieldPanel is missing");
}
JComponent component = ui.get("battlefieldPanel");
//JScrollPane jScrollPane = (JScrollPane) component;
JLayeredPane battlefieldPanel = (JLayeredPane) component2;
if (component == null) {
throw new RuntimeException("Error: battlefieldPanel is missing");
}
JLayeredPane battlefieldPanel = (JLayeredPane) component;
JComponent jPanel = ui.get("jPanel");
Row allLands = new Row();
@ -126,8 +118,9 @@ public class CardPluginImpl implements CardPlugin {
outerLoop:
//
for (MagePermanent permanent : permanents) {
if (!CardUtil.isLand(permanent) || CardUtil.isCreature(permanent))
if (!CardUtil.isLand(permanent) || CardUtil.isCreature(permanent)) {
continue;
}
int insertIndex = -1;
@ -150,8 +143,9 @@ public class CardPluginImpl implements CardPlugin {
stack.add(0, permanent);
continue outerLoop;
}
if (insertIndex != -1)
if (insertIndex != -1) {
break;
}
}
Stack stack = new Stack();
@ -178,11 +172,11 @@ public class CardPluginImpl implements CardPlugin {
while (true) {
rows.clear();
cardHeight = Math.round(cardWidth * CardPanel.ASPECT_RATIO);
extraCardSpacingX = (int) Math.round(cardWidth * EXTRA_CARD_SPACING_X);
extraCardSpacingX = Math.round(cardWidth * EXTRA_CARD_SPACING_X);
cardSpacingX = cardHeight - cardWidth + extraCardSpacingX;
cardSpacingY = (int) Math.round(cardHeight * CARD_SPACING_Y);
stackSpacingX = stackVertical ? 0 : (int) Math.round(cardWidth * STACK_SPACING_X);
stackSpacingY = (int) Math.round(cardHeight * STACK_SPACING_Y);
cardSpacingY = Math.round(cardHeight * CARD_SPACING_Y);
stackSpacingX = stackVertical ? 0 : Math.round(cardWidth * STACK_SPACING_X);
stackSpacingY = Math.round(cardHeight * STACK_SPACING_Y);
Row creatures = (Row) allCreatures.clone();
Row lands = (Row) allLands.clone();
Row others = (Row) allOthers.clone();
@ -192,26 +186,30 @@ public class CardPluginImpl implements CardPlugin {
wrap(lands, rows, afterCreaturesIndex);
// Store the current rows and others.
List<Row> storedRows = new ArrayList<Row>(rows.size());
for (Row row : rows)
for (Row row : rows) {
storedRows.add((Row) row.clone());
}
Row storedOthers = (Row) others.clone();
// Fill in all rows with others.
for (Row row : rows)
for (Row row : rows) {
fillRow(others, rows, row);
}
// Stop if everything fits, otherwise revert back to the stored values.
if (creatures.isEmpty() && lands.isEmpty() && others.isEmpty())
if (creatures.isEmpty() && lands.isEmpty() && others.isEmpty()) {
break;
}
rows = storedRows;
others = storedOthers;
// Try to put others on their own row(s) and fill in the rest.
wrap(others, rows, afterCreaturesIndex);
for (Row row : rows)
for (Row row : rows) {
fillRow(others, rows, row);
}
// If that still doesn't fit, scale down.
if (creatures.isEmpty() && lands.isEmpty() && others.isEmpty())
if (creatures.isEmpty() && lands.isEmpty() && others.isEmpty()) {
break;
//cardWidth = (int)(cardWidth / 1.2);
}
//FIXME: -1 is too slow. why not binary search?
cardWidth -= 3;
}
@ -232,7 +230,6 @@ public class CardPluginImpl implements CardPlugin {
}
// Position all card panels.
x = 0;
y = GUTTER_Y;
for (Row row : rows) {
int rowBottom = 0;
@ -242,17 +239,18 @@ public class CardPluginImpl implements CardPlugin {
// Align others to the right.
if (othersOnTheRight && RowType.other.isType(stack.get(0))) {
x = playAreaWidth - GUTTER_X + extraCardSpacingX;
for (int i = stackIndex, n = row.size(); i < n; i++)
for (int i = stackIndex, n = row.size(); i < n; i++) {
x -= row.get(i).getWidth();
}
}
for (int panelIndex = 0, panelCount = stack.size(); panelIndex < panelCount; panelIndex++) {
MagePermanent panel = stack.get(panelIndex);
int stackPosition = panelCount - panelIndex - 1;
if (jPanel != null)
if (jPanel != null) {
jPanel.setComponentZOrder(panel, panelIndex);
}
int panelX = x + (stackPosition * stackSpacingX);
int panelY = y + (stackPosition * stackSpacingY);
//panel.setLocation(panelX, panelY);
try {
// may cause:
// java.lang.IllegalArgumentException: illegal component position 26 should be less then 26
@ -286,10 +284,12 @@ public class CardPluginImpl implements CardPlugin {
int rowWidth = currentRow.getWidth();
if (!currentRow.isEmpty() && rowWidth + stack.getWidth() > playAreaWidth) {
// Stop processing if the row is too wide or tall.
if (!allowHeightOverflow && rowWidth > playAreaWidth)
if (!allowHeightOverflow && rowWidth > playAreaWidth) {
break;
if (!allowHeightOverflow && getRowsHeight(rows) + sourceRow.getHeight() > playAreaHeight)
}
if (!allowHeightOverflow && getRowsHeight(rows) + sourceRow.getHeight() > playAreaHeight) {
break;
}
rows.add(insertIndex == -1 ? rows.size() : insertIndex, currentRow);
currentRow = new Row();
}
@ -305,9 +305,11 @@ public class CardPluginImpl implements CardPlugin {
}
}
// Remove the wrapped stacks from the source row.
for (Row row : rows)
for (Stack stack : row)
for (Row row : rows) {
for (Stack stack : row) {
sourceRow.remove(stack);
}
}
return insertIndex;
}
@ -316,11 +318,12 @@ public class CardPluginImpl implements CardPlugin {
while (!sourceRow.isEmpty()) {
Stack stack = sourceRow.get(0);
rowWidth += stack.getWidth();
if (rowWidth > playAreaWidth)
if (rowWidth > playAreaWidth) {
break;
}
if (stack.getHeight() > row.getHeight()
&& getRowsHeight(rows) - row.getHeight() + stack.getHeight() > playAreaHeight) {
break;
if (stack.getHeight() > row.getHeight()) {
if (getRowsHeight(rows) - row.getHeight() + stack.getHeight() > playAreaHeight)
break;
}
row.add(sourceRow.remove(0));
}
@ -328,12 +331,13 @@ public class CardPluginImpl implements CardPlugin {
private int getRowsHeight(List<Row> rows) {
int height = 0;
for (Row row : rows)
for (Row row : rows) {
height += row.getHeight();
}
return height - cardSpacingY + GUTTER_Y * 2;
}
static private enum RowType {
private static enum RowType {
land, creature, other;
public boolean isType(MagePermanent card) {
@ -351,6 +355,8 @@ public class CardPluginImpl implements CardPlugin {
}
private class Row extends ArrayList<Stack> {
private static final long serialVersionUID = 1L;
public Row() {
super(16);
}
@ -379,37 +385,35 @@ public class CardPluginImpl implements CardPlugin {
}
private int getWidth() {
if (isEmpty())
if (isEmpty()) {
return 0;
}
int width = 0;
for (Stack stack : this)
for (Stack stack : this) {
width += stack.getWidth();
}
return width + GUTTER_X * 2 - extraCardSpacingX;
}
private int getHeight() {
if (isEmpty())
if (isEmpty()) {
return 0;
}
int height = 0;
for (Stack stack : this)
for (Stack stack : this) {
height = Math.max(height, stack.getHeight());
}
return height;
}
}
private class Stack extends ArrayList<MagePermanent> {
private static final long serialVersionUID = 1L;
public Stack() {
super(8);
}
@Override
public boolean add(MagePermanent panel) {
boolean appended = super.add(panel);
//for (CardPanel attachedPanel : panel.attachedPanels)
//add(attachedPanel);
return appended;
}
private int getWidth() {
return cardWidth + (size() - 1) * stackSpacingX + cardSpacingX;
}

View file

@ -3,31 +3,31 @@ package mage.cards;
import mage.cards.action.ActionCallback;
import mage.view.CardView;
import javax.swing.*;
import java.awt.*;
import java.awt.Image;
import java.util.UUID;
import javax.swing.JPanel;
public abstract class MageCard extends JPanel {
private static final long serialVersionUID = 6089945326434301879L;
abstract public void onBeginAnimation();
abstract public void onEndAnimation();
abstract public boolean isTapped();
abstract public boolean isFlipped();
abstract public void setAlpha(float transparency);
abstract public float getAlpha();
abstract public CardView getOriginal();
abstract public void setCardBounds(int x, int y, int width, int height);
abstract public void update(CardView card);
abstract public void updateImage();
abstract public Image getImage();
abstract public void setFoil(boolean foil);
abstract public boolean isFoil();
abstract public void setZone(String zone);
abstract public String getZone();
abstract public void updateCallback(ActionCallback callback, UUID gameId);
abstract public void toggleTransformed();
abstract public boolean isTransformed();
abstract public void showCardTitle();
abstract public void setSelected(boolean selected);
public abstract void onBeginAnimation();
public abstract void onEndAnimation();
public abstract boolean isTapped();
public abstract boolean isFlipped();
public abstract void setAlpha(float transparency);
public abstract float getAlpha();
public abstract CardView getOriginal();
public abstract void setCardBounds(int x, int y, int width, int height);
public abstract void update(CardView card);
public abstract void updateImage();
public abstract Image getImage();
public abstract void setFoil(boolean foil);
public abstract boolean isFoil();
public abstract void setZone(String zone);
public abstract String getZone();
public abstract void updateCallback(ActionCallback callback, UUID gameId);
public abstract void toggleTransformed();
public abstract boolean isTransformed();
public abstract void showCardTitle();
public abstract void setSelected(boolean selected);
}

View file

@ -6,7 +6,7 @@ import mage.view.PermanentView;
public abstract class MagePermanent extends MageCard {
private static final long serialVersionUID = -3469258620601702171L;
abstract public List<MagePermanent> getLinks();
abstract public void update(PermanentView card);
abstract public PermanentView getOriginalPermanent();
public abstract List<MagePermanent> getLinks();
public abstract void update(PermanentView card);
public abstract PermanentView getOriginalPermanent();
}

View file

@ -12,11 +12,12 @@ import java.util.concurrent.TimeUnit;
*/
public class ThreadUtils {
static public ThreadPoolExecutor threadPool;
static public ThreadPoolExecutor threadPool2;
static private int threadCount;
public static final ThreadPoolExecutor threadPool;
public static final ThreadPoolExecutor threadPool2;
private static int threadCount;
static {
threadPool = new ThreadPoolExecutor(4, 4, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue(), new ThreadFactory() {
@Override
public Thread newThread (Runnable runnable) {
threadCount++;
Thread thread = new Thread(runnable, "Util" + threadCount);
@ -26,6 +27,7 @@ public class ThreadUtils {
});
threadPool.prestartAllCoreThreads();
threadPool2 = new ThreadPoolExecutor(4, 4, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue(), new ThreadFactory() {
@Override
public Thread newThread (Runnable runnable) {
threadCount++;
Thread thread = new Thread(runnable, "TP2" + threadCount);
@ -36,14 +38,14 @@ public class ThreadUtils {
threadPool2.prestartAllCoreThreads();
}
static public void sleep (int millis) {
public static void sleep (int millis) {
try {
Thread.sleep(millis);
} catch (InterruptedException ignored) {
}
}
static public void wait (Object lock) {
public static void wait (Object lock) {
synchronized (lock) {
try {
lock.wait();

View file

@ -52,7 +52,7 @@ import org.apache.log4j.Logger;
*/
public class ConsolePanel extends javax.swing.JPanel {
private final static Logger logger = Logger.getLogger(ConsolePanel.class);
private static final Logger logger = Logger.getLogger(ConsolePanel.class);
private TableUserModel tableUserModel;
private TableTableModel tableTableModel;
@ -400,7 +400,7 @@ class UpdateUsersTask extends SwingWorker<Void, List<UserView>> {
private Session session;
private ConsolePanel panel;
private final static Logger logger = Logger.getLogger(UpdateUsersTask.class);
private static final Logger logger = Logger.getLogger(UpdateUsersTask.class);
UpdateUsersTask(Session session, ConsolePanel panel) {
this.session = session;
@ -439,7 +439,7 @@ class UpdateTablesTask extends SwingWorker<Void, Collection<TableView>> {
private UUID roomId;
private ConsolePanel panel;
private final static Logger logger = Logger.getLogger(UpdateTablesTask.class);
private static final Logger logger = Logger.getLogger(UpdateTablesTask.class);
UpdateTablesTask(Session session, UUID roomId, ConsolePanel panel) {
this.session = session;

View file

@ -52,7 +52,7 @@ import java.util.UUID;
*/
public class Immerwolf extends CardImpl<Immerwolf> {
private final static FilterCreaturePermanent filter = new FilterCreaturePermanent("Wolf and Werewolf creatures");
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("Wolf and Werewolf creatures");
static {
filter.add(Predicates.or(new SubtypePredicate("Wolf"), new SubtypePredicate("Werewolf")));
@ -90,8 +90,8 @@ public class Immerwolf extends CardImpl<Immerwolf> {
class ImmerwolfEffect extends ReplacementEffectImpl<ImmerwolfEffect> {
private final static FilterCreaturePermanent filterWerewolf = new FilterCreaturePermanent("Werewolf creature");
private final static FilterCreaturePermanent filterNonhuman = new FilterCreaturePermanent("Non-human creature");
private static final FilterCreaturePermanent filterWerewolf = new FilterCreaturePermanent("Werewolf creature");
private static final FilterCreaturePermanent filterNonhuman = new FilterCreaturePermanent("Non-human creature");
static {
filterWerewolf.add(new SubtypePredicate("Werewolf"));

View file

@ -50,10 +50,10 @@ import mage.target.TargetPlayer;
*/
public class BalefireLiege extends CardImpl<BalefireLiege> {
private final static FilterCreaturePermanent filterRedCreature = new FilterCreaturePermanent("red creatures");
private final static FilterCreaturePermanent filterWhiteCreature = new FilterCreaturePermanent("white creatures");
private final static FilterSpell filterRedSpell = new FilterSpell("a red spell");
private final static FilterSpell filterWhiteSpell = new FilterSpell("a white spell");
private static final FilterCreaturePermanent filterRedCreature = new FilterCreaturePermanent("red creatures");
private static final FilterCreaturePermanent filterWhiteCreature = new FilterCreaturePermanent("white creatures");
private static final FilterSpell filterRedSpell = new FilterSpell("a red spell");
private static final FilterSpell filterWhiteSpell = new FilterSpell("a white spell");
static {
filterRedCreature.add(new ColorPredicate(ObjectColor.RED));

View file

@ -53,10 +53,10 @@ import mage.target.common.TargetCreaturePermanent;
* @author Loki
*/
public class DeathbringerLiege extends CardImpl<DeathbringerLiege> {
private final static FilterCreaturePermanent filterWhite = new FilterCreaturePermanent("white creatures");
private final static FilterCreaturePermanent filterBlack = new FilterCreaturePermanent("black creatures");
private final static FilterSpell filterWhiteSpellCard = new FilterSpell("a white spell");
private final static FilterSpell filterBlackSpellCard = new FilterSpell("a black spell");
private static final FilterCreaturePermanent filterWhite = new FilterCreaturePermanent("white creatures");
private static final FilterCreaturePermanent filterBlack = new FilterCreaturePermanent("black creatures");
private static final FilterSpell filterWhiteSpellCard = new FilterSpell("a white spell");
private static final FilterSpell filterBlackSpellCard = new FilterSpell("a black spell");
static {
filterWhite.add(new ColorPredicate(ObjectColor.WHITE));

View file

@ -52,9 +52,9 @@ import mage.target.common.TargetCreaturePermanent;
*/
public class TiborAndLumia extends CardImpl<TiborAndLumia> {
private final static FilterSpell filterBlue = new FilterSpell("a blue spell");
private final static FilterCreaturePermanent filter = new FilterCreaturePermanent("creature without flying");
private final static FilterSpell filterRed = new FilterSpell("a red spell");
private static final FilterSpell filterBlue = new FilterSpell("a blue spell");
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("creature without flying");
private static final FilterSpell filterRed = new FilterSpell("a red spell");
static {
filterBlue.add(new ColorPredicate(ObjectColor.BLUE));