Remove unused classes and fix a few typos

This commit is contained in:
Fabian Becker 2015-11-30 15:09:09 +01:00
parent a0b554d3ec
commit 5a6210ff04
10 changed files with 21 additions and 328 deletions

View File

@ -123,12 +123,12 @@ public class EvATabbedFrameMaker implements Serializable, PanelMaker, InterfaceN
} }
} }
public JParaPanel getGOPanel() { public JParaPanel getOptimizationParametersPanel() {
try { try {
JParaPanel sP = (JParaPanel) pmContainer.get(1); JParaPanel sP = (JParaPanel) pmContainer.get(1);
return sP; return sP;
} catch (Exception e) { } 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; return null;
} }

View File

@ -19,9 +19,6 @@ public class JParaPanel implements Serializable, PanelMaker {
*/ */
private JPanel tempPanel = new JPanel(); private JPanel tempPanel = new JPanel();
public JParaPanel() {
}
/** /**
*/ */
public JParaPanel(Object Parameter, String name) { public JParaPanel(Object Parameter, String name) {

View File

@ -12,7 +12,6 @@ import eva2.tools.BasicResourceLoader;
import eva2.tools.EVAERROR; import eva2.tools.EVAERROR;
import eva2.tools.ReflectPackage; import eva2.tools.ReflectPackage;
import eva2.util.ClassPreloader; import eva2.util.ClassPreloader;
import eva2.util.EvAComAdapter;
import javax.help.HelpSet; import javax.help.HelpSet;
import javax.help.JHelpContentViewer; import javax.help.JHelpContentViewer;
@ -71,8 +70,6 @@ public class MainFrame extends JFrame implements OptimizationStateListener {
private java.util.List<OptimizationStateListener> superListenerList = null; private java.util.List<OptimizationStateListener> superListenerList = null;
private EvAComAdapter comAdapter;
public void addOptimizationStateListener(OptimizationStateListener l) { public void addOptimizationStateListener(OptimizationStateListener l) {
if (superListenerList == null) { if (superListenerList == null) {
@ -199,7 +196,6 @@ public class MainFrame extends JFrame implements OptimizationStateListener {
} }
} }
this.comAdapter = EvAComAdapter.getInstance();
splashScreenTime = 2500; splashScreenTime = 2500;
initRunnable = new Runnable() { initRunnable = new Runnable() {
@ -699,8 +695,7 @@ public class MainFrame extends JFrame implements OptimizationStateListener {
if (optimizationParameters == null) { if (optimizationParameters == null) {
params = OptimizationParameters.getInstance(); params = OptimizationParameters.getInstance();
} }
newModuleAdapter = new GOModuleAdapter(selectedModule, params, withGUI ? null : "EvA2"); newModuleAdapter = new OptimizationModuleAdapter(selectedModule, params, withGUI ? null : "EvA2");
//newModuleAdapter = comAdapter.getModuleAdapter(selectedModule, optimizationParameters, withGUI ? null : "EvA2");
} catch (Exception e) { } catch (Exception e) {
LOGGER.log(Level.SEVERE, "Error loading module.", e); LOGGER.log(Level.SEVERE, "Error loading module.", e);
EVAERROR.EXIT("Error while comAdapter.GetModuleAdapter Host: " + e.getMessage()); 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.err.println("adding base dir and trying again...");
System.setProperty("java.class.path", cp + System.getProperty("path.separator") + dir); System.setProperty("java.class.path", cp + System.getProperty("path.separator") + dir);
ReflectPackage.resetDynCP(); ReflectPackage.resetDynCP();
comAdapter.updateLocalMainAdapter();
loadSpecificModule(selectedModule, optimizationParameters); // end recursive call! handle with care! loadSpecificModule(selectedModule, optimizationParameters); // end recursive call! handle with care!
} }
} else { } else {
@ -736,9 +730,9 @@ public class MainFrame extends JFrame implements OptimizationStateListener {
GridBagConstraints gbConstraints = new GridBagConstraints(); GridBagConstraints gbConstraints = new GridBagConstraints();
/* ToDo: Find a way to properly add the TreeView to the GOPanel */ /* 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; JComponent tree = null;
tree = getEvATreeView(frameMaker.getGOPanel(), "OptimizationParameters", ((AbstractModuleAdapter) newModuleAdapter).getOptimizationParameters()); tree = getEvATreeView(frameMaker.getOptimizationParametersPanel(), "OptimizationParameters", ((AbstractModuleAdapter) newModuleAdapter).getOptimizationParameters());
gbConstraints.gridx = 0; gbConstraints.gridx = 0;
gbConstraints.gridy = 0; gbConstraints.gridy = 0;
gbConstraints.fill = GridBagConstraints.BOTH; gbConstraints.fill = GridBagConstraints.BOTH;

View File

@ -149,6 +149,8 @@ public class StandaloneOptimization implements InterfaceStandaloneOptimization,
if ((object != null) && (editor != null)) { if ((object != null) && (editor != null)) {
paraPanel.registerEditor(object, editor); paraPanel.registerEditor(object, editor);
} }
// Tabs
this.parameterPanel1 = (paraPanel.makePanel()); this.parameterPanel1 = (paraPanel.makePanel());
this.optionsPanel = new JTabbedPane(); this.optionsPanel = new JTabbedPane();
JParaPanel paraPanel2 = new JParaPanel(this.optimizationParameters, "MyGUI"); JParaPanel paraPanel2 = new JParaPanel(this.optimizationParameters, "MyGUI");

View File

@ -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);
}

View File

@ -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);
}
}

View File

@ -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<Class<?>> 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<String> 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;
}
}

View File

@ -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") @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"; 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 * @param adapterName the title of the ModuleAdapter
*/ */
public GOModuleAdapter(String adapterName) { public OptimizationModuleAdapter(String adapterName) {
super(adapterName, "", OptimizationParameters.getInstance(), false); 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 adapterName the title of the ModuleAdapter
* @param optimizationParameters the client instance * @param optimizationParameters the client instance
* @param noGuiLogFile * @param noGuiLogFile
*/ */
public GOModuleAdapter(String adapterName, InterfaceOptimizationParameters optimizationParameters, String noGuiLogFile) { public OptimizationModuleAdapter(String adapterName, InterfaceOptimizationParameters optimizationParameters, String noGuiLogFile) {
super(adapterName, "", optimizationParameters, false, noGuiLogFile); super(adapterName, "", optimizationParameters, false, noGuiLogFile);
} }
} }

View File

@ -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 str The string
* @param len * @param len Line length
* @param tolerancePerCent Tolerance in percent
* @return * @return
*/ */
public static String wrapLine(String str, int len, double tolerancePerCent) { 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 str The string
* @param len * @param len Line length
* @return * @return
*/ */
public static String wrapLine(String str, char[] breakChars, int len, double tolerancePerCent) { public static String wrapLine(String str, char[] breakChars, int len, double tolerancePerCent) {
@ -246,7 +247,7 @@ public final class StringTools {
String rest = str; String rest = str;
int minLen = (int) ((1. - tolerancePerCent) * (double) len); int minLen = (int) ((1. - tolerancePerCent) * (double) len);
int maxLen = (int) ((1. + tolerancePerCent) * (double) len); int maxLen = (int) ((1. + tolerancePerCent) * (double) len);
int nextBreak = -1; int nextBreak;
while (rest.length() > 0) { while (rest.length() > 0) {
if (rest.length() <= maxLen) { if (rest.length() <= maxLen) {
nextBreak = rest.length() - 1; nextBreak = rest.length() - 1;

View File

@ -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;
}
}