use gradle for building, reorg src/res dirs, add Sidekick lib source
just some "standardization" (debatable i guess) to the source directory layout and resources directory. removal of the dependancy on Sidekick-1.2 jar is mainly because Xunkar does not have the source for this particular version of the library and the current version on Github does not have some of the stuff that we need for for this version (not even in an updated form, looks like he did a fair bit of cleaning out of stuff he no longer needed). i would rather _not_ depend on jars where no source / future support is possible so i included decompiled sources for this library so future bugfixing and modification is a bit easier moving forward. can decide if we want to move to the latest version of Sidekick at a later time.
3
.gitignore
vendored
|
@ -1,10 +1,13 @@
|
|||
.DS_Store
|
||||
.idea/
|
||||
.settings/
|
||||
.gradle/
|
||||
target/
|
||||
out/
|
||||
build/
|
||||
.project
|
||||
.classpath
|
||||
*.iml
|
||||
*.ipr
|
||||
*.iws
|
||||
/llanfair.xml
|
13
build.gradle
Normal file
|
@ -0,0 +1,13 @@
|
|||
apply plugin: 'java'
|
||||
|
||||
sourceCompatibility = 1.7
|
||||
targetCompatibility = 1.7
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile fileTree(dir: 'lib', include: ['*.jar'])
|
||||
}
|
||||
|
|
@ -1,33 +1,9 @@
|
|||
package org.fenix.llanfair;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Font;
|
||||
import java.awt.GraphicsEnvironment;
|
||||
import java.awt.Point;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseWheelEvent;
|
||||
import java.awt.event.MouseWheelListener;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.awt.event.WindowListener;
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Locale;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPopupMenu;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.ToolTipManager;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.event.TableModelEvent;
|
||||
import javax.swing.event.TableModelListener;
|
||||
import org.fenix.llanfair.config.Settings;
|
||||
import org.fenix.llanfair.gui.RunPane;
|
||||
import org.fenix.utils.gui.BorderlessFrame;
|
||||
import org.fenix.utils.Resources;
|
||||
import org.fenix.utils.gui.BorderlessFrame;
|
||||
import org.fenix.utils.locale.LocaleDelegate;
|
||||
import org.fenix.utils.locale.LocaleEvent;
|
||||
import org.fenix.utils.locale.LocaleListener;
|
||||
|
@ -36,6 +12,18 @@ import org.jnativehook.NativeHookException;
|
|||
import org.jnativehook.keyboard.NativeKeyEvent;
|
||||
import org.jnativehook.keyboard.NativeKeyListener;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.TableModelEvent;
|
||||
import javax.swing.event.TableModelListener;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Main frame executing Llanfair.
|
||||
*
|
||||
|
@ -76,7 +64,9 @@ public class Llanfair extends BorderlessFrame implements TableModelListener,
|
|||
LocaleDelegate.setDefault( Settings.GNR_LANG.get() );
|
||||
LocaleDelegate.addLocaleListener( this );
|
||||
|
||||
RESOURCES = new Resources( "res" );
|
||||
//ResourceBundle b = ResourceBundle.getBundle("language");
|
||||
|
||||
RESOURCES = new Resources();
|
||||
registerFonts();
|
||||
setLookAndFeel();
|
||||
|
||||
|
@ -106,7 +96,7 @@ public class Llanfair extends BorderlessFrame implements TableModelListener,
|
|||
if ( args.length > 0 ) {
|
||||
String locale = args[0];
|
||||
LocaleDelegate.setDefault( new Locale( locale ) );
|
||||
RESOURCES = new Resources( "res" );
|
||||
RESOURCES = new Resources();
|
||||
dumpLocalization();
|
||||
System.exit( 0 );
|
||||
}
|
|
@ -1,13 +1,12 @@
|
|||
package org.fenix.llanfair;
|
||||
|
||||
import org.fenix.llanfair.config.Settings;
|
||||
import org.fenix.utils.Images;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.Serializable;
|
||||
import javax.swing.Icon;
|
||||
import org.fenix.llanfair.Language;
|
||||
import org.fenix.llanfair.config.Settings;
|
||||
|
||||
import org.fenix.utils.Images;
|
||||
|
||||
/**
|
||||
* Represents a portion of a run. As such, a segment is associated to a
|
48
src/main/java/org/fenix/utils/Images.java
Normal file
|
@ -0,0 +1,48 @@
|
|||
//
|
||||
// Source code recreated from a .class file by IntelliJ IDEA
|
||||
// (powered by Fernflower decompiler)
|
||||
//
|
||||
|
||||
package org.fenix.utils;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
public class Images {
|
||||
public Images() {
|
||||
}
|
||||
|
||||
public static Icon rescale(Icon icon, int size) {
|
||||
if(icon == null) {
|
||||
throw new NullPointerException("Icon is null");
|
||||
} else if(size <= 0) {
|
||||
throw new IllegalArgumentException("Illegal size: " + size);
|
||||
} else {
|
||||
int height = icon.getIconHeight();
|
||||
int width = icon.getIconWidth();
|
||||
double scale;
|
||||
BufferedImage buffer;
|
||||
if(height > width) {
|
||||
scale = (double)size / (double)height;
|
||||
buffer = new BufferedImage((int)((double)width * scale), size, 2);
|
||||
} else {
|
||||
scale = (double)size / (double)width;
|
||||
buffer = new BufferedImage(size, (int)((double)height * scale), 2);
|
||||
}
|
||||
|
||||
Graphics2D g2 = buffer.createGraphics();
|
||||
if(scale < 1.0D) {
|
||||
g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
|
||||
} else {
|
||||
g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR);
|
||||
}
|
||||
|
||||
g2.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
|
||||
g2.scale(scale, scale);
|
||||
icon.paintIcon((Component)null, g2, 0, 0);
|
||||
g2.dispose();
|
||||
return new ImageIcon(buffer);
|
||||
}
|
||||
}
|
||||
}
|
16
src/main/java/org/fenix/utils/MixedPair.java
Normal file
|
@ -0,0 +1,16 @@
|
|||
//
|
||||
// Source code recreated from a .class file by IntelliJ IDEA
|
||||
// (powered by Fernflower decompiler)
|
||||
//
|
||||
|
||||
package org.fenix.utils;
|
||||
|
||||
public class MixedPair<F, S> {
|
||||
public F first;
|
||||
public S second;
|
||||
|
||||
public MixedPair(F first, S second) {
|
||||
this.first = first;
|
||||
this.second = second;
|
||||
}
|
||||
}
|
96
src/main/java/org/fenix/utils/Resources.java
Normal file
|
@ -0,0 +1,96 @@
|
|||
//
|
||||
// Source code recreated from a .class file by IntelliJ IDEA
|
||||
// (powered by Fernflower decompiler)
|
||||
//
|
||||
|
||||
package org.fenix.utils;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.Locale;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
public class Resources {
|
||||
private String path;
|
||||
private ResourceBundle language;
|
||||
private MessageFormat formatter;
|
||||
|
||||
public Resources() {
|
||||
this.path = "";
|
||||
this.formatter = new MessageFormat("");
|
||||
this.defaultLocaleChanged();
|
||||
}
|
||||
|
||||
public Resources(String path) {
|
||||
if(path != null && !path.equals("")) {
|
||||
if (!path.endsWith("/"))
|
||||
path += "/";
|
||||
|
||||
this.path = path;
|
||||
this.formatter = new MessageFormat("");
|
||||
this.defaultLocaleChanged();
|
||||
} else {
|
||||
throw new NullPointerException("Unspecified resource path");
|
||||
}
|
||||
}
|
||||
|
||||
public String getString(String key) {
|
||||
return !this.language.keySet().contains(key)?null:this.language.getString(key);
|
||||
}
|
||||
|
||||
public String getString(String key, Object[] parameters) {
|
||||
String string = this.getString(key);
|
||||
this.formatter.applyPattern(string);
|
||||
return this.formatter.format(parameters);
|
||||
}
|
||||
|
||||
public Icon getIcon(String path) {
|
||||
String fullPath = this.path + "img/" + path;
|
||||
URL url = ClassLoader.getSystemResource(fullPath);
|
||||
|
||||
try {
|
||||
return new ImageIcon(ImageIO.read(url));
|
||||
} catch (Exception var5) {
|
||||
throw new IllegalArgumentException("Cannot load: " + fullPath);
|
||||
}
|
||||
}
|
||||
|
||||
public Image getImage(String path) {
|
||||
String fullPath = this.path + "img/" + path;
|
||||
URL url = ClassLoader.getSystemResource(fullPath);
|
||||
|
||||
try {
|
||||
return Toolkit.getDefaultToolkit().createImage(url);
|
||||
} catch (Exception var5) {
|
||||
throw new IllegalArgumentException("Cannot load: " + fullPath);
|
||||
}
|
||||
}
|
||||
|
||||
public InputStream getStream(String path) {
|
||||
return ClassLoader.getSystemResourceAsStream(this.path + path);
|
||||
}
|
||||
|
||||
public ResourceBundle getBundle(String path) {
|
||||
return ResourceBundle.getBundle(this.path + path);
|
||||
}
|
||||
|
||||
public final void defaultLocaleChanged() {
|
||||
String baseName;
|
||||
if (this.path.equals(""))
|
||||
baseName = "language";
|
||||
else
|
||||
baseName = this.path + "language";
|
||||
|
||||
try {
|
||||
this.language = ResourceBundle.getBundle(baseName);
|
||||
} catch (Exception var2) {
|
||||
this.language = ResourceBundle.getBundle(baseName, Locale.ENGLISH);
|
||||
}
|
||||
|
||||
this.formatter.setLocale(Locale.getDefault());
|
||||
}
|
||||
}
|
77
src/main/java/org/fenix/utils/TableModelSupport.java
Normal file
|
@ -0,0 +1,77 @@
|
|||
//
|
||||
// Source code recreated from a .class file by IntelliJ IDEA
|
||||
// (powered by Fernflower decompiler)
|
||||
//
|
||||
|
||||
package org.fenix.utils;
|
||||
|
||||
import javax.swing.event.EventListenerList;
|
||||
import javax.swing.event.TableModelEvent;
|
||||
import javax.swing.event.TableModelListener;
|
||||
import javax.swing.table.TableModel;
|
||||
|
||||
public class TableModelSupport {
|
||||
private TableModel source;
|
||||
private EventListenerList listeners;
|
||||
|
||||
public TableModelSupport(TableModel source) {
|
||||
if(source == null) {
|
||||
throw new NullPointerException("Source TableModel is null");
|
||||
} else {
|
||||
this.source = source;
|
||||
this.listeners = new EventListenerList();
|
||||
}
|
||||
}
|
||||
|
||||
public TableModel getSource() {
|
||||
return this.source;
|
||||
}
|
||||
|
||||
public void addTableModelListener(TableModelListener listener) {
|
||||
if(listener == null) {
|
||||
throw new NullPointerException("TableModelListener is null");
|
||||
} else {
|
||||
this.listeners.add(TableModelListener.class, listener);
|
||||
}
|
||||
}
|
||||
|
||||
public void removeTableModelListener(TableModelListener listener) {
|
||||
this.listeners.remove(TableModelListener.class, listener);
|
||||
}
|
||||
|
||||
public void fireTableDataChanged() {
|
||||
this.fire(new TableModelEvent(this.source, 0, this.source.getRowCount() - 1));
|
||||
}
|
||||
|
||||
public void fireTableStructureChanged() {
|
||||
this.fire(new TableModelEvent(this.source, -1));
|
||||
}
|
||||
|
||||
public void fireTableRowsInserted(int firstRow, int lastRow) {
|
||||
this.fire(new TableModelEvent(this.source, firstRow, lastRow, -1, 1));
|
||||
}
|
||||
|
||||
public void fireTableRowsUpdated(int firstRow, int lastRow) {
|
||||
this.fire(new TableModelEvent(this.source, firstRow, lastRow, -1, 0));
|
||||
}
|
||||
|
||||
public void fireTableRowsDeleted(int firstRow, int lastRow) {
|
||||
this.fire(new TableModelEvent(this.source, firstRow, lastRow, -1, -1));
|
||||
}
|
||||
|
||||
public void fireTableCellUpdated(int row, int col) {
|
||||
this.fire(new TableModelEvent(this.source, row, row, col, 0));
|
||||
}
|
||||
|
||||
private void fire(TableModelEvent event) {
|
||||
TableModelListener[] tableListeners = (TableModelListener[])this.listeners.getListeners(TableModelListener.class);
|
||||
TableModelListener[] arr$ = tableListeners;
|
||||
int len$ = tableListeners.length;
|
||||
|
||||
for(int i$ = 0; i$ < len$; ++i$) {
|
||||
TableModelListener listener = arr$[i$];
|
||||
listener.tableChanged(event);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
90
src/main/java/org/fenix/utils/about/AboutDialog.java
Normal file
|
@ -0,0 +1,90 @@
|
|||
//
|
||||
// Source code recreated from a .class file by IntelliJ IDEA
|
||||
// (powered by Fernflower decompiler)
|
||||
//
|
||||
|
||||
package org.fenix.utils.about;
|
||||
|
||||
import org.fenix.utils.gui.GBC;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.net.URL;
|
||||
|
||||
public class AboutDialog extends JDialog implements ActionListener {
|
||||
private JLabel icon = new JLabel();
|
||||
private JLabel message;
|
||||
private HyperLabel website;
|
||||
private HyperLabel donate;
|
||||
private JButton okButton;
|
||||
|
||||
public AboutDialog(Window owner, String title) {
|
||||
super(owner, title);
|
||||
this.icon.setIcon((Icon)UIManager.get("OptionPane.informationIcon"));
|
||||
this.okButton = new JButton("OK");
|
||||
this.okButton.addActionListener(this);
|
||||
this.donate = null;
|
||||
this.website = null;
|
||||
this.message = null;
|
||||
this.setResizable(false);
|
||||
}
|
||||
|
||||
public void display() {
|
||||
this.setLayout(new GridBagLayout());
|
||||
this.add(this.icon, GBC.grid(0, 0).insets(20, 20).anchor(19));
|
||||
if(this.message != null) {
|
||||
this.add(this.message, GBC.grid(1, 0).insets(10, 0, 0, 15));
|
||||
}
|
||||
|
||||
if(this.website != null || this.donate != null) {
|
||||
this.add(new JLabel(), GBC.grid(0, 1, 2, 1).insets(5, 0));
|
||||
}
|
||||
|
||||
if(this.website != null) {
|
||||
this.add(this.website, GBC.grid(0, 2, 2, 1).insets(5, 0).anchor(10));
|
||||
}
|
||||
|
||||
if(this.donate != null) {
|
||||
this.add(this.donate, GBC.grid(0, 3, 2, 1).insets(5, 0).anchor(10));
|
||||
}
|
||||
|
||||
this.add(this.okButton, GBC.grid(0, 4, 2, 1).insets(10, 0));
|
||||
this.pack();
|
||||
this.setLocationRelativeTo(this.getOwner());
|
||||
this.setVisible(true);
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
this.message = new JLabel(message);
|
||||
}
|
||||
|
||||
public void setDonateLink(URL url, Icon icon) {
|
||||
if(url == null) {
|
||||
throw new NullPointerException("Donate URL is null");
|
||||
} else {
|
||||
this.donate = new HyperLabel(url, icon);
|
||||
}
|
||||
}
|
||||
|
||||
public void setWebsite(URL url) {
|
||||
this.setWebsite(url, (String)null);
|
||||
}
|
||||
|
||||
public void setWebsite(URL url, String text) {
|
||||
if(url == null) {
|
||||
throw new NullPointerException("Website URL is null");
|
||||
} else {
|
||||
if(text == null || text.equals("")) {
|
||||
text = url.toString();
|
||||
}
|
||||
|
||||
this.website = new HyperLabel(url, text);
|
||||
}
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
this.dispose();
|
||||
}
|
||||
}
|
192
src/main/java/org/fenix/utils/config/Configuration.java
Normal file
|
@ -0,0 +1,192 @@
|
|||
//
|
||||
// Source code recreated from a .class file by IntelliJ IDEA
|
||||
// (powered by Fernflower decompiler)
|
||||
//
|
||||
|
||||
package org.fenix.utils.config;
|
||||
|
||||
import com.thoughtworks.xstream.XStream;
|
||||
import com.thoughtworks.xstream.io.xml.DomDriver;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.beans.PropertyChangeSupport;
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class Configuration implements Serializable {
|
||||
private static final long serialVersionUID = 1001L;
|
||||
private transient File path;
|
||||
private Map<String, Map<String, Object>> values;
|
||||
private transient PropertyChangeSupport pcSupport;
|
||||
|
||||
public Configuration() {
|
||||
this.values = new HashMap<>();
|
||||
this.pcSupport = new PropertyChangeSupport(this);
|
||||
}
|
||||
|
||||
private Configuration(File path) {
|
||||
this();
|
||||
this.setPath(path);
|
||||
}
|
||||
|
||||
public static Configuration newInstance(File path) {
|
||||
return path.exists()?deserialize(path):new Configuration(path);
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return this.values.isEmpty();
|
||||
}
|
||||
|
||||
public File getPath() {
|
||||
return this.path;
|
||||
}
|
||||
|
||||
public final void setPath(File path) {
|
||||
if(path == null) {
|
||||
throw new NullPointerException("Null path");
|
||||
} else if(path.isDirectory()) {
|
||||
throw new IllegalArgumentException("Path is a directory");
|
||||
} else {
|
||||
File parent = path.getAbsoluteFile().getParentFile();
|
||||
if(parent.canRead() && parent.canWrite()) {
|
||||
this.path = path;
|
||||
} else {
|
||||
throw new IllegalArgumentException("Denied: " + parent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T get(String section, String key) {
|
||||
if(!this.values.containsKey(section)) {
|
||||
return null;
|
||||
} else {
|
||||
if(section == null) {
|
||||
section = "";
|
||||
}
|
||||
|
||||
Map<String, Object> subMap = this.values.get(section);
|
||||
return !subMap.containsKey(key)?null:(T)subMap.get(key);
|
||||
}
|
||||
}
|
||||
|
||||
public <T> T get(String key) {
|
||||
if(key != null && key.contains(".")) {
|
||||
String[] split = key.split("\\.");
|
||||
return this.get(split[0], split[1]);
|
||||
} else {
|
||||
return this.get("", key);
|
||||
}
|
||||
}
|
||||
|
||||
public void put(String section, String key, Object value) {
|
||||
if(key != null && !key.equals("")) {
|
||||
if(section == null) {
|
||||
section = "";
|
||||
}
|
||||
|
||||
Map<String, Object> subMap = this.values.get(section);
|
||||
if(subMap == null) {
|
||||
subMap = new HashMap<>();
|
||||
this.values.put(section, subMap);
|
||||
}
|
||||
|
||||
Object old = subMap.get(key);
|
||||
subMap.put(key, value);
|
||||
this.pcSupport.firePropertyChange(section + "." + key, old, value);
|
||||
} else {
|
||||
throw new NullPointerException("Null key");
|
||||
}
|
||||
}
|
||||
|
||||
public void put(String key, Object value) {
|
||||
if(key != null && key.contains(".")) {
|
||||
String[] split = key.split("\\.");
|
||||
this.put(split[0], split[1], value);
|
||||
} else {
|
||||
this.put("", key, value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void remove(String section, String key) {
|
||||
if(section == null) {
|
||||
section = "";
|
||||
}
|
||||
|
||||
if(this.values.containsKey(section)) {
|
||||
((Map)this.values.get(section)).remove(key);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void remove(String key) {
|
||||
this.remove("", key);
|
||||
}
|
||||
|
||||
public boolean contains(String section, String key) {
|
||||
if(section == null) {
|
||||
section = "";
|
||||
}
|
||||
|
||||
return !this.values.containsKey(section)?false:this.values.get(section).containsKey(key);
|
||||
}
|
||||
|
||||
public boolean contains(String key) {
|
||||
if(key != null && key.contains(".")) {
|
||||
String[] split = key.split("\\.");
|
||||
return this.contains(split[0], split[1]);
|
||||
} else {
|
||||
return this.contains("", key);
|
||||
}
|
||||
}
|
||||
|
||||
public void addPropertyChangeListener(PropertyChangeListener listener) {
|
||||
if(listener == null) {
|
||||
throw new NullPointerException("Null listener");
|
||||
} else {
|
||||
this.pcSupport.addPropertyChangeListener(listener);
|
||||
}
|
||||
}
|
||||
|
||||
public void removePropertyChangeListener(PropertyChangeListener pcl) {
|
||||
this.pcSupport.removePropertyChangeListener(pcl);
|
||||
}
|
||||
|
||||
public void serialize() {
|
||||
XStream xstream = new XStream(new DomDriver());
|
||||
String xmlOutput = xstream.toXML(this);
|
||||
FileWriter stream = null;
|
||||
|
||||
try {
|
||||
stream = new FileWriter(this.path);
|
||||
stream.write(xmlOutput);
|
||||
} catch (Exception var12) {
|
||||
throw new IllegalStateException("I/O Error for: " + this.path);
|
||||
} finally {
|
||||
try {
|
||||
stream.close();
|
||||
} catch (Exception var11) {
|
||||
;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static Configuration deserialize(File path) {
|
||||
XStream xstream = new XStream(new DomDriver());
|
||||
Configuration input = (Configuration)xstream.fromXML(path);
|
||||
input.setPath(path);
|
||||
return input;
|
||||
}
|
||||
|
||||
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
|
||||
in.defaultReadObject();
|
||||
this.pcSupport = new PropertyChangeSupport(this);
|
||||
}
|
||||
}
|
180
src/main/java/org/fenix/utils/gui/BorderlessFrame.java
Normal file
|
@ -0,0 +1,180 @@
|
|||
//
|
||||
// Source code recreated from a .class file by IntelliJ IDEA
|
||||
// (powered by Fernflower decompiler)
|
||||
//
|
||||
|
||||
package org.fenix.utils.gui;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseListener;
|
||||
import java.awt.event.MouseMotionListener;
|
||||
|
||||
public class BorderlessFrame extends JFrame implements MouseListener, MouseMotionListener {
|
||||
private int snapSize;
|
||||
private int startMouseX;
|
||||
private int startMouseY;
|
||||
private int startFrameX;
|
||||
private int startFrameY;
|
||||
private int startHeight;
|
||||
private int startWidth;
|
||||
private boolean doDrag;
|
||||
private boolean doResize;
|
||||
|
||||
public BorderlessFrame(String title) {
|
||||
this();
|
||||
this.setTitle(title);
|
||||
}
|
||||
|
||||
public BorderlessFrame() {
|
||||
this.doDrag = false;
|
||||
this.doResize = false;
|
||||
this.snapSize = 10;
|
||||
this.setUndecorated(true);
|
||||
this.addMouseListener(this);
|
||||
this.addMouseMotionListener(this);
|
||||
}
|
||||
|
||||
public int getSnapSize() {
|
||||
return this.snapSize;
|
||||
}
|
||||
|
||||
public void setSnapSize(int snapSize) {
|
||||
if(snapSize < 0) {
|
||||
throw new IllegalArgumentException("Illegal snap: " + snapSize);
|
||||
} else {
|
||||
this.snapSize = snapSize;
|
||||
}
|
||||
}
|
||||
|
||||
public void mousePressed(MouseEvent event) {
|
||||
if(this.getCursor().getType() != 0) {
|
||||
this.doResize = true;
|
||||
this.startFrameX = this.getX();
|
||||
this.startFrameY = this.getY();
|
||||
this.startHeight = this.getHeight();
|
||||
this.startWidth = this.getWidth();
|
||||
} else {
|
||||
this.doDrag = true;
|
||||
this.startMouseX = event.getX();
|
||||
this.startMouseY = event.getY();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void mouseDragged(MouseEvent event) {
|
||||
if(SwingUtilities.isLeftMouseButton(event)) {
|
||||
int type;
|
||||
int width;
|
||||
if(this.doDrag) {
|
||||
type = this.getX() + event.getX() - this.startMouseX;
|
||||
width = this.getY() + event.getY() - this.startMouseY;
|
||||
this.setLocation(type, width);
|
||||
}
|
||||
|
||||
if(this.doResize) {
|
||||
type = this.getCursor().getType();
|
||||
width = this.getWidth();
|
||||
int height = this.getHeight();
|
||||
int frameX = this.startFrameX;
|
||||
int frameY = this.startFrameY;
|
||||
if(type == 5) {
|
||||
width = event.getXOnScreen() - this.startFrameX;
|
||||
height = event.getYOnScreen() - this.startFrameY;
|
||||
} else if(type == 11) {
|
||||
width = event.getXOnScreen() - this.startFrameX;
|
||||
} else if(type == 7) {
|
||||
width = event.getXOnScreen() - this.startFrameX;
|
||||
height = this.startFrameY + this.startHeight - event.getYOnScreen();
|
||||
frameY = event.getYOnScreen();
|
||||
} else if(type == 8) {
|
||||
height = this.startFrameY + this.startHeight - event.getYOnScreen();
|
||||
frameY = event.getYOnScreen();
|
||||
} else if(type == 6) {
|
||||
width = this.startFrameX + this.startWidth - event.getXOnScreen();
|
||||
height = this.startFrameY + this.startHeight - event.getYOnScreen();
|
||||
frameY = event.getYOnScreen();
|
||||
frameX = event.getXOnScreen();
|
||||
} else if(type == 10) {
|
||||
width = this.startFrameX + this.startWidth - event.getXOnScreen();
|
||||
frameX = event.getXOnScreen();
|
||||
} else if(type == 4) {
|
||||
width = this.startFrameX + this.startWidth - event.getXOnScreen();
|
||||
height = event.getYOnScreen() - this.startFrameY;
|
||||
frameX = event.getXOnScreen();
|
||||
} else if(type == 9) {
|
||||
height = event.getYOnScreen() - this.startFrameY;
|
||||
}
|
||||
|
||||
Dimension minSize = this.getMinimumSize();
|
||||
if(width > minSize.width && height > minSize.height) {
|
||||
this.setSize(width, height);
|
||||
this.setLocation(frameX, frameY);
|
||||
} else if(width > minSize.width) {
|
||||
this.setSize(width, minSize.height);
|
||||
this.setLocation(frameX, this.getY());
|
||||
} else if(height > minSize.height) {
|
||||
this.setSize(minSize.width, height);
|
||||
this.setLocation(this.getX(), frameY);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void mouseMoved(MouseEvent event) {
|
||||
int farSnapX = this.getX() + this.getWidth() - this.snapSize;
|
||||
int farSnapY = this.getY() + this.getHeight() - this.snapSize;
|
||||
int lowSnapX = this.getX() + this.snapSize;
|
||||
int lowSnapY = this.getY() + this.snapSize;
|
||||
int mouseX = event.getXOnScreen();
|
||||
int mouseY = event.getYOnScreen();
|
||||
if(mouseX > farSnapX) {
|
||||
if(mouseY > farSnapY) {
|
||||
this.changeCursor(5);
|
||||
} else if(mouseY < lowSnapY) {
|
||||
this.changeCursor(7);
|
||||
} else {
|
||||
this.changeCursor(11);
|
||||
}
|
||||
} else if(mouseX < lowSnapX) {
|
||||
if(mouseY < lowSnapY) {
|
||||
this.changeCursor(6);
|
||||
} else if(mouseY > farSnapY) {
|
||||
this.changeCursor(4);
|
||||
} else {
|
||||
this.changeCursor(10);
|
||||
}
|
||||
} else if(mouseY > farSnapY) {
|
||||
this.changeCursor(9);
|
||||
} else if(mouseY < lowSnapY) {
|
||||
this.changeCursor(8);
|
||||
} else {
|
||||
this.changeCursor(0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void mouseReleased(MouseEvent event) {
|
||||
this.doDrag = false;
|
||||
this.doResize = false;
|
||||
}
|
||||
|
||||
public void mouseClicked(MouseEvent event) {
|
||||
}
|
||||
|
||||
public void mouseEntered(MouseEvent event) {
|
||||
}
|
||||
|
||||
public void mouseExited(MouseEvent event) {
|
||||
}
|
||||
|
||||
private void changeCursor(int cursorType) {
|
||||
int type = this.getCursor().getType();
|
||||
if(cursorType != type) {
|
||||
this.setCursor(Cursor.getPredefinedCursor(cursorType));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
73
src/main/java/org/fenix/utils/gui/GBC.java
Normal file
|
@ -0,0 +1,73 @@
|
|||
//
|
||||
// Source code recreated from a .class file by IntelliJ IDEA
|
||||
// (powered by Fernflower decompiler)
|
||||
//
|
||||
|
||||
package org.fenix.utils.gui;
|
||||
|
||||
import java.awt.GridBagConstraints;
|
||||
import java.awt.Insets;
|
||||
|
||||
public class GBC extends GridBagConstraints {
|
||||
public static final int LS = 21;
|
||||
public static final int LE = 22;
|
||||
public static final int PS = 19;
|
||||
public static final int PE = 20;
|
||||
public static final int BL = 512;
|
||||
public static final int BT = 768;
|
||||
public static final int FLS = 23;
|
||||
public static final int FLE = 24;
|
||||
public static final int LLS = 25;
|
||||
public static final int LLE = 26;
|
||||
public static final int H = 2;
|
||||
public static final int V = 3;
|
||||
public static final int C = 10;
|
||||
public static final int B = 1;
|
||||
|
||||
public GBC() {
|
||||
}
|
||||
|
||||
public static GBC grid(int x, int y, int w, int h) {
|
||||
GBC gbc = new GBC();
|
||||
gbc.gridx = x;
|
||||
gbc.gridy = y;
|
||||
gbc.gridwidth = w;
|
||||
gbc.gridheight = h;
|
||||
return gbc;
|
||||
}
|
||||
|
||||
public static GBC grid(int x, int y) {
|
||||
return grid(x, y, 1, 1);
|
||||
}
|
||||
|
||||
public GBC weight(double x, double y) {
|
||||
this.weightx = x;
|
||||
this.weighty = y;
|
||||
return this;
|
||||
}
|
||||
|
||||
public GBC anchor(int anchor) {
|
||||
this.anchor = anchor;
|
||||
return this;
|
||||
}
|
||||
|
||||
public GBC fill(int fill) {
|
||||
this.fill = fill;
|
||||
return this;
|
||||
}
|
||||
|
||||
public GBC insets(int top, int left, int bottom, int right) {
|
||||
this.insets = new Insets(top, left, bottom, right);
|
||||
return this;
|
||||
}
|
||||
|
||||
public GBC insets(int y, int x) {
|
||||
return this.insets(y, x, y, x);
|
||||
}
|
||||
|
||||
public GBC padding(int x, int y) {
|
||||
this.ipadx = x;
|
||||
this.ipady = y;
|
||||
return this;
|
||||
}
|
||||
}
|
74
src/main/java/org/fenix/utils/gui/HyperLabel.java
Normal file
|
@ -0,0 +1,74 @@
|
|||
//
|
||||
// Source code recreated from a .class file by IntelliJ IDEA
|
||||
// (powered by Fernflower decompiler)
|
||||
//
|
||||
|
||||
package org.fenix.utils.about;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Cursor;
|
||||
import java.awt.Desktop;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseListener;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.JLabel;
|
||||
|
||||
public class HyperLabel extends JLabel implements MouseListener {
|
||||
private URI href;
|
||||
|
||||
public HyperLabel(URL url, String text) {
|
||||
super(text);
|
||||
if(url == null) {
|
||||
throw new NullPointerException("URL is null");
|
||||
} else {
|
||||
this.decorate();
|
||||
|
||||
try {
|
||||
this.href = url.toURI();
|
||||
} catch (URISyntaxException var4) {
|
||||
throw new IllegalStateException(url.toString());
|
||||
}
|
||||
|
||||
this.addMouseListener(this);
|
||||
}
|
||||
}
|
||||
|
||||
public HyperLabel(URL url, Icon icon) {
|
||||
this(url, (String)null);
|
||||
this.setIcon(icon);
|
||||
}
|
||||
|
||||
public void mouseClicked(MouseEvent event) {
|
||||
try {
|
||||
Desktop.getDesktop().browse(this.href);
|
||||
} catch (IOException var3) {
|
||||
throw new IllegalStateException(var3.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void mouseEntered(MouseEvent event) {
|
||||
}
|
||||
|
||||
public void mouseExited(MouseEvent event) {
|
||||
}
|
||||
|
||||
public void mousePressed(MouseEvent event) {
|
||||
}
|
||||
|
||||
public void mouseReleased(MouseEvent event) {
|
||||
}
|
||||
|
||||
private void decorate() {
|
||||
this.setForeground(Color.BLUE);
|
||||
this.setCursor(Cursor.getPredefinedCursor(12));
|
||||
if(this.getText() != null) {
|
||||
this.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Color.BLUE));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
109
src/main/java/org/fenix/utils/gui/LinkedCheckBox.java
Normal file
|
@ -0,0 +1,109 @@
|
|||
//
|
||||
// Source code recreated from a .class file by IntelliJ IDEA
|
||||
// (powered by Fernflower decompiler)
|
||||
//
|
||||
|
||||
package org.fenix.utils.gui;
|
||||
|
||||
import org.fenix.utils.MixedPair;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.ItemEvent;
|
||||
import java.awt.event.ItemListener;
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
public class LinkedCheckBox extends JCheckBox implements ItemListener {
|
||||
private boolean purgesSelectState = true;
|
||||
private List<MixedPair<JCheckBox, Boolean>> constraints = new ArrayList();
|
||||
private List<MixedPair<JCheckBox, Boolean>> sideEffects = new ArrayList();
|
||||
|
||||
public LinkedCheckBox() {
|
||||
this.addItemListener(this);
|
||||
}
|
||||
|
||||
public boolean purgesSelectState() {
|
||||
return this.purgesSelectState;
|
||||
}
|
||||
|
||||
public void activates(JCheckBox box) {
|
||||
if(box == null) {
|
||||
throw new NullPointerException("Target CheckBox is null");
|
||||
} else {
|
||||
this.sideEffects.add(new MixedPair(box, Boolean.TRUE));
|
||||
}
|
||||
}
|
||||
|
||||
public void deactivates(JCheckBox box) {
|
||||
if(box == null) {
|
||||
throw new NullPointerException("Target CheckBox is null");
|
||||
} else {
|
||||
this.sideEffects.add(new MixedPair(box, Boolean.FALSE));
|
||||
}
|
||||
}
|
||||
|
||||
public void requires(JCheckBox box, boolean state) {
|
||||
if(box == null) {
|
||||
throw new NullPointerException("Required CheckBox is null");
|
||||
} else {
|
||||
this.constraints.add(new MixedPair(box, Boolean.valueOf(state)));
|
||||
box.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
LinkedCheckBox.this.checkConstraints();
|
||||
}
|
||||
});
|
||||
box.addPropertyChangeListener("enabled", new PropertyChangeListener() {
|
||||
public void propertyChange(PropertyChangeEvent evt) {
|
||||
LinkedCheckBox.this.checkConstraints();
|
||||
}
|
||||
});
|
||||
this.checkConstraints();
|
||||
}
|
||||
}
|
||||
|
||||
public void setPurgesSelectState(boolean purgesSelectState) {
|
||||
this.purgesSelectState = purgesSelectState;
|
||||
}
|
||||
|
||||
public void setEnabled(boolean b) {
|
||||
super.setEnabled(b);
|
||||
if(!b && this.purgesSelectState) {
|
||||
this.setSelected(false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void itemStateChanged(ItemEvent event) {
|
||||
boolean selected = this.isSelected();
|
||||
Iterator i$ = this.sideEffects.iterator();
|
||||
|
||||
while(true) {
|
||||
while(i$.hasNext()) {
|
||||
MixedPair pair = (MixedPair)i$.next();
|
||||
if(((Boolean)pair.second).booleanValue()) {
|
||||
((JCheckBox)pair.first).setSelected(selected);
|
||||
} else {
|
||||
((JCheckBox)pair.first).setSelected(!selected && ((JCheckBox)pair.first).isSelected());
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
protected void checkConstraints() {
|
||||
boolean enabled = true;
|
||||
|
||||
MixedPair pair;
|
||||
for(Iterator i$ = this.constraints.iterator(); i$.hasNext(); enabled &= ((JCheckBox)pair.first).isSelected() == ((Boolean)pair.second).booleanValue()) {
|
||||
pair = (MixedPair)i$.next();
|
||||
}
|
||||
|
||||
this.setEnabled(enabled);
|
||||
}
|
||||
}
|
52
src/main/java/org/fenix/utils/locale/LocaleDelegate.java
Normal file
|
@ -0,0 +1,52 @@
|
|||
//
|
||||
// Source code recreated from a .class file by IntelliJ IDEA
|
||||
// (powered by Fernflower decompiler)
|
||||
//
|
||||
|
||||
package org.fenix.utils.locale;
|
||||
|
||||
import javax.swing.event.EventListenerList;
|
||||
import java.util.Locale;
|
||||
|
||||
public class LocaleDelegate {
|
||||
private static EventListenerList listeners = new EventListenerList();
|
||||
|
||||
public LocaleDelegate() {
|
||||
}
|
||||
|
||||
public static void setDefault(Locale locale) {
|
||||
if(locale == null) {
|
||||
throw new NullPointerException("Null locale");
|
||||
} else {
|
||||
Locale old = Locale.getDefault();
|
||||
if(!old.equals(locale)) {
|
||||
Locale.setDefault(locale);
|
||||
fireLocalChanged(old, locale);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static void addLocaleListener(LocaleListener listener) {
|
||||
if(listener == null) {
|
||||
throw new NullPointerException("Null listener");
|
||||
} else {
|
||||
listeners.add(LocaleListener.class, listener);
|
||||
}
|
||||
}
|
||||
|
||||
public static void removeLocaleListener(LocaleListener listener) {
|
||||
listeners.remove(LocaleListener.class, listener);
|
||||
}
|
||||
|
||||
private static void fireLocalChanged(Locale oldLocale, Locale newLocale) {
|
||||
LocaleListener[] arr$ = (LocaleListener[])listeners.getListeners(LocaleListener.class);
|
||||
int len$ = arr$.length;
|
||||
|
||||
for(int i$ = 0; i$ < len$; ++i$) {
|
||||
LocaleListener ll = arr$[i$];
|
||||
ll.localeChanged(new LocaleEvent(oldLocale, newLocale));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
29
src/main/java/org/fenix/utils/locale/LocaleEvent.java
Normal file
|
@ -0,0 +1,29 @@
|
|||
//
|
||||
// Source code recreated from a .class file by IntelliJ IDEA
|
||||
// (powered by Fernflower decompiler)
|
||||
//
|
||||
|
||||
package org.fenix.utils.locale;
|
||||
|
||||
import java.awt.AWTEvent;
|
||||
import java.util.Locale;
|
||||
|
||||
public class LocaleEvent extends AWTEvent {
|
||||
public static final int DEFAULT_UPDATE = 0;
|
||||
private Locale oldLocale;
|
||||
private Locale newLocale;
|
||||
|
||||
public LocaleEvent(Locale old, Locale neu) {
|
||||
super(Locale.class, 0);
|
||||
this.oldLocale = old;
|
||||
this.newLocale = neu;
|
||||
}
|
||||
|
||||
public Locale getOldLocale() {
|
||||
return this.oldLocale;
|
||||
}
|
||||
|
||||
public Locale getNewLocale() {
|
||||
return this.newLocale;
|
||||
}
|
||||
}
|
12
src/main/java/org/fenix/utils/locale/LocaleListener.java
Normal file
|
@ -0,0 +1,12 @@
|
|||
//
|
||||
// Source code recreated from a .class file by IntelliJ IDEA
|
||||
// (powered by Fernflower decompiler)
|
||||
//
|
||||
|
||||
package org.fenix.utils.locale;
|
||||
|
||||
import java.util.EventListener;
|
||||
|
||||
public interface LocaleListener extends EventListener {
|
||||
void localeChanged(LocaleEvent var1);
|
||||
}
|
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 3 KiB After Width: | Height: | Size: 3 KiB |
Before Width: | Height: | Size: 35 KiB After Width: | Height: | Size: 35 KiB |
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 3 KiB After Width: | Height: | Size: 3 KiB |
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 3 KiB After Width: | Height: | Size: 3 KiB |
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 4.3 KiB |
Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 3 KiB After Width: | Height: | Size: 3 KiB |
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 3 KiB After Width: | Height: | Size: 3 KiB |
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 3.3 KiB |
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 3 KiB After Width: | Height: | Size: 3 KiB |
Before Width: | Height: | Size: 3 KiB After Width: | Height: | Size: 3 KiB |
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 3.3 KiB |
Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 3.4 KiB |
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 3.5 KiB After Width: | Height: | Size: 3.5 KiB |
Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 3 KiB After Width: | Height: | Size: 3 KiB |
Before Width: | Height: | Size: 3 KiB After Width: | Height: | Size: 3 KiB |