mirror of
https://github.com/magefree/mage.git
synced 2025-12-20 02:30:08 -08:00
[refactoring][minor] Replaced all tabs with four spaces.
This commit is contained in:
parent
e646e4768d
commit
239a4fb100
2891 changed files with 79411 additions and 79411 deletions
|
|
@ -1,6 +1,6 @@
|
|||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
<artifactId>mage-plugins</artifactId>
|
||||
<version>0.8.6</version>
|
||||
</parent>
|
||||
|
||||
|
||||
<artifactId>mage-counter-plugin</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<name>Mage Counter Plugin</name>
|
||||
|
|
|
|||
|
|
@ -9,22 +9,22 @@ import java.io.Serializable;
|
|||
* @author nantuko
|
||||
*/
|
||||
public class CounterBean implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 6382055182568871761L;
|
||||
|
||||
private int gamesPlayed;
|
||||
|
||||
private int version = 1;
|
||||
|
||||
public int getGamesPlayed() {
|
||||
return gamesPlayed;
|
||||
}
|
||||
private static final long serialVersionUID = 6382055182568871761L;
|
||||
|
||||
public void setGamesPlayed(int gamesPlayed) {
|
||||
this.gamesPlayed = gamesPlayed;
|
||||
}
|
||||
private int gamesPlayed;
|
||||
|
||||
public final int getVersion() {
|
||||
return version;
|
||||
}
|
||||
private int version = 1;
|
||||
|
||||
public int getGamesPlayed() {
|
||||
return gamesPlayed;
|
||||
}
|
||||
|
||||
public void setGamesPlayed(int gamesPlayed) {
|
||||
this.gamesPlayed = gamesPlayed;
|
||||
}
|
||||
|
||||
public final int getVersion() {
|
||||
return version;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,122 +28,122 @@ import org.apache.log4j.Logger;
|
|||
@Author(name = "nantuko")
|
||||
public class CounterPluginImpl implements CounterPlugin {
|
||||
|
||||
private static final String PLUGIN_DATA_FOLDER_PATH = "plugins" + File.separator + "plugin.data" + File.separator + "counters";
|
||||
|
||||
private static final String DATA_STORAGE_FILE = "counters";
|
||||
private static final String PLUGIN_DATA_FOLDER_PATH = "plugins" + File.separator + "plugin.data" + File.separator + "counters";
|
||||
|
||||
private static final Logger log = Logger.getLogger(CounterPluginImpl.class);
|
||||
|
||||
private boolean isLoaded = false;
|
||||
|
||||
@Init
|
||||
public void init() {
|
||||
File dataFolder = new File(PLUGIN_DATA_FOLDER_PATH);
|
||||
if (!dataFolder.exists()) {
|
||||
dataFolder.mkdirs();
|
||||
if (!dataFolder.exists()) {
|
||||
throw new RuntimeException("CounterPluginImpl: Couldn't create folders: " + PLUGIN_DATA_FOLDER_PATH);
|
||||
}
|
||||
}
|
||||
File data = new File(PLUGIN_DATA_FOLDER_PATH + File.separator + DATA_STORAGE_FILE);
|
||||
if (!data.exists()) {
|
||||
try {
|
||||
data.createNewFile();
|
||||
} catch (IOException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw new RuntimeException("Couldn't create data file for counter plugin: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
this.isLoaded = true;
|
||||
}
|
||||
|
||||
@PluginLoaded
|
||||
public void newPlugin(CounterPlugin plugin) {
|
||||
log.info(plugin.toString() + " has been loaded.");
|
||||
}
|
||||
private static final String DATA_STORAGE_FILE = "counters";
|
||||
|
||||
public String toString() {
|
||||
return "[Game counter plugin, version 0.1]";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addGamePlayed() throws PluginException {
|
||||
if (!isLoaded) return;
|
||||
File data = new File(PLUGIN_DATA_FOLDER_PATH + File.separator + DATA_STORAGE_FILE);
|
||||
ObjectInputStream ois = null;
|
||||
ObjectOutputStream oos = null;
|
||||
if (data.exists()) {
|
||||
int prev = 0;
|
||||
try {
|
||||
ois = new ObjectInputStream(new FileInputStream(data));
|
||||
Object o = ois.readObject();
|
||||
CounterBean c = null;
|
||||
if (o instanceof CounterBean) {
|
||||
c = (CounterBean)o;
|
||||
prev = c.getGamesPlayed();
|
||||
}
|
||||
} catch (EOFException e) {
|
||||
// do nothing
|
||||
} catch (IOException e) {
|
||||
throw new PluginException(e);
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new PluginException(e);
|
||||
} finally {
|
||||
if (ois != null) try { ois.close(); } catch (Exception e) {}
|
||||
}
|
||||
|
||||
try {
|
||||
synchronized (this) {
|
||||
oos = new ObjectOutputStream(new FileOutputStream(data));
|
||||
CounterBean c = new CounterBean();
|
||||
c.setGamesPlayed(prev+1);
|
||||
oos.writeObject(c);
|
||||
oos.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new PluginException(e);
|
||||
} finally {
|
||||
if (oos != null) try { oos.close(); } catch (Exception e) {}
|
||||
}
|
||||
} else {
|
||||
log.error("Counter plugin: data file doesn't exist, please restart plugin.");
|
||||
}
|
||||
}
|
||||
private static final Logger log = Logger.getLogger(CounterPluginImpl.class);
|
||||
|
||||
private boolean isLoaded = false;
|
||||
|
||||
@Init
|
||||
public void init() {
|
||||
File dataFolder = new File(PLUGIN_DATA_FOLDER_PATH);
|
||||
if (!dataFolder.exists()) {
|
||||
dataFolder.mkdirs();
|
||||
if (!dataFolder.exists()) {
|
||||
throw new RuntimeException("CounterPluginImpl: Couldn't create folders: " + PLUGIN_DATA_FOLDER_PATH);
|
||||
}
|
||||
}
|
||||
File data = new File(PLUGIN_DATA_FOLDER_PATH + File.separator + DATA_STORAGE_FILE);
|
||||
if (!data.exists()) {
|
||||
try {
|
||||
data.createNewFile();
|
||||
} catch (IOException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw new RuntimeException("Couldn't create data file for counter plugin: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
this.isLoaded = true;
|
||||
}
|
||||
|
||||
@PluginLoaded
|
||||
public void newPlugin(CounterPlugin plugin) {
|
||||
log.info(plugin.toString() + " has been loaded.");
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "[Game counter plugin, version 0.1]";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addGamePlayed() throws PluginException {
|
||||
if (!isLoaded) return;
|
||||
File data = new File(PLUGIN_DATA_FOLDER_PATH + File.separator + DATA_STORAGE_FILE);
|
||||
ObjectInputStream ois = null;
|
||||
ObjectOutputStream oos = null;
|
||||
if (data.exists()) {
|
||||
int prev = 0;
|
||||
try {
|
||||
ois = new ObjectInputStream(new FileInputStream(data));
|
||||
Object o = ois.readObject();
|
||||
CounterBean c = null;
|
||||
if (o instanceof CounterBean) {
|
||||
c = (CounterBean)o;
|
||||
prev = c.getGamesPlayed();
|
||||
}
|
||||
} catch (EOFException e) {
|
||||
// do nothing
|
||||
} catch (IOException e) {
|
||||
throw new PluginException(e);
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new PluginException(e);
|
||||
} finally {
|
||||
if (ois != null) try { ois.close(); } catch (Exception e) {}
|
||||
}
|
||||
|
||||
try {
|
||||
synchronized (this) {
|
||||
oos = new ObjectOutputStream(new FileOutputStream(data));
|
||||
CounterBean c = new CounterBean();
|
||||
c.setGamesPlayed(prev+1);
|
||||
oos.writeObject(c);
|
||||
oos.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new PluginException(e);
|
||||
} finally {
|
||||
if (oos != null) try { oos.close(); } catch (Exception e) {}
|
||||
}
|
||||
} else {
|
||||
log.error("Counter plugin: data file doesn't exist, please restart plugin.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getGamePlayed() throws PluginException {
|
||||
if (!isLoaded) return -1;
|
||||
File data = new File(PLUGIN_DATA_FOLDER_PATH + File.separator + DATA_STORAGE_FILE);
|
||||
if (!data.exists()) {
|
||||
return 0;
|
||||
}
|
||||
if (data.exists()) {
|
||||
ObjectInputStream ois = null;
|
||||
try {
|
||||
synchronized (this) {
|
||||
ois = new ObjectInputStream(new FileInputStream(data));
|
||||
Object o = ois.readObject();
|
||||
CounterBean c = null;
|
||||
if (o instanceof CounterBean) {
|
||||
c = (CounterBean)o;
|
||||
}
|
||||
ois.close();
|
||||
return c.getGamesPlayed();
|
||||
}
|
||||
} catch (EOFException e) {
|
||||
return 0;
|
||||
} catch (IOException e) {
|
||||
throw new PluginException(e);
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new PluginException(e);
|
||||
} finally {
|
||||
if (ois != null) try { ois.close(); } catch (Exception e) {}
|
||||
}
|
||||
} else {
|
||||
log.error("Counter plugin: data file doesn't exist, please restart plugin.");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getGamePlayed() throws PluginException {
|
||||
if (!isLoaded) return -1;
|
||||
File data = new File(PLUGIN_DATA_FOLDER_PATH + File.separator + DATA_STORAGE_FILE);
|
||||
if (!data.exists()) {
|
||||
return 0;
|
||||
}
|
||||
if (data.exists()) {
|
||||
ObjectInputStream ois = null;
|
||||
try {
|
||||
synchronized (this) {
|
||||
ois = new ObjectInputStream(new FileInputStream(data));
|
||||
Object o = ois.readObject();
|
||||
CounterBean c = null;
|
||||
if (o instanceof CounterBean) {
|
||||
c = (CounterBean)o;
|
||||
}
|
||||
ois.close();
|
||||
return c.getGamesPlayed();
|
||||
}
|
||||
} catch (EOFException e) {
|
||||
return 0;
|
||||
} catch (IOException e) {
|
||||
throw new PluginException(e);
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new PluginException(e);
|
||||
} finally {
|
||||
if (ois != null) try { ois.close(); } catch (Exception e) {}
|
||||
}
|
||||
} else {
|
||||
log.error("Counter plugin: data file doesn't exist, please restart plugin.");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,71 +1,71 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>org.mage</groupId>
|
||||
<artifactId>mage-plugins</artifactId>
|
||||
<version>0.8.6</version>
|
||||
</parent>
|
||||
<parent>
|
||||
<groupId>org.mage</groupId>
|
||||
<artifactId>mage-plugins</artifactId>
|
||||
<version>0.8.6</version>
|
||||
</parent>
|
||||
|
||||
<groupId>org.mage</groupId>
|
||||
<artifactId>mage-rating-plugin</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<version>${plugin-version}</version>
|
||||
<name>Mage Rating Plugin</name>
|
||||
<description>Plugin that rates cards</description>
|
||||
<groupId>org.mage</groupId>
|
||||
<artifactId>mage-rating-plugin</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<version>${plugin-version}</version>
|
||||
<name>Mage Rating Plugin</name>
|
||||
<description>Plugin that rates cards</description>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.mage</groupId>
|
||||
<artifactId>mage-sets</artifactId>
|
||||
<version>${mage-version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mage</groupId>
|
||||
<artifactId>mage-client</artifactId>
|
||||
<version>${mage-version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.googlecode.jspf</groupId>
|
||||
<artifactId>jspf-core</artifactId>
|
||||
<version>${jspf-version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
<version>1.2.9</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.collections</groupId>
|
||||
<artifactId>google-collections</artifactId>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.mortennobel</groupId>
|
||||
<artifactId>java-image-scaling</artifactId>
|
||||
<version>0.8.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.swinglabs</groupId>
|
||||
<artifactId>swingx</artifactId>
|
||||
<version>1.6.1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.mage</groupId>
|
||||
<artifactId>mage-sets</artifactId>
|
||||
<version>${mage-version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mage</groupId>
|
||||
<artifactId>mage-client</artifactId>
|
||||
<version>${mage-version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.googlecode.jspf</groupId>
|
||||
<artifactId>jspf-core</artifactId>
|
||||
<version>${jspf-version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
<version>1.2.9</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.collections</groupId>
|
||||
<artifactId>google-collections</artifactId>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.mortennobel</groupId>
|
||||
<artifactId>java-image-scaling</artifactId>
|
||||
<version>0.8.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.swinglabs</groupId>
|
||||
<artifactId>swingx</artifactId>
|
||||
<version>1.6.1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>1.6</source>
|
||||
<target>1.6</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>1.6</source>
|
||||
<target>1.6</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<configuration>
|
||||
<archive>
|
||||
|
|
@ -78,14 +78,14 @@
|
|||
</descriptorRefs>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
|
||||
<finalName>mage-rate-plugin</finalName>
|
||||
</build>
|
||||
</plugins>
|
||||
|
||||
<properties>
|
||||
<plugin-version>0.1</plugin-version>
|
||||
<jspf-version>0.9.1</jspf-version>
|
||||
</properties>
|
||||
<finalName>mage-rate-plugin</finalName>
|
||||
</build>
|
||||
|
||||
<properties>
|
||||
<plugin-version>0.1</plugin-version>
|
||||
<jspf-version>0.9.1</jspf-version>
|
||||
</properties>
|
||||
</project>
|
||||
|
|
|
|||
|
|
@ -16,58 +16,58 @@ import org.mage.plugins.rating.ui.ImageHelper;
|
|||
|
||||
public class RateCallback implements ActionCallback {
|
||||
|
||||
private Card card1;
|
||||
private Card card2;
|
||||
private RateThread callback;
|
||||
private BigCard bigCard;
|
||||
|
||||
public RateCallback(Card card1, Card card2, RateThread callback, BigCard bigCard) {
|
||||
this.card1 = card1;
|
||||
this.card2 = card2;
|
||||
this.callback = callback;
|
||||
this.bigCard = bigCard;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent arg0, TransferData arg1) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mousePressed(MouseEvent arg0, TransferData arg1) {
|
||||
this.callback.reportResult(card1, card2);
|
||||
}
|
||||
private Card card1;
|
||||
private Card card2;
|
||||
private RateThread callback;
|
||||
private BigCard bigCard;
|
||||
|
||||
@Override
|
||||
public void mouseEntered(MouseEvent arg0, TransferData arg1) {
|
||||
MageCard card = (MageCard)arg1.component;
|
||||
Image image = card.getImage();
|
||||
if (image != null && image instanceof BufferedImage) {
|
||||
image = ImageHelper.getResizedImage((BufferedImage) image, bigCard.getWidth(), bigCard.getHeight());
|
||||
bigCard.setCard(card.getOriginal().getId(), image, card.getOriginal().getRules());
|
||||
bigCard.showTextComponent();
|
||||
if (card.getOriginal().isAbility()) {
|
||||
bigCard.showTextComponent();
|
||||
} else {
|
||||
bigCard.hideTextComponent();
|
||||
};
|
||||
} else {
|
||||
JXPanel panel = GuiDisplayUtil.getDescription(card.getOriginal(), bigCard.getWidth(), bigCard.getHeight());
|
||||
panel.setVisible(true);
|
||||
bigCard.hideTextComponent();
|
||||
bigCard.addJXPanel(card.getOriginal().getId(), panel);
|
||||
}
|
||||
}
|
||||
public RateCallback(Card card1, Card card2, RateThread callback, BigCard bigCard) {
|
||||
this.card1 = card1;
|
||||
this.card2 = card2;
|
||||
this.callback = callback;
|
||||
this.bigCard = bigCard;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseExited(MouseEvent arg0, TransferData arg1) {
|
||||
}
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent arg0, TransferData arg1) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hidePopup() {
|
||||
}
|
||||
@Override
|
||||
public void mousePressed(MouseEvent arg0, TransferData arg1) {
|
||||
this.callback.reportResult(card1, card2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseMoved(MouseEvent arg0, TransferData arg1) {
|
||||
}
|
||||
@Override
|
||||
public void mouseEntered(MouseEvent arg0, TransferData arg1) {
|
||||
MageCard card = (MageCard)arg1.component;
|
||||
Image image = card.getImage();
|
||||
if (image != null && image instanceof BufferedImage) {
|
||||
image = ImageHelper.getResizedImage((BufferedImage) image, bigCard.getWidth(), bigCard.getHeight());
|
||||
bigCard.setCard(card.getOriginal().getId(), image, card.getOriginal().getRules());
|
||||
bigCard.showTextComponent();
|
||||
if (card.getOriginal().isAbility()) {
|
||||
bigCard.showTextComponent();
|
||||
} else {
|
||||
bigCard.hideTextComponent();
|
||||
};
|
||||
} else {
|
||||
JXPanel panel = GuiDisplayUtil.getDescription(card.getOriginal(), bigCard.getWidth(), bigCard.getHeight());
|
||||
panel.setVisible(true);
|
||||
bigCard.hideTextComponent();
|
||||
bigCard.addJXPanel(card.getOriginal().getId(), panel);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseExited(MouseEvent arg0, TransferData arg1) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hidePopup() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseMoved(MouseEvent arg0, TransferData arg1) {
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,85 +21,85 @@ import org.mage.plugins.rating.ui.BigCard;
|
|||
|
||||
public class RateFrame extends JFrame {
|
||||
|
||||
private static Logger log = Logger.getLogger(RateFrame.class);
|
||||
private BigCard bigCard;
|
||||
private JLabel label;
|
||||
private static Logger log = Logger.getLogger(RateFrame.class);
|
||||
private BigCard bigCard;
|
||||
private JLabel label;
|
||||
|
||||
public RateFrame() {
|
||||
setTitle("Mage Rate Cards, version 0.1");
|
||||
public RateFrame() {
|
||||
setTitle("Mage Rate Cards, version 0.1");
|
||||
|
||||
try {
|
||||
UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
|
||||
} catch (Exception ex) {
|
||||
log.error(ex.getMessage(), ex);
|
||||
}
|
||||
try {
|
||||
UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
|
||||
} catch (Exception ex) {
|
||||
log.error(ex.getMessage(), ex);
|
||||
}
|
||||
|
||||
addWindowListener(new WindowAdapter() {
|
||||
@Override
|
||||
public void windowClosing(WindowEvent e) {
|
||||
if (JOptionPane.showConfirmDialog(null, "Do you want to save recent compares?", "Save before exit", JOptionPane.YES_NO_OPTION) == JOptionPane.OK_OPTION) {
|
||||
RateThread.getInstance().forceSave();
|
||||
}
|
||||
}
|
||||
});
|
||||
addWindowListener(new WindowAdapter() {
|
||||
@Override
|
||||
public void windowClosing(WindowEvent e) {
|
||||
if (JOptionPane.showConfirmDialog(null, "Do you want to save recent compares?", "Save before exit", JOptionPane.YES_NO_OPTION) == JOptionPane.OK_OPTION) {
|
||||
RateThread.getInstance().forceSave();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
int width = 621;
|
||||
int height = 384;
|
||||
setSize(width, height);
|
||||
setResizable(false);
|
||||
int w = getGraphicsConfiguration().getBounds().width;
|
||||
int h = getGraphicsConfiguration().getBounds().height;
|
||||
setLocation((w - width) / 2, (h - height) / 2);
|
||||
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
|
||||
setLayout(null);
|
||||
int width = 621;
|
||||
int height = 384;
|
||||
setSize(width, height);
|
||||
setResizable(false);
|
||||
int w = getGraphicsConfiguration().getBounds().width;
|
||||
int h = getGraphicsConfiguration().getBounds().height;
|
||||
setLocation((w - width) / 2, (h - height) / 2);
|
||||
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
|
||||
setLayout(null);
|
||||
|
||||
bigCard = new BigCard();
|
||||
bigCard.setBounds(20, 10, RateThread.bigCardDimension.frameWidth, RateThread.bigCardDimension.frameHeight);
|
||||
bigCard.setBorder(BorderFactory.createLineBorder(Color.gray));
|
||||
add(bigCard);
|
||||
bigCard = new BigCard();
|
||||
bigCard.setBounds(20, 10, RateThread.bigCardDimension.frameWidth, RateThread.bigCardDimension.frameHeight);
|
||||
bigCard.setBorder(BorderFactory.createLineBorder(Color.gray));
|
||||
add(bigCard);
|
||||
|
||||
//JLabel label = new JLabel("The results are stored for every 10 compare.");
|
||||
label = new JLabel("Loading cards...Please wait.");
|
||||
label.setBounds(290, 270, 300, 30);
|
||||
add(label);
|
||||
//JLabel label = new JLabel("The results are stored for every 10 compare.");
|
||||
label = new JLabel("Loading cards...Please wait.");
|
||||
label.setBounds(290, 270, 300, 30);
|
||||
add(label);
|
||||
|
||||
JButton rate = new JButton("Create results.txt");
|
||||
rate.setBounds(340, 230, 120, 25);
|
||||
rate.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
try {
|
||||
ResultHandler.getInstance().rate();
|
||||
JOptionPane.showMessageDialog(null, "Done! Find results in ratings.txt file.");
|
||||
} catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
JOptionPane.showMessageDialog(null, "Some error occured! Find more details in logs.");
|
||||
}
|
||||
}
|
||||
});
|
||||
add(rate);
|
||||
}
|
||||
JButton rate = new JButton("Create results.txt");
|
||||
rate.setBounds(340, 230, 120, 25);
|
||||
rate.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
try {
|
||||
ResultHandler.getInstance().rate();
|
||||
JOptionPane.showMessageDialog(null, "Done! Find results in ratings.txt file.");
|
||||
} catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
JOptionPane.showMessageDialog(null, "Some error occured! Find more details in logs.");
|
||||
}
|
||||
}
|
||||
});
|
||||
add(rate);
|
||||
}
|
||||
|
||||
public void startRating() {
|
||||
CardsStorage.getAllCards();
|
||||
label.setText("The results are stored for every 10 compare.");
|
||||
RateThread.getInstance().start(this, this.bigCard);
|
||||
}
|
||||
public void startRating() {
|
||||
CardsStorage.getAllCards();
|
||||
label.setText("The results are stored for every 10 compare.");
|
||||
RateThread.getInstance().start(this, this.bigCard);
|
||||
}
|
||||
|
||||
public static void main(String args[]) {
|
||||
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
|
||||
public void uncaughtException(Thread t, Throwable e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
});
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
RateFrame frame = new RateFrame();
|
||||
frame.setVisible(true);
|
||||
frame.startRating();
|
||||
}
|
||||
});
|
||||
}
|
||||
public static void main(String args[]) {
|
||||
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
|
||||
public void uncaughtException(Thread t, Throwable e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
});
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
RateFrame frame = new RateFrame();
|
||||
frame.setVisible(true);
|
||||
frame.startRating();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = -5836021378309984439L;
|
||||
private static final long serialVersionUID = -5836021378309984439L;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,100 +22,100 @@ import org.mage.plugins.rating.ui.BigCard;
|
|||
|
||||
public class RateThread extends Thread {
|
||||
|
||||
private static RateThread fInstance = new RateThread();
|
||||
private CardPluginImpl impl = new CardPluginImpl();
|
||||
public static CardDimensions dimensions = new CardDimensions(0.4);
|
||||
public static Dimension cardDimension = new Dimension(dimensions.frameWidth, dimensions.frameHeight);
|
||||
public static CardDimensions bigCardDimension = new CardDimensions(0.8);
|
||||
private JFrame frame;
|
||||
private MageCard mageCard1;
|
||||
private MageCard mageCard2;
|
||||
private BigCard bigCard;
|
||||
private boolean stop = false;
|
||||
private Random random = new Random();
|
||||
|
||||
private static List<Rating> results = new ArrayList<Rating>();
|
||||
|
||||
public RateThread() {
|
||||
setDaemon(true);
|
||||
start();
|
||||
}
|
||||
|
||||
public static RateThread getInstance() {
|
||||
return fInstance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void run() {
|
||||
while (!stop) {
|
||||
try {
|
||||
Card card1 = getRandomUniqueNonLandCard(null);
|
||||
Card card2 = getRandomUniqueNonLandCard(card1);
|
||||
|
||||
mageCard1 = impl.getMageCard(new CardView(card1), cardDimension, UUID.randomUUID(), new RateCallback(card1, card2, this, bigCard), false, true);
|
||||
mageCard1.setCardBounds(bigCardDimension.frameWidth + 80, 10, dimensions.frameWidth, dimensions.frameHeight);
|
||||
frame.add(mageCard1);
|
||||
|
||||
mageCard2 = impl.getMageCard(new CardView(card2), cardDimension, UUID.randomUUID(), new RateCallback(card2, card1, this, bigCard), false, true);
|
||||
mageCard2.setCardBounds(bigCardDimension.frameWidth + 80 + dimensions.frameWidth + 30, 10, dimensions.frameWidth, dimensions.frameHeight);
|
||||
frame.add(mageCard2);
|
||||
|
||||
frame.validate();
|
||||
|
||||
wait();
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected Card getRandomUniqueNonLandCard(Card previousCard) {
|
||||
int count = CardsStorage.getUniqueCards().size();
|
||||
int index = random.nextInt(count);
|
||||
Card card1 = CardsStorage.getUniqueCards().get(index);
|
||||
while (card1.getCardType().contains(CardType.LAND) || card1.getName().equals(previousCard)) {
|
||||
index = random.nextInt(count);
|
||||
card1 = CardsStorage.getUniqueCards().get(index);
|
||||
}
|
||||
return card1;
|
||||
}
|
||||
|
||||
public void start(JFrame frame, BigCard bigCard) {
|
||||
this.frame = frame;
|
||||
this.bigCard = bigCard;
|
||||
}
|
||||
|
||||
protected synchronized void generateNext() {
|
||||
notify();
|
||||
}
|
||||
|
||||
public void reportResult(Card card1, Card card2) {
|
||||
results.add(new Rating(card1.getName(), card2.getName()));
|
||||
removeCard(mageCard1);
|
||||
removeCard(mageCard2);
|
||||
frame.validate();
|
||||
if (results.size() == 10) {
|
||||
ResultHandler.getInstance().save(results);
|
||||
results.clear();
|
||||
}
|
||||
generateNext();
|
||||
}
|
||||
|
||||
public void forceSave() {
|
||||
if (results.size() > 0) {
|
||||
ResultHandler.getInstance().save(results);
|
||||
results.clear();
|
||||
}
|
||||
}
|
||||
|
||||
private void removeCard(Component component) {
|
||||
if (component != null) {
|
||||
frame.remove(component);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void stopRating() {
|
||||
this.stop = true;
|
||||
notify();
|
||||
}
|
||||
private static RateThread fInstance = new RateThread();
|
||||
private CardPluginImpl impl = new CardPluginImpl();
|
||||
public static CardDimensions dimensions = new CardDimensions(0.4);
|
||||
public static Dimension cardDimension = new Dimension(dimensions.frameWidth, dimensions.frameHeight);
|
||||
public static CardDimensions bigCardDimension = new CardDimensions(0.8);
|
||||
private JFrame frame;
|
||||
private MageCard mageCard1;
|
||||
private MageCard mageCard2;
|
||||
private BigCard bigCard;
|
||||
private boolean stop = false;
|
||||
private Random random = new Random();
|
||||
|
||||
private static List<Rating> results = new ArrayList<Rating>();
|
||||
|
||||
public RateThread() {
|
||||
setDaemon(true);
|
||||
start();
|
||||
}
|
||||
|
||||
public static RateThread getInstance() {
|
||||
return fInstance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void run() {
|
||||
while (!stop) {
|
||||
try {
|
||||
Card card1 = getRandomUniqueNonLandCard(null);
|
||||
Card card2 = getRandomUniqueNonLandCard(card1);
|
||||
|
||||
mageCard1 = impl.getMageCard(new CardView(card1), cardDimension, UUID.randomUUID(), new RateCallback(card1, card2, this, bigCard), false, true);
|
||||
mageCard1.setCardBounds(bigCardDimension.frameWidth + 80, 10, dimensions.frameWidth, dimensions.frameHeight);
|
||||
frame.add(mageCard1);
|
||||
|
||||
mageCard2 = impl.getMageCard(new CardView(card2), cardDimension, UUID.randomUUID(), new RateCallback(card2, card1, this, bigCard), false, true);
|
||||
mageCard2.setCardBounds(bigCardDimension.frameWidth + 80 + dimensions.frameWidth + 30, 10, dimensions.frameWidth, dimensions.frameHeight);
|
||||
frame.add(mageCard2);
|
||||
|
||||
frame.validate();
|
||||
|
||||
wait();
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected Card getRandomUniqueNonLandCard(Card previousCard) {
|
||||
int count = CardsStorage.getUniqueCards().size();
|
||||
int index = random.nextInt(count);
|
||||
Card card1 = CardsStorage.getUniqueCards().get(index);
|
||||
while (card1.getCardType().contains(CardType.LAND) || card1.getName().equals(previousCard)) {
|
||||
index = random.nextInt(count);
|
||||
card1 = CardsStorage.getUniqueCards().get(index);
|
||||
}
|
||||
return card1;
|
||||
}
|
||||
|
||||
public void start(JFrame frame, BigCard bigCard) {
|
||||
this.frame = frame;
|
||||
this.bigCard = bigCard;
|
||||
}
|
||||
|
||||
protected synchronized void generateNext() {
|
||||
notify();
|
||||
}
|
||||
|
||||
public void reportResult(Card card1, Card card2) {
|
||||
results.add(new Rating(card1.getName(), card2.getName()));
|
||||
removeCard(mageCard1);
|
||||
removeCard(mageCard2);
|
||||
frame.validate();
|
||||
if (results.size() == 10) {
|
||||
ResultHandler.getInstance().save(results);
|
||||
results.clear();
|
||||
}
|
||||
generateNext();
|
||||
}
|
||||
|
||||
public void forceSave() {
|
||||
if (results.size() > 0) {
|
||||
ResultHandler.getInstance().save(results);
|
||||
results.clear();
|
||||
}
|
||||
}
|
||||
|
||||
private void removeCard(Component component) {
|
||||
if (component != null) {
|
||||
frame.remove(component);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void stopRating() {
|
||||
this.stop = true;
|
||||
notify();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,28 +10,28 @@ import mage.cards.ExpansionSet;
|
|||
import mage.sets.Sets;
|
||||
|
||||
public class CardsStorage {
|
||||
private static List<Card> allCards = new ArrayList<Card>();
|
||||
private static List<Card> uniqueCards = new ArrayList<Card>();
|
||||
|
||||
static {
|
||||
for (ExpansionSet set: Sets.getInstance().values()) {
|
||||
allCards.addAll(set.getCards());
|
||||
}
|
||||
Set<String> names = new HashSet<String>();
|
||||
for (Card card : allCards) {
|
||||
if (!names.contains(card.getName())) {
|
||||
uniqueCards.add(card);
|
||||
names.add(card.getName());
|
||||
}
|
||||
}
|
||||
System.out.println("cards=" + allCards.size() + ", unique cards=" + uniqueCards.size());
|
||||
}
|
||||
|
||||
public static List<Card> getAllCards() {
|
||||
return allCards;
|
||||
}
|
||||
|
||||
public static List<Card> getUniqueCards() {
|
||||
return uniqueCards;
|
||||
}
|
||||
private static List<Card> allCards = new ArrayList<Card>();
|
||||
private static List<Card> uniqueCards = new ArrayList<Card>();
|
||||
|
||||
static {
|
||||
for (ExpansionSet set: Sets.getInstance().values()) {
|
||||
allCards.addAll(set.getCards());
|
||||
}
|
||||
Set<String> names = new HashSet<String>();
|
||||
for (Card card : allCards) {
|
||||
if (!names.contains(card.getName())) {
|
||||
uniqueCards.add(card);
|
||||
names.add(card.getName());
|
||||
}
|
||||
}
|
||||
System.out.println("cards=" + allCards.size() + ", unique cards=" + uniqueCards.size());
|
||||
}
|
||||
|
||||
public static List<Card> getAllCards() {
|
||||
return allCards;
|
||||
}
|
||||
|
||||
public static List<Card> getUniqueCards() {
|
||||
return uniqueCards;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
package org.mage.plugins.rating.results;
|
||||
|
||||
public class Rating {
|
||||
public String winnerCardName;
|
||||
public String loserCardName;
|
||||
|
||||
public Rating(String win, String lose) {
|
||||
this.winnerCardName = win;
|
||||
this.loserCardName = lose;
|
||||
}
|
||||
public String winnerCardName;
|
||||
public String loserCardName;
|
||||
|
||||
public Rating(String win, String lose) {
|
||||
this.winnerCardName = win;
|
||||
this.loserCardName = lose;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,69 +18,69 @@ import org.mage.plugins.rating.util.MapSorter;
|
|||
|
||||
public class ResultHandler {
|
||||
|
||||
private static ResultHandler fInstance = new ResultHandler();
|
||||
private static Map<String, Integer> ratings = new LinkedHashMap<String, Integer>();
|
||||
private static String newLine = System.getProperty("line.separator");
|
||||
private static Pattern scorePattern = Pattern.compile("([^|]*)[|]+ > [|]+([^|]*)");
|
||||
private static ResultHandler fInstance = new ResultHandler();
|
||||
private static Map<String, Integer> ratings = new LinkedHashMap<String, Integer>();
|
||||
private static String newLine = System.getProperty("line.separator");
|
||||
private static Pattern scorePattern = Pattern.compile("([^|]*)[|]+ > [|]+([^|]*)");
|
||||
private static Pattern pickPattern = Pattern.compile("[\\w\\d]{3}\\|(.*)\\|(.*)\\|(.*)");
|
||||
private static Logger log = Logger.getLogger(ResultHandler.class);
|
||||
private static Logger log = Logger.getLogger(ResultHandler.class);
|
||||
|
||||
static {
|
||||
File file = new File("results");
|
||||
if (!file.exists()) {
|
||||
file.mkdir();
|
||||
}
|
||||
}
|
||||
static {
|
||||
File file = new File("results");
|
||||
if (!file.exists()) {
|
||||
file.mkdir();
|
||||
}
|
||||
}
|
||||
|
||||
public static ResultHandler getInstance() {
|
||||
return fInstance;
|
||||
}
|
||||
public static ResultHandler getInstance() {
|
||||
return fInstance;
|
||||
}
|
||||
|
||||
public void save(List<Rating> results) {
|
||||
File f = new File("results" + File.separator + UUID.randomUUID() + ".txt");
|
||||
try {
|
||||
if (f.createNewFile()) {
|
||||
FileOutputStream fos = new FileOutputStream(f);
|
||||
BufferedOutputStream b = new BufferedOutputStream(fos);
|
||||
for (Rating r : results) {
|
||||
String line = r.winnerCardName + "| > |" + r.loserCardName + newLine;
|
||||
b.write(line.getBytes());
|
||||
}
|
||||
b.close();
|
||||
fos.close();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
public void save(List<Rating> results) {
|
||||
File f = new File("results" + File.separator + UUID.randomUUID() + ".txt");
|
||||
try {
|
||||
if (f.createNewFile()) {
|
||||
FileOutputStream fos = new FileOutputStream(f);
|
||||
BufferedOutputStream b = new BufferedOutputStream(fos);
|
||||
for (Rating r : results) {
|
||||
String line = r.winnerCardName + "| > |" + r.loserCardName + newLine;
|
||||
b.write(line.getBytes());
|
||||
}
|
||||
b.close();
|
||||
fos.close();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void rate() throws Exception {
|
||||
ratings.clear();
|
||||
File file = new File("results");
|
||||
File ratingFile = new File("ratings.txt");
|
||||
if (ratingFile.exists()) {
|
||||
if (!ratingFile.delete()) {
|
||||
throw new RuntimeException("Couldn't delete previous ratings.txt file");
|
||||
}
|
||||
}
|
||||
if (ratingFile.createNewFile()) {
|
||||
public void rate() throws Exception {
|
||||
ratings.clear();
|
||||
File file = new File("results");
|
||||
File ratingFile = new File("ratings.txt");
|
||||
if (ratingFile.exists()) {
|
||||
if (!ratingFile.delete()) {
|
||||
throw new RuntimeException("Couldn't delete previous ratings.txt file");
|
||||
}
|
||||
}
|
||||
if (ratingFile.createNewFile()) {
|
||||
loadPickFiles("picks");
|
||||
for (File f : file.listFiles()) {
|
||||
if (!f.getName().equals("rating.txt")) {
|
||||
parseFile(f);
|
||||
}
|
||||
}
|
||||
ratings = MapSorter.sortByValue(ratings);
|
||||
FileOutputStream fos = new FileOutputStream(ratingFile);
|
||||
BufferedOutputStream b = new BufferedOutputStream(fos);
|
||||
for (Entry<String, Integer> entry : ratings.entrySet()) {
|
||||
String line = entry.getValue() + " : " + entry.getKey() + newLine;
|
||||
b.write(line.getBytes());
|
||||
}
|
||||
b.close();
|
||||
fos.close();
|
||||
}
|
||||
}
|
||||
for (File f : file.listFiles()) {
|
||||
if (!f.getName().equals("rating.txt")) {
|
||||
parseFile(f);
|
||||
}
|
||||
}
|
||||
ratings = MapSorter.sortByValue(ratings);
|
||||
FileOutputStream fos = new FileOutputStream(ratingFile);
|
||||
BufferedOutputStream b = new BufferedOutputStream(fos);
|
||||
for (Entry<String, Integer> entry : ratings.entrySet()) {
|
||||
String line = entry.getValue() + " : " + entry.getKey() + newLine;
|
||||
b.write(line.getBytes());
|
||||
}
|
||||
b.close();
|
||||
fos.close();
|
||||
}
|
||||
}
|
||||
|
||||
private void loadPickFiles(String directory) throws Exception {
|
||||
File directoryFile = new File(directory);
|
||||
|
|
@ -113,43 +113,43 @@ public class ResultHandler {
|
|||
}
|
||||
}
|
||||
|
||||
private void parseFile(File f) throws Exception {
|
||||
Scanner s = new Scanner(f);
|
||||
while (s.hasNextLine()) {
|
||||
String line = s.nextLine();
|
||||
Matcher m = scorePattern.matcher(line);
|
||||
if (m.matches()) {
|
||||
String winner = m.group(1);String loser = m.group(2);
|
||||
Integer winnerRating = ratings.get(winner);
|
||||
if (winnerRating == null)
|
||||
winnerRating = 1000;
|
||||
Integer loserRating = ratings.get(loser);
|
||||
if (loserRating == null)
|
||||
loserRating = 1000;
|
||||
Integer newWinnerRating = countEloRating(winnerRating, loserRating, true);
|
||||
Integer newLoserRating = countEloRating(loserRating, winnerRating, false);
|
||||
log.info("Winner(" + winner + "): " + winnerRating + " >> " + newWinnerRating);
|
||||
log.info("Loser(" + loser + "): " + loserRating + " >> " + newLoserRating);
|
||||
ratings.put(winner, newWinnerRating);
|
||||
ratings.put(loser, newLoserRating);
|
||||
} else {
|
||||
log.warn("Doesn't match rate pattern: " + line);
|
||||
}
|
||||
}
|
||||
s.close();
|
||||
}
|
||||
private void parseFile(File f) throws Exception {
|
||||
Scanner s = new Scanner(f);
|
||||
while (s.hasNextLine()) {
|
||||
String line = s.nextLine();
|
||||
Matcher m = scorePattern.matcher(line);
|
||||
if (m.matches()) {
|
||||
String winner = m.group(1);String loser = m.group(2);
|
||||
Integer winnerRating = ratings.get(winner);
|
||||
if (winnerRating == null)
|
||||
winnerRating = 1000;
|
||||
Integer loserRating = ratings.get(loser);
|
||||
if (loserRating == null)
|
||||
loserRating = 1000;
|
||||
Integer newWinnerRating = countEloRating(winnerRating, loserRating, true);
|
||||
Integer newLoserRating = countEloRating(loserRating, winnerRating, false);
|
||||
log.info("Winner(" + winner + "): " + winnerRating + " >> " + newWinnerRating);
|
||||
log.info("Loser(" + loser + "): " + loserRating + " >> " + newLoserRating);
|
||||
ratings.put(winner, newWinnerRating);
|
||||
ratings.put(loser, newLoserRating);
|
||||
} else {
|
||||
log.warn("Doesn't match rate pattern: " + line);
|
||||
}
|
||||
}
|
||||
s.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* Count rating using Elo Rating System.
|
||||
*
|
||||
* @param ra
|
||||
* @param rb
|
||||
* @return
|
||||
*/
|
||||
private Integer countEloRating(Integer ra, Integer rb, boolean firstWon) {
|
||||
double d = (rb - ra) / 400.0;
|
||||
double expected = 1.0d / (1 + Math.pow(10, d));
|
||||
double actual = firstWon ? 1 : 0;
|
||||
return Integer.valueOf((int) Math.round(ra + 32 * (actual - expected)));
|
||||
}
|
||||
/**
|
||||
* Count rating using Elo Rating System.
|
||||
*
|
||||
* @param ra
|
||||
* @param rb
|
||||
* @return
|
||||
*/
|
||||
private Integer countEloRating(Integer ra, Integer rb, boolean firstWon) {
|
||||
double d = (rb - ra) / 400.0;
|
||||
double expected = 1.0d / (1 + Math.pow(10, d));
|
||||
double actual = firstWon ? 1 : 0;
|
||||
return Integer.valueOf((int) Math.round(ra + 32 * (actual - expected)));
|
||||
}
|
||||
}
|
||||
|
|
@ -59,73 +59,73 @@ import org.jdesktop.swingx.JXPanel;
|
|||
*/
|
||||
public class BigCard extends javax.swing.JPanel {
|
||||
|
||||
protected Image bigImage;
|
||||
protected UUID cardId;
|
||||
protected JXPanel panel;
|
||||
protected boolean initState;
|
||||
protected Image bigImage;
|
||||
protected UUID cardId;
|
||||
protected JXPanel panel;
|
||||
protected boolean initState;
|
||||
|
||||
public BigCard() {
|
||||
public BigCard() {
|
||||
initComponents();
|
||||
}
|
||||
|
||||
protected void initBounds() {
|
||||
initState = true;
|
||||
|
||||
protected void initBounds() {
|
||||
initState = true;
|
||||
scrollPane.setBounds(20, 230, 210, 120);
|
||||
scrollPane.setBounds(new Rectangle(CONTENT_MAX_XOFFSET, TEXT_MAX_YOFFSET, TEXT_MAX_WIDTH, TEXT_MAX_HEIGHT));
|
||||
}
|
||||
|
||||
public void setCard(UUID cardId, Image image, List<String> strings) {
|
||||
if (this.cardId == null || !this.cardId.equals(cardId)) {
|
||||
if (this.panel != null) remove(this.panel);
|
||||
this.cardId = cardId;
|
||||
bigImage = image;
|
||||
this.repaint();
|
||||
drawText(strings);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setCard(UUID cardId, Image image, List<String> strings) {
|
||||
if (this.cardId == null || !this.cardId.equals(cardId)) {
|
||||
if (this.panel != null) remove(this.panel);
|
||||
this.cardId = cardId;
|
||||
bigImage = image;
|
||||
this.repaint();
|
||||
drawText(strings);
|
||||
}
|
||||
}
|
||||
|
||||
public UUID getCardId() {
|
||||
return cardId;
|
||||
}
|
||||
|
||||
private void drawText(java.util.List<String> strings) {
|
||||
text.setText("");
|
||||
StyledDocument doc = text.getStyledDocument();
|
||||
return cardId;
|
||||
}
|
||||
|
||||
try {
|
||||
for (String line: strings) {
|
||||
doc.insertString(doc.getLength(), line + "\n", doc.getStyle("regular"));
|
||||
}
|
||||
} catch (BadLocationException ble) { }
|
||||
text.setCaretPosition(0);
|
||||
}
|
||||
private void drawText(java.util.List<String> strings) {
|
||||
text.setText("");
|
||||
StyledDocument doc = text.getStyledDocument();
|
||||
|
||||
@Override
|
||||
public void paintComponent(Graphics graphics) {
|
||||
if (bigImage != null)
|
||||
graphics.drawImage(bigImage, 0, 0, this);
|
||||
super.paintComponent(graphics);
|
||||
}
|
||||
try {
|
||||
for (String line: strings) {
|
||||
doc.insertString(doc.getLength(), line + "\n", doc.getStyle("regular"));
|
||||
}
|
||||
} catch (BadLocationException ble) { }
|
||||
text.setCaretPosition(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paintComponent(Graphics graphics) {
|
||||
if (bigImage != null)
|
||||
graphics.drawImage(bigImage, 0, 0, this);
|
||||
super.paintComponent(graphics);
|
||||
}
|
||||
|
||||
public void hideTextComponent() {
|
||||
this.scrollPane.setVisible(false);
|
||||
this.scrollPane.setVisible(false);
|
||||
}
|
||||
|
||||
public void showTextComponent() {
|
||||
if (!initState) {initBounds();}
|
||||
this.scrollPane.setVisible(true);
|
||||
if (!initState) {initBounds();}
|
||||
this.scrollPane.setVisible(true);
|
||||
}
|
||||
|
||||
public void addJXPanel(UUID cardId, JXPanel jxPanel) {
|
||||
bigImage = null;
|
||||
synchronized (this) {
|
||||
if (this.panel != null) remove(this.panel);
|
||||
this.panel = jxPanel;
|
||||
add(jxPanel);
|
||||
}
|
||||
this.repaint();
|
||||
bigImage = null;
|
||||
synchronized (this) {
|
||||
if (this.panel != null) remove(this.panel);
|
||||
this.panel = jxPanel;
|
||||
add(jxPanel);
|
||||
}
|
||||
this.repaint();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** This method is called from within the constructor to
|
||||
* initialize the form.
|
||||
|
|
|
|||
|
|
@ -14,77 +14,77 @@ import mage.view.CardView;
|
|||
import org.jdesktop.swingx.JXPanel;
|
||||
|
||||
public class GuiDisplayUtil {
|
||||
private static final Font cardNameFont = new Font("Calibri", Font.BOLD, 15);
|
||||
|
||||
public static JXPanel getDescription(CardView card, int width, int height) {
|
||||
JXPanel descriptionPanel = new JXPanel();
|
||||
|
||||
//descriptionPanel.setAlpha(.8f);
|
||||
descriptionPanel.setBounds(0, 0, width, height);
|
||||
descriptionPanel.setVisible(false);
|
||||
descriptionPanel.setLayout(null);
|
||||
|
||||
//descriptionPanel.setBorder(BorderFactory.createLineBorder(Color.green));
|
||||
|
||||
JButton j = new JButton("");
|
||||
j.setBounds(0, 0, width, height);
|
||||
j.setBackground(Color.black);
|
||||
j.setLayout(null);
|
||||
private static final Font cardNameFont = new Font("Calibri", Font.BOLD, 15);
|
||||
|
||||
JLabel name = new JLabel("Wrath of God");
|
||||
name.setBounds(5, 5, width - 90, 20);
|
||||
name.setForeground(Color.white);
|
||||
name.setFont(cardNameFont);
|
||||
//name.setBorder(BorderFactory.createLineBorder(Color.green));
|
||||
j.add(name);
|
||||
|
||||
JLabel cost = new JLabel("B R G W U");
|
||||
cost.setBounds(width - 85, 5, 77, 20);
|
||||
cost.setForeground(Color.white);
|
||||
cost.setFont(cardNameFont);
|
||||
//cost.setBorder(BorderFactory.createLineBorder(Color.green));
|
||||
cost.setHorizontalAlignment(SwingConstants.RIGHT);
|
||||
j.add(cost);
|
||||
|
||||
JLabel type = new JLabel("Creature - Goblin Shaman");
|
||||
type.setBounds(5, 70, width - 8, 20);
|
||||
type.setForeground(Color.white);
|
||||
type.setFont(cardNameFont);
|
||||
//type.setBorder(BorderFactory.createLineBorder(Color.green));
|
||||
j.add(type);
|
||||
|
||||
JLabel cardText = new JLabel();
|
||||
cardText.setBounds(5, 100, width - 8, 260);
|
||||
cardText.setForeground(Color.white);
|
||||
cardText.setFont(cardNameFont);
|
||||
cardText.setVerticalAlignment(SwingConstants.TOP);
|
||||
//cardText.setBorder(new EtchedBorder());
|
||||
j.add(cardText);
|
||||
|
||||
name.setText(card.getName());
|
||||
cost.setText(card.getManaCost().toString());
|
||||
String typeText = "";
|
||||
String delimiter = card.getCardTypes().size() > 1 ? " - " : "";
|
||||
for (CardType t : card.getCardTypes()) {
|
||||
typeText += t;
|
||||
typeText += delimiter;
|
||||
delimiter = " "; // next delimiters are just spaces
|
||||
}
|
||||
type.setText(typeText);
|
||||
cardText.setText("<html>"+card.getRules()+"</html>");
|
||||
|
||||
if (CardUtil.isCreature(card)) {
|
||||
JLabel pt = new JLabel(card.getPower() + "/" + card.getToughness());
|
||||
pt.setBounds(width - 50, height - 30, 40, 20);
|
||||
pt.setForeground(Color.white);
|
||||
pt.setFont(cardNameFont);
|
||||
pt.setHorizontalAlignment(JLabel.RIGHT);
|
||||
j.add(pt);
|
||||
}
|
||||
|
||||
descriptionPanel.add(j);
|
||||
|
||||
return descriptionPanel;
|
||||
public static JXPanel getDescription(CardView card, int width, int height) {
|
||||
JXPanel descriptionPanel = new JXPanel();
|
||||
|
||||
//descriptionPanel.setAlpha(.8f);
|
||||
descriptionPanel.setBounds(0, 0, width, height);
|
||||
descriptionPanel.setVisible(false);
|
||||
descriptionPanel.setLayout(null);
|
||||
|
||||
//descriptionPanel.setBorder(BorderFactory.createLineBorder(Color.green));
|
||||
|
||||
JButton j = new JButton("");
|
||||
j.setBounds(0, 0, width, height);
|
||||
j.setBackground(Color.black);
|
||||
j.setLayout(null);
|
||||
|
||||
JLabel name = new JLabel("Wrath of God");
|
||||
name.setBounds(5, 5, width - 90, 20);
|
||||
name.setForeground(Color.white);
|
||||
name.setFont(cardNameFont);
|
||||
//name.setBorder(BorderFactory.createLineBorder(Color.green));
|
||||
j.add(name);
|
||||
|
||||
JLabel cost = new JLabel("B R G W U");
|
||||
cost.setBounds(width - 85, 5, 77, 20);
|
||||
cost.setForeground(Color.white);
|
||||
cost.setFont(cardNameFont);
|
||||
//cost.setBorder(BorderFactory.createLineBorder(Color.green));
|
||||
cost.setHorizontalAlignment(SwingConstants.RIGHT);
|
||||
j.add(cost);
|
||||
|
||||
JLabel type = new JLabel("Creature - Goblin Shaman");
|
||||
type.setBounds(5, 70, width - 8, 20);
|
||||
type.setForeground(Color.white);
|
||||
type.setFont(cardNameFont);
|
||||
//type.setBorder(BorderFactory.createLineBorder(Color.green));
|
||||
j.add(type);
|
||||
|
||||
JLabel cardText = new JLabel();
|
||||
cardText.setBounds(5, 100, width - 8, 260);
|
||||
cardText.setForeground(Color.white);
|
||||
cardText.setFont(cardNameFont);
|
||||
cardText.setVerticalAlignment(SwingConstants.TOP);
|
||||
//cardText.setBorder(new EtchedBorder());
|
||||
j.add(cardText);
|
||||
|
||||
name.setText(card.getName());
|
||||
cost.setText(card.getManaCost().toString());
|
||||
String typeText = "";
|
||||
String delimiter = card.getCardTypes().size() > 1 ? " - " : "";
|
||||
for (CardType t : card.getCardTypes()) {
|
||||
typeText += t;
|
||||
typeText += delimiter;
|
||||
delimiter = " "; // next delimiters are just spaces
|
||||
}
|
||||
type.setText(typeText);
|
||||
cardText.setText("<html>"+card.getRules()+"</html>");
|
||||
|
||||
if (CardUtil.isCreature(card)) {
|
||||
JLabel pt = new JLabel(card.getPower() + "/" + card.getToughness());
|
||||
pt.setBounds(width - 50, height - 30, 40, 20);
|
||||
pt.setForeground(Color.white);
|
||||
pt.setFont(cardNameFont);
|
||||
pt.setHorizontalAlignment(JLabel.RIGHT);
|
||||
j.add(pt);
|
||||
}
|
||||
|
||||
descriptionPanel.add(j);
|
||||
|
||||
return descriptionPanel;
|
||||
}
|
||||
|
||||
public static String cleanString(String in) {
|
||||
|
|
|
|||
|
|
@ -10,14 +10,14 @@ import com.mortennobel.imagescaling.ResampleOp;
|
|||
* @author ayrat
|
||||
*/
|
||||
public class ImageHelper {
|
||||
/**
|
||||
* Returns an image scaled to the size appropriate for the card picture
|
||||
* panel
|
||||
*/
|
||||
public static BufferedImage getResizedImage(BufferedImage original, int width, int height) {
|
||||
ResampleOp resampleOp = new ResampleOp(width, height);
|
||||
BufferedImage image = resampleOp.filter(original, null);
|
||||
return image;
|
||||
}
|
||||
/**
|
||||
* Returns an image scaled to the size appropriate for the card picture
|
||||
* panel
|
||||
*/
|
||||
public static BufferedImage getResizedImage(BufferedImage original, int width, int height) {
|
||||
ResampleOp resampleOp = new ResampleOp(width, height);
|
||||
BufferedImage image = resampleOp.filter(original, null);
|
||||
return image;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,20 +9,20 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
public class MapSorter {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Map sortByValue(Map map) {
|
||||
List list = new LinkedList(map.entrySet());
|
||||
Collections.sort(list, new Comparator() {
|
||||
public int compare(Object o2, Object o1) {
|
||||
return ((Comparable) ((Map.Entry) (o1)).getValue()).compareTo(((Map.Entry) (o2)).getValue());
|
||||
}
|
||||
});
|
||||
Map result = new LinkedHashMap();
|
||||
for (Iterator it = list.iterator(); it.hasNext();) {
|
||||
Map.Entry entry = (Map.Entry) it.next();
|
||||
result.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Map sortByValue(Map map) {
|
||||
List list = new LinkedList(map.entrySet());
|
||||
Collections.sort(list, new Comparator() {
|
||||
public int compare(Object o2, Object o1) {
|
||||
return ((Comparable) ((Map.Entry) (o1)).getValue()).compareTo(((Map.Entry) (o2)).getValue());
|
||||
}
|
||||
});
|
||||
Map result = new LinkedHashMap();
|
||||
for (Iterator it = list.iterator(); it.hasNext();) {
|
||||
Map.Entry entry = (Map.Entry) it.next();
|
||||
result.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,56 +1,56 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>org.mage</groupId>
|
||||
<artifactId>mage-plugins</artifactId>
|
||||
<version>0.8.6</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>mage-theme-plugin</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<version>${plugin-version}</version>
|
||||
<name>Mage Theme Plugin</name>
|
||||
<description>Contains resources for drawing background</description>
|
||||
<parent>
|
||||
<groupId>org.mage</groupId>
|
||||
<artifactId>mage-plugins</artifactId>
|
||||
<version>0.8.6</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>mage-common</artifactId>
|
||||
<version>${mage-version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.googlecode.jspf</groupId>
|
||||
<artifactId>jspf-core</artifactId>
|
||||
<version>${jspf-version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
<version>1.2.9</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<artifactId>mage-theme-plugin</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<version>${plugin-version}</version>
|
||||
<name>Mage Theme Plugin</name>
|
||||
<description>Contains resources for drawing background</description>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>1.6</source>
|
||||
<target>1.6</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>mage-common</artifactId>
|
||||
<version>${mage-version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.googlecode.jspf</groupId>
|
||||
<artifactId>jspf-core</artifactId>
|
||||
<version>${jspf-version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
<version>1.2.9</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<finalName>mage-theme-plugin</finalName>
|
||||
</build>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>1.6</source>
|
||||
<target>1.6</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
|
||||
<properties>
|
||||
<plugin-version>0.4</plugin-version>
|
||||
<jspf-version>0.9.1</jspf-version>
|
||||
</properties>
|
||||
<finalName>mage-theme-plugin</finalName>
|
||||
</build>
|
||||
|
||||
<properties>
|
||||
<plugin-version>0.4</plugin-version>
|
||||
<jspf-version>0.9.1</jspf-version>
|
||||
</properties>
|
||||
</project>
|
||||
|
|
|
|||
|
|
@ -22,101 +22,101 @@ import org.apache.log4j.Logger;
|
|||
@Author(name = "nantuko")
|
||||
public class ThemePluginImpl implements ThemePlugin {
|
||||
|
||||
private final static Logger log = Logger.getLogger(ThemePluginImpl.class);
|
||||
private static BufferedImage background;
|
||||
private final static Logger log = Logger.getLogger(ThemePluginImpl.class);
|
||||
private static BufferedImage background;
|
||||
|
||||
@Init
|
||||
public void init() {
|
||||
}
|
||||
@Init
|
||||
public void init() {
|
||||
}
|
||||
|
||||
@PluginLoaded
|
||||
public void newPlugin(ThemePlugin plugin) {
|
||||
log.info(plugin.toString() + " has been loaded.");
|
||||
}
|
||||
@PluginLoaded
|
||||
public void newPlugin(ThemePlugin plugin) {
|
||||
log.info(plugin.toString() + " has been loaded.");
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "[Theme plugin, version 0.4]";
|
||||
}
|
||||
public String toString() {
|
||||
return "[Theme plugin, version 0.4]";
|
||||
}
|
||||
|
||||
public void applyInGame(Map<String, JComponent> ui) {
|
||||
String filename = "/wood.png";
|
||||
try {
|
||||
InputStream is = this.getClass().getResourceAsStream(filename);
|
||||
public void applyInGame(Map<String, JComponent> ui) {
|
||||
String filename = "/wood.png";
|
||||
try {
|
||||
InputStream is = this.getClass().getResourceAsStream(filename);
|
||||
|
||||
if (is == null) {
|
||||
throw new FileNotFoundException("Couldn't find " + filename + " in resources.");
|
||||
}
|
||||
if (is == null) {
|
||||
throw new FileNotFoundException("Couldn't find " + filename + " in resources.");
|
||||
}
|
||||
|
||||
BufferedImage background = ImageIO.read(is);
|
||||
BufferedImage background = ImageIO.read(is);
|
||||
|
||||
if (background == null) {
|
||||
throw new FileNotFoundException("Couldn't find " + filename + " in resources.");
|
||||
}
|
||||
if (background == null) {
|
||||
throw new FileNotFoundException("Couldn't find " + filename + " in resources.");
|
||||
}
|
||||
|
||||
if (ui.containsKey("gamePanel") && ui.containsKey("jLayeredPane")) {
|
||||
ImagePanel bgPanel = new ImagePanel(background, ImagePanel.TILED);
|
||||
if (ui.containsKey("gamePanel") && ui.containsKey("jLayeredPane")) {
|
||||
ImagePanel bgPanel = new ImagePanel(background, ImagePanel.TILED);
|
||||
|
||||
unsetOpaque(ui.get("jSplitPane1"));
|
||||
unsetOpaque(ui.get("pnlBattlefield"));
|
||||
unsetOpaque(ui.get("jPanel3"));
|
||||
unsetOpaque(ui.get("hand"));
|
||||
unsetOpaque(ui.get("gameChatPanel"));
|
||||
unsetOpaque(ui.get("userChatPanel"));
|
||||
unsetOpaque(ui.get("jSplitPane1"));
|
||||
unsetOpaque(ui.get("pnlBattlefield"));
|
||||
unsetOpaque(ui.get("jPanel3"));
|
||||
unsetOpaque(ui.get("hand"));
|
||||
unsetOpaque(ui.get("gameChatPanel"));
|
||||
unsetOpaque(ui.get("userChatPanel"));
|
||||
|
||||
ui.get("gamePanel").remove(ui.get("jLayeredPane"));
|
||||
bgPanel.add(ui.get("jLayeredPane"));
|
||||
ui.get("gamePanel").add(bgPanel);
|
||||
} else {
|
||||
log.error("error: no components");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return;
|
||||
}
|
||||
}
|
||||
ui.get("gamePanel").remove(ui.get("jLayeredPane"));
|
||||
bgPanel.add(ui.get("jLayeredPane"));
|
||||
ui.get("gamePanel").add(bgPanel);
|
||||
} else {
|
||||
log.error("error: no components");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public JComponent updateTable(Map<String, JComponent> ui) {
|
||||
ImagePanel bgPanel = createImagePanelInstance();
|
||||
public JComponent updateTable(Map<String, JComponent> ui) {
|
||||
ImagePanel bgPanel = createImagePanelInstance();
|
||||
|
||||
unsetOpaque(ui.get("jScrollPane1"));
|
||||
unsetOpaque(ui.get("jPanel1"));
|
||||
unsetOpaque(ui.get("tablesPanel"));
|
||||
JComponent viewport = ui.get("jScrollPane1ViewPort");
|
||||
if (viewport != null) {
|
||||
viewport.setBackground(new Color(255,255,255,50));
|
||||
}
|
||||
return bgPanel;
|
||||
}
|
||||
unsetOpaque(ui.get("jScrollPane1"));
|
||||
unsetOpaque(ui.get("jPanel1"));
|
||||
unsetOpaque(ui.get("tablesPanel"));
|
||||
JComponent viewport = ui.get("jScrollPane1ViewPort");
|
||||
if (viewport != null) {
|
||||
viewport.setBackground(new Color(255,255,255,50));
|
||||
}
|
||||
return bgPanel;
|
||||
}
|
||||
|
||||
private ImagePanel createImagePanelInstance() {
|
||||
if (background == null) {
|
||||
synchronized (ThemePluginImpl.class) {
|
||||
if (background == null) {
|
||||
String filename = "/background.png";
|
||||
try {
|
||||
InputStream is = this.getClass().getResourceAsStream(filename);
|
||||
private ImagePanel createImagePanelInstance() {
|
||||
if (background == null) {
|
||||
synchronized (ThemePluginImpl.class) {
|
||||
if (background == null) {
|
||||
String filename = "/background.png";
|
||||
try {
|
||||
InputStream is = this.getClass().getResourceAsStream(filename);
|
||||
|
||||
if (is == null)
|
||||
throw new FileNotFoundException("Couldn't find " + filename + " in resources.");
|
||||
if (is == null)
|
||||
throw new FileNotFoundException("Couldn't find " + filename + " in resources.");
|
||||
|
||||
background = ImageIO.read(is);
|
||||
background = ImageIO.read(is);
|
||||
|
||||
if (background == null)
|
||||
throw new FileNotFoundException("Couldn't find " + filename + " in resources.");
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return new ImagePanel(background, ImagePanel.SCALED);
|
||||
}
|
||||
if (background == null)
|
||||
throw new FileNotFoundException("Couldn't find " + filename + " in resources.");
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return new ImagePanel(background, ImagePanel.SCALED);
|
||||
}
|
||||
|
||||
private void unsetOpaque(JComponent c) {
|
||||
if (c != null) {
|
||||
c.setOpaque(false);
|
||||
}
|
||||
}
|
||||
private void unsetOpaque(JComponent c) {
|
||||
if (c != null) {
|
||||
c.setOpaque(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,24 +1,24 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>org.mage</groupId>
|
||||
<artifactId>mage-root</artifactId>
|
||||
<version>0.8.6</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>mage-plugins</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<name>Mage Plugins</name>
|
||||
<description>Mage Plugins POM</description>
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
|
||||
<modules>
|
||||
<module>Mage.Theme.Plugin</module>
|
||||
<module>Mage.Counter.Plugin</module>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>org.mage</groupId>
|
||||
<artifactId>mage-root</artifactId>
|
||||
<version>0.8.6</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>mage-plugins</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<name>Mage Plugins</name>
|
||||
<description>Mage Plugins POM</description>
|
||||
|
||||
<modules>
|
||||
<module>Mage.Theme.Plugin</module>
|
||||
<module>Mage.Counter.Plugin</module>
|
||||
<module>Mage.Rating.Plugin</module>
|
||||
</modules>
|
||||
|
||||
</modules>
|
||||
|
||||
</project>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue