Corrected and removed redundant error messages on resources not found.

This commit is contained in:
Marcel Kronfeld 2010-05-12 08:48:32 +00:00
parent ebe02870df
commit f29dae18c6
18 changed files with 180 additions and 297 deletions

View File

@ -96,17 +96,31 @@ public class EvAInfo {
try { try {
EVA_PROPERTIES = BasicResourceLoader.readProperties(EvAInfo.propertyFile); EVA_PROPERTIES = BasicResourceLoader.readProperties(EvAInfo.propertyFile);
} catch (Exception ex) { } catch (Exception ex) {
System.err.println("ERROR! Could not read the configuration file "+ EvAInfo.propertyFile); System.err.println(resourceNotFoundErrorMessage(EvAInfo.propertyFile));
System.err.println(ex.getMessage()); System.err.println(ex.getMessage());
System.exit(1); System.exit(1);
} }
File f=new File(EvAInfo.iconLocation); File f=new File(EvAInfo.iconLocation);
if (!f.exists()) { if (!f.exists()) {
System.err.println("Error: Could not find EvA2 resources. Did you copy the resources folder to working directory? (EvAInfo.static)"); throw new RuntimeException(resourceNotFoundErrorMessage(EvAInfo.iconLocation) + " (EvAInfo.static)");
// System.exit(2); // dont be as harsh right here - there will be plenty of exceptions later in the bad case... // System.exit(2); // dont be as harsh right here - there will be plenty of exceptions later in the bad case...
} }
} }
/**
* An eloquent error message in case a resource was not found - which was
* expected in the EvA2 resource directory.
* @param resourceName
* @return
*/
public static String resourceNotFoundErrorMessage(String resourceName) {
String cp = System.getProperty("java.class.path");
return "Could not find " + resourceName +
"\nPlease make resources folder available on the class path! " +
"Current class path is: " + cp +
"\nYou may copy it there or add the parent folder of resources/ to the class path.";
}
public static String getProperty(String key) { public static String getProperty(String key) {
String myVal = EVA_PROPERTIES.getProperty(key); String myVal = EVA_PROPERTIES.getProperty(key);
return myVal; return myVal;

View File

@ -282,12 +282,8 @@ public class EvAClient implements RemoteStateListener, Serializable {
if (withGUI ) { if (withGUI ) {
m_Frame = new JEFrame(EvAInfo.productName + " workbench"); m_Frame = new JEFrame(EvAInfo.productName + " workbench");
BasicResourceLoader loader = BasicResourceLoader.instance(); BasicResourceLoader loader = BasicResourceLoader.instance();
byte[] bytes = loader.getBytesFromResourceLocation(EvAInfo.iconLocation); byte[] bytes = loader.getBytesFromResourceLocation(EvAInfo.iconLocation, true);
try { m_Frame.setIconImage(Toolkit.getDefaultToolkit().createImage(bytes));
m_Frame.setIconImage(Toolkit.getDefaultToolkit().createImage(bytes));
} catch (java.lang.NullPointerException e) {
System.err.println("Could not find EvA2 icon, please move resources folder to working directory!");
}
// m_Frame.setTitle(EvAInfo.productName + " workbench"); // m_Frame.setTitle(EvAInfo.productName + " workbench");
try { try {
@ -986,18 +982,14 @@ class SplashScreen extends Frame {
public void splash(){ public void splash(){
JWindow splashWindow = new JWindow(this); JWindow splashWindow = new JWindow(this);
BasicResourceLoader loader = BasicResourceLoader.instance(); BasicResourceLoader loader = BasicResourceLoader.instance();
byte[] bytes = loader.getBytesFromResourceLocation(imgLocation); byte[] bytes = loader.getBytesFromResourceLocation(imgLocation, true);
try { 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); splashWindow.add(splashLabel);
splashWindow.add(splashLabel); splashWindow.pack();
splashWindow.pack(); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); splashWindow.setLocation(screenSize.width / 2 - splashWindow.getSize().width / 2, screenSize.height / 2 - splashWindow.getSize().height / 2);
splashWindow.setLocation(screenSize.width / 2 - splashWindow.getSize().width / 2, screenSize.height / 2 - splashWindow.getSize().height / 2); splashWindow.setVisible(true);
splashWindow.setVisible(true);
} catch (java.lang.NullPointerException e) {
System.err.println("Could not find EvA2 splash screen, please move resources folder to working directory!");
}
} }
} }

View File

@ -174,13 +174,8 @@ public class GenericOptimizationObjectivesEditor extends JPanel implements Prope
gbc.fill = GridBagConstraints.REMAINDER; gbc.fill = GridBagConstraints.REMAINDER;
gbc.gridx = 1; gbc.gridx = 1;
gbc.weightx = 1; gbc.weightx = 1;
bytes = loader.getBytesFromResourceLocation("resources/images/Sub24.gif"); bytes = loader.getBytesFromResourceLocation("resources/images/Sub24.gif", true);
try { this.m_Delete[i] = new JButton("", new ImageIcon(Toolkit.getDefaultToolkit().createImage(bytes)));
this.m_Delete[i] = new JButton("", new ImageIcon(Toolkit.getDefaultToolkit().createImage(bytes)));
} catch (java.lang.NullPointerException e) {
System.out.println("Could not find Sub24 icon, please move resources folder to working directory!");
this.m_Delete[i] = new JButton("Sub");
}
this.m_Delete[i].addActionListener(deleteTarget); this.m_Delete[i].addActionListener(deleteTarget);
this.m_TargetList.add(this.m_Delete[i], gbc); this.m_TargetList.add(this.m_Delete[i], gbc);
} }

View File

@ -198,13 +198,8 @@ public class GenericOptimizationObjectivesWithParamEditor extends JPanel impleme
gbc.fill = GridBagConstraints.REMAINDER; gbc.fill = GridBagConstraints.REMAINDER;
gbc.gridx = 2; gbc.gridx = 2;
gbc.weightx = 1; gbc.weightx = 1;
bytes = loader.getBytesFromResourceLocation("resources/images/Sub24.gif"); bytes = loader.getBytesFromResourceLocation("resources/images/Sub24.gif", true);
try { this.m_Delete[i] = new JButton("", new ImageIcon(Toolkit.getDefaultToolkit().createImage(bytes)));
this.m_Delete[i] = new JButton("", new ImageIcon(Toolkit.getDefaultToolkit().createImage(bytes)));
} catch (java.lang.NullPointerException e) {
System.out.println("Could not find Sub24 icon, please move resources folder to working directory!");
this.m_Delete[i] = new JButton("Sub");
}
this.m_Delete[i].addActionListener(deleteTarget); this.m_Delete[i].addActionListener(deleteTarget);
this.m_TargetList.add(this.m_Delete[i], gbc); this.m_TargetList.add(this.m_Delete[i], gbc);
} }

