diff --git a/src/eva2/client/package-info.java b/src/eva2/client/package-info.java deleted file mode 100644 index 241cf986..00000000 --- a/src/eva2/client/package-info.java +++ /dev/null @@ -1 +0,0 @@ -package eva2.client; \ No newline at end of file diff --git a/src/eva2/examples/package-info.java b/src/eva2/examples/package-info.java index 6746fb8d..4d616b24 100644 --- a/src/eva2/examples/package-info.java +++ b/src/eva2/examples/package-info.java @@ -1 +1,4 @@ +/** + * Contains example implementations for custom Terminators and Optimizations. + */ package eva2.examples; \ No newline at end of file diff --git a/src/eva2/gui/BeanInspector.java b/src/eva2/gui/BeanInspector.java index 932de012..3a6c920c 100644 --- a/src/eva2/gui/BeanInspector.java +++ b/src/eva2/gui/BeanInspector.java @@ -511,7 +511,7 @@ public class BeanInspector { * For a primitive type, return the boxed referenced type. Return null for * any non-primitive type. * - * @param clz1 + * @param cls * @return */ public static Class getBoxedType(Class cls) { diff --git a/src/eva2/gui/EvATreeNode.java b/src/eva2/gui/EvATreeNode.java index 39d00d6a..6dee4ac2 100644 --- a/src/eva2/gui/EvATreeNode.java +++ b/src/eva2/gui/EvATreeNode.java @@ -11,7 +11,7 @@ import javax.swing.tree.DefaultMutableTreeNode; * * @author mkron * @see PropertySheetPanel - * @see GOParameters + * @see eva2.optimization.modules.OptimizationParameters */ public class EvATreeNode extends DefaultMutableTreeNode { private String[] childrenNames = null; diff --git a/src/eva2/gui/Main.java b/src/eva2/gui/Main.java index 25eb17e5..9892a19b 100644 --- a/src/eva2/gui/Main.java +++ b/src/eva2/gui/Main.java @@ -1,8 +1,8 @@ package eva2.gui; import eva2.EvAInfo; -import eva2.client.ClassPreloader; -import eva2.client.EvAComAdapter; +import eva2.util.ClassPreloader; +import eva2.util.EvAComAdapter; import eva2.optimization.OptimizationStateListener; import eva2.optimization.go.InterfaceOptimizationParameters; import eva2.optimization.modules.AbstractModuleAdapter; @@ -90,7 +90,7 @@ public class Main extends JFrame implements OptimizationStateListener { /** * Constructor of GUI of EvA2. Works as client for the EvA2 server. Note - * that the Main initialized multi-threaded for efficiency. Use {@link #awaitGuiInitialized()} + * that the Main initialized multi-threaded for efficiency. Use {@link #awaitClientInitialized()} } * to await full initialization if necessary. */ public Main(final String hostName) { @@ -100,7 +100,7 @@ public class Main extends JFrame implements OptimizationStateListener { /** * A constructor. Splash screen is optional, Gui is activated, no parent * window. Note that the Main initialized multi-threaded for - * efficiency. Use {@link #awaitGuiInitialized()} to await full + * efficiency. Use {@link #awaitClientInitialized()} to await full * initialization if necessary. * * @param hostName @@ -114,7 +114,7 @@ public class Main extends JFrame implements OptimizationStateListener { /** * A constructor with optional spash screen. Note that the Main is - * initialized multi-threaded for efficiency. Use {@link #awaitGuiInitialized()} + * initialized multi-threaded for efficiency. Use {@link #awaitClientInitialized()} * to await full initialization if necessary. * * @param hostName @@ -128,7 +128,7 @@ public class Main extends JFrame implements OptimizationStateListener { /** * A constructor with optional splash screen. Note that the Main - * initialized multi-threaded for efficiency. Use {@link #awaitGuiInitialized()} + * initialized multi-threaded for efficiency. Use {@link #awaitClientInitialized()} * to await full initialization if necessary. * * @param hostName @@ -144,11 +144,11 @@ public class Main extends JFrame implements OptimizationStateListener { /** * A constructor with optional splash screen. Note that the Main - * initialized multi-threaded for efficiency. Use {@link #awaitGuiInitialized()} + * initialized multi-threaded for efficiency. Use {@link #awaitClientInitialized()} * to await full initialization if necessary. * * @param hostName - * @param paramsFile + * @param optimizationParameters * @param autorun * @param noSplash * @param noGui @@ -179,7 +179,7 @@ public class Main extends JFrame implements OptimizationStateListener { * from a file (paramsFile) or given directly as a java instance. Both may * be null to start with standard parameters. If both are non null, the java * instance has the higher priority. Note that the Main initialized - * multi-threaded for efficiency. Use {@link #awaitGuiInitialized()} to + * multi-threaded for efficiency. Use {@link #awaitClientInitialized()} to * await full initialization if necessary. * * @param hostName diff --git a/src/eva2/gui/package-info.java b/src/eva2/gui/package-info.java index c6db757a..061c85cc 100644 --- a/src/eva2/gui/package-info.java +++ b/src/eva2/gui/package-info.java @@ -1 +1,4 @@ +/** + * Base package for the EvA2 GUI. + */ package eva2.gui; \ No newline at end of file diff --git a/src/eva2/json/package-info.java b/src/eva2/json/package-info.java new file mode 100644 index 00000000..c0261a75 --- /dev/null +++ b/src/eva2/json/package-info.java @@ -0,0 +1,4 @@ +/** + * JSON package for serializing and deserializing optimization configurations. + */ +package eva2.json; \ No newline at end of file diff --git a/src/eva2/optimization/ModuleServer.java b/src/eva2/optimization/ModuleServer.java index 3aa6e25f..de52fca7 100644 --- a/src/eva2/optimization/ModuleServer.java +++ b/src/eva2/optimization/ModuleServer.java @@ -26,6 +26,7 @@ public final class ModuleServer { /** * + * @param EvAProps */ public ModuleServer(Properties EvAProps) { if (instanceCounter > 0) { @@ -93,6 +94,9 @@ public final class ModuleServer { * 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) { diff --git a/src/eva2/optimization/go/SwingWorker.java b/src/eva2/optimization/go/SwingWorker.java index 920d893a..bad8bf55 100644 --- a/src/eva2/optimization/go/SwingWorker.java +++ b/src/eva2/optimization/go/SwingWorker.java @@ -7,11 +7,11 @@ import javax.swing.*; * SwingWorker 3), an abstract class that you subclass to * perform GUI-related work in a dedicated thread. For * instructions on using this class, see: - *

+ *

* http://java.sun.com/products/jfc/tsc/articles/threads/threads2.html * or * http://java.sun.com/docs/books/tutorial/uiswing/misc/threads.html - *

+ *

* Note that the API changed slightly in the 3rd version: * You must now invoke start() on the SwingWorker after * creating it. diff --git a/src/eva2/optimization/modules/GOModuleAdapter.java b/src/eva2/optimization/modules/GOModuleAdapter.java index 289a7ea2..7f0b785d 100644 --- a/src/eva2/optimization/modules/GOModuleAdapter.java +++ b/src/eva2/optimization/modules/GOModuleAdapter.java @@ -8,6 +8,7 @@ import java.io.Serializable; /** * Starts a statistics GUI and the GOProcessor thread. */ +@SuppressWarnings("unused") public class GOModuleAdapter extends GenericModuleAdapter implements ModuleAdapter, Serializable { private static final String moduleName = "Genetic_Optimization"; diff --git a/src/eva2/optimization/modules/GenericModuleAdapter.java b/src/eva2/optimization/modules/GenericModuleAdapter.java index 9ab25960..bd93e398 100644 --- a/src/eva2/optimization/modules/GenericModuleAdapter.java +++ b/src/eva2/optimization/modules/GenericModuleAdapter.java @@ -56,7 +56,6 @@ public class GenericModuleAdapter extends AbstractModuleAdapter implements Seria * * @param adapterName The AdapterName * @param helperFName name of a html help file name - * @param Client The client to serve * @param params a parameter set describing the optimizer module * @param optimizerExpert set to true if setting the optimizer is an expert option being hidden from the gui */ diff --git a/src/eva2/optimization/modules/OptimizationParameters.java b/src/eva2/optimization/modules/OptimizationParameters.java index 09b9927a..1fc6ccb1 100644 --- a/src/eva2/optimization/modules/OptimizationParameters.java +++ b/src/eva2/optimization/modules/OptimizationParameters.java @@ -20,7 +20,7 @@ import java.util.logging.Level; /** * OptimizationParameters for configuration of an * optimization run. - *

+ *

* This class is used to generate the default GUI * configuration panel for optimizations. */ diff --git a/src/eva2/optimization/modules/Processor.java b/src/eva2/optimization/modules/Processor.java index 23a15f61..6a6d54e1 100644 --- a/src/eva2/optimization/modules/Processor.java +++ b/src/eva2/optimization/modules/Processor.java @@ -40,8 +40,6 @@ import java.util.logging.Logger; * interface, it is applied to the instance that returned it directly. For * arrays of objects each array entry is again handled by checking for * getParamControl, thus recursive controllable structures are possible. - * - * @author mkron */ public class Processor extends Thread implements InterfaceProcessor, InterfacePopulationChangedEventListener { @@ -227,7 +225,6 @@ public class Processor extends Thread implements InterfaceProcessor, InterfacePo optimizationParameters.getOptimizer().addPopulationChangedEventListener(this); runCounter = 0; - String popLog = null; //"populationLog.txt"; while (isOptimizationRunning() && (runCounter < statistics.getStatisticsParameter().getMultiRuns())) { LOGGER.info(String.format("Starting Optimization %d/%d", runCounter + 1, statistics.getStatisticsParameter().getMultiRuns())); @@ -244,19 +241,11 @@ public class Processor extends Thread implements InterfaceProcessor, InterfacePo if (optimizationStateListener != null) { optimizationStateListener.updateProgress(getStatusPercent(optimizationParameters.getOptimizer().getPopulation(), runCounter, statistics.getStatisticsParameter().getMultiRuns()), null); } - if (popLog != null) { - EVAHELP.clearLog(popLog); - } do { // main loop maybeUpdateParamCtrl(optimizationParameters); this.optimizationParameters.getOptimizer().optimize(); - // registerPopulationStateChanged *SHOULD* be fired by the optimizer or resp. the population - // as we are event listener - if (popLog != null) { - EVAHELP.logString(this.optimizationParameters.getOptimizer().getPopulation().getIndyList(), popLog); - } } while (isOptimizationRunning() && !this.optimizationParameters.getTerminator().isTerminated(this.optimizationParameters.getOptimizer().getAllSolutions())); diff --git a/src/eva2/optimization/package-info.java b/src/eva2/optimization/package-info.java index 7bd1b7a9..7794a259 100644 --- a/src/eva2/optimization/package-info.java +++ b/src/eva2/optimization/package-info.java @@ -1 +1,4 @@ +/** + * + */ package eva2.optimization; \ No newline at end of file diff --git a/src/eva2/optimization/population/Population.java b/src/eva2/optimization/population/Population.java index 77048e42..ac55d766 100644 --- a/src/eva2/optimization/population/Population.java +++ b/src/eva2/optimization/population/Population.java @@ -955,7 +955,7 @@ public class Population extends ArrayList implements PopulationInterface, Clonea * population. If the population is empty, -1 is returned. * * @return The index of the best individual. - * @see getIndexOfBestOrWorstIndividual() + * @see #getIndexOfBestOrWorstIndividual(boolean, java.util.Comparator) */ public int getIndexOfBestIndividualPrefFeasible() { if (size() < 1) { @@ -969,7 +969,7 @@ public class Population extends ArrayList implements PopulationInterface, Clonea * the population. * * @return The index of the worst individual. - * @see getIndexOfBestOrWorstIndividual() + * @see #getIndexOfBestOrWorstIndividual(boolean, java.util.Comparator) */ public int getIndexOfWorstIndividualNoConstr() { return getIndexOfBestOrWorstIndy(false, false, -1); @@ -981,7 +981,7 @@ public class Population extends ArrayList implements PopulationInterface, Clonea * fitIndex < 0). If the population is empty, -1 is returned. * * @return The index of the best individual. - * @see getIndexOfBestOrWorstIndividual() + * @see #getIndexOfBestOrWorstIndividual(boolean, java.util.Comparator) */ public int getIndexOfBestIndividualPrefFeasible(int fitIndex) { if (size() < 1) { @@ -996,7 +996,7 @@ public class Population extends ArrayList implements PopulationInterface, Clonea * fitIndex < 0). * * @return The index of the best individual. - * @see getIndexOfBestOrWorstIndividual() + * @see #getIndexOfBestOrWorstIndividual(boolean, java.util.Comparator) */ public int getIndexOfWorstIndividualNoConstr(int fitIndex) { return getIndexOfBestOrWorstIndy(false, false, fitIndex); @@ -1257,7 +1257,6 @@ public class Population extends ArrayList implements PopulationInterface, Clonea * instance. * * @param n - * @param l */ public Population toTail(int n) { Population retPop = new Population(n); @@ -1310,8 +1309,7 @@ public class Population extends ArrayList implements PopulationInterface, Clonea * the population has not been modified. The returned array must not be * altered! * - * @param fitIndex the fitness criterion to be used or -1 for pareto - * dominance + * @param comp The comparator * @return */ public ArrayList getSorted(Comparator comp) { @@ -1332,7 +1330,7 @@ public class Population extends ArrayList implements PopulationInterface, Clonea /** * Returns the sorted population as a new population instance. * - * @see getSorted(Comparator) + * @see #getSorted(java.util.Comparator) */ public Population getSortedPop(Comparator comp) { Population pop = this.cloneWithoutInds(); @@ -1386,8 +1384,8 @@ public class Population extends ArrayList implements PopulationInterface, Clonea * returns dst Population. * * @param n - * @param from - * @param to + * @param src + * @param dst * @return */ public static Population moveNInds(int n, Population src, Population dst) { @@ -1402,8 +1400,8 @@ public class Population extends ArrayList implements PopulationInterface, Clonea /** * Move one random individual from src to dst population. * - * @param from - * @param to + * @param src + * @param dst */ public static void moveRandIndFromTo(Population src, Population dst) { int k = RNG.randomInt(src.size()); @@ -1762,7 +1760,7 @@ public class Population extends ArrayList implements PopulationInterface, Clonea * individual to be removed is not contained in the instance. Otherwise, * this is ignored. * - * @param tmpPop + * @param popToRemove * @param errorOnMissing */ public void removeMembers(Population popToRemove, boolean errorOnMissing) { @@ -1843,7 +1841,7 @@ public class Population extends ArrayList implements PopulationInterface, Clonea /** * Returns the average, minimal and maximal individual distance as diversity * measure for the population. If the given metric argument is null, the - * euclidian distance of individual positions is used, which presumes that {@link AbstractEAIndividual.getDoublePosition(indy)} + * euclidian distance of individual positions is used, which presumes that {@link eva2.optimization.individuals.AbstractEAIndividual#getDoublePosition(eva2.optimization.individuals.AbstractEAIndividual)} * returns a valid double position for the individuals of the population. * This is of course rather expensive computationally. * @@ -1859,7 +1857,7 @@ public class Population extends ArrayList implements PopulationInterface, Clonea /** * Returns the average, minimal and maximal individual distance as diversity * measure for the population. If the given metric argument is null, the - * euclidian distance of individual positions is used, which presumes that {@link AbstractEAIndividual.getDoublePosition(indy)} + * euclidian distance of individual positions is used, which presumes that {@link AbstractEAIndividual#getDoublePosition(eva2.optimization.individuals.AbstractEAIndividual)} * returns a valid double position for the individuals of the population. * This is of course rather expensive computationally. * @@ -2046,7 +2044,7 @@ public class Population extends ArrayList implements PopulationInterface, Clonea * Return a Pair of the individuals index and distance. If the population is * empty, a Pair of (-1,-1) is returned. * - * @param pos + * @param refIndy * @param pop * @param closestOrFarthest if true, the closest individual is retrieved, * otherwise the farthest @@ -2073,8 +2071,8 @@ public class Population extends ArrayList implements PopulationInterface, Clonea * population. * * @param indy - * @param pop * @param d + * @param metric * @return true if d(indy,pop)<=d, else false */ public boolean isWithinPopDist(AbstractEAIndividual indy, double d, InterfaceDistanceMetric metric) { @@ -2140,7 +2138,6 @@ public class Population extends ArrayList implements PopulationInterface, Clonea * * @param criterion * @return - * @see AbstractEAIndidivual.getDoublePosition(individual) */ public double[] getCenterWeighted(AbstractSelProb selProb, int criterion, boolean obeyConst) { selProb.computeSelectionProbability(this, "Fitness", obeyConst); @@ -2162,7 +2159,7 @@ public class Population extends ArrayList implements PopulationInterface, Clonea * Search for the closest individual to the indexed individual within the * population. Return its index or -1 if none could be found. * - * @param indy + * @param neighborIndex * @return closest neighbor (euclidian measure) of the given individual in * the given population */ @@ -2309,8 +2306,8 @@ public class Population extends ArrayList implements PopulationInterface, Clonea * true and the individuals are out of range, they are projected into the * range by force. * - * @param modRange - * @param b + * @param range + * @param forceRange */ public void updateRange(double[][] range, boolean forceRange) { for (int i = 0; i < size(); i++) { @@ -2337,19 +2334,6 @@ public class Population extends ArrayList implements PopulationInterface, Clonea public String initMethodTipText() { return "Define the initial sampling method. Note that anything other than inidividualDefault will override the individual initialization concerning the positions in solution space."; } -// /** -// * Check whether the population at the current state has been marked as -// * evaluated. This allows to avoid double evaluations. -// * -// * @return true if the population has been marked as evaluated in its current state, else false -// */ -// public boolean isEvaluated() { -// if (evaluationTimeModCount != modCount) return false; -// Pair hashes = getIndyHashSums(); -// -// if (evaluationTimeHashes == null) return false; -// else return ((hashes.head().equals(evaluationTimeHashes.head())) && (hashes.tail().equals(evaluationTimeHashes.tail())) && (evaluationTimeModCount == modCount)); -// } /** * Add the population data of a given population to this instance. Note that @@ -2435,7 +2419,7 @@ public class Population extends ArrayList implements PopulationInterface, Clonea * Return true if the current instance is a subset of the given population, * otherwise false. * - * @param offspring + * @param set * @return */ public boolean isSubSet(Population set) { diff --git a/src/eva2/optimization/stat/AbstractStatistics.java b/src/eva2/optimization/stat/AbstractStatistics.java index 10b7c174..77c04fba 100644 --- a/src/eva2/optimization/stat/AbstractStatistics.java +++ b/src/eva2/optimization/stat/AbstractStatistics.java @@ -97,7 +97,7 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter private List lastInformerList = null; private PopulationInterface lastSols = null; private String textFieldDelimiter = "\t"; - private int defaultFitCriterion = 0; // TODO this might be a user chosen int - or even more elegantly, a MOSOConverter + private int defaultFitCriterion = 0; // ToDo this might be a user chosen int - or even more elegantly, a MOSOConverter protected StringSelection lastFieldSelection = null; // store the graph selection at the beginning of a multi-run protected boolean lastIsShowFull = false; // store the "show full text" stats property at the beginning of a multi-run @@ -891,7 +891,6 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter } } return values; -// return StringTools.concatValues(values, textFieldDelimiter); } /** @@ -899,7 +898,6 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter * The length of this list depends on the field selection state. * * @param informerList - * @param pop * @param metaInfo if non null, the meta info strings are returned in this list * @return */ @@ -913,7 +911,6 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter if (metaInfo != null) { metaInfo.addAll(Arrays.asList(informer.getAdditionalDataInfo())); } -// hdr = hdr + "\t " + informer.getAdditionalDataHeader(pop); } Iterator hIter = headers.iterator(); Iterator mIter = (metaInfo != null) ? metaInfo.iterator() : null; @@ -950,48 +947,15 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter return new Pair<>(statValuesString, statValues.toArray(new Object[statValues.size()])); } -// /** -// * Append additional informer informations to the given StringBuffer. -// * -// * @param informerList -// * @param pop -// * @param sbuf -// */ -// protected Double[] appendAdditionalInfo(List informerList, PopulationInterface pop, StringBuffer sbuf) { -// if (informerList != null) { -// ArrayList additionalObjects = new ArrayList(5); -// -// for (InterfaceAdditionalPopulationInformer informer : informerList) { -// additionalObjects.addAll(Arrays.asList(informer.getAdditionalDataValue(pop))); -// } -// String addInfo = StringTools.concatValues(additionalObjects, textFieldDelimiter); -// Double[] retVals = parseDoubles(additionalObjects); -// if (sbuf!=null) sbuf.append(addInfo); -// return retVals; -// -//// StringBuffer addBuffer = new StringBuffer(); -//// for (InterfaceAdditionalPopulationInformer informer : informerList) { -//// addBuffer.append(" \t "); -//// addBuffer.append(informer.getAdditionalDataValue(pop)); -//// } -//// String addInfo = addBuffer.toString().trim(); -//// if (addInfo.startsWith("\t")) addInfo.substring(2); // remove first separator to avoid returning empty field as double -//// Double[] retVals = parseDoubles(addInfo, "\t"); -//// if (sbuf!=null) sbuf.append(addInfo); -//// return retVals; -// } -// return null; -// } - /** - * @deprecated The method {@link #createNextGenerationPerformed(PopulationInterface, List)} should be used instead. + * @deprecated The method {@link #createNextGenerationPerformed(eva2.optimization.population.PopulationInterface, eva2.optimization.strategies.InterfaceOptimizer, java.util.List)} should be used instead. */ @Override - public synchronized void createNextGenerationPerformed(double[] bestfit, - double[] worstfit, int calls) { + public synchronized void createNextGenerationPerformed(double[] bestFit, + double[] worstFit, int calls) { functionCalls = calls; - currentBestFit = bestfit; - currentWorstFit = worstfit; + currentBestFit = bestFit; + currentWorstFit = worstFit; currentBestFeasibleFit = null; currentMeanFit = null; @@ -1044,7 +1008,7 @@ public abstract class AbstractStatistics implements InterfaceTextListener, Inter * If the population returns a specific data array, this method is called instead of doing standard output * * @param pop - * @param informer + * @param informerList */ public abstract void plotSpecificData(PopulationInterface pop, List informerList); diff --git a/src/eva2/optimization/stat/GenericStatistics.java b/src/eva2/optimization/stat/GenericStatistics.java index 32a5062c..84160f91 100644 --- a/src/eva2/optimization/stat/GenericStatistics.java +++ b/src/eva2/optimization/stat/GenericStatistics.java @@ -52,17 +52,16 @@ public class GenericStatistics implements Serializable { states = new boolean[fields.length]; for (int i = 0; i < fields.length; i++) { String desc = fields[i].toString(); //System.out.println("desc "+desc); - int istransient = desc.indexOf("transient"); + int isTransient = desc.indexOf("transient"); Object FieldValue = null; - if (istransient == -1 || fields[i].getName().equals("elementData")) { // the elementdatahack + if (isTransient == -1 || fields[i].getName().equals("elementData")) { // the elementdatahack fields[i].setAccessible(true); FieldValue = fields[i].get(target); } propertyNames[i] = fields[i].getName(); } } catch (Exception ex) { - System.out.println("ERROR in GenericStatistics:" + ex.getMessage()); - ex.printStackTrace(); + LOGGER.severe("GenericStatistics:" + ex.getMessage()); } } @@ -98,7 +97,6 @@ public class GenericStatistics implements Serializable { * */ public void setState(boolean[] x) { - System.out.println("in statistics setState !!!!!!!!!!!!!!!!!!"); states = x; } @@ -149,8 +147,7 @@ public class GenericStatistics implements Serializable { try { fields = getDeclaredFields(target); } catch (Exception ex) { - System.out.println("ERROR in GenericStatistics:" + ex.getMessage()); - ex.printStackTrace(); + LOGGER.severe("ERROR in GenericStatistics:" + ex.getMessage()); } int index = 0; for (int i = 0; i < fields.length; i++) { @@ -159,11 +156,11 @@ public class GenericStatistics implements Serializable { continue; } if (fields[i].getName().equals(propertyNames[n])) { - String desc = fields[i].toString(); //System.out.println("desc "+desc); - int istransient = desc.indexOf("transient"); + String desc = fields[i].toString(); + int isTransient = desc.indexOf("transient"); Object fieldValue = null; - if (istransient == -1 || fields[i].getName().equals("elementData")) { // the elementdatahack + if (isTransient == -1 || fields[i].getName().equals("elementData")) { // the elementdatahack fields[i].setAccessible(true); try { fieldValue = fields[i].get(target); @@ -175,8 +172,7 @@ public class GenericStatistics implements Serializable { } index++; } catch (Exception ex) { - System.out.println("ERROR in GenericStatistics:" + ex.getMessage()); - ex.printStackTrace(); + LOGGER.severe("ERROR in GenericStatistics:" + ex.getMessage()); } } break; diff --git a/src/eva2/optimization/stat/GraphSelectionEnum.java b/src/eva2/optimization/stat/GraphSelectionEnum.java index 6f0d78f0..6afac900 100644 --- a/src/eva2/optimization/stat/GraphSelectionEnum.java +++ b/src/eva2/optimization/stat/GraphSelectionEnum.java @@ -5,11 +5,10 @@ import eva2.tools.StringSelection; /** * An Enum to be used in the statistics classes for identifying data fields. * - * @author mkron * @see AbstractStatistics */ public enum GraphSelectionEnum { - // DONT change this order, or the relation to AbstractStatistics will be lost + // DON'T change this order, or the relation to AbstractStatistics will be lost currentBest, meanFit, currentWorst, runBest, currentBestFeasible, runBestFeasible, avgEucPopDistance, maxEucPopDistance, avgPopMetricDist, maxPopMetricDist; diff --git a/src/eva2/optimization/stat/InterfaceStatistics.java b/src/eva2/optimization/stat/InterfaceStatistics.java index d8f01527..bf317b1d 100644 --- a/src/eva2/optimization/stat/InterfaceStatistics.java +++ b/src/eva2/optimization/stat/InterfaceStatistics.java @@ -15,7 +15,7 @@ public interface InterfaceStatistics { /** * Initialize statistics computations. */ - void startOptimizationPerformed(String InfoString, int runnumber, Object params, List informerList); // called from processor + void startOptimizationPerformed(String infoString, int runNumber, Object params, List informerList); // called from processor /** * Finalize statistics computations. @@ -34,7 +34,7 @@ public interface InterfaceStatistics { void createNextGenerationPerformed(PopulationInterface Pop, InterfaceOptimizer opt, List informerList); - void createNextGenerationPerformed(double[] bestfit, double[] worstfit, int calls); + void createNextGenerationPerformed(double[] bestFit, double[] worstFit, int calls); InterfaceStatisticsParameter getStatisticsParameter(); // called from moduleadapter diff --git a/src/eva2/optimization/stat/OptimizationJobList.java b/src/eva2/optimization/stat/OptimizationJobList.java index 931f7960..c5bb2d16 100644 --- a/src/eva2/optimization/stat/OptimizationJobList.java +++ b/src/eva2/optimization/stat/OptimizationJobList.java @@ -183,7 +183,6 @@ public class OptimizationJobList extends PropertySelectableList genericArrayEditor.addUpperActionButton("Test Stats", al); genericArrayEditor.addLowerActionButton("Save selected", sal); -// edi.addPopupItem("Reset selected", getClearSelectedActionListener(parent, jobList)); // this option does not make much sense - instead of deleting data, taking over the settings for a new run is more plausible genericArrayEditor.addPopupItem("Reuse as current settings", getReuseActionListener(parent, jobList)); genericArrayEditor.setAdditionalCenterPane(createStatsPanel(jobList, genericArrayEditor)); genericArrayEditor.setValue(jobList); @@ -193,12 +192,11 @@ public class OptimizationJobList extends PropertySelectableList private static JComponent createStatsPanel(final OptimizationJobList jobList, final GenericArrayEditor edi) { JParaPanel pan = new JParaPanel(EvAStatisticalEvaluation.statsParams, "Statistics"); - JComponent paraPan = pan.makePanel(); - return paraPan; + return pan.makePanel(); } private static ActionListener getReuseActionListener(final Component parent, final OptimizationJobList jobList) { - ActionListener al = new ActionListener() { + return new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @@ -215,11 +213,10 @@ public class OptimizationJobList extends PropertySelectableList } } }; - return al; } private static ActionListener getClearSelectedActionListener(final Component parent, final OptimizationJobList jobList) { - ActionListener al = new ActionListener() { + return new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @@ -229,13 +226,12 @@ public class OptimizationJobList extends PropertySelectableList } } }; - return al; } /** * Link a processor to the job list for re-scheduling jobs. * - * @param processor + * @param mod */ public void setModule(ModuleAdapter mod) { module = mod; @@ -251,16 +247,9 @@ public class OptimizationJobList extends PropertySelectableList } public boolean removeTextListener(InterfaceTextListener tListener) { - if (listeners != null) { - return listeners.remove(tListener); - } else { - return false; - } + return listeners != null && listeners.remove(tListener); } - /* - * (non-Javadoc) @see eva2.server.stat.InterfaceTextListener#print(java.lang.String) - */ @Override public void print(String str) { if (listeners != null) { @@ -270,9 +259,6 @@ public class OptimizationJobList extends PropertySelectableList } } - /* - * (non-Javadoc) @see eva2.server.stat.InterfaceTextListener#println(java.lang.String) - */ @Override public void println(String str) { if (listeners != null) { diff --git a/src/eva2/optimization/stat/StatisticsDummy.java b/src/eva2/optimization/stat/StatisticsDummy.java index a05a42b9..74e96ef9 100644 --- a/src/eva2/optimization/stat/StatisticsDummy.java +++ b/src/eva2/optimization/stat/StatisticsDummy.java @@ -51,8 +51,8 @@ public class StatisticsDummy implements InterfaceStatistics, InterfaceTextListen } @Override - public void createNextGenerationPerformed(double[] bestfit, - double[] worstfit, int calls) { + public void createNextGenerationPerformed(double[] bestFit, + double[] worstFit, int calls) { } @Override @@ -93,9 +93,9 @@ public class StatisticsDummy implements InterfaceStatistics, InterfaceTextListen } @Override - public void startOptimizationPerformed(String InfoString, int runnumber, + public void startOptimizationPerformed(String infoString, int runNumber, Object params, List informerList) { - if (runnumber == 0) { + if (runNumber == 0) { bestIndividualAllover = null; } bestRunIndy = null; diff --git a/src/eva2/optimization/strategies/ANPSO.java b/src/eva2/optimization/strategies/ANPSO.java index 17872ed9..9af8cc47 100644 --- a/src/eva2/optimization/strategies/ANPSO.java +++ b/src/eva2/optimization/strategies/ANPSO.java @@ -424,7 +424,6 @@ public class ANPSO extends NichePSO implements InterfaceOptimizer, InterfaceAddi /** * The returned array may contain null entries (for indies scheduled for reinitialization). * - * @param pop * @return an array of references sorted according to the particle indices * (i.e. returnedArray[i] = individual with individualIndex i) */ @@ -569,11 +568,7 @@ public class ANPSO extends NichePSO implements InterfaceOptimizer, InterfaceAddi useAsMainSwarm(newMainPop); } -/********************************************************************************************************************** - * Optimization - */ /** - * @tested (non-Javadoc) @see javaeva.server.oa.go.Strategies.InterfaceOptimizer#optimize() */ @Override public void optimize() { @@ -674,7 +669,6 @@ public class ANPSO extends NichePSO implements InterfaceOptimizer, InterfaceAddi */ /** * @param size - * @tested ps * sets the !initial! size of the mainswarm population * use this instead of getPopulation.setPopulationSize() */ @@ -709,7 +703,6 @@ public class ANPSO extends NichePSO implements InterfaceOptimizer, InterfaceAddi /** * @return a population consisting of copies from the mainswarm and all subswarms. - * @tested junit * returns a population consisting of copies from the mainswarm and all subswarms * (active and inactive, so the size of this Population is not necessarily constant). * Especially important for the call back regarding the output file... @@ -748,7 +741,6 @@ public class ANPSO extends NichePSO implements InterfaceOptimizer, InterfaceAddi /** * @return array with copies of the gbest individuals - * @tested junit * returns the cloned global best individuals (ie best of all time) from every subswarm */ public Population getSubswarmRepresentatives() { @@ -769,7 +761,6 @@ public class ANPSO extends NichePSO implements InterfaceOptimizer, InterfaceAddi /** * @return descriptive string of the elite - * @tested emp * returns a string that lists the global best individuals (ie best of all time) from every subswarm */ public String getSubswarmRepresentativesAsString() { @@ -782,7 +773,6 @@ public class ANPSO extends NichePSO implements InterfaceOptimizer, InterfaceAddi } /** - * @tested plots all subswarms as connected lines to their respective best individual */ @Override protected void plotSubSwarms() { @@ -845,7 +835,6 @@ public class ANPSO extends NichePSO implements InterfaceOptimizer, InterfaceAddi * @return inactive particles with given index * (may return more than one particle for a given index because indizes are reused during deactivation * and the reinitialized particle may be deactivated again...) - * @tested method not used any more */ public Vector getInactiveIndiesByParticleIndex(Integer index) { Vector indies = null; @@ -862,7 +851,6 @@ public class ANPSO extends NichePSO implements InterfaceOptimizer, InterfaceAddi /** * @return The name of the algorithm - * @tested nn * This method will return a naming String */ @Override @@ -1031,22 +1019,6 @@ public class ANPSO extends NichePSO implements InterfaceOptimizer, InterfaceAddi return representatives; } -/* - public String[] getAdditionalDataHeader(PopulationInterface pop) { - return new String[]{"mainSwarmSize","numActSpec","numArchived", "archivedMedCorr"}; - } - - public Object[] getAdditionalDataValue(PopulationInterface pop) { - int actSwarms = countActiveSubswarms(); - double medCor = (getSubswarmRepresentatives(true)).getCorrelations()[3]; // median correlation of best indies of inactive subswarms - return new Object[]{getMainSwarm().getPopulation().size(), - actSwarms, - (getSubSwarms().size()-actSwarms), - medCor}; - } - -*/ - /** * Return the median correlation of the best individuals of the given set of swarms. */ diff --git a/src/eva2/optimization/strategies/DifferentialEvolution.java b/src/eva2/optimization/strategies/DifferentialEvolution.java index 582c95dc..5eacad1a 100644 --- a/src/eva2/optimization/strategies/DifferentialEvolution.java +++ b/src/eva2/optimization/strategies/DifferentialEvolution.java @@ -195,7 +195,7 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial } isEmpty = (isEmpty && (result[i] == 0)); } - // single parent! dont add another one + // single parent! don't add another one } return result; @@ -250,7 +250,7 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial } isEmpty = (isEmpty && (result[i] == 0)); } - // single parent! dont add another one + // single parent! don't add another one } return result; @@ -538,8 +538,7 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial optimizationProblem.evaluate(children); /** - * MdP: added a reevalutation mechanism for dynamically changing - * problems + * Re-evalutation mechanism for dynamically changing problems */ if (isReEvaluate()) { for (int i = 0; i < this.population.size(); i++) { @@ -594,8 +593,7 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial /** - * MdP: added a reevalutation mechanism for dynamically changing - * problems + * Reevalutation mechanism for dynamically changing problems */ if (isReEvaluate()) { nextDoomed = -1; diff --git a/src/eva2/package-info.java b/src/eva2/package-info.java index 09b47870..cfd66a7d 100644 --- a/src/eva2/package-info.java +++ b/src/eva2/package-info.java @@ -1,4 +1,4 @@ /** - * Base package of the project that contains globally important classes. + * Base package of EvA2 */ package eva2; \ No newline at end of file diff --git a/src/eva2/problems/AbstractOptimizationProblem.java b/src/eva2/problems/AbstractOptimizationProblem.java index a1a1ff72..0494d148 100644 --- a/src/eva2/problems/AbstractOptimizationProblem.java +++ b/src/eva2/problems/AbstractOptimizationProblem.java @@ -56,7 +56,6 @@ public abstract class AbstractOptimizationProblem implements InterfaceOptimizati population.incrFunctionCalls(); semaphore.release(); } - } /** @@ -68,7 +67,7 @@ public abstract class AbstractOptimizationProblem implements InterfaceOptimizati */ public static final String OLD_FITNESS_KEY = "oldFitness"; - private int parallelthreads = 1; + private int parallelThreads = 1; protected AbstractEAIndividual template = null; @@ -83,11 +82,11 @@ public abstract class AbstractOptimizationProblem implements InterfaceOptimizati public abstract Object clone(); public int getParallelThreads() { - return parallelthreads; + return parallelThreads; } - public void setParallelThreads(int parallelthreads) { - this.parallelthreads = parallelthreads; + public void setParallelThreads(int parallelThreads) { + this.parallelThreads = parallelThreads; } public String parallelThreadsTipText() { @@ -120,10 +119,10 @@ public abstract class AbstractOptimizationProblem implements InterfaceOptimizati AbstractEAIndividual tmpIndy; evaluatePopulationStart(population); - if (this.parallelthreads > 1) { + if (this.parallelThreads > 1) { Vector queue = new Vector<>(population.size()); Semaphore sema = new Semaphore(0); - ExecutorService pool = Executors.newFixedThreadPool(parallelthreads); + ExecutorService pool = Executors.newFixedThreadPool(parallelThreads); int cntIndies = 0; for (; cntIndies < population.size(); cntIndies++) { AbstractEAIndividual tmpindy = (AbstractEAIndividual) population.get(cntIndies); @@ -160,17 +159,14 @@ public abstract class AbstractOptimizationProblem implements InterfaceOptimizati * * @param population */ - - public void evaluatePopulationStart(Population population) { - } + public void evaluatePopulationStart(Population population) {} /** * Empty thunk for implementation in subclasses. This is called after a population was evaluated. * * @param population */ - public void evaluatePopulationEnd(Population population) { - } + public void evaluatePopulationEnd(Population population) {} /** * This method evaluate a single individual and sets the fitness values @@ -224,7 +220,7 @@ public abstract class AbstractOptimizationProblem implements InterfaceOptimizati */ @Override public Double getDoublePlotValue(Population pop) { - return new Double(pop.getBestEAIndividual().getFitness(0)); + return pop.getBestEAIndividual().getFitness(0); } /** diff --git a/src/eva2/tools/BasicResourceLoader.java b/src/eva2/tools/BasicResourceLoader.java index acc866d7..47522fe9 100644 --- a/src/eva2/tools/BasicResourceLoader.java +++ b/src/eva2/tools/BasicResourceLoader.java @@ -40,17 +40,15 @@ import java.util.zip.ZipEntry; import java.util.zip.ZipFile; import java.util.zip.ZipInputStream; - /** * Loads resource file from directory OR jar file. Now it is easier possible to * access resource files in a directory structure or a .jar/.zip file. * - * @.author Marcel Kronfeld - * @.author wegnerj - * @.author Robin Friedman, rfriedman@TriadTherapeutics.com - * @.author Gerd Mueller - * @.license GPL - * @.cvsversion $Revision: 1.3 $, $Date: 2005/02/17 16:48:44 $ + * @author Marcel Kronfeld + * @author wegnerj + * @author Robin Friedman, rfriedman@TriadTherapeutics.com + * @author Gerd Mueller + * @license GPL */ public class BasicResourceLoader implements ResourceLoader { /** @@ -81,7 +79,7 @@ public class BasicResourceLoader implements ResourceLoader { /** * Description of the Method * - * @param resourceFile Description of the Parameter + * @param resourceFile Source file to read * @return Description of the Return Value */ public static List readLines(String resourceFile) { @@ -91,8 +89,8 @@ public class BasicResourceLoader implements ResourceLoader { /** * Description of the Method * - * @param resourceFile Description of the Parameter - * @param ignoreComments Description of the Parameter + * @param resourceFile Source file to read + * @param ignoreCommentedLines Whether to ignore commented lines * @return Description of the Return Value */ public static List readLines(String resourceFile, @@ -106,7 +104,7 @@ public class BasicResourceLoader implements ResourceLoader { * @param resourceFile File to read * @param ignorePrefix array of prefixes which mark a line to be ignored * @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 less than 0, all lines are read * @return List of lines which were read or null on an error */ public static List readLines(String resourceFile, diff --git a/src/eva2/tools/CubicSpline.java b/src/eva2/tools/CubicSpline.java deleted file mode 100644 index d38ca38e..00000000 --- a/src/eva2/tools/CubicSpline.java +++ /dev/null @@ -1,210 +0,0 @@ -package eva2.tools; - -/** - * ******************************************************* - *

- * Class CubicSpline - *

- * Class for performing an interpolation using a cubic spline - * setTabulatedArrays and interpolate adapted from Numerical Recipes in C - *

- * WRITTEN BY: Mick Flanagan - *

- * DATE: May 2002 - *

- * DOCUMENTATION: - * See Michael T Flanagan's JAVA library on-line web page: - * CubicSpline.html - *

- * ******************************************************** - */ - -public class CubicSpline { - - private int npoints = 0; // no. of tabulated points - private double[] y = null; // y=f(x) tabulated function - private double[] x = null; // x in tabulated function f(x) - private double[] y2 = null; // returned second derivatives of y - private double yp1 = 0.0D; // first derivative at point one - // default value = zero (natural spline) - private double ypn = 0.0D; // first derivative at point n - // default value = zero (natural spline) - - // Constructors - // Constructor with data arrays initialised to arrays x and y - public CubicSpline(double[] x, double[] y) { - this.npoints = x.length; - if (this.npoints != y.length) { - throw new IllegalArgumentException("Arrays x and y are of different length"); - } - this.x = new double[npoints]; - this.y = new double[npoints]; - this.y2 = new double[npoints]; - for (int i = 0; i < this.npoints; i++) { - this.x[i] = x[i]; - this.y[i] = y[i]; - } - this.yp1 = 1e40; - this.ypn = 1e40; - } - - // Constructor with data arrays initialised to zero - // Primarily for use by BiCubicSpline - CubicSpline(int npoints) { - this.npoints = npoints; - this.x = new double[npoints]; - this.y = new double[npoints]; - this.y2 = new double[npoints]; - this.yp1 = 1e40; - this.ypn = 1e40; - } - - // METHODS - // Resets the x y data arrays - primarily for use in BiCubicSpline - public void resetData(double[] x, double[] y) { - if (x.length != y.length) { - throw new IllegalArgumentException("Arrays x and y are of different length"); - } - if (this.npoints != x.length) { - throw new IllegalArgumentException("Original array length not matched by new array length"); - } - for (int i = 0; i < this.npoints; i++) { - this.x[i] = x[i]; - this.y[i] = y[i]; - } - } - - // Returns a new CubicSpline setting array lengths to n and all array values to zero with natural spline default - // Primarily for use in BiCubicSpline - public static CubicSpline zero(int n) { - CubicSpline aa = new CubicSpline(n); - return aa; - } - - // Create a one dimensional array of cubic spline objects of length n each of array length m - // Primarily for use in BiCubicSpline - public static CubicSpline[] oneDarray(int n, int m) { - CubicSpline[] a = new CubicSpline[n]; - for (int i = 0; i < n; i++) { - a[i] = CubicSpline.zero(m); - } - return a; - } - - // Enters the first derivatives of the cubic spline at - // the first and last point of the tabulated data - // Overrides a natural spline - public void setDerivLimits(double yp1, double ypn) { - this.yp1 = yp1; - this.ypn = ypn; - } - - // Returns the internal array of second derivatives - public double[] getDeriv() { - return this.y2; - } - - // Calculates the second derivatives of the tabulated function - // for use by the cubic spline interpolation method (.interpolate) - public void calcDeriv() { - int i = 0, k = 0; - double p = 0.0D, qn = 0.0D, sig = 0.0D, un = 0.0D; - double[] u = new double[npoints]; - - if (yp1 > 0.99e30) { - y2[0] = u[0] = 0.0; - } else { - this.y2[0] = -0.5; - u[0] = (3.0 / (this.x[1] - this.x[0])) * ((this.y[1] - this.y[0]) / (this.x[1] - this.x[0]) - this.yp1); - } - - for (i = 1; i <= this.npoints - 2; i++) { - sig = (this.x[i] - this.x[i - 1]) / (this.x[i + 1] - this.x[i - 1]); - p = sig * this.y2[i - 1] + 2.0; - this.y2[i] = (sig - 1.0) / p; - u[i] = (this.y[i + 1] - this.y[i]) / (this.x[i + 1] - this.x[i]) - (this.y[i] - this.y[i - 1]) / (this.x[i] - this.x[i - 1]); - u[i] = (6.0 * u[i] / (this.x[i + 1] - this.x[i - 1]) - sig * u[i - 1]) / p; - } - - if (this.ypn > 0.99e30) { - qn = un = 0.0; - } else { - qn = 0.5; - un = (3.0 / (this.x[npoints - 1] - this.x[this.npoints - 2])) * (this.ypn - (this.y[this.npoints - 1] - this.y[this.npoints - 2]) / (this.x[this.npoints - 1] - x[this.npoints - 2])); - } - - this.y2[this.npoints - 1] = (un - qn * u[this.npoints - 2]) / (qn * this.y2[this.npoints - 2] + 1.0); - for (k = this.npoints - 2; k >= 0; k--) { - this.y2[k] = this.y2[k] * this.y2[k + 1] + u[k]; - } - } - - // INTERPOLATE - // Returns an interpolated value of y for a value of xfrom a tabulated function y=f(x) - // after the data has been entered via a constructor and the derivatives calculated and - // stored by calcDeriv(). - public double interpolate(double xx) { - int klo = 0, khi = 0, k = 0; - double h = 0.0D, b = 0.0D, a = 0.0D, yy = 0.0D; - - if (xx < this.x[0] || xx > this.x[this.npoints - 1]) { -// System.out.println(xx); - xx -= 0.00001; - //throw new IllegalArgumentException("x is outside the range of data points"); - } - - klo = 0; - khi = this.npoints - 1; - while (khi - klo > 1) { - k = (khi + klo) >> 1; - if (this.x[k] > xx) { - khi = k; - } else { - klo = k; - } - } - h = this.x[khi] - this.x[klo]; - - if (h == 0.0) { - throw new IllegalArgumentException("Two values of x are identical"); - } else { - a = (this.x[khi] - xx) / h; - b = (xx - this.x[klo]) / h; - yy = a * this.y[klo] + b * this.y[khi] + ((a * a * a - a) * this.y2[klo] + (b * b * b - b) * this.y2[khi]) * (h * h) / 6.0; - } - return yy; - } - - // Returns an interpolated value of y for a value of x (xx) from a tabulated function y=f(x) - // after the derivatives (deriv) have been calculated independently of and calcDeriv(). - public static double interpolate(double xx, double[] x, double[] y, double[] deriv) { - if (((x.length != y.length) || (x.length != deriv.length)) || (y.length != deriv.length)) { - throw new IllegalArgumentException("array lengths are not all equal"); - } - int n = x.length; - int klo = 0, khi = 0, k = 0; - double h = 0.0D, b = 0.0D, a = 0.0D, yy = 0.0D; - - klo = 0; - khi = n - 1; - while (khi - klo > 1) { - k = (khi + klo) >> 1; - if (x[k] > xx) { - khi = k; - } else { - klo = k; - } - } - h = x[khi] - x[klo]; - - if (h == 0.0) { - throw new IllegalArgumentException("Two values of x are identical"); - } else { - a = (x[khi] - xx) / h; - b = (xx - x[klo]) / h; - yy = a * y[klo] + b * y[khi] + ((a * a * a - a) * deriv[klo] + (b * b * b - b) * deriv[khi]) * (h * h) / 6.0; - } - return yy; - } - -} diff --git a/src/eva2/tools/JarResources.java b/src/eva2/tools/JarResources.java index 309150a5..c0d6c781 100644 --- a/src/eva2/tools/JarResources.java +++ b/src/eva2/tools/JarResources.java @@ -1,21 +1,7 @@ package eva2.tools; -/** - * Title: EvA2 - * Description: - * Copyright: Copyright (c) 2003 - * Company: University of Tuebingen, Computer Architecture - * @author Holger Ulmer, Felix Streichert, Hannes Planatscher - * @version: $Revision: 10 $ - * $Date: 2006-01-18 11:02:22 +0100 (Wed, 18 Jan 2006) $ - * $Author: streiche $ - */ -/*==========================================================================* - * IMPORTS - *==========================================================================*/ import java.io.BufferedInputStream; import java.io.FileInputStream; -import java.io.FileNotFoundException; import java.io.IOException; import java.util.Enumeration; import java.util.Hashtable; @@ -25,7 +11,7 @@ import java.util.zip.ZipInputStream; /** * JarResources: JarResources maps all resources included in a - * Zip or Jar file. Additionaly, it provides a method to extract one + * Zip or Jar file. Additionally, it provides a method to extract one * as a blob. */ public final class JarResources { @@ -34,15 +20,15 @@ public final class JarResources { public boolean debugOn = false; // jar resource mapping tables - private Hashtable htSizes = new Hashtable(); - private Hashtable htJarContents = new Hashtable(); + private Hashtable htSizes = new Hashtable<>(); + private Hashtable htJarContents = new Hashtable<>(); // a jar file private String jarFileName; /** * creates a JarResources. It extracts all resources from a Jar - * into an internal hashtable, keyed by resource names. + * into an internal HashTable, keyed by resource names. * * @param jarFileName a jar or zip file */ @@ -57,7 +43,7 @@ public final class JarResources { * @param name a resource name. */ public byte[] getResource(String name) { - return (byte[]) htJarContents.get(name); + return htJarContents.get(name); } /** @@ -73,15 +59,15 @@ public final class JarResources { if (debugOn) { System.out.println(dumpZipEntry(ze)); } - htSizes.put(ze.getName(), new Integer((int) ze.getSize())); + htSizes.put(ze.getName(), (int) ze.getSize()); } zf.close(); - // extract resources and put them into the hashtable. + // extract resources and put them into the HashTable. FileInputStream fis = new FileInputStream(jarFileName); BufferedInputStream bis = new BufferedInputStream(fis); ZipInputStream zis = new ZipInputStream(bis); - ZipEntry ze = null; + ZipEntry ze; while ((ze = zis.getNextEntry()) != null) { if (ze.isDirectory()) { continue; @@ -94,11 +80,11 @@ public final class JarResources { int size = (int) ze.getSize(); // -1 means unknown size. if (size == -1) { - size = ((Integer) htSizes.get(ze.getName())).intValue(); + size = htSizes.get(ze.getName()); } byte[] b = new byte[size]; int rb = 0; - int chunk = 0; + int chunk; while ((size - rb) > 0) { chunk = zis.read(b, rb, size - rb); if (chunk == -1) { @@ -106,7 +92,7 @@ public final class JarResources { } rb += chunk; } - // add to internal resource hashtable + // add to internal resource HashTable htJarContents.put(ze.getName(), b); if (debugOn) { System.out.println( @@ -118,8 +104,6 @@ public final class JarResources { } } catch (NullPointerException e) { System.out.println("done."); - } catch (FileNotFoundException e) { - e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } @@ -144,15 +128,15 @@ public final class JarResources { } sb.append(ze.getName()); sb.append("\t"); - sb.append("" + ze.getSize()); + sb.append("").append(ze.getSize()); if (ze.getMethod() == ZipEntry.DEFLATED) { - sb.append("/" + ze.getCompressedSize()); + sb.append("/").append(ze.getCompressedSize()); } return (sb.toString()); } /** - * Is a test driver. Given a jar file and a resource name, it trys to + * Is a test driver. Given a jar file and a resource name, it tries to * extract the resource and then tells us whether it could or not. *

* Example @@ -185,4 +169,4 @@ public final class JarResources { } } -} // End of JarResources class. +} diff --git a/src/eva2/tools/ReflectPackage.java b/src/eva2/tools/ReflectPackage.java index 5e65a93b..f576576e 100644 --- a/src/eva2/tools/ReflectPackage.java +++ b/src/eva2/tools/ReflectPackage.java @@ -41,7 +41,6 @@ public class ReflectPackage { * * @param pckgname * @return - * @throws ClassNotFoundException */ public static int getClassesFromFilesFltr(HashSet set, String path, String pckgname, boolean includeSubs, Class reqSuperCls) { try { @@ -91,9 +90,7 @@ public class ReflectPackage { } else { cntAdded += addClass(set, cls); } - } catch (Exception e) { - System.err.println("ReflectPackage: Couldnt get Class from jar for " + pckgname + '.' + file + ": " + e.getMessage()); - } catch (Error e) { + } catch (Exception | Error e) { System.err.println("ReflectPackage: Couldnt get Class from jar for " + pckgname + '.' + file + ": " + e.getMessage()); } } else if (includeSubs) { @@ -157,7 +154,7 @@ public class ReflectPackage { String jarEntryName = jarEntry.getName(); if ((jarEntryName.startsWith(packageName)) && (jarEntryName.endsWith(".class"))) { -// subpackages are hit here as well! + // subpackages are hit here as well! if (!includeSubs) { // check if the class belongs to a subpackage int lastDash = jarEntryName.lastIndexOf('/'); isInSubPackage = lastDash > packageName.length() + 1; diff --git a/src/eva2/tools/SelectedTag.java b/src/eva2/tools/SelectedTag.java index 3c07ccbf..70806cb6 100644 --- a/src/eva2/tools/SelectedTag.java +++ b/src/eva2/tools/SelectedTag.java @@ -4,7 +4,6 @@ package eva2.tools; * This serves as activation state of one item in an array of Tags * identified by integer IDs. String names should be unique as well as integer IDs. */ - public class SelectedTag implements java.io.Serializable { protected int selectedId; protected Tag[] tags; @@ -30,7 +29,7 @@ public class SelectedTag implements java.io.Serializable { * Constructor from a String array, creates a Tag array where the IDs correspond to array index. * * @param selID - * @param tagStrings + * @param strings */ public SelectedTag(int selID, String... strings) { init(selID, strings); diff --git a/src/eva2/tools/SerializedObject.java b/src/eva2/tools/SerializedObject.java index f17b9a1c..1323f0b8 100644 --- a/src/eva2/tools/SerializedObject.java +++ b/src/eva2/tools/SerializedObject.java @@ -26,7 +26,6 @@ public class SerializedObject implements Serializable { * * @param obj the Object to serialize. * @throws IOException - * @throws Exception if the object is not Serializable. */ public SerializedObject(Object obj) throws IOException { this(obj, false); @@ -38,7 +37,6 @@ public class SerializedObject implements Serializable { * @param obj the Object to serialize. * @param compress true if the object should be stored compressed. * @throws IOException - * @throws Exception if the object is not Serializable. */ public SerializedObject(Object obj, boolean compress) throws IOException { isCompressed = compress; @@ -51,8 +49,7 @@ public class SerializedObject implements Serializable { * @param obj the Object to serialize * @param compress true if the object should be compressed. * @return the byte array containing the serialized object. - * @throws IOException - * @throws Exception if the object is not Serializable. + * @throws IOException if the object is not Serializable. */ protected static byte[] toByteArray(Object obj, boolean compress) throws IOException { ByteArrayOutputStream bo = new ByteArrayOutputStream(); @@ -86,10 +83,6 @@ public class SerializedObject implements Serializable { Object result = oi.readObject(); oi.close(); return result; -// } catch (Exception ex) { -// ex.printStackTrace(); -// } -// return null; } /** diff --git a/src/eva2/tools/StringTools.java b/src/eva2/tools/StringTools.java index 9f60adcf..f1a7ed00 100644 --- a/src/eva2/tools/StringTools.java +++ b/src/eva2/tools/StringTools.java @@ -22,8 +22,8 @@ public final class StringTools { * Returns a HTML formatted String, in which each line is at most lineBreak * symbols long. * - * @param string - * @param lineBreak + * @param string Text to be converted to HTML + * @param lineBreak Number of characters until a line break is inserted * @return */ public static String toHTML(String string, int lineBreak) { @@ -129,7 +129,7 @@ public final class StringTools { || (!ignoreCase && (args[i].equals(keys[k])))) { // if the key was found found = true; if (arities[k] == 0) { - values[k] = new String("true"); + values[k] = "true"; } // and its zero-arity, just return true as its value else { // else return an array of size arity with following strings try { @@ -302,7 +302,7 @@ public final class StringTools { * Concatenate a list of Objects using a given delimiter string. * The objects are converted to strings using the BeanInspector class. * - * @param headlineFields + * @param objects * @param delim * @return */ @@ -337,7 +337,7 @@ public final class StringTools { /** * Remove or replace blanks, braces, etc. from a string for use as a file name. * - * @param predefName + * @param str * @return */ public static String simplifySymbols(String str) { diff --git a/src/eva2/tools/ToolBox.java b/src/eva2/tools/ToolBox.java index 7e369657..89bad3af 100644 --- a/src/eva2/tools/ToolBox.java +++ b/src/eva2/tools/ToolBox.java @@ -7,8 +7,6 @@ import java.util.List; /** * Collection of miscellaneous static helper methods. - * - * @author mkron */ public final class ToolBox { /** @@ -20,28 +18,29 @@ public final class ToolBox { /** * Convert all items of an enum to a String array and append the given String array at the end. * - * @param additionals + * @param e The enum to convert + * @param additionalValues Additional string values * @return */ - public static String[] appendEnumAndArray(Enum e, String[] additionals) { + public static String[] appendEnumAndArray(Enum e, String[] additionalValues) { Enum[] fields = e.getClass().getEnumConstants(); int enumLen = fields.length; //values().length; - int len = enumLen + additionals.length; + int len = enumLen + additionalValues.length; String[] ret = new String[len]; for (int i = 0; i < enumLen; i++) { ret[i] = fields[i].toString(); } - System.arraycopy(additionals, enumLen - enumLen, ret, enumLen, ret.length - enumLen); + System.arraycopy(additionalValues, enumLen - enumLen, ret, enumLen, ret.length - enumLen); return ret; } /** * Append two String arrays. If both are null, null is returned. * - * @param strArr1 - * @param strArr2 - * @return + * @param strArr1 First array + * @param strArr2 Second array + * @return A single array containing the merged set of values */ public static String[] appendArrays(String[] strArr1, String[] strArr2) { if (strArr1 == null) { @@ -82,16 +81,15 @@ public final class ToolBox { * converted double arrays whenever this is directly possible, or null otherwise. * The length of the array will correspond to the length of the given list. * - * @param l - * @return - * @see BeanInspector.toString(Object) + * @param l A list of Objects + * @return A double array containing the converted object values */ public static Double[] parseDoubles(List l) { - ArrayList vals = new ArrayList<>(); + ArrayList values = new ArrayList<>(); for (Object o : l) { - vals.add(toDouble(o)); // null if unsuccessfull + values.add(toDouble(o)); // null if unsuccessful } - return vals.toArray(new Double[vals.size()]); + return values.toArray(new Double[values.size()]); } /** @@ -107,8 +105,7 @@ public final class ToolBox { return ((Number) o).doubleValue(); } else { try { - Double d = Double.parseDouble(BeanInspector.toString(o)); - return d; + return Double.parseDouble(BeanInspector.toString(o)); } catch (Exception e) { // Here be dragons! } @@ -120,9 +117,8 @@ public final class ToolBox { * For an array of objects, generate an array of Double which contains the * converted double arrays whenever this is directly possible, or null otherwise. * - * @param l - * @return - * @see BeanInspector.toString(Object) + * @param os + * @return Double array containing the converted object values. */ public static Double[] parseDoubles(Object[] os) { Double[] vals = new Double[os.length]; diff --git a/src/eva2/tools/chart2d/DArea.java b/src/eva2/tools/chart2d/DArea.java index ac622657..ec48f5e8 100644 --- a/src/eva2/tools/chart2d/DArea.java +++ b/src/eva2/tools/chart2d/DArea.java @@ -94,10 +94,10 @@ public class DArea extends JComponent implements DParent, Printable { /** * method 'adds' a certain border around the contained rectangle that means - * that it takes the old border and takes the maxima of the old and the new + * that it takes the old border and takes the maximum of the old and the new * values * - * @param clip the java.awt.Insets object of the new clip + * @param b The border */ @Override public void addDBorder(DBorder b) { @@ -146,7 +146,7 @@ public class DArea extends JComponent implements DParent, Printable { /** * returns the measures of the DArea The DMeasures object calculates the - * different coodinates and contains a Graphics object to paint the + * different coordinates and contains a Graphics object to paint the * DElements of the area * * @return the measures of the DArea @@ -424,8 +424,7 @@ public class DArea extends JComponent implements DParent, Printable { * @param pf the @see java.awt.print.PageFormat * @param pi the page index * @return int @see java.awt.print.Printable - * @see java.awt.print.Printable and - * @see java.awt.print.PrintJob + * @see java.awt.print.Printable */ @Override public int print(Graphics g, PageFormat pf, int pi) { diff --git a/src/eva2/tools/chart2d/DArray.java b/src/eva2/tools/chart2d/DArray.java index 1445e93e..7f3e61a4 100644 --- a/src/eva2/tools/chart2d/DArray.java +++ b/src/eva2/tools/chart2d/DArray.java @@ -97,7 +97,7 @@ public class DArray implements DIntDoubleMap { * the given image value becomes the image of (highest source value + 1) * * @param image the new image value - * @return true<\code> when the minmal or the maximal image value + * @return true when the minimal or the maximal image value * has been changed by this method call, else it returns * false @see #getMinImageValue(), #getMaxImageValue() */ diff --git a/src/eva2/tools/chart2d/DComponent.java b/src/eva2/tools/chart2d/DComponent.java index 19bbc74b..a54a0a6d 100644 --- a/src/eva2/tools/chart2d/DComponent.java +++ b/src/eva2/tools/chart2d/DComponent.java @@ -6,7 +6,7 @@ import java.awt.*; * DComponent is the mother of all objects which can be displayed * by a DArea object, even when it would be also enough to * implement the DElement interface to an class - *

+ *

* DComponent is abstract because the paint method has to be overridden */ public abstract class DComponent implements DElement { diff --git a/src/eva2/tools/chart2d/DIntDoubleMap.java b/src/eva2/tools/chart2d/DIntDoubleMap.java index f6218cb5..b74968e7 100644 --- a/src/eva2/tools/chart2d/DIntDoubleMap.java +++ b/src/eva2/tools/chart2d/DIntDoubleMap.java @@ -16,7 +16,7 @@ public interface DIntDoubleMap { * * @param source the preimage of the image * @param image the new image of the source value - * @return true<\code> when the minmal or the maximal image value + * @return true when the minimal or the maximal image value * has been changed by this method call, else it returns * false @see #getMinImageValue(), #getMaxImageValue() */ @@ -34,7 +34,7 @@ public interface DIntDoubleMap { * the image of the highest source value + 1 should be the given image value * * @param image the new image value - * @return true<\code> when the minmal or the maximal image value + * @return true when the minimal or the maximal image value * has been changed by this method call, else it returns * false @see #getMinImageValue(), #getMaxImageValue() */ @@ -51,23 +51,23 @@ public interface DIntDoubleMap { * returns the maximal image value * * @return the maximal image value - * @throw an IllegalArgumentException when it has no image values + * @throws IllegalArgumentException when it has no image values */ double getMaxImageValue(); /** * returns the minimal image value * - * @return the minmal image value - * @throw an IllegalArgumentException when it has no image values + * @return the minimal image value + * @throws IllegalArgumentException when it has no image values */ double getMinImageValue(); /** * returns the minimal image value * - * @return the minmal image value - * @throw an IllegalArgumentException when it has no image values + * @return the minimal image value + * @throws IllegalArgumentException when it has no image values */ double getMinPositiveImageValue(); @@ -76,7 +76,7 @@ public interface DIntDoubleMap { * when at least one of them has changed * * @return true when either the maximal image value or the - * minmal image value has changed + * minimal image value has changed */ boolean restore(); diff --git a/src/eva2/tools/chart2d/DRectangle.java b/src/eva2/tools/chart2d/DRectangle.java index dd738e2f..f3c9418f 100644 --- a/src/eva2/tools/chart2d/DRectangle.java +++ b/src/eva2/tools/chart2d/DRectangle.java @@ -202,7 +202,7 @@ public class DRectangle extends DComponent { /** * method resizes the rectangle to insert p * - * @param the dPoint p to insert + * @param p the dPoint p to insert * @return true when the size of the rectangle changed */ public boolean insert(DPoint p) { diff --git a/src/eva2/tools/chart2d/ScaledBorder.java b/src/eva2/tools/chart2d/ScaledBorder.java index cdab04e9..40d057d6 100644 --- a/src/eva2/tools/chart2d/ScaledBorder.java +++ b/src/eva2/tools/chart2d/ScaledBorder.java @@ -144,8 +144,8 @@ public class ScaledBorder implements Border { } /** - * constructor creates a new ScaledBorder - * surrounded by the specified Border + * constructor creates a new ScaledBorder + * surrounded by the specified Border */ public ScaledBorder(Border outer) { outerBorder = outer; @@ -171,9 +171,8 @@ public class ScaledBorder implements Border { /** * method sets the differences between source x-values of the displayed values * - * @see setAutoScaleX(). - * If scale functions are used there might be a difference between the shown values - * and the source values + * If scale functions are used there might be a difference between the shown values + * and the source values */ public void setSrcdX(double dX) { autoScaleX = false; @@ -183,9 +182,8 @@ public class ScaledBorder implements Border { /** * method sets the differences between source y-values of the displayed values * - * @see setAutoScaleY(). - * If scale functions are used there might be a difference between the shown values - * and the source values + * If scale functions are used there might be a difference between the shown values + * and the source values */ public void setSrcdY(double dY) { autoScaleY = false; diff --git a/src/eva2/tools/math/Jama/util/Maths.java b/src/eva2/tools/math/Jama/util/Maths.java index f585f5cf..d337f4d2 100644 --- a/src/eva2/tools/math/Jama/util/Maths.java +++ b/src/eva2/tools/math/Jama/util/Maths.java @@ -3,9 +3,12 @@ package eva2.tools.math.Jama.util; public class Maths { /** - * sqrt(a^2 + b^2) without under/overflow. * + * sqrt(a^2 + b^2) without under/overflow. + * + * @param a + * @param b + * @return */ - public static double hypot(double a, double b) { double r; double aa = Math.abs(a); diff --git a/src/eva2/tools/matlab/JMatLink.java b/src/eva2/tools/matlab/JMatLink.java index ccc06ac0..c0ddc1fb 100644 --- a/src/eva2/tools/matlab/JMatLink.java +++ b/src/eva2/tools/matlab/JMatLink.java @@ -20,11 +20,11 @@ * 13.08.1999 thread implementation due to ActiveX thread problem (0.05) * - * 15.08.1999 intruduced 2 locking mechanisms to lock the engine and * + * 15.08.1999 introduced 2 locking mechanisms to lock the engine and * * wait for data to be return to caller. (0.06) * - * 16.08.1999 wait for all engine calls to return savely (0.06a)* + * 16.08.1999 wait for all engine calls to return safely (0.06a)* * 29.08.1999 made all engine routines "synchronized" (0.07) * @@ -113,15 +113,10 @@ package eva2.tools.matlab; // **** Thread programming. Notify and start and stop **** - // Look at - // file:///e%7C/jdk1.2/docs/guide/misc/threadPrimitiveDeprecation.html - -// on how to suspend, start, stop, interrupt a thread savely in JDK1.2.x - +// on how to suspend, start, stop, interrupt a thread safely in JDK1.2.x // The problem is ActiveX: one only can make calls to the engine library - // (especially engEvalString) from ONE single thread. import java.io.UnsupportedEncodingException; diff --git a/src/eva2/client/ClassPreloader.java b/src/eva2/util/ClassPreloader.java similarity index 95% rename from src/eva2/client/ClassPreloader.java rename to src/eva2/util/ClassPreloader.java index fc67d221..ea744506 100644 --- a/src/eva2/client/ClassPreloader.java +++ b/src/eva2/util/ClassPreloader.java @@ -1,4 +1,4 @@ -package eva2.client; +package eva2.util; import eva2.gui.editor.GenericObjectEditor; @@ -6,8 +6,6 @@ import eva2.gui.editor.GenericObjectEditor; * This Runnable just requests a number of classes as does the * GenericObjectEditor so that they are loaded into the system cache. It can be * done at startup time and accelerates later reloading. - * - * @author mkron */ public class ClassPreloader implements Runnable { diff --git a/src/eva2/client/EvAComAdapter.java b/src/eva2/util/EvAComAdapter.java similarity index 98% rename from src/eva2/client/EvAComAdapter.java rename to src/eva2/util/EvAComAdapter.java index d78c72b3..b884b6f1 100644 --- a/src/eva2/client/EvAComAdapter.java +++ b/src/eva2/util/EvAComAdapter.java @@ -1,4 +1,4 @@ -package eva2.client; +package eva2.util; import eva2.gui.LoggingPanel; diff --git a/src/eva2/util/package-info.java b/src/eva2/util/package-info.java index f645a25e..8fe78cd5 100644 --- a/src/eva2/util/package-info.java +++ b/src/eva2/util/package-info.java @@ -1 +1,4 @@ +/** + * Utility classes used in EvA + */ package eva2.util; \ No newline at end of file