Several fixes, cleanup.

This commit is contained in:
Fabian Becker 2015-01-13 14:20:59 +01:00
parent 164ccd8a9d
commit 0132c09c69
18 changed files with 22 additions and 23 deletions

View File

@ -55,7 +55,7 @@ public class EvAInfo {
System.err.println(ex.getMessage()); System.err.println(ex.getMessage());
System.exit(1); System.exit(1);
} }
InputStream istr = BasicResourceLoader.instance().getStreamFromResourceLocation(EvAInfo.iconLocation); InputStream istr = BasicResourceLoader.getInstance().getStreamFromResourceLocation(EvAInfo.iconLocation);
if (istr == null) { if (istr == null) {
throw new RuntimeException(resourceNotFoundErrorMessage(EvAInfo.iconLocation) + " (EvAInfo.static)"); throw new RuntimeException(resourceNotFoundErrorMessage(EvAInfo.iconLocation) + " (EvAInfo.static)");
} }

View File

@ -35,7 +35,7 @@ class AboutDialog extends JDialog {
setResizable(false); setResizable(false);
/* Load EvA2 Image */ /* Load EvA2 Image */
BasicResourceLoader loader = BasicResourceLoader.instance(); BasicResourceLoader loader = BasicResourceLoader.getInstance();
byte[] bytes = loader.getBytesFromResourceLocation(eva2.EvAInfo.splashLocation, true); byte[] bytes = loader.getBytesFromResourceLocation(eva2.EvAInfo.splashLocation, true);
ImageIcon imageIcon = new ImageIcon(Toolkit.getDefaultToolkit().createImage(bytes)); ImageIcon imageIcon = new ImageIcon(Toolkit.getDefaultToolkit().createImage(bytes));

View File

@ -77,7 +77,7 @@ public class HtmlDemo {
return; return;
} }
JFrame frame = new JFrame(name); JFrame frame = new JFrame(name);
BasicResourceLoader loader = BasicResourceLoader.instance(); BasicResourceLoader loader = BasicResourceLoader.getInstance();
byte[] bytes = loader.getBytesFromResourceLocation(EvAInfo.iconLocation, true); byte[] bytes = loader.getBytesFromResourceLocation(EvAInfo.iconLocation, true);
frame.setIconImage(Toolkit.getDefaultToolkit().createImage(bytes)); frame.setIconImage(Toolkit.getDefaultToolkit().createImage(bytes));
JScrollPane scroller = new JScrollPane(); JScrollPane scroller = new JScrollPane();

View File

