diff --git a/src/eva2/gui/EvATabbedFrameMaker.java b/src/eva2/gui/EvATabbedFrameMaker.java index 079dc09c..525c6270 100644 --- a/src/eva2/gui/EvATabbedFrameMaker.java +++ b/src/eva2/gui/EvATabbedFrameMaker.java @@ -123,12 +123,12 @@ public class EvATabbedFrameMaker implements Serializable, PanelMaker, InterfaceN } } - public JParaPanel getGOPanel() { + public JParaPanel getOptimizationParametersPanel() { try { JParaPanel sP = (JParaPanel) pmContainer.get(1); return sP; } catch (Exception e) { - System.err.println("Failed to get GO panel from " + this.getClass()); + System.err.println("Failed to get OptimizationParameters panel from " + this.getClass()); } return null; } diff --git a/src/eva2/gui/JParaPanel.java b/src/eva2/gui/JParaPanel.java index cfc136db..b7ca82fe 100644 --- a/src/eva2/gui/JParaPanel.java +++ b/src/eva2/gui/JParaPanel.java @@ -19,9 +19,6 @@ public class JParaPanel implements Serializable, PanelMaker { */ private JPanel tempPanel = new JPanel(); - public JParaPanel() { - } - /** */ public JParaPanel(Object Parameter, String name) { diff --git a/src/eva2/gui/MainFrame.java b/src/eva2/gui/MainFrame.java index 410660a8..6b69862d 100644 --- a/src/eva2/gui/MainFrame.java +++ b/src/eva2/gui/MainFrame.java @@ -12,7 +12,6 @@ import eva2.tools.BasicResourceLoader; import eva2.tools.EVAERROR; import eva2.tools.ReflectPackage; import eva2.util.ClassPreloader; -import eva2.util.EvAComAdapter; import javax.help.HelpSet; import javax.help.JHelpContentViewer; @@ -71,8 +70,6 @@ public class MainFrame extends JFrame implements OptimizationStateListener { private java.util.List superListenerList = null; - private EvAComAdapter comAdapter; - public void addOptimizationStateListener(OptimizationStateListener l) { if (superListenerList == null) { @@ -199,7 +196,6 @@ public class MainFrame extends JFrame implements OptimizationStateListener { } } - this.comAdapter = EvAComAdapter.getInstance(); splashScreenTime = 2500; initRunnable = new Runnable() { @@ -699,8 +695,7 @@ public class MainFrame extends JFrame implements OptimizationStateListener { if (optimizationParameters == null) { params = OptimizationParameters.getInstance(); } - newModuleAdapter = new GOModuleAdapter(selectedModule, params, withGUI ? null : "EvA2"); - //newModuleAdapter = comAdapter.getModuleAdapter(selectedModule, optimizationParameters, withGUI ? null : "EvA2"); + newModuleAdapter = new OptimizationModuleAdapter(selectedModule, params, withGUI ? null : "EvA2"); } catch (Exception e) { LOGGER.log(Level.SEVERE, "Error loading module.", e); EVAERROR.EXIT("Error while comAdapter.GetModuleAdapter Host: " + e.getMessage()); @@ -717,7 +712,6 @@ public class MainFrame extends JFrame implements OptimizationStateListener { System.err.println("adding base dir and trying again..."); System.setProperty("java.class.path", cp + System.getProperty("path.separator") + dir); ReflectPackage.resetDynCP(); - comAdapter.updateLocalMainAdapter(); loadSpecificModule(selectedModule, optimizationParameters); // end recursive call! handle with care! } } else { @@ -736,9 +730,9 @@ public class MainFrame extends JFrame implements OptimizationStateListener { GridBagConstraints gbConstraints = new GridBagConstraints(); /* ToDo: Find a way to properly add the TreeView to the GOPanel */ - if (withTreeView && (newModuleAdapter instanceof AbstractModuleAdapter)) { + if (false && (newModuleAdapter instanceof AbstractModuleAdapter)) { JComponent tree = null; - tree = getEvATreeView(frameMaker.getGOPanel(), "OptimizationParameters", ((AbstractModuleAdapter) newModuleAdapter).getOptimizationParameters()); + tree = getEvATreeView(frameMaker.getOptimizationParametersPanel(), "OptimizationParameters", ((AbstractModuleAdapter) newModuleAdapter).getOptimizationParameters()); gbConstraints.gridx = 0; gbConstraints.gridy = 0; gbConstraints.fill = GridBagConstraints.BOTH; diff --git a/src/eva2/gui/StandaloneOptimization.java b/src/eva2/gui/StandaloneOptimization.java index af49a158..a0c52a6a 100644 --- a/src/eva2/gui/StandaloneOptimization.java +++ b/src/eva2/gui/StandaloneOptimization.java @@ -149,6 +149,8 @@ public class StandaloneOptimization implements InterfaceStandaloneOptimization, if ((object != null) && (editor != null)) { paraPanel.registerEditor(object, editor); } + + // Tabs this.parameterPanel1 = (paraPanel.makePanel()); this.optionsPanel = new JTabbedPane(); JParaPanel paraPanel2 = new JParaPanel(this.optimizationParameters, "MyGUI"); diff --git a/src/eva2/optimization/EvAMainAdapter.java b/src/eva2/optimization/EvAMainAdapter.java deleted file mode 100644 index 8aacf250..00000000 --- a/src/eva2/optimization/EvAMainAdapter.java +++ /dev/null @@ -1,25 +0,0 @@ -package eva2.optimization; -/** - * Title: EvA2 - * Description: API for distributed and parallel computing. - * Copyright: Copyright (c) 2004 - * Company: University of Tuebingen - * @version: $Revision: 259 $ - * $Date: 2007-11-16 17:25:09 +0100 (Fri, 16 Nov 2007) $ - * $Author: mkron $ - */ - -import eva2.optimization.modules.ModuleAdapter; - -/** - * - */ -public interface EvAMainAdapter { - - String[] getModuleNameList(); - // returns the corresponding ModuleAdapter - - ModuleAdapter getModuleAdapter(String selectedModuleName); - - ModuleAdapter getModuleAdapter(String selectedModuleName, InterfaceOptimizationParameters goParams, String noGuiStatsFile); -} diff --git a/src/eva2/optimization/EvAMainAdapterImpl.java b/src/eva2/optimization/EvAMainAdapterImpl.java deleted file mode 100644 index c7fb231e..00000000 --- a/src/eva2/optimization/EvAMainAdapterImpl.java +++ /dev/null @@ -1,43 +0,0 @@ -package eva2.optimization; - -/** - * Title: The JProxy Framework - * Description: API for distributed and parallel computing. - * Copyright: Copyright (c) 2004 - * Company: University of Tuebingen - * @version: $Revision: 315 $ - * $Date: 2007-12-04 15:23:57 +0100 (Tue, 04 Dec 2007) $ - * $Author: mkron $ - */ - -import eva2.EvAInfo; -import eva2.optimization.modules.ModuleAdapter; - -/** - * - */ -public class EvAMainAdapterImpl implements EvAMainAdapter { - - private ModuleServer moduleServer = null; - - public EvAMainAdapterImpl() { - super(); - moduleServer = new ModuleServer(EvAInfo.getProperties()); - } - - @Override - public String[] getModuleNameList() { - return moduleServer.getModuleNameList(); - } - - @Override - public ModuleAdapter getModuleAdapter(String selectedModule) { - return getModuleAdapter(selectedModule); - } - - @Override - public ModuleAdapter getModuleAdapter(String selectedModule, InterfaceOptimizationParameters goParams, String noGuiStatsFile) { - return moduleServer.createModuleAdapter(selectedModule, goParams, noGuiStatsFile); - } -} - diff --git a/src/eva2/optimization/ModuleServer.java b/src/eva2/optimization/ModuleServer.java deleted file mode 100644 index fdc6c597..00000000 --- a/src/eva2/optimization/ModuleServer.java +++ /dev/null @@ -1,162 +0,0 @@ -package eva2.optimization; - -import eva2.optimization.modules.ModuleAdapter; -import eva2.tools.EVAERROR; -import eva2.tools.ReflectPackage; - -import java.lang.reflect.Constructor; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.List; -import java.util.Properties; -import java.util.logging.Level; -import java.util.logging.Logger; - -/** - * Collect available ModuleAdapter implementations and load them on request. - */ -public final class ModuleServer { - - private static final Logger LOGGER = Logger.getLogger(ModuleServer.class.getName()); - private static int instanceCounter = 0; - private List> moduleClassList; - private ModuleAdapter moduleAdapter; - private int moduleAdapterCounter = 0; - - /** - * - * @param EvAProps - */ - public ModuleServer(Properties EvAProps) { - if (instanceCounter > 0) { - EVAERROR.EXIT("ModuleServer created twice"); - } - moduleClassList = new ArrayList<>(); - - String modulePckg = null; - Class filterBy = null; - try { - /* Fetch the name of the package containing the modules */ - modulePckg = EvAProps.getProperty("ModulePackage"); - /* Fetch the the super class for all modules */ - filterBy = Class.forName(EvAProps.getProperty("ModuleFilterClass")); - } catch (Exception ex) { - System.err.println("Creating ModuleServer failed: couldn't load modules:" + ex.getMessage()); - System.err.println("module path was " + modulePckg + ", is it valid?"); - System.err.println("filter class path was " + ((filterBy == null) ? "null" : filterBy.getName())); - } - - // this gets a list of all valid modules from the package - Class[] classes = ReflectPackage.getAssignableClassesInPackage(modulePckg, filterBy, true, true); - for (Object cls : classes) { - moduleClassList.add((Class) cls); - } - - instanceCounter++; - } - - /** - * Iterates over the list of available modules and fetches the name of the - * module by calling the static getName() method. - * - * @return Array of available modules - */ - public String[] getModuleNameList() { - List moduleNameList = new ArrayList<>(); - for (Class module : moduleClassList) { - try { - Method[] methods = module.getDeclaredMethods(); - for (Method method : methods) { - if (method.getName().equals("getName")) { - String name = (String) method.invoke(null, (Object[]) null); - if (name != null) { - moduleNameList.add(name); - } else { - LOGGER.log(Level.FINE, "Module {0} does not specify a diplayable name.", module.getCanonicalName()); - } - break; - } - } - } catch (Exception ex) { - LOGGER.log(Level.WARNING, "Error while fetching name from module.", ex); - } - - } - - String[] x = new String[moduleNameList.size()]; - moduleNameList.toArray(x); - return x; - } - - /** - * Load the module indicated by the selectedModuleName from all available - * module classes; if necessary through a remote proxy. Try to load a given - * parameter file in case its a GOModuleAdapter. - * - * @param selectedModuleName - * @param optimizationParameters - * @param noGuiLogFile - * @return the loaded module adapter instance - */ - public ModuleAdapter createModuleAdapter(String selectedModuleName, InterfaceOptimizationParameters optimizationParameters, String noGuiLogFile) { - moduleAdapterCounter++; - String adapterName = "ERROR MODULADAPTER !!"; - String moduleName = null; - Method[] methods; - for (Class module : moduleClassList) { - try { - methods = module.getDeclaredMethods(); - - for (Method method : methods) { - if (method.getName().equals("getName")) { - moduleName = (String) method.invoke(null, (Object[]) null); - } - } - } catch (Exception ex) { - LOGGER.log(Level.WARNING, ex.getMessage(), ex); - } - if ((moduleName != null) && (selectedModuleName.equals(moduleName))) { - try { - adapterName = moduleAdapterCounter + "_Running_" + selectedModuleName; - - Constructor[] constructorArr = module.getConstructors(); - /* create a module instance */ - int constrIndex = 0; - - if ((optimizationParameters == null && noGuiLogFile == null)) { - if (optimizationParameters != null) { - System.err.println("Cant set params - no matching constructor found for " + adapterName + " (ModuleServer)"); - } - if (noGuiLogFile != null) { - System.err.println("Cant deactivate GUI - no matching constructor found for " + adapterName + " (ModuleServer)"); - } - Object[] Para = new Object[1]; - while ((constructorArr[constrIndex].getParameterTypes().length != 1) && (constrIndex < constructorArr.length)) { - constrIndex++; - } - Class paramTypes[] = (constructorArr[constrIndex]).getParameterTypes(); - Para[0] = paramTypes[0].cast(adapterName); - moduleAdapter = (ModuleAdapter) constructorArr[constrIndex].newInstance(Para); - } else { - Object[] param = new Object[4]; - param[0] = adapterName; - param[1] = optimizationParameters; - param[2] = noGuiLogFile; - while ((constructorArr[constrIndex].getParameterTypes().length != 4) && (constrIndex < constructorArr.length)) { - constrIndex++; - } - moduleAdapter = (ModuleAdapter) constructorArr[constrIndex].newInstance(param); - } - } catch (Exception ex) { - LOGGER.log(Level.SEVERE, "Error in RMI-Moduladapter initialization", ex); - EVAERROR.EXIT("Error in RMI-Moduladapter initialization: " + ex.getMessage()); - return null; - } - return moduleAdapter; - } - } - - LOGGER.log(Level.SEVERE, "No valid module defined: {0}", selectedModuleName); - return null; - } -} \ No newline at end of file diff --git a/src/eva2/optimization/modules/GOModuleAdapter.java b/src/eva2/optimization/modules/OptimizationModuleAdapter.java similarity index 60% rename from src/eva2/optimization/modules/GOModuleAdapter.java rename to src/eva2/optimization/modules/OptimizationModuleAdapter.java index 36d92949..5b9a9c88 100644 --- a/src/eva2/optimization/modules/GOModuleAdapter.java +++ b/src/eva2/optimization/modules/OptimizationModuleAdapter.java @@ -7,10 +7,10 @@ import java.io.Serializable; /** - * Starts a statistics GUI and the GOProcessor thread. + * Starts a statistics GUI and the Processor thread. */ @SuppressWarnings("unused") -public class GOModuleAdapter extends GenericModuleAdapter implements ModuleAdapter, Serializable { +public class OptimizationModuleAdapter extends GenericModuleAdapter implements ModuleAdapter, Serializable { private static final String moduleName = "Genetic_Optimization"; @@ -22,22 +22,22 @@ public class GOModuleAdapter extends GenericModuleAdapter implements ModuleAdapt } /** - * Starts a statistics GUI and the GOProcessor thread. + * Starts a statistics GUI and the Processor thread. * * @param adapterName the title of the ModuleAdapter */ - public GOModuleAdapter(String adapterName) { + public OptimizationModuleAdapter(String adapterName) { super(adapterName, "", OptimizationParameters.getInstance(), false); } /** - * Starts a statistics GUI and the GOProcessor thread with a given OptimizationParameters file. + * Starts a statistics GUI and the Processor thread with a given OptimizationParameters file. * * @param adapterName the title of the ModuleAdapter * @param optimizationParameters the client instance * @param noGuiLogFile */ - public GOModuleAdapter(String adapterName, InterfaceOptimizationParameters optimizationParameters, String noGuiLogFile) { + public OptimizationModuleAdapter(String adapterName, InterfaceOptimizationParameters optimizationParameters, String noGuiLogFile) { super(adapterName, "", optimizationParameters, false, noGuiLogFile); } } \ No newline at end of file diff --git a/src/eva2/tools/StringTools.java b/src/eva2/tools/StringTools.java index 3abc40d1..5bb9a429 100644 --- a/src/eva2/tools/StringTools.java +++ b/src/eva2/tools/StringTools.java @@ -224,10 +224,11 @@ public final class StringTools { } /** - * Rewrap a given string to lines of approx. length len. + * Re-wrap a given string to lines of approx. length len. * - * @param str - * @param len + * @param str The string + * @param len Line length + * @param tolerancePerCent Tolerance in percent * @return */ public static String wrapLine(String str, int len, double tolerancePerCent) { @@ -235,10 +236,10 @@ public final class StringTools { } /** - * Rewrap a given string to lines of approx. length len. + * Re-wrap a given string to lines of approx. length len. * - * @param str - * @param len + * @param str The string + * @param len Line length * @return */ public static String wrapLine(String str, char[] breakChars, int len, double tolerancePerCent) { @@ -246,7 +247,7 @@ public final class StringTools { String rest = str; int minLen = (int) ((1. - tolerancePerCent) * (double) len); int maxLen = (int) ((1. + tolerancePerCent) * (double) len); - int nextBreak = -1; + int nextBreak; while (rest.length() > 0) { if (rest.length() <= maxLen) { nextBreak = rest.length() - 1; diff --git a/src/eva2/util/EvAComAdapter.java b/src/eva2/util/EvAComAdapter.java deleted file mode 100644 index cf35f191..00000000 --- a/src/eva2/util/EvAComAdapter.java +++ /dev/null @@ -1,71 +0,0 @@ -package eva2.util; - - -import eva2.optimization.EvAMainAdapter; -import eva2.optimization.EvAMainAdapterImpl; -import eva2.optimization.InterfaceOptimizationParameters; -import eva2.optimization.modules.ModuleAdapter; - -import java.util.logging.Logger; - -/** - * - */ -public class EvAComAdapter { - private final static Logger LOGGER = Logger.getLogger(EvAComAdapter.class.getName()); - private EvAMainAdapterImpl localMainAdapter; - private static EvAComAdapter instance; - - /** - * - */ - public static EvAComAdapter getInstance() { - if (instance == null) { - instance = new EvAComAdapter(); - } - return instance; - } - - /** - * Creates the ModuleAdapters RMI Object on the server - * - * @return - */ - public ModuleAdapter getModuleAdapter(String selectedModuleName, InterfaceOptimizationParameters goParams, String noGuiStatsFile) { - ModuleAdapter newModuleAdapter; - newModuleAdapter = getLocalMainAdapter().getModuleAdapter(selectedModuleName, goParams, noGuiStatsFile); - - return newModuleAdapter; - } - - public void updateLocalMainAdapter() { - localMainAdapter = new EvAMainAdapterImpl(); - } - - private EvAMainAdapter getLocalMainAdapter() { - if (localMainAdapter == null) { - localMainAdapter = new EvAMainAdapterImpl(); - } - return localMainAdapter; - } - - /** - * Returns a list of modules available on the server. - * - * @return - */ - public String[] getModuleNameList() { - System.exit(1); - String[] list = getLocalMainAdapter().getModuleNameList(); - LOGGER.info("List of modules available:"); - - if (list != null) { - for (String item : list) { - if (!item.isEmpty()) { - LOGGER.info(item); - } - } - } - return list; - } -} \ No newline at end of file