Moved ImagePanel class to common (as used in three modules). Replaced startup background by the image used in tablespane and deckeditor. Changed table background color from black to white. Reuploaded plugins.

This commit is contained in:
magenoxx 2010-12-04 09:23:19 +00:00
parent fe3903d825
commit 8193502a6e
9 changed files with 21 additions and 139 deletions

View file

@ -46,6 +46,8 @@ import java.awt.event.WindowEvent;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import java.util.logging.Level;
import java.util.logging.Logger;
@ -60,9 +62,9 @@ import javax.swing.JLabel;
import javax.swing.JLayeredPane;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JToolBar.Separator;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.JToolBar.Separator;
import mage.client.cards.CardsStorage;
import mage.client.components.MageComponents;
@ -74,7 +76,7 @@ import mage.client.plugins.impl.Plugins;
import mage.client.remote.Session;
import mage.client.util.EDTExceptionHandler;
import mage.client.util.gui.ArrowBuilder;
import mage.client.util.gui.ImagePanel;
import mage.components.ImagePanel;
import mage.util.Logging;
/**
@ -147,9 +149,14 @@ public class MageFrame extends javax.swing.JFrame {
String filename = "/background.jpg";
try {
if (Plugins.getInstance().isThemePluginLoaded()) {
Map<String, JComponent> ui = new HashMap<String, JComponent>();
backgroundPane = (ImagePanel) Plugins.getInstance().updateTablePanel(ui);
} else {
InputStream is = this.getClass().getResourceAsStream(filename);
BufferedImage background = ImageIO.read(is);
backgroundPane = new ImagePanel(background, ImagePanel.SCALED);
}
backgroundPane.setSize(1024, 768);
desktopPane.add(backgroundPane, JLayeredPane.DEFAULT_LAYER);
} catch (IOException e) {

View file

@ -34,22 +34,14 @@
package mage.client.table;
import java.awt.Color;
import java.awt.image.BufferedImage;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import javax.imageio.ImageIO;
import javax.swing.JComponent;
import javax.swing.JLayeredPane;
import mage.client.MageFrame;
import mage.client.MagePane;
import mage.client.plugins.impl.Plugins;
import mage.client.util.gui.ImagePanel;
/**
*

View file

@ -34,19 +34,9 @@
package mage.client.table;
import mage.client.components.MageComponents;
import mage.client.dialog.NewTableDialog;
import mage.client.dialog.JoinTableDialog;
import mage.client.dialog.TableWaitingDialog;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import java.awt.image.BufferedImage;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@ -57,22 +47,22 @@ import java.util.UUID;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.imageio.ImageIO;
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.JComponent;
import javax.swing.JLayeredPane;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.Timer;
import javax.swing.table.AbstractTableModel;
import mage.cards.decks.DeckCardLists;
import mage.client.MageFrame;
import mage.client.components.MageComponents;
import mage.client.dialog.JoinTableDialog;
import mage.client.dialog.NewTableDialog;
import mage.client.dialog.TableWaitingDialog;
import mage.client.remote.MageRemoteException;
import mage.client.remote.Session;
import mage.client.util.ButtonColumn;
import mage.client.util.gui.ArrowBuilder;
import mage.client.util.gui.ImagePanel;
import mage.util.Logging;
import mage.view.TableView;

View file

@ -1,4 +1,4 @@
package mage.client.util.gui;
package mage.components;
import java.awt.BorderLayout;
import java.awt.Component;

View file

@ -27,6 +27,7 @@ import mage.cards.MagePermanent;
import mage.cards.TextPopup;
import mage.cards.action.ActionCallback;
import mage.cards.action.TransferData;
import mage.components.ImagePanel;
import mage.utils.CardUtil;
import mage.view.AbilityView;
import mage.view.CardView;
@ -37,7 +38,6 @@ import org.apache.log4j.Logger;
import org.mage.card.arcane.ScaledImagePanel.MultipassType;
import org.mage.card.arcane.ScaledImagePanel.ScalingType;
import org.mage.plugins.card.images.ImageCache;
import org.mage.plugins.card.utils.ImagePanel;
import org.mage.plugins.card.utils.impl.ImageManagerImpl;

View file

@ -1,105 +0,0 @@
package org.mage.plugins.card.utils;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JViewport;
@SuppressWarnings("serial")
public class ImagePanel extends JPanel {
public static final int TILED = 0;
public static final int SCALED = 1;
public static final int ACTUAL = 2;
private BufferedImage image;
private int style;
private float alignmentX = 0.5f;
private float alignmentY = 0.5f;
public ImagePanel(BufferedImage image) {
this(image, TILED);
}
public ImagePanel(BufferedImage image, int style) {
this.image = image;
this.style = style;
setLayout(new BorderLayout());
}
public void setImageAlignmentX(float alignmentX) {
this.alignmentX = alignmentX > 1.0f ? 1.0f : alignmentX < 0.0f ? 0.0f : alignmentX;
}
public void setImageAlignmentY(float alignmentY) {
this.alignmentY = alignmentY > 1.0f ? 1.0f : alignmentY < 0.0f ? 0.0f : alignmentY;
}
public void add(JComponent component) {
add(component, null);
}
public void add(JComponent component, Object constraints) {
component.setOpaque(false);
if (component instanceof JScrollPane) {
JScrollPane scrollPane = (JScrollPane) component;
JViewport viewport = scrollPane.getViewport();
viewport.setOpaque(false);
Component c = viewport.getView();
if (c instanceof JComponent) {
((JComponent) c).setOpaque(false);
}
}
super.add(component, constraints);
}
protected void paintComponent(Graphics g) {
super.paintComponent(g);
if (image == null)
return;
switch (style) {
case TILED:
drawTiled(g);
break;
case SCALED:
Dimension d = getSize();
g.drawImage(image, 0, 0, d.width, d.height, null);
break;
case ACTUAL:
drawActual(g);
break;
}
}
private void drawTiled(Graphics g) {
Dimension d = getSize();
int width = image.getWidth(null);
int height = image.getHeight(null);
for (int x = 0; x < d.width; x += width) {
for (int y = 0; y < d.height; y += height) {
g.drawImage(image, x, y, null, null);
}
}
}
private void drawActual(Graphics g) {
Dimension d = getSize();
float x = (d.width - image.getWidth()) * alignmentX;
float y = (d.height - image.getHeight()) * alignmentY;
g.drawImage(image, (int) x, (int) y, this);
}
}

View file

@ -1,7 +1,6 @@
package org.mage.plugins.theme;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.FileNotFoundException;
import java.io.InputStream;
@ -9,8 +8,8 @@ import java.util.Map;
import javax.imageio.ImageIO;
import javax.swing.JComponent;
import javax.swing.JPanel;
import mage.components.ImagePanel;
import mage.interfaces.plugin.ThemePlugin;
import net.xeoh.plugins.base.annotations.PluginImplementation;
import net.xeoh.plugins.base.annotations.events.Init;
@ -18,7 +17,6 @@ import net.xeoh.plugins.base.annotations.events.PluginLoaded;
import net.xeoh.plugins.base.annotations.meta.Author;
import org.apache.log4j.Logger;
import org.mage.plugins.component.ImagePanel;
@PluginImplementation
@Author(name = "nantuko")
@ -95,7 +93,7 @@ public class ThemePluginImpl implements ThemePlugin {
unsetOpaque(ui.get("tablesPanel"));
JComponent viewport = ui.get("jScrollPane1ViewPort");
if (viewport != null) {
viewport.setBackground(new Color(20,20,20,50));
viewport.setBackground(new Color(255,255,255,50));
}
return bgPanel;
} catch (Exception e) {