View File

@ -111,13 +111,9 @@ public class GenericRemoteServersEditor extends JPanel implements PropertyEditor
private JButton makeButtonWith(String iconSrc, String title) { private JButton makeButtonWith(String iconSrc, String title) {
JButton tmpB; JButton tmpB;
byte[] bytes; byte[] bytes;
bytes = BasicResourceLoader.instance().getBytesFromResourceLocation(iconSrc); bytes = BasicResourceLoader.instance().getBytesFromResourceLocation(iconSrc, false);
try { if (bytes!=null) tmpB = new JButton(title, new ImageIcon(Toolkit.getDefaultToolkit().createImage(bytes)));
tmpB = new JButton(title, new ImageIcon(Toolkit.getDefaultToolkit().createImage(bytes))); else tmpB = new JButton(title);
} catch (java.lang.NullPointerException e) {
System.err.println("Could not find icon " + iconSrc + ", please move resources folder to working directory!");
tmpB = new JButton(title);
}
return tmpB; return tmpB;
} }
@ -172,7 +168,7 @@ public class GenericRemoteServersEditor extends JPanel implements PropertyEditor
this.m_ServerList.add(this.m_CPUs[i], gbc); this.m_ServerList.add(this.m_CPUs[i], gbc);
// The delete button // The delete button
setGBC(gbc, GridBagConstraints.WEST, GridBagConstraints.REMAINDER, 3, 10); setGBC(gbc, GridBagConstraints.WEST, GridBagConstraints.REMAINDER, 3, 10);
bytes = BasicResourceLoader.instance().getBytesFromResourceLocation("resources/images/Sub24.gif"); bytes = BasicResourceLoader.instance().getBytesFromResourceLocation("resources/images/Sub24.gif", true);
this.m_Delete[i] = new JButton("", new ImageIcon(Toolkit.getDefaultToolkit().createImage(bytes))); this.m_Delete[i] = new JButton("", new ImageIcon(Toolkit.getDefaultToolkit().createImage(bytes)));
this.m_Delete[i].addActionListener(deleteServer); this.m_Delete[i].addActionListener(deleteServer);
this.m_ServerList.add(this.m_Delete[i], gbc); this.m_ServerList.add(this.m_Delete[i], gbc);

View File