@ -390,7 +390,7 @@ public class Main extends JFrame implements OptimizationStateListener {
desktopConst.weighty = 1.0; desktopConst.weighty = 1.0;
desktopPanel.add(desktopPane, desktopConst); desktopPanel.add(desktopPane, desktopConst);
BasicResourceLoader loader = BasicResourceLoader.instance(); BasicResourceLoader loader = BasicResourceLoader.getInstance();
byte[] bytes = loader.getBytesFromResourceLocation(EvAInfo.iconLocation, true); byte[] bytes = loader.getBytesFromResourceLocation(EvAInfo.iconLocation, true);
// TODO: use setIconImages (for better support of multiple icons when changing programs etc.) // TODO: use setIconImages (for better support of multiple icons when changing programs etc.)
setIconImage(Toolkit.getDefaultToolkit().createImage(bytes)); setIconImage(Toolkit.getDefaultToolkit().createImage(bytes));

View File

@ -234,7 +234,7 @@ public class OptimizationEditorPanel extends JPanel implements ItemListener {
private JButton makeIconButton(final String iconSrc, final String title) { private JButton makeIconButton(final String iconSrc, final String title) {
JButton newButton; JButton newButton;
byte[] bytes; byte[] bytes;
bytes = BasicResourceLoader.instance().getBytesFromResourceLocation(iconSrc, false); bytes = BasicResourceLoader.getInstance().getBytesFromResourceLocation(iconSrc, false);
if (bytes == null) { if (bytes == null) {
newButton = new JButton(title); newButton = new JButton(title);
} else { } else {

View File

@ -23,7 +23,7 @@ public class PropertyDialog extends JDialog {
public PropertyDialog(Window parent, PropertyEditor editor, String title) { public PropertyDialog(Window parent, PropertyEditor editor, String title) {
super(parent, title, ModalityType.APPLICATION_MODAL); super(parent, title, ModalityType.APPLICATION_MODAL);
setTitle(getFrameNameFromEditor(editor)); setTitle(getFrameNameFromEditor(editor));
BasicResourceLoader loader = BasicResourceLoader.instance(); BasicResourceLoader loader = BasicResourceLoader.getInstance();
byte[] bytes = loader.getBytesFromResourceLocation(EvAInfo.iconLocation, true); byte[] bytes = loader.getBytesFromResourceLocation(EvAInfo.iconLocation, true);
setDefaultCloseOperation(DISPOSE_ON_CLOSE); setDefaultCloseOperation(DISPOSE_ON_CLOSE);
setLayout(new BorderLayout()); setLayout(new BorderLayout());

View File

@ -14,7 +14,7 @@ class SplashScreen extends JWindow {
public SplashScreen(String imgLoc) { public SplashScreen(String imgLoc) {
imgLocation = imgLoc; imgLocation = imgLoc;
BasicResourceLoader loader = BasicResourceLoader.instance(); BasicResourceLoader loader = BasicResourceLoader.getInstance();
byte[] bytes = loader.getBytesFromResourceLocation(imgLocation, true); byte[] bytes = loader.getBytesFromResourceLocation(imgLocation, true);
ImageIcon ii = new ImageIcon(Toolkit.getDefaultToolkit().createImage(bytes)); ImageIcon ii = new ImageIcon(Toolkit.getDefaultToolkit().createImage(bytes));
JLabel splashLabel = new JLabel(ii); JLabel splashLabel = new JLabel(ii);

View File

@ -130,7 +130,7 @@ public class OptimizationObjectivesEditor extends JPanel implements PropertyEdit
* This method updates the server list * This method updates the server list
*/ */
private void updateTargetList() { private void updateTargetList() {
BasicResourceLoader loader = BasicResourceLoader.instance(); BasicResourceLoader loader = BasicResourceLoader.getInstance();
byte[] bytes; byte[] bytes;
InterfaceOptimizationObjective[] list = this.optimizationObjectives.getSelectedTargets(); InterfaceOptimizationObjective[] list = this.optimizationObjectives.getSelectedTargets();

View File

@ -140,7 +140,7 @@ public class OptimizationObjectivesWithParamEditor extends JPanel implements Pro
* This method updates the server list * This method updates the server list
*/ */
private void updateTargetList() { private void updateTargetList() {
BasicResourceLoader loader = BasicResourceLoader.instance(); BasicResourceLoader loader = BasicResourceLoader.getInstance();
byte[] bytes; byte[] bytes;
InterfaceOptimizationObjective[] list = this.optimizationObjectivesWithWeights.getSelectedTargets(); InterfaceOptimizationObjective[] list = this.optimizationObjectivesWithWeights.getSelectedTargets();
double[] weights = this.optimizationObjectivesWithWeights.getWeights(); double[] weights = this.optimizationObjectivesWithWeights.getWeights();

View File

@ -114,7 +114,7 @@ public class TagEditor extends PropertyEditorSupport {
ce.setValue(initial); ce.setValue(initial);
PropertyValueSelector ps = new PropertyValueSelector(ce); PropertyValueSelector ps = new PropertyValueSelector(ce);
JFrame f = new JFrame(); JFrame f = new JFrame();
BasicResourceLoader loader = BasicResourceLoader.instance(); BasicResourceLoader loader = BasicResourceLoader.getInstance();
byte[] bytes = loader.getBytesFromResourceLocation(EvAInfo.iconLocation, true); byte[] bytes = loader.getBytesFromResourceLocation(EvAInfo.iconLocation, true);
f.setIconImage(Toolkit.getDefaultToolkit().createImage(bytes)); f.setIconImage(Toolkit.getDefaultToolkit().createImage(bytes));
f.addWindowListener(new WindowAdapter() { f.addWindowListener(new WindowAdapter() {

View File

@ -151,7 +151,7 @@ public class Plot implements PlotInterface, Serializable {
@Override @Override
public void init() { public void init() {
internalFrame = new JEFrame("Plot: " + plotName); internalFrame = new JEFrame("Plot: " + plotName);
BasicResourceLoader loader = BasicResourceLoader.instance(); BasicResourceLoader loader = BasicResourceLoader.getInstance();
byte[] bytes = loader.getBytesFromResourceLocation(EvAInfo.iconLocation, true); byte[] bytes = loader.getBytesFromResourceLocation(EvAInfo.iconLocation, true);
buttonPanel = new JPanel(); buttonPanel = new JPanel();

View File

@ -45,7 +45,7 @@ public class MOCCOChooseMOStrategy extends MOCCOPhase implements InterfaceProces
JPanel tmpP = new JPanel(); JPanel tmpP = new JPanel();
tmpP.setLayout(new GridBagLayout()); tmpP.setLayout(new GridBagLayout());
JButton tmpB; JButton tmpB;
BasicResourceLoader loader = BasicResourceLoader.instance(); BasicResourceLoader loader = BasicResourceLoader.getInstance();
byte[] bytes; byte[] bytes;
GridBagConstraints gbc = new GridBagConstraints(); GridBagConstraints gbc = new GridBagConstraints();
gbc.anchor = GridBagConstraints.WEST; gbc.anchor = GridBagConstraints.WEST;

View File

@ -137,7 +137,7 @@ public class PropertyCrossoverMixerEditor extends JPanel implements PropertyEdit
* This method updates the server list * This method updates the server list
*/ */
private void updateTargetList() { private void updateTargetList() {
BasicResourceLoader loader = BasicResourceLoader.instance(); BasicResourceLoader loader = BasicResourceLoader.getInstance();
byte[] bytes; byte[] bytes;
InterfaceCrossover[] list = this.crossoverMixer.getSelectedCrossers(); InterfaceCrossover[] list = this.crossoverMixer.getSelectedCrossers();
double[] weights = this.crossoverMixer.getWeights(); double[] weights = this.crossoverMixer.getWeights();

View File

@ -139,7 +139,7 @@ public class PropertyMutationMixerEditor extends JPanel implements PropertyEdito
* This method updates the server list * This method updates the server list
*/ */
private void updateTargetList() { private void updateTargetList() {
BasicResourceLoader loader = BasicResourceLoader.instance(); BasicResourceLoader loader = BasicResourceLoader.getInstance();
byte[] bytes; byte[] bytes;
InterfaceMutation[] list = this.mutatorsWithWeights.getSelectedMutators(); InterfaceMutation[] list = this.mutatorsWithWeights.getSelectedMutators();
double[] weights = this.mutatorsWithWeights.getWeights(); double[] weights = this.mutatorsWithWeights.getWeights();

View File

@ -24,7 +24,7 @@ public class FileTools {
*/ */
static public String[] loadStringsFromFile(String file) { static public String[] loadStringsFromFile(String file) {
String[] result = null; String[] result = null;
BasicResourceLoader loader = BasicResourceLoader.instance(); BasicResourceLoader loader = BasicResourceLoader.getInstance();
byte bytes[] = loader.getBytesFromResourceLocation(file, false); byte bytes[] = loader.getBytesFromResourceLocation(file, false);
if (bytes != null) { if (bytes != null) {
String data = new String(bytes); String data = new String(bytes);

View File

@ -68,7 +68,7 @@ public class BasicResourceLoader implements ResourceLoader {
* *
* @return Description of the Return Value * @return Description of the Return Value
*/ */
public static synchronized BasicResourceLoader instance() { public static synchronized BasicResourceLoader getInstance() {
if (resourceLoader == null) { if (resourceLoader == null) {
resourceLoader = new BasicResourceLoader(); resourceLoader = new BasicResourceLoader();
} }
@ -113,7 +113,7 @@ public class BasicResourceLoader implements ResourceLoader {
return null; return null;
} }
byte[] bytes = BasicResourceLoader.instance() byte[] bytes = BasicResourceLoader.getInstance()
.getBytesFromResourceLocation( .getBytesFromResourceLocation(
resourceFile, false); resourceFile, false);
@ -345,7 +345,7 @@ public class BasicResourceLoader implements ResourceLoader {
} }
if (in == null) { if (in == null) {
// try to search other classpathes...? not really necessary. // try to search other classpaths...? not really necessary.
// in = getStreamFromClassPath(resourceLocation); // in = getStreamFromClassPath(resourceLocation);
} }
@ -417,8 +417,7 @@ public class BasicResourceLoader implements ResourceLoader {
// only files with <65536 bytes are allowed // only files with <65536 bytes are allowed
if (ze.getSize() > 65536) { if (ze.getSize() > 65536) {
System.out.println( System.out.println("Resource files should be smaller than 65536 bytes...");
"Resource files should be smaller than 65536 bytes...");
} }
size = (int) ze.getSize(); size = (int) ze.getSize();
@ -567,7 +566,7 @@ public class BasicResourceLoader implements ResourceLoader {
*/ */
public static Properties readProperties(String resourceName) throws Exception { public static Properties readProperties(String resourceName) throws Exception {
Properties prop = new Properties(); Properties prop = new Properties();
BasicResourceLoader loader = BasicResourceLoader.instance(); BasicResourceLoader loader = BasicResourceLoader.getInstance();
byte bytes[] = loader.getBytesFromResourceLocation(resourceName, false); byte bytes[] = loader.getBytesFromResourceLocation(resourceName, false);
if (bytes != null) { if (bytes != null) {

View File

@ -292,7 +292,7 @@ public class ReflectPackage {
*/ */
public static InputStream getResourceStreamFromCP(String res) { public static InputStream getResourceStreamFromCP(String res) {
InputStream in = BasicResourceLoader.instance().getStreamFromResourceLocation(res); InputStream in = BasicResourceLoader.getInstance().getStreamFromResourceLocation(res);
if (in != null) { if (in != null) {
return in; return in;
} }

View File

@ -58,7 +58,7 @@ public class ToolBoxGui {
public static JButton createIconifiedButton(final String iconSrc, final String title, final boolean withTitle) { public static JButton createIconifiedButton(final String iconSrc, final String title, final boolean withTitle) {
JButton newButton; JButton newButton;
byte[] bytes; byte[] bytes;
bytes = BasicResourceLoader.instance().getBytesFromResourceLocation(iconSrc, false); bytes = BasicResourceLoader.getInstance().getBytesFromResourceLocation(iconSrc, false);
if (bytes == null) { if (bytes == null) {
newButton = new JButton(title); newButton = new JButton(title);
} else if (withTitle) { } else if (withTitle) {