@ -94,12 +94,8 @@ public class HtmlDemo {
} }
JFrame frame = new JFrame (m_name); JFrame frame = new JFrame (m_name);
BasicResourceLoader loader = BasicResourceLoader.instance(); BasicResourceLoader loader = BasicResourceLoader.instance();
byte[] bytes = loader.getBytesFromResourceLocation(EvAInfo.iconLocation); byte[] bytes = loader.getBytesFromResourceLocation(EvAInfo.iconLocation, true);
try { frame.setIconImage(Toolkit.getDefaultToolkit().createImage(bytes));
frame.setIconImage(Toolkit.getDefaultToolkit().createImage(bytes));
} catch (java.lang.NullPointerException e) {
System.err.println("Could not find EvA2 icon, please move resources folder to working directory!");
}
JScrollPane scroller = new JScrollPane(); JScrollPane scroller = new JScrollPane();
JViewport vp = scroller.getViewport(); JViewport vp = scroller.getViewport();
vp.add(m_html); vp.add(m_html);

View File

@ -107,12 +107,9 @@ Serializable {
m_TextArea.setCaretPosition(0); m_TextArea.setCaretPosition(0);
BasicResourceLoader loader = BasicResourceLoader.instance(); BasicResourceLoader loader = BasicResourceLoader.instance();
byte[] bytes = loader.getBytesFromResourceLocation(EvAInfo.iconLocation); byte[] bytes = loader.getBytesFromResourceLocation(EvAInfo.iconLocation, true);
try { frame.setIconImage(Toolkit.getDefaultToolkit().createImage(bytes));
frame.setIconImage(Toolkit.getDefaultToolkit().createImage(bytes));
} catch (java.lang.NullPointerException e) {
System.out.println("Could not find EvA2 icon, please move resources folder to working directory!");
}
frame.addWindowListener(new WindowAdapter() { frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) { public void windowClosing(WindowEvent e) {
frame.dispose(); frame.dispose();

View File

@ -105,12 +105,8 @@ public class LogPanel extends JPanel {
final JFrame frame = new JFrame("Log_Panel_Test"); final JFrame frame = new JFrame("Log_Panel_Test");
frame.getContentPane().setLayout(new BorderLayout()); frame.getContentPane().setLayout(new BorderLayout());
BasicResourceLoader loader = BasicResourceLoader.instance(); BasicResourceLoader loader = BasicResourceLoader.instance();
byte[] bytes = loader.getBytesFromResourceLocation(EvAInfo.iconLocation); byte[] bytes = loader.getBytesFromResourceLocation(EvAInfo.iconLocation, true);
try { frame.setIconImage(Toolkit.getDefaultToolkit().createImage(bytes));
frame.setIconImage(Toolkit.getDefaultToolkit().createImage(bytes));
} catch (java.lang.NullPointerException e) {
System.out.println("Could not find EvA2 icon, please move resources folder to working directory!");
}
LogPanel panel = new LogPanel(); LogPanel panel = new LogPanel();
frame.getContentPane().add(panel, BorderLayout.CENTER); frame.getContentPane().add(panel, BorderLayout.CENTER);
frame.addWindowListener(new WindowAdapter() { frame.addWindowListener(new WindowAdapter() {

View File

@ -221,16 +221,8 @@ public class Plot implements PlotInterface, Serializable {
public void init() { public void init() {
m_Frame = new JEFrame("Plot: " + m_PlotName); m_Frame = new JEFrame("Plot: " + m_PlotName);
BasicResourceLoader loader = BasicResourceLoader.instance(); BasicResourceLoader loader = BasicResourceLoader.instance();
byte[] bytes = loader byte[] bytes = loader.getBytesFromResourceLocation(EvAInfo.iconLocation, true);
.getBytesFromResourceLocation(EvAInfo.iconLocation); m_Frame.setIconImage(Toolkit.getDefaultToolkit().createImage(bytes));
try {
m_Frame
.setIconImage(Toolkit.getDefaultToolkit()
.createImage(bytes));
} catch (java.lang.NullPointerException e) {
System.err
.println("Could not find EvA2 icon, please move resources folder to working directory!");
}
m_ButtonPanel = new JPanel(); m_ButtonPanel = new JPanel();
m_PlotArea = new FunctionArea(m_xname, m_yname); m_PlotArea = new FunctionArea(m_xname, m_yname);

View File

@ -35,12 +35,9 @@ public class PropertyDialog extends JEFrame {
public PropertyDialog (PropertyEditor editor,String Title, int x, int y) { public PropertyDialog (PropertyEditor editor,String Title, int x, int y) {
super(getFrameNameFromEditor(editor)); // that was the long class name !! super(getFrameNameFromEditor(editor)); // that was the long class name !!
BasicResourceLoader loader = BasicResourceLoader.instance(); BasicResourceLoader loader = BasicResourceLoader.instance();
byte[] bytes = loader.getBytesFromResourceLocation(EvAInfo.iconLocation); byte[] bytes = loader.getBytesFromResourceLocation(EvAInfo.iconLocation, true);
try { setIconImage(Toolkit.getDefaultToolkit().createImage(bytes));
setIconImage(Toolkit.getDefaultToolkit().createImage(bytes));
} catch (java.lang.NullPointerException e) {
System.err.println("Could not find EvA2 icon, please move resources folder to working directory!");
}
//System.out.println("PropertyDialog.Constructor of "+ Title); //System.out.println("PropertyDialog.Constructor of "+ Title);
setDefaultCloseOperation(DISPOSE_ON_CLOSE); setDefaultCloseOperation(DISPOSE_ON_CLOSE);
getContentPane().setLayout(new BorderLayout()); getContentPane().setLayout(new BorderLayout());

View File

@ -126,12 +126,8 @@ public class TagEditor extends PropertyEditorSupport {
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.instance();
byte[] bytes = loader.getBytesFromResourceLocation(EvAInfo.iconLocation); byte[] bytes = loader.getBytesFromResourceLocation(EvAInfo.iconLocation, true);
try { f.setIconImage(Toolkit.getDefaultToolkit().createImage(bytes));
f.setIconImage(Toolkit.getDefaultToolkit().createImage(bytes));
} catch (java.lang.NullPointerException e) {
System.out.println("Could not find EvA2 icon, please move resources folder to working directory!");
}
f.addWindowListener(new WindowAdapter() { f.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) { public void windowClosing(WindowEvent e) {
System.exit(0); System.exit(0);

View File

@ -34,136 +34,111 @@ public class MOCCOChooseMOStrategy extends MOCCOPhase implements InterfaceProces
/** This method will call the init method and will go to stall /** This method will call the init method and will go to stall
*/ */
public void initProcessElementParametrization() { public void initProcessElementParametrization() {
this.m_Mocco.m_JPanelControl.removeAll(); this.m_Mocco.m_JPanelControl.removeAll();
this.m_Mocco.m_JPanelParameters.removeAll(); this.m_Mocco.m_JPanelParameters.removeAll();
this.m_Mocco.m_JPanelParameters.setLayout(new BorderLayout()); this.m_Mocco.m_JPanelParameters.setLayout(new BorderLayout());
// The button panel // The button panel
// the parameter panel // the parameter panel
this.m_Mocco.m_JPanelParameters.add(this.makeHelpText("Please choose a multi-objective" + this.m_Mocco.m_JPanelParameters.add(this.makeHelpText("Please choose a multi-objective" +
" optimization strategy for the next optimization iteration. The different optimization approaches" + " optimization strategy for the next optimization iteration. The different optimization approaches" +
" not only differ in the number of soltuion alternatives generated (more soltuions typicall require" + " not only differ in the number of soltuion alternatives generated (more soltuions typicall require" +
" higher computational effort), but also in the amount of input required by the decision maker (DM)."), BorderLayout.NORTH); " higher computational effort), but also in the amount of input required by the decision maker (DM)."), BorderLayout.NORTH);
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.instance();
byte[] bytes; byte[] bytes;
GridBagConstraints gbc = new GridBagConstraints(); GridBagConstraints gbc = new GridBagConstraints();
gbc.anchor = GridBagConstraints.WEST; gbc.anchor = GridBagConstraints.WEST;
gbc.fill = GridBagConstraints.BOTH; gbc.fill = GridBagConstraints.BOTH;
gbc.weightx = 100; gbc.weightx = 100;
tmpB = new JButton(); tmpB = new JButton();
try { bytes = loader.getBytesFromResourceLocation("resources/MOCCO/MOCCO_MOEA.gif", true);
bytes = loader.getBytesFromResourceLocation("resources/MOCCO/MOCCO_MOEA.gif"); tmpB.setIcon(new ImageIcon(Toolkit.getDefaultToolkit().createImage(bytes)));
tmpB.setIcon(new ImageIcon(Toolkit.getDefaultToolkit().createImage(bytes))); tmpB.setBackground(Color.WHITE);
tmpB.setBackground(Color.WHITE); gbc.gridy = 0;
} catch (java.lang.NullPointerException e) { gbc.gridx = 0;
System.out.println("Could not find MOCCO_MOEA icon, please move resources folder to working directory!"); tmpP.add(tmpB, gbc);
tmpB.setText("Multi-Objective EA"); tmpB.setEnabled(true);
} tmpB.addActionListener(choosenMOEA);
gbc.gridy = 0; gbc.gridy = 0;
gbc.gridx = 0; gbc.gridx = 1;
tmpP.add(tmpB, gbc); tmpP.add(this.makeInformationText("Multi-Objective Evolutionary Algorithm", "The MOEA is the" +
tmpB.setEnabled(true); " only optimization strategy, which returns an approximated Pareto set in a single run." +
tmpB.addActionListener(choosenMOEA); " Please note that with increasing number of objectives the selection pressure for" +
gbc.gridy = 0; " the evolutionary algorithm decreases significantly in case of multi-objective" +
gbc.gridx = 1; " optimization. Therefore the MOEA should only be applied in case of less than ten" +
tmpP.add(this.makeInformationText("Multi-Objective Evolutionary Algorithm", "The MOEA is the" + " objectives."), gbc);
" only optimization strategy, which returns an approximated Pareto set in a single run." +
" Please note that with increasing number of objectives the selection pressure for" +
" the evolutionary algorithm decreases significantly in case of multi-objective" +
" optimization. Therefore the MOEA should only be applied in case of less than ten" +
" objectives."), gbc);
tmpB = new JButton(); tmpB = new JButton();
try { bytes = loader.getBytesFromResourceLocation("resources/MOCCO/MOCCO_GDF.gif", true);
bytes = loader.getBytesFromResourceLocation("resources/MOCCO/MOCCO_GDF.gif"); tmpB.setIcon(new ImageIcon(Toolkit.getDefaultToolkit().createImage(bytes)));
tmpB.setIcon(new ImageIcon(Toolkit.getDefaultToolkit().createImage(bytes))); tmpB.setBackground(Color.WHITE);
tmpB.setBackground(Color.WHITE); gbc.gridy = 1;
} catch (java.lang.NullPointerException e) { gbc.gridx = 0;
System.out.println("Could not find MOCCO_GDF icon, please move resources folder to working directory!"); tmpP.add(tmpB, gbc);
tmpB.setText("Geoffrion-Dyer-Feinberg Meth."); tmpB.setEnabled(true);
} tmpB.addActionListener(choosenGDF);
gbc.gridy = 1; gbc.gridy = 1;
gbc.gridx = 0; gbc.gridx = 1;
tmpP.add(tmpB, gbc); tmpP.add(this.makeInformationText("Geoffrion-Dyer-Feinberg Method", "Here the DM needs to select a reference solution" +
tmpB.setEnabled(true); " from the currently known solution. For this solution the DM has to specify trade-off values for each" +
tmpB.addActionListener(choosenGDF); " objective. This method assumes a linear utility function by results in a simple weighted aggregation."), gbc);
gbc.gridy = 1; this.m_Mocco.m_JPanelParameters.add(tmpP, BorderLayout.CENTER);
gbc.gridx = 1;
tmpP.add(this.makeInformationText("Geoffrion-Dyer-Feinberg Method", "Here the DM needs to select a reference solution" +
" from the currently known solution. For this solution the DM has to specify trade-off values for each" +
" objective. This method assumes a linear utility function by results in a simple weighted aggregation."), gbc);
this.m_Mocco.m_JPanelParameters.add(tmpP, BorderLayout.CENTER);
tmpB = new JButton(); tmpB = new JButton();
try { bytes = loader.getBytesFromResourceLocation("resources/MOCCO/MOCCO_STEP.gif", true);
bytes = loader.getBytesFromResourceLocation("resources/MOCCO/MOCCO_STEP.gif"); tmpB.setIcon(new ImageIcon(Toolkit.getDefaultToolkit().createImage(bytes)));
tmpB.setIcon(new ImageIcon(Toolkit.getDefaultToolkit().createImage(bytes))); tmpB.setBackground(Color.WHITE);
tmpB.setBackground(Color.WHITE); gbc.gridy = 2;
} catch (java.lang.NullPointerException e) { gbc.gridx = 0;
System.out.println("Could not find MOCCO_STEP icon, please move resources folder to working directory!"); tmpP.add(tmpB, gbc);
tmpB.setText("STEP Method"); tmpB.setEnabled(true);
} tmpB.addActionListener(choosenSTEP);
gbc.gridy = 2; gbc.gridy = 2;
gbc.gridx = 0; gbc.gridx = 1;
tmpP.add(tmpB, gbc); tmpP.add(this.makeInformationText("STEP Method", "The STEP method requires the DM to select a" +
tmpB.setEnabled(true); " reference solution from the current solution set. For this solution the obtained objective values are to" +
tmpB.addActionListener(choosenSTEP); " be classified by the DM into satisfactory and unsatisfactory ones. The satifactory ones" +
gbc.gridy = 2; " are treaded as constraints, while the unsatisfactory objectives are weight aggregated" +
gbc.gridx = 1; " into a single objectives. The individual weights are also to be given by the DM."), gbc);
tmpP.add(this.makeInformationText("STEP Method", "The STEP method requires the DM to select a" +
" reference solution from the current solution set. For this solution the obtained objective values are to" +
" be classified by the DM into satisfactory and unsatisfactory ones. The satifactory ones" +
" are treaded as constraints, while the unsatisfactory objectives are weight aggregated" +
" into a single objectives. The individual weights are also to be given by the DM."), gbc);
tmpB = new JButton(); tmpB = new JButton();
try { bytes = loader.getBytesFromResourceLocation("resources/MOCCO/MOCCO_REFP.gif", true);
bytes = loader.getBytesFromResourceLocation("resources/MOCCO/MOCCO_REFP.gif"); tmpB.setIcon(new ImageIcon(Toolkit.getDefaultToolkit().createImage(bytes)));
tmpB.setIcon(new ImageIcon(Toolkit.getDefaultToolkit().createImage(bytes))); tmpB.setBackground(Color.WHITE);
tmpB.setBackground(Color.WHITE); gbc.gridy = 3;
} catch (java.lang.NullPointerException e) { gbc.gridx = 0;
System.out.println("Could not find MOCCO_REFP icon, please move resources folder to working directory!"); tmpP.add(tmpB, gbc);
tmpB.setText("Reference Point Method"); tmpB.setEnabled(true);
} tmpB.addActionListener(choosenREFP);
gbc.gridy = 3; gbc.gridy = 3;
gbc.gridx = 0; gbc.gridx = 1;
tmpP.add(tmpB, gbc); tmpP.add(this.makeInformationText("Reference Point Method", "Here the DM chooses a reference point of" +
tmpB.setEnabled(true); " aspiration levels (unattainable values are allowed). The optimizier tries to minimze the L-metric (<Inf)" +
tmpB.addActionListener(choosenREFP); " to that reference point. To increase the number of solution alternatives this method can try to" +
gbc.gridy = 3; " minimize the distance to multiple alternative/perturbated versions of the reference point at the" +
gbc.gridx = 1; " same time."), gbc);
tmpP.add(this.makeInformationText("Reference Point Method", "Here the DM chooses a reference point of" +
" aspiration levels (unattainable values are allowed). The optimizier tries to minimze the L-metric (<Inf)" +
" to that reference point. To increase the number of solution alternatives this method can try to" +
" minimize the distance to multiple alternative/perturbated versions of the reference point at the" +
" same time."), gbc);
tmpB = new JButton(); tmpB = new JButton();
try { bytes = loader.getBytesFromResourceLocation("resources/MOCCO/MOCCO_TBCH.gif", true);
bytes = loader.getBytesFromResourceLocation("resources/MOCCO/MOCCO_TBCH.gif"); tmpB.setIcon(new ImageIcon(Toolkit.getDefaultToolkit().createImage(bytes)));
tmpB.setIcon(new ImageIcon(Toolkit.getDefaultToolkit().createImage(bytes))); tmpB.setBackground(Color.WHITE);
tmpB.setBackground(Color.WHITE); gbc.gridy = 4;
} catch (java.lang.NullPointerException e) { gbc.gridx = 0;
System.out.println("Could not find MOCCO_TBCH icon, please move resources folder to working directory!"); tmpB.addActionListener(choosenTBCH);
tmpB.setText("Tchebycheff Method"); tmpB.setEnabled(true);
} tmpP.add(tmpB, gbc);
gbc.gridy = 4; gbc.gridy = 4;
gbc.gridx = 0; gbc.gridx = 1;
tmpB.addActionListener(choosenTBCH); tmpP.add(this.makeInformationText("Tchebycheff Method", "This method also requires a possibly unatainable" +
tmpB.setEnabled(true); " reference point and tries to minimze the L-metric (=Inf). To obtain multiple alternative soltuions" +
tmpP.add(tmpB, gbc); " a weighted L-metric is used with different weigths for a number of optimization runs."), gbc);
gbc.gridy = 4;
gbc.gridx = 1;
tmpP.add(this.makeInformationText("Tchebycheff Method", "This method also requires a possibly unatainable" +
" reference point and tries to minimze the L-metric (=Inf). To obtain multiple alternative soltuions" +
" a weighted L-metric is used with different weigths for a number of optimization runs."), gbc);
this.m_Mocco.m_JPanelParameters.validate(); this.m_Mocco.m_JPanelParameters.validate();
this.m_Mocco.m_JPanelControl.validate(); this.m_Mocco.m_JPanelControl.validate();
} }
/** This method returns the choosen strategy /** This method returns the choosen strategy

View File

@ -50,32 +50,6 @@ public abstract class MOCCOPhase implements InterfaceProcessElement {
} }
}; };
// /** Fetch the alternatives for a given class
// * @param type The class to test
// * @return The class alternatives
// */
// public Vector getClassAlternatives4(String type) {
// String typeOptions = EvAClient.getProperty(type);
// Vector classes = new Vector();
// StringTokenizer st = new StringTokenizer(typeOptions, ", ");
// while (st.hasMoreTokens()) {
// String current = st.nextToken().trim();
// try {
// try {
// Class c = Class.forName(current);
// classes.addElement(current);
// } catch (java.lang.ClassNotFoundException et) {
// System.out.println("Could not find class for value " + current + " for type " + type);
// }
// } catch (Exception ex) {
// System.out.println("Couldn't load class with name: " + current + " for type " + type);
// System.out.println("ex:"+ex.getMessage());
// ex.printStackTrace();
// }
// }
// return classes;
// }
/** This method makes a helptext element similar to that used in EvA /** This method makes a helptext element similar to that used in EvA
* @param help The text to display * @param help The text to display
* @return the helptext component * @return the helptext component

View File

@ -201,13 +201,8 @@ public class PropertyCrossoverMixerEditor extends JPanel implements PropertyEdit
gbc.fill = GridBagConstraints.REMAINDER; gbc.fill = GridBagConstraints.REMAINDER;
gbc.gridx = 2; gbc.gridx = 2;
gbc.weightx = 1; gbc.weightx = 1;
bytes = loader.getBytesFromResourceLocation("resources/images/Sub24.gif"); bytes = loader.getBytesFromResourceLocation("resources/images/Sub24.gif", true);
try { this.m_Delete[i] = new JButton("", new ImageIcon(Toolkit.getDefaultToolkit().createImage(bytes)));
this.m_Delete[i] = new JButton("", new ImageIcon(Toolkit.getDefaultToolkit().createImage(bytes)));
} catch (java.lang.NullPointerException e) {
System.out.println("Could not find sub24 icon, please move resources folder to working directory!");
this.m_Delete[i] = new JButton("Sub");
}
this.m_Delete[i].addActionListener(deleteTarget); this.m_Delete[i].addActionListener(deleteTarget);
this.m_TargetList.add(this.m_Delete[i], gbc); this.m_TargetList.add(this.m_Delete[i], gbc);
} }

View File

@ -176,13 +176,8 @@ public class PropertyMutationMixerEditor extends JPanel implements PropertyEdito
gbc.fill = GridBagConstraints.REMAINDER; gbc.fill = GridBagConstraints.REMAINDER;
gbc.gridx = 2; gbc.gridx = 2;
gbc.weightx = 1; gbc.weightx = 1;
bytes = loader.getBytesFromResourceLocation("resources/images/Sub24.gif"); bytes = loader.getBytesFromResourceLocation("resources/images/Sub24.gif", true);
try { this.m_Delete[i] = new JButton("", new ImageIcon(Toolkit.getDefaultToolkit().createImage(bytes)));
this.m_Delete[i] = new JButton("", new ImageIcon(Toolkit.getDefaultToolkit().createImage(bytes)));
} catch (java.lang.NullPointerException e) {
System.out.println("Could not find sub24 icon, please move resources folder to working directory!");
this.m_Delete[i] = new JButton("Sub");
}
this.m_Delete[i].addActionListener(deleteTarget); this.m_Delete[i].addActionListener(deleteTarget);
this.m_TargetList.add(this.m_Delete[i], gbc); this.m_TargetList.add(this.m_Delete[i], gbc);
} }

View File

@ -37,17 +37,17 @@ 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.instance();
byte bytes[] = loader.getBytesFromResourceLocation(file); byte bytes[] = loader.getBytesFromResourceLocation(file, false);
if (bytes != null) { if (bytes != null) {
String data = new String(bytes); String data = new String(bytes);
result = data.split("\n"); result = data.split("\n");
} else { } else {
System.out.println("BasicResourceLoader failed to read "+file); System.err.println("BasicResourceLoader failed to read "+file);
BufferedReader reader= null; BufferedReader reader= null;
try { try {
reader = new BufferedReader(new FileReader(file)); reader = new BufferedReader(new FileReader(file));
} catch (java.io.FileNotFoundException e) { } catch (java.io.FileNotFoundException e) {
System.out.println("Could not find " + file); System.err.println("Could not find " + file);
return result; return result;
} }
String currentLine; String currentLine;
@ -63,7 +63,7 @@ public class FileTools {
} }
reader.close(); reader.close();
} catch (java.io.IOException e) { } catch (java.io.IOException e) {
System.out.println("Java.io.IOExeption: " + e.getMessage()); System.err.println("Java.io.IOExeption: " + e.getMessage());
} }
} }
return result; return result;

View File

@ -43,6 +43,8 @@ import java.util.zip.ZipEntry;
import java.util.zip.ZipFile; import java.util.zip.ZipFile;
import java.util.zip.ZipInputStream; import java.util.zip.ZipInputStream;
import eva2.EvAInfo;
/** /**
* Loads resource file from directory OR jar file. Now it is easier possible to * Loads resource file from directory OR jar file. Now it is easier possible to
@ -117,13 +119,13 @@ public class BasicResourceLoader implements ResourceLoader
} }
/** /**
* Description of the Method * Read String lines from a file into a list.
* *
* @param resourceFile Description of the Parameter * @param resourceFile File to read
* @param ignorePrefix array of prefixes which mark a line to be ignored * @param ignorePrefix array of prefixes which mark a line to be ignored
* @param lOffset offset of the first line to read * @param lOffset offset of the first line to read
* @param lCnt number of lines to read, if <= 0, all lines are read * @param lCnt number of lines to read, if <= 0, all lines are read
* @return Description of the Return Value * @return List of lines which were read or null on an error
*/ */
public static List<String> readLines(String resourceFile, public static List<String> readLines(String resourceFile,
String[] ignorePrefix, int lOffset, int lCnt) String[] ignorePrefix, int lOffset, int lCnt)
@ -135,7 +137,7 @@ public class BasicResourceLoader implements ResourceLoader
byte[] bytes = BasicResourceLoader.instance() byte[] bytes = BasicResourceLoader.instance()
.getBytesFromResourceLocation( .getBytesFromResourceLocation(
resourceFile); resourceFile, false);
if (bytes == null) if (bytes == null)
{ {
@ -382,21 +384,34 @@ public class BasicResourceLoader implements ResourceLoader
// } // }
// return getStreamFromFile(found.get(0)); // return getStreamFromFile(found.get(0));
// } // }
/** /**
* Gets the byte data from a file at the given resource location. * Gets the byte data from a file at the given resource location.
* *
* @param rawResrcLoc Description of the Parameter * @param rawResrcLoc Description of the Parameter
* @return the byte array of file. * @return the byte array of file.
*/ */
public byte[] getBytesFromResourceLocation(String rawResrcLoc) public byte[] getBytesFromResourceLocation(String rawResrcLoc) {
return getBytesFromResourceLocation(rawResrcLoc, false);
}
/**
* Gets the byte data from a file at the given resource location.
*
* @param rawResrcLoc Location of the resource
* @param exceptionOnNotFound if true, a RuntimeException is thrown if the resource was not found.
* @return the byte array of file.
*/
public byte[] getBytesFromResourceLocation(String rawResrcLoc, boolean exceptionOnNotFound)
{ {
InputStream in = getStreamFromResourceLocation(rawResrcLoc); InputStream in = getStreamFromResourceLocation(rawResrcLoc);
byte[] arr = null;
if (in == null) { if (in != null) {
return null; arr = getBytesFromStream(in);
} }
return getBytesFromStream(in); if (exceptionOnNotFound && (arr==null)) {
throw new RuntimeException(EvAInfo.resourceNotFoundErrorMessage(rawResrcLoc));
}
return arr;
} }
/** /**
@ -621,7 +636,7 @@ public class BasicResourceLoader implements ResourceLoader
Properties prop = new Properties(); Properties prop = new Properties();
BasicResourceLoader loader = BasicResourceLoader.instance(); BasicResourceLoader loader = BasicResourceLoader.instance();
byte bytes[] = loader.getBytesFromResourceLocation(resourceName); byte bytes[] = loader.getBytesFromResourceLocation(resourceName, false);
if (bytes != null) { if (bytes != null) {
ByteArrayInputStream bais = new ByteArrayInputStream(bytes); ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
prop.load(bais); prop.load(bais);

View File

@ -12,12 +12,9 @@ package eva2.tools;
/*==========================================================================* /*==========================================================================*
* IMPORTS * IMPORTS
*==========================================================================*/ *==========================================================================*/
import java.io.BufferedOutputStream;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.BufferedWriter; import java.io.BufferedWriter;
import java.io.ByteArrayInputStream;
import java.io.File; import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.io.PrintWriter; import java.io.PrintWriter;
@ -25,8 +22,6 @@ import java.net.InetAddress;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.Properties; import java.util.Properties;
import eva2.client.EvAClient;
/** /**
* *
@ -36,38 +31,6 @@ public class EVAHELP {
/** /**
* *
*/ */
/**
*
*/
static public Properties readProperties(String resourceName) throws Exception {
if (EvAClient.TRACE) System.out.println("readProperties of file: " + resourceName);
Properties prop = new Properties();
BasicResourceLoader loader = BasicResourceLoader.instance();
byte bytes[] = loader.getBytesFromResourceLocation(resourceName);
if (bytes != null) {
ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
prop.load(bais);
}
if (prop != null)
return prop;
/////////////
int slInd = resourceName.lastIndexOf('/');
if (slInd != -1)
resourceName = resourceName.substring(slInd + 1);
Properties userProps = new Properties();
File propFile = new File(File.separatorChar + "resources" +
File.separatorChar + resourceName);
if (propFile.exists()) {
try {
userProps.load(new FileInputStream(propFile));
}
catch (Exception ex) {
System.out.println("Problem reading user properties: " + propFile);
}
}
return userProps;
}
/** /**
* *