diff --git a/.classpath b/.classpath new file mode 100644 index 00000000..bdb2412f --- /dev/null +++ b/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/.project b/.project new file mode 100644 index 00000000..51c6ca7b --- /dev/null +++ b/.project @@ -0,0 +1,17 @@ + + + JORelease + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Manifest.txt b/Manifest.txt new file mode 100644 index 00000000..66158fb8 --- /dev/null +++ b/Manifest.txt @@ -0,0 +1 @@ +Class-Path: lib/activation.jar lib/j2ssh-common.jar lib/jmatlink.jar lib/mail.jar lib/commons-logging.jar lib/j2ssh-core.jar lib/libJMatLink.so pop3.jar lib/wsi2.jar lib/imap.jar lib/j2ssh-dameon.jar lib/log4j.jar lib/smtp.jar lib/xalan2.jar lib/j2ssh-ant.jar lib/jdom.jar lib/mailapi.jar lib/sshfactory.jar lib/libJMatLink.so lib/windows/JMatLink.dll lib/windows/SNNS_jkr.dll diff --git a/ant/build.xml b/ant/build.xml new file mode 100644 index 00000000..1c76844f --- /dev/null +++ b/ant/build.xml @@ -0,0 +1,888 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Supported targets (default=compileAll): + ------------------------------------------------------------------------- + check - checks if all needed binary and source libraries are + available. + compile - compile all project files. + compileAll - 1. gets an actual version from the WSI library + 2. and compiles all project files. + javadoc - build project javadoc files + binaryDist - will create a complete binary distribution + clean - will clean up files, except the source files and the api + documentation + run - will start JavaEvA + + use 'ant -projecthelp' for further Main targets + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Test]]> + +
+ JavaEvA + + ]]> +
+ + + + + +
+
+ + + + + Checking Project Mess Detection (PMD) rulesets. + + + + + + + + + + + + + + + + result written to ${basedir}/${build.directory}/pmdReport4JavaEVA-${DSTAMP}_basic.html + + + + + + + + result written to ${basedir}/${build.directory}/pmdReport4JavaEVA-${DSTAMP}_braces.html + + + + + + + + result written to ${basedir}/${build.directory}/pmdReport4JavaEVA-${DSTAMP}_codesize.html + + + + + + + + result written to ${basedir}/${build.directory}/pmdReport4JavaEVA-${DSTAMP}_controversial.html + + + + + + + + result written to ${basedir}/${build.directory}/pmdReport4JavaEVA-${DSTAMP}_coupling.html + + + + + + + + result written to ${basedir}/${build.directory}/pmdReport4JavaEVA-${DSTAMP}_finalizers.html + + + + + + + + result written to ${basedir}/${build.directory}/pmdReport4JavaEVA-${DSTAMP}_imports.html + + + + + + + + result written to ${basedir}/${build.directory}/pmdReport4JavaEVA-${DSTAMP}_naming.html + + + + + + + + result written to ${basedir}/${build.directory}/pmdReport4JavaEVA-${DSTAMP}_strictexception.html + + + + + + + + result written to ${basedir}/${build.directory}/pmdReport4JavaEVA-${DSTAMP}_strings.html + + + + + + + + result written to ${basedir}/${build.directory}/pmdReport4JavaEVA-${DSTAMP}_unusedcode.html + + + WARNING: use environment variable: ANT_OPTS=-Xmx512m or this task will fail. + Checking for duplicated code using the Copy/Paste Detector (CPD). + + + + + + + + + + + + + + result written to ${basedir}/${build.directory}/duplicatedCodeReport4JavaEVA-${DSTAMP}.txt + + + + + Starts JavaNCSS ... + + + + + + + + + Cyclomatic +Complexity Ease of Risk +Number (CCN) maintenance +(McCabe metric) +--------------------------------------------- +1-10, simple easy minimum +11-20, complex moderate moderate +21-50, more complex hard high +>50, unstable very hard very high + + + + result written to ${basedir}/${build.directory}/javancssReport4JavaEVA-${DSTAMP}.txt + + + + + + + + + + + + + + + Starts VizANT ... + + + + + + + + + + + + + + + + + + + + + + + + + result written to ${basedir}/${build.directory}/vizant_build.dot ... + result written to ${basedir}/${build.directory}/vizant_check.dot. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Starts findBugs ... + + result written to ${basedir}/${build.directory}/javaeva-fb.xml, now you can open this file with the findBugs GUI ... + open with 'File->LoadBugs' then open '${basedir}/${build.directory}/javaeva-fb.xml'. + + +
+ + diff --git a/ant/check.xml b/ant/check.xml new file mode 100644 index 00000000..f195fb0a --- /dev/null +++ b/ant/check.xml @@ -0,0 +1,104 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ant/out b/ant/out new file mode 100644 index 00000000..234c307f --- /dev/null +++ b/ant/out @@ -0,0 +1,52 @@ +Buildfile: build.xml + +usage: + [echo] + [echo] Supported targets (default=compileAll): + [echo] ------------------------------------------------------------------------- + [echo] check - checks if all needed binary and source libraries are + [echo] available. + [echo] compile - compile all project files. + [echo] compileAll - 1. gets an actual version from the WSI library + [echo] 2. and compiles all project files. + [echo] javadoc - build project javadoc files + [echo] binaryDist - will create a complete binary distribution + [echo] clean - will clean up files, except the source files and the api + [echo] documentation + [echo] run - will start JavaEvA + [echo] + [echo] use 'ant -projecthelp' for further Main targets + [echo] + +init: + +buildDirectories: + +check: + +binary.libraries.check: + +binary.libraries.test.SNNS.windows: + +binary.libraries.test.SNNS.unix: + [echo] WARNING: lib/linux/libSNNS_jkr.so not available. + +binary.libraries.test.WSI: + [echo] WARNING: wsi package not available at lib/wsi.jar. + +binary.libraries.test.JavaNNS: + [echo] WARNING: javanns package not available at lib/JavaNNS.jar. + +binary.libraries.test: + +compileInfo: + [echo] ANT_HOME is set to = c:\jakarta-ant-1.5.1 + [echo] JAVA_HOME is set to = c:\j2sdk1.4.1 + [echo] You are using JDK version 1.4 + [echo] currently JDK version 1.3 is recomended! + + [echo] use 'ant compileAll' - to compile all java sources (+ WSI). + [echo] use 'ant compile' - to compile only the java sources (faster). + +compile: + [javac] Compiling 223 source files to Z:\work\JOpt\build diff --git a/lastmodule.ser b/lastmodule.ser new file mode 100644 index 00000000..9714c0dc Binary files /dev/null and b/lastmodule.ser differ diff --git a/resources/ConvergenceTerminator.html b/resources/ConvergenceTerminator.html new file mode 100644 index 00000000..0fd630c2 --- /dev/null +++ b/resources/ConvergenceTerminator.html @@ -0,0 +1,13 @@ + + +Convergence Terminator + + +

Convergence Terminator

+
+

+The convergence terminator stops the optimization, when there has been hardly +any change in the best population fitness (within percentual range) for a certain +time, given in generations or fitness calls. + + \ No newline at end of file diff --git a/resources/Default.html b/resources/Default.html new file mode 100644 index 00000000..c25cad58 --- /dev/null +++ b/resources/Default.html @@ -0,0 +1,15 @@ + + +Default page + + +  +

HTML description file is missing

+
+

+Unfortunately there is no additional HTML description +file to this class. Please refer to the JOptDocumentation +file or the JavaDoc for more information on this class. + + + \ No newline at end of file diff --git a/resources/EPSILON_SVM.html b/resources/EPSILON_SVM.html new file mode 100644 index 00000000..e80ece2b --- /dev/null +++ b/resources/EPSILON_SVM.html @@ -0,0 +1,13 @@ + + +Epsilon SV-Regression + + +  +

Epsilon SV-Regression

+
+

+Please read the JavaEvA manual for a detailed description. + + + \ No newline at end of file diff --git a/resources/ESIndividual.html b/resources/ESIndividual.html new file mode 100644 index 00000000..867a80aa --- /dev/null +++ b/resources/ESIndividual.html @@ -0,0 +1,16 @@ + + +ESIndividual + + +  +

ESIndividual

+
+

+This element represents the properties of an individual. +The most important evolutionary operator of an ES is +the mutation of the objective variables representing +the solution of the problem, which is responsible +for the self-adaptation capability of the ES + + \ No newline at end of file diff --git a/resources/ESInitPopulationDOptimal.html b/resources/ESInitPopulationDOptimal.html new file mode 100644 index 00000000..3fda59a2 --- /dev/null +++ b/resources/ESInitPopulationDOptimal.html @@ -0,0 +1,18 @@ + + +f_1 : Sphere function + + +  +

ESInitPopulationSpaceFilling

+
+

+ESPara contains the information describing the Evolution Strategy: + + + \ No newline at end of file diff --git a/resources/ESInitPopulationRandom.html b/resources/ESInitPopulationRandom.html new file mode 100644 index 00000000..4cccdc84 --- /dev/null +++ b/resources/ESInitPopulationRandom.html @@ -0,0 +1,10 @@ + + +ESInitPopulationRandom + + +  +

ESInitPopulationRandom

+
+

+Here you can specify the number of individuals, which are randomly initialized. \ No newline at end of file diff --git a/resources/ESInitPopulationSpaceFilling.html b/resources/ESInitPopulationSpaceFilling.html new file mode 100644 index 00000000..3fda59a2 --- /dev/null +++ b/resources/ESInitPopulationSpaceFilling.html @@ -0,0 +1,18 @@ + + +f_1 : Sphere function + + +  +

ESInitPopulationSpaceFilling

+
+

+ESPara contains the information describing the Evolution Strategy: + + + \ No newline at end of file diff --git a/resources/ESPara.html b/resources/ESPara.html new file mode 100644 index 00000000..ad6427c3 --- /dev/null +++ b/resources/ESPara.html @@ -0,0 +1,17 @@ + + +f_1 : Sphere function + +  +

Parameters for the Evolution Strategy

+
+

+The Java Class ESPara contains the information describing an Evolution Strategy (ES): + + + \ No newline at end of file diff --git a/resources/ESPopulation.html b/resources/ESPopulation.html new file mode 100644 index 00000000..1b8b65ee --- /dev/null +++ b/resources/ESPopulation.html @@ -0,0 +1,18 @@ + + +ESPopulation + +  +

ESPopulation

+
+

+ESPopulation contains the information describing an Evolution Strategy (ES): + + + \ No newline at end of file diff --git a/resources/ESRecombination.html b/resources/ESRecombination.html new file mode 100644 index 00000000..0f764bf9 --- /dev/null +++ b/resources/ESRecombination.html @@ -0,0 +1,18 @@ + + +ESRecombination + + +  +

ESRecombination

+
+

+The recombination operator has the following editable properties: + + + \ No newline at end of file diff --git a/resources/ESSelectionStrategyComma.html b/resources/ESSelectionStrategyComma.html new file mode 100644 index 00000000..50da1887 --- /dev/null +++ b/resources/ESSelectionStrategyComma.html @@ -0,0 +1,12 @@ + + +ES Comma Selection + + +  +

ES Comma Selection Operator

+
+

+The best mu individuals are selected from lambda offspring individuals. + + \ No newline at end of file diff --git a/resources/ESSelectionStrategyMedian.html b/resources/ESSelectionStrategyMedian.html new file mode 100644 index 00000000..bb41fb2d --- /dev/null +++ b/resources/ESSelectionStrategyMedian.html @@ -0,0 +1,26 @@ + + +ES - Median Selection + + +  +

ES Median Selection Strategy

+
+

+The main application field of the Median Selection Strategy +operator are steady state algorithms. +A standard steady-state ES is equivalent to a (mu + 1) ES. +Only one individual is generated and evaluated +at each step and gets immediately integrated into the population. +Compared to generation based algorithms the information of +new evaluated individuals can be integrated directly into the optimization process. +The idea is to approximate the selection mechanism +of a standard (mu,lambda) ES, by +using a fitness buffer containing +fitness values of the last n evaluations. +Given a relative rate of acceptance r=mu\lambda. +A newly evaluated individual substitutes the worst individual +of the population, if it has a better fitness than the r*n best individuals +in the buffer. + + \ No newline at end of file diff --git a/resources/ESSelectionStrategyMixed.html b/resources/ESSelectionStrategyMixed.html new file mode 100644 index 00000000..5fb72426 --- /dev/null +++ b/resources/ESSelectionStrategyMixed.html @@ -0,0 +1,18 @@ + + +f_1 : Sphere function + + +  +

ESSelectionStrategyMedian

+
+

+ESPara contains the information describing the Evolution Strategy: + + + \ No newline at end of file diff --git a/resources/ESSelectionStrategyPlus.html b/resources/ESSelectionStrategyPlus.html new file mode 100644 index 00000000..88f18849 --- /dev/null +++ b/resources/ESSelectionStrategyPlus.html @@ -0,0 +1,13 @@ + + +Plus Selection Strategy + + +  +

ES Plus Selection Operator

+
+

+The best mu individuals are selected from the +aggregation of the lambda offspring individuals and the mu parents. + + \ No newline at end of file diff --git a/resources/EvolutionStrategies.html b/resources/EvolutionStrategies.html new file mode 100644 index 00000000..4ec6818b --- /dev/null +++ b/resources/EvolutionStrategies.html @@ -0,0 +1,21 @@ + + +Evolution Strategy - ES + + +  +

Evolution Strategy - ES

+
+

+An ES works on a population of real valued solutions +by repeated use of evolutionary operators like reproduction, +recombination and mutation (see pseudocode in figures. +lambda offspring individuals are generated from mu parents +by recombination and mutation. After evaluating the fitness of the lambda +offspring individuals, mu individuals with the best fitness are +selected by a comma-strategy to build the parent population for the next generation. +On the other hand, a plus-strategy selects the best mu individuals +from the aggregation of parents and offspring individuals. +The properties of ES are given in the population sub frame. + + \ No newline at end of file diff --git a/resources/F1Problem.html b/resources/F1Problem.html new file mode 100644 index 00000000..00b97033 --- /dev/null +++ b/resources/F1Problem.html @@ -0,0 +1,24 @@ + + +f_1 : Sphere function + +  +

The Sphere function

+
+ +

+The sphere function is a n-dimensional, axis-symmetric, continuously differentiable, convex function: +

+Because of its simplicity every optimization-algorithm should be able to find its global minimum at x=[0, 0, ... , 0] +

+ + + +


+More information about the sphere function can be found at: +

+ +Kenneth De Jong. An analysis of the behaviour of a class of genetic adaptive systems. Dissertation, University of Michigan, 1975. Diss. Abstr. Int. 36(10), 5140B, University Microflims No. 76-9381. + + + \ No newline at end of file diff --git a/resources/F2Problem.html b/resources/F2Problem.html new file mode 100644 index 00000000..7397650e --- /dev/null +++ b/resources/F2Problem.html @@ -0,0 +1,36 @@ + + +Generalized Rosenbrock's function + +  +

Generalized Rosenbrock's function

+
+ +
+

+This function i unimodal and continuous, but the global optimum is hard to find, because of independence through the term (x_(i+1) - x_i*x_i)^2 between contiguous parameters. +

+ +
+Rosenbrock's function within the co-domain -5 <= x <= 5. +

+The global optimum is located in a prabolic formed valley (among the curve x^2 = x_1^2), which has a flatten ground. +
+ +
+The function close to its global optimum, which is: f(x) = f(1, 1, ... , 1) = 0. +

+Rosenbrock' function is not symmetric, not convex and not linear. + +


+More information about Rosenbrock's function can be found at: +

+Kenneth De Jong. An analysis of the behaviour of a class of genetic adaptive systems. Dissertation, University of Michigan, 1975. Diss. Abstr. Int. 36(10), 5140B, University Microflims No. 76-9381. +

+Hans Paul Schwefel. Evolution and optimum seeking. Sixth-Generation Computer Technology Series. John Wiley & Sons, INC., 1995. +

+Darrell Whitley, Soraya Rana, John Dzubera, Keith E. Mathias. Evaluating Evolutionary Algorithms. Artificial Intelligence, 85(1-2):245-276. 1996. +

+Eberhard Schoeneburg, Frank Heinzmann, Sven Feddersen. Genetische Algorithmen und Evolutionstrategien - Eine Einfuehrung in Theorie und Praxis der simulierten Evolution. Addison-Wesley, 1994. + + \ No newline at end of file diff --git a/resources/F3Problem.html b/resources/F3Problem.html new file mode 100644 index 00000000..a082d759 --- /dev/null +++ b/resources/F3Problem.html @@ -0,0 +1,29 @@ + + +The step function + +  +

The step function

+
+ +
+

+The idea of this function is the implementation of a flat plateau (slope 0)in an underlying continuous function.Its harder for optimization algortihms to find optimums because minor changes of the object variables don't affect the fitness. Therefore no conclusions about the search direction can be made. +

+ +

+The step function is symmetric considering the underlying function (here: f(x,y) = f(y,x)), but between the bulk constant plateau-areas not continuously differentiable. +

+Its minimum-area is located in the intervalls: f(x)=f([-5.12,-5), ... , [-5.12,-5))=0. +

+ +


+More information about the step function can be found at: +

+Thomas Baeck, Evolutionary Algorithms in Theory and Practice. Oxford University Press, 1996. +

+Darrell Whitley, Soraya Rana, John Dzubera, Keith E. Mathias. Evaluating Evolutionary Algorithms. Artificial Intelligence, 85(1-2):245-276. 1996. +

+Eberhard Schoeneburg, Frank Heinzmann, Sven Feddersen. Genetische Algorithmen und Evolutionstrategien - Eine Einfuehrung in Theorie und Praxis der simulierten Evolution. Addison-Wesley, 1994. + + \ No newline at end of file diff --git a/resources/F5Problem.html b/resources/F5Problem.html new file mode 100644 index 00000000..4d8ac72a --- /dev/null +++ b/resources/F5Problem.html @@ -0,0 +1,27 @@ + + +Schwefel's double sum + +  +

Schwefels double sum

+
+ +
+

+Schwefel's double sum is a quadratic minimization problem which difficulty increases by the dimension n in O(n˛). It is used for analysis of correlating mutations. +

+It possesses specific symmetrical properties:
+ + +

+Its minimum is located at: f(x)=f([0, 0, ... , 0])=0 +

+ + +


+More information about Schwefel's double sum can be found at: +

+Hans Paul Schwefel. Evolution and optimum seeking. Sixth-Generation Computer Technology Series. John Wiley & Sons, INC., 1995. + + + \ No newline at end of file diff --git a/resources/F6Problem.html b/resources/F6Problem.html new file mode 100644 index 00000000..70abac76 --- /dev/null +++ b/resources/F6Problem.html @@ -0,0 +1,42 @@ + + +Generalized Rastrigin's function + +  +

Generalized Rastrigin's function

+
+ +
+

+Rastrigin's function is symmetric. It is based on the simple sphere function (called f_1 in the JavaEvaŠ context), but it is multimodal because a modulation term on the basis of the cosine function is added. This evokes hills and valleys which are misleading local optimums. +

+Values are used for the following illustrations: A=10, ω=2*π, n=2. + +
+ + +
+ +Rastrigin's function within the co-domain -20>=x>=20 + +

+ +
+ +Rastrigin's function within the co-domain -5>=x>=5 + +

+ +Like Ackley's function a simple evolutionary algorithm would get stuck in a local optimum, while a broader searching algorithm would get out of the local optimum closer to the global optimum, which in this case is: f(x) = f(0, 0, ... , 0) = 0. +

+
+Rastrigin's function close to its optimum. + +


+More information about Rastrigin's function can be found at: +

+Darrell Whitley, Soraya Rana, John Dzubera, Keith E. Mathias. Evaluating Evolutionary Algorithms. Artificial Intelligence, 85(1-2):245-276. 1996. +

+Eberhard Schoeneburg, Frank Heinzmann, Sven Feddersen. Genetische Algorithmen und Evolutionstrategien - Eine Einfuehrung in Theorie und Praxis der simulierten Evolution. Addison-Wesley, 1994. + + \ No newline at end of file diff --git a/resources/F8Problem.html b/resources/F8Problem.html new file mode 100644 index 00000000..64f45238 --- /dev/null +++ b/resources/F8Problem.html @@ -0,0 +1,34 @@ + + +Ackley's function + +  +

Ackley's function

+
+ +
+

+Ackley's function is intense multimodal and symmetrical. It refers to an exponential function which is modulated through a cosine function. The outside region is almost planar by the growing influence of the exponential function. In the center it possesses a hole by the influence of the cosine function.
+Its minimum is at: f(x)=f([0, 0, ... , 0])=0. +

+The difficulty for an optmization algorithm is mid-graded because a simple optimization-algorithm like hill-climbing would get stuck in a local minimum. The optimization algorithm has to search a broader environ to overcome the local minimum and get closer to the global optima. + +

+ + +
+Ackley's function within the co-domain -20 >= x >= 20, a=20, b=0.2, c=2*π, n=2. +

+ + +
+Ackley's function close to the optimum. +


+More information about Ackley's function can be found at: +

+David. H. Ackley. A connection machine for genetic hillclimbing. Kluwer Academic Publishers, Boston, 1987. +

+Thomas Baeck. Evolutionary Algorithms in Theory and Practice. Oxford University Press, 1996. + + + \ No newline at end of file diff --git a/resources/GO.html b/resources/GO.html new file mode 100644 index 00000000..f4687953 --- /dev/null +++ b/resources/GO.html @@ -0,0 +1,17 @@ + + +JavaEvA Genetic Optimization + + +

The JavaEvA Genetic Optimization Module

+
+The Genetic Optimization module allows the application of a variety of +nature-inspired heuristics within one framework. You can combine several +datatypes as representations with specific evolutionary operators and +widely independently choose an optimization strategy. Some strategies, +however, only work with certain datatypes. Most remarkably, DE and PSO +require a real-valued representations for the moment, whereas GA, for example, +is typically run with a binary datatype but also works on real valued individuals +by just accessing the analoguous evolutionary operators. + + diff --git a/resources/GOParameters.html b/resources/GOParameters.html new file mode 100644 index 00000000..a76b4b03 --- /dev/null +++ b/resources/GOParameters.html @@ -0,0 +1,25 @@ + + +JavaEvA Genetic Optimization + + +

Genetic Optimization Parameters

+
+The GO parameter class is used to change main GO optimization settings. You may: + +Note:
+The evolutionary operators used by a strategy are tightly connected to the representation used. +On the other hand, the representation is usually defined by the underlying problem, therefore, +to change the operators effecting the individuals, select the problem and set them within the +Individual class presented there. Also note, that not all optimizers can handle all types +of representations. + + \ No newline at end of file diff --git a/resources/GaussProcess.html b/resources/GaussProcess.html new file mode 100644 index 00000000..7b33ff24 --- /dev/null +++ b/resources/GaussProcess.html @@ -0,0 +1,13 @@ + + +Gauss Process Regression Model + + +  +

Gauss Process Regression Model

+
+

+Please read the JavaEvA manual for a detailed description. + + + \ No newline at end of file diff --git a/resources/JavaEvA.props b/resources/JavaEvA.props new file mode 100644 index 00000000..7b82dc18 --- /dev/null +++ b/resources/JavaEvA.props @@ -0,0 +1,19 @@ +# Select a default module. Set empty or comment out to select from all available modules. +# +# possible values are the names of module objects as returned by their getName method (!). +# DefaultModule = Evolution_Strategy +DefaultModule = Genetic_Optimization + +## Uncomment this to show all loadable modules. Most are redundant, though. +ShowModules + +ServerList = localhost,134.2.172.14,ranode22 + +# base class for modules. Do not alter! +ModulePackage = javaeva.server.modules + +# filter class for modules. Do not alter! +ModuleFilterClass = javaeva.server.modules.AbstractModuleAdapter + +###################### The GO part ###################################### +# there are no further props necessary \ No newline at end of file diff --git a/resources/MAES.html b/resources/MAES.html new file mode 100644 index 00000000..69d5849a --- /dev/null +++ b/resources/MAES.html @@ -0,0 +1,28 @@ + + +Model Assisted Evolution Strategy - MAES + + +  +

Model Assisted Evolution Strategy - MAES

+
+

+In the pre-selection concept lambdaPlus>lambda +individuals are generated from mu parents. +All lambdaPlus individuals are evaluated by a +surrogate model of the fitness landscape and the estimated +fitness values are used to pre-select the lambda +best individuals, which will be evaluated with +the real fitness function. +The model is trained at the beginning with a randomly created +initial population and is updated after each generation +step with lambda new fitness cases. +The idea behind this approach is that only the +most promising individuals with a good fitness prediction +are evaluated with the true fitness function. + +Every generation a new offspring lambda is evaluated with the real fitness function, +the model is updated with this information of \lambda fitness cases. + + + \ No newline at end of file diff --git a/resources/MAESIndividual.html b/resources/MAESIndividual.html new file mode 100644 index 00000000..c7c2a730 --- /dev/null +++ b/resources/MAESIndividual.html @@ -0,0 +1,16 @@ + + +MAESIndividual + + +  +

MAESIndividual

+
+

+This element represents the properties of an individual. +The most important evolutionary operator of an ES is +the mutation of the objective variables representing +the solution of the problem, which is responsible +for the self-adaptation capability of the ES + + \ No newline at end of file diff --git a/resources/MAESPara.html b/resources/MAESPara.html new file mode 100644 index 00000000..3856eb08 --- /dev/null +++ b/resources/MAESPara.html @@ -0,0 +1,17 @@ + + +MAESPara + +  +

MAESPara

+
+

+MAESPara contains the information describing an Evolution Strategy (ES): + + + \ No newline at end of file diff --git a/resources/MAESPopulation.html b/resources/MAESPopulation.html new file mode 100644 index 00000000..36328310 --- /dev/null +++ b/resources/MAESPopulation.html @@ -0,0 +1,23 @@ + + +MAESPopulation + +  +

Model Assisted Population

+
+

+The MAESPopulation panel contains the information describing the Model Assisted Evolution Strategy (MAES): + + + \ No newline at end of file diff --git a/resources/MAESRecombination.html b/resources/MAESRecombination.html new file mode 100644 index 00000000..c5dcb583 --- /dev/null +++ b/resources/MAESRecombination.html @@ -0,0 +1,18 @@ + + +MAESRecombination + + +  +

MAESRecombination

+
+

+The recombination operator has the following editable properties: + + + \ No newline at end of file diff --git a/resources/MAESSelectionStrategyComma.html b/resources/MAESSelectionStrategyComma.html new file mode 100644 index 00000000..4c96d77e --- /dev/null +++ b/resources/MAESSelectionStrategyComma.html @@ -0,0 +1,12 @@ + + +MAES Comma Selection + + +  +

MAES Comma Selection Operator

+
+

+The best mu individuals are selected from lambda offspring individuals. + + \ No newline at end of file diff --git a/resources/MAESSelectionStrategyMedian.html b/resources/MAESSelectionStrategyMedian.html new file mode 100644 index 00000000..8fa75fb6 --- /dev/null +++ b/resources/MAESSelectionStrategyMedian.html @@ -0,0 +1,32 @@ + + +MAES - Median Selection + + +  +

MAES Median Selection Strategy

+
+

+The main application field of the Median Selection Strategy +operator are steady state algorithms. +A standard steady-state ES is equivalent to a (mu + 1) ES. +Only one individual is generated and evaluated +at each step and gets immediately integrated into the population. +Compared to generation based algorithms the information of +new evaluated individuals can be integrated directly into the optimization process. +The idea is to approximate the selection mechanism +of a standard (mu,lambda) ES, by +using a fitness buffer containing +fitness values of the last n evaluations. +Given a relative rate of acceptance r=mu\lambda. +A newly evaluated individual substitutes the worst individual +of the population, if it has a better fitness than the r*n best individuals +in the buffer. + + + \ No newline at end of file diff --git a/resources/MAESSelectionStrategyPlus.html b/resources/MAESSelectionStrategyPlus.html new file mode 100644 index 00000000..8cc93b09 --- /dev/null +++ b/resources/MAESSelectionStrategyPlus.html @@ -0,0 +1,13 @@ + + +Plus Selection Strategy + + +  +

MAES Plus Selection Operator

+
+

+The best mu individuals are selected from the +aggredation of the lambda offspring individuals and the mu parents. + + \ No newline at end of file diff --git a/resources/MOCCO/MOCCO_GDF.gif b/resources/MOCCO/MOCCO_GDF.gif new file mode 100644 index 00000000..d4a7f2c1 Binary files /dev/null and b/resources/MOCCO/MOCCO_GDF.gif differ diff --git a/resources/MOCCO/MOCCO_MOEA.gif b/resources/MOCCO/MOCCO_MOEA.gif new file mode 100644 index 00000000..a2910c1a Binary files /dev/null and b/resources/MOCCO/MOCCO_MOEA.gif differ diff --git a/resources/MOCCO/MOCCO_REFP.gif b/resources/MOCCO/MOCCO_REFP.gif new file mode 100644 index 00000000..8d113173 Binary files /dev/null and b/resources/MOCCO/MOCCO_REFP.gif differ diff --git a/resources/MOCCO/MOCCO_STEP.gif b/resources/MOCCO/MOCCO_STEP.gif new file mode 100644 index 00000000..5962168a Binary files /dev/null and b/resources/MOCCO/MOCCO_STEP.gif differ diff --git a/resources/MOCCO/MOCCO_TBCH.gif b/resources/MOCCO/MOCCO_TBCH.gif new file mode 100644 index 00000000..a44c66b0 Binary files /dev/null and b/resources/MOCCO/MOCCO_TBCH.gif differ diff --git a/resources/MOPReference/T1_250.txt b/resources/MOPReference/T1_250.txt new file mode 100644 index 00000000..0778cc1a --- /dev/null +++ b/resources/MOPReference/T1_250.txt @@ -0,0 +1,252 @@ +x1 x2 +0.0 1.0 +0.0040 0.9367544467966324 +0.0080 0.9105572809000084 +0.012 0.8904554884989668 +0.016 0.8735088935932649 +0.02 0.8585786437626906 +0.024 0.8450806661517033 +0.028 0.8326679946931849 +0.032 0.8211145618000169 +0.036000000000000004 0.8102633403898972 +0.04 0.8 +0.044 0.7902382303659696 +0.048 0.7809109769979335 +0.052000000000000005 0.7719649149801724 +0.056 0.7633568086760154 +0.06 0.7550510257216823 +0.064 0.7470177871865297 +0.068 0.739231903791894 +0.07200000000000001 0.7316718427000253 +0.076 0.7243190249581956 +0.08 0.717157287525381 +0.084 0.7101724650762112 +0.088 0.7033520605161735 +0.092 0.696684982237938 +0.096 0.6901613323034066 +0.1 0.683772233983162 +0.10400000000000001 0.677509690068058 +0.108 0.6713664654969003 +0.112 0.6653359893863697 +0.116 0.659412272681472 +0.12 0.6535898384862245 +0.124 0.6478636627668198 +0.128 0.6422291236000337 +0.132 0.6366819575083009 +0.136 0.6312182217082845 +0.14 0.6258342613226058 +0.14400000000000002 0.6205266807797944 +0.148 0.6152923187665731 +0.152 0.6101282262076415 +0.156 0.60503164683737 +0.16 0.6 +0.164 0.5950308653736682 +0.168 0.590121969361616 +0.17200000000000001 0.5852711729334455 +0.176 0.5804764607319394 +0.18 0.5757359312880714 +0.184 0.5710477882094557 +0.188 0.566410332226424 +0.192 0.5618219539958671 +0.196 0.5572811275764269 +0.2 0.5527864045000421 +0.20400000000000001 0.5483364083745514 +0.20800000000000002 0.5439298299603448 +0.212 0.5395654226711465 +0.216 0.53524199845511 +0.22 0.530958424017657 +0.224 0.5267136173520307 +0.228 0.522506544547467 +0.232 0.5183362168483081 +0.23600000000000002 0.5142016879403553 +0.24 0.5101020514433644 +0.244 0.5060364385908612 +0.248 0.5020040160804506 +0.252 0.4980039840795547 +0.256 0.49403557437305934 +0.26 0.4900980486407215 +0.264 0.4861906968533948 +0.268 0.4823128357782086 +0.272 0.47846380758378804 +0.276 0.4746429785374521 +0.28 0.47084973778708183 +0.28400000000000003 0.46708349622103085 +0.28800000000000003 0.46334368540005044 +0.292 0.4596297565557482 +0.296 0.45594117965058223 +0.3 0.4522774424948339 +0.304 0.4486380499163911 +0.308 0.4450225229795357 +0.312 0.44143039824924235 +0.316 0.4378612270977922 +0.32 0.434314575050762 +0.324 0.4307900211696917 +0.328 0.42728715746894586 +0.332 0.4238055883644827 +0.336 0.42034493015242247 +0.34 0.4169048105154699 +0.34400000000000003 0.41348486805539275 +0.34800000000000003 0.4100847518498949 +0.352 0.406704121032347 +0.356 0.4033426443929481 +0.36 0.4 +0.364 0.3966758748400657 +0.368 0.3933699644758759 +0.372 0.3900819727209237 +0.376 0.3868116113297644 +0.38 0.38355859970310235 +0.384 0.3803226646068133 +0.388 0.3771035399041025 +0.392 0.37390096630005887 +0.396 0.3707146910979091 +0.4 0.3675444679663241 +0.404 0.36439005671717184 +0.40800000000000003 0.3612512230931475 +0.41200000000000003 0.35812773856475144 +0.41600000000000004 0.355019380136116 +0.42 0.35192593015921403 +0.424 0.3488471761560118 +0.428 0.3457829106481549 +0.432 0.34273293099380064 +0.436 0.33969703923123284 +0.44 0.33667504192892006 +0.444 0.3336667500416928 +0.448 0.33067197877273957 +0.452 0.32769054744113557 +0.456 0.3247222793546347 +0.46 0.3217670016874732 +0.464 0.3188245453629439 +0.468 0.31589474494051717 +0.47200000000000003 0.3129774385072932 +0.47600000000000003 0.3100724675735864 +0.48 0.3071796769724491 +0.484 0.30429891476295656 +0.488 0.30143003213708075 +0.492 0.29857288332999277 +0.496 0.2957273255336397 +0.5 0.2928932188134524 +0.504 0.2900704260280461 +0.508 0.28725881275178156 +0.512 0.2844582472000673 +0.516 0.2816686001572811 +0.52 0.2788897449072021 +0.524 0.27612155716584563 +0.528 0.27336391501660195 +0.532 0.2706166988475812 +0.536 0.26787979129107486 +0.54 0.26515307716504655 +0.544 0.262436443416569 +0.548 0.25972977906713013 +0.552 0.25703297515973156 +0.556 0.25434592470771 +0.56 0.25166852264521167 +0.5640000000000001 0.2490006657792565 +0.5680000000000001 0.2463422527433291 +0.5720000000000001 0.24369318395243844 +0.5760000000000001 0.2410533615595889 +0.58 0.23842268941360922 +0.584 0.235801073018288 +0.588 0.23318841949276747 +0.592 0.23058463753314618 +0.596 0.2279896373752487 +0.6 0.2254033307585166 +0.604 0.22282563089098206 +0.608 0.2202564524152829 +0.612 0.2176957113756821 +0.616 0.2151433251860566 +0.62 0.21259921259881887 +0.624 0.21006329367474008 +0.628 0.207535489753642 +0.632 0.20501572342592833 +0.636 0.20250391850492455 +0.64 0.19999999999999996 +0.644 0.19750389409044478 +0.648 0.19501552810007572 +0.652 0.19253483047254605 +0.656 0.19006173074733645 +0.66 0.18759615953640396 +0.664 0.18513804850146542 +0.668 0.182687330331898 +0.672 0.18024393872323208 +0.676 0.17780780835622134 +0.68 0.17537887487646786 +0.684 0.17295707487458667 +0.6880000000000001 0.1705423458668911 +0.6920000000000001 0.16813462627658315 +0.6960000000000001 0.1657338554154315 +0.7000000000000001 0.16333997346592444 +0.704 0.16095292146387874 +0.708 0.15857264128149484 +0.712 0.15619907561084057 +0.716 0.15383216794775278 +0.72 0.15147186257614298 +0.724 0.14911810455269414 +0.728 0.14677083969193838 +0.732 0.14443001455170246 +0.736 0.14209557641891135 +0.74 0.13976747329573735 +0.744 0.13744565388608698 +0.748 0.13513006758241386 +0.752 0.13282066445284801 +0.756 0.1305173952286337 +0.76 0.12822021129186534 +0.764 0.12592906466351372 +0.768 0.12364390799173419 +0.772 0.12136469454044818 +0.776 0.11909137817819038 +0.78 0.11682391336721532 +0.784 0.11456225515285379 +0.788 0.11230635915311415 +0.792 0.11005618154852037 +0.796 0.10781167907218148 +0.8 0.10557280900008414 +0.804 0.10333952914160416 +0.808 0.10111179783023072 +0.812 0.09888957391449515 +0.8160000000000001 0.09667281674910277 +0.8200000000000001 0.09446148618625827 +0.8240000000000001 0.0922555425671826 +0.8280000000000001 0.09005494671381387 +0.8320000000000001 0.08785965992068956 +0.836 0.08566964394700316 +0.84 0.08348486100883201 +0.844 0.08130527377153185 +0.848 0.07913084534229298 +0.852 0.07696153926285387 +0.856 0.07479731950236979 +0.86 0.07263815045042965 +0.864 0.07048399691022 +0.868 0.06833482409183078 +0.872 0.06619059760569979 +0.876 0.06405128345619282 +0.88 0.061916848035314054 +0.884 0.05978725811654728 +0.888 0.05766248084882031 +0.892 0.05554248375059245 +0.896 0.05342723470406141 +0.9 0.05131670194948623 +0.904 0.049210854079623 +0.908 0.047109660034272305 +0.912 0.04501308909493418 +0.916 0.04292111087956807 +0.92 0.040833695337456066 +0.924 0.038750812744166696 +0.928 0.036672433696616324 +0.932 0.03459852910822636 +0.936 0.03252907020417406 +0.9400000000000001 0.030464028516734132 +0.9440000000000001 0.028403375880710402 +0.9480000000000001 0.02634708442895317 +0.9520000000000001 0.024295126587962512 +0.9560000000000001 0.022247475073574607 +0.96 0.020204102886728803 +0.964 0.01816498330931382 +0.968 0.01613008990009257 +0.972 0.014099396490701022 +0.976 0.012072877181722452 +0.98 0.01005050633883342 +0.984 0.008032258589020458 +0.988 0.006018108816865819 +0.992 0.004008032160901398 +0.996 0.0020020040100280356 +1.0 0.0 \ No newline at end of file diff --git a/resources/MOPReference/T1_500.txt b/resources/MOPReference/T1_500.txt new file mode 100644 index 00000000..e80f4603 --- /dev/null +++ b/resources/MOPReference/T1_500.txt @@ -0,0 +1,502 @@ +x1 x2 +0.0 1.0 +0.0020 0.9552786404500042 +0.0040 0.9367544467966324 +0.0060 0.9225403330758517 +0.0080 0.9105572809000084 +0.01 0.9 +0.012 0.8904554884989668 +0.014 0.8816784043380077 +0.016 0.8735088935932649 +0.018000000000000002 0.8658359213500126 +0.02 0.8585786437626906 +0.022 0.8516760302580868 +0.024 0.8450806661517033 +0.026000000000000002 0.838754845034029 +0.028 0.8326679946931849 +0.03 0.8267949192431123 +0.032 0.8211145618000169 +0.034 0.8156091108541422 +0.036000000000000004 0.8102633403898972 +0.038 0.8050641131038208 +0.04 0.8 +0.042 0.795060984680808 +0.044 0.7902382303659696 +0.046 0.7855238941047278 +0.048 0.7809109769979335 +0.05 0.7763932022500211 +0.052000000000000005 0.7719649149801724 +0.054 0.767620999227555 +0.056 0.7633568086760154 +0.058 0.759168108424154 +0.06 0.7550510257216823 +0.062 0.7510020080402253 +0.064 0.7470177871865297 +0.066 0.7430953484266973 +0.068 0.739231903791894 +0.07 0.735424868893541 +0.07200000000000001 0.7316718427000253 +0.074 0.7279705898252911 +0.076 0.7243190249581956 +0.078 0.7207151991246212 +0.08 0.717157287525381 +0.082 0.7136435787344729 +0.084 0.7101724650762112 +0.08600000000000001 0.7067424340276964 +0.088 0.7033520605161735 +0.09 0.7 +0.092 0.696684982237938 +0.094 0.6934058056648822 +0.096 0.6901613323034066 +0.098 0.6869504831500295 +0.1 0.683772233983162 +0.10200000000000001 0.6806256115465737 +0.10400000000000001 0.677509690068058 +0.106 0.6744235880780058 +0.108 0.6713664654969003 +0.11 0.66833752096446 +0.112 0.6653359893863697 +0.114 0.6623611396773174 +0.116 0.659412272681472 +0.11800000000000001 0.6564887192536466 +0.12 0.6535898384862245 +0.122 0.6507150160685404 +0.124 0.6478636627668198 +0.126 0.6450352130140231 +0.128 0.6422291236000337 +0.13 0.639444872453601 +0.132 0.6366819575083009 +0.134 0.6339398956455374 +0.136 0.6312182217082845 +0.138 0.6285164875798658 +0.14 0.6258342613226058 +0.14200000000000002 0.6231711263716646 +0.14400000000000002 0.6205266807797944 +0.146 0.617900536509144 +0.148 0.6152923187665731 +0.15 0.6127016653792583 +0.152 0.6101282262076415 +0.154 0.6075716625930283 +0.156 0.60503164683737 +0.158 0.6025078617129642 +0.16 0.6 +0.162 0.5975077640500379 +0.164 0.5950308653736682 +0.166 0.5925690242507327 +0.168 0.590121969361616 +0.17 0.587689437438234 +0.17200000000000001 0.5852711729334455 +0.17400000000000002 0.5828669277077158 +0.176 0.5804764607319394 +0.178 0.5780995378054203 +0.18 0.5757359312880714 +0.182 0.5733854198459691 +0.184 0.5710477882094557 +0.186 0.5687228269430435 +0.188 0.566410332226424 +0.19 0.5641101056459327 +0.192 0.5618219539958671 +0.194 0.5595456890890952 +0.196 0.5572811275764269 +0.198 0.5550280907742602 +0.2 0.5527864045000421 +0.202 0.5505558989151154 +0.20400000000000001 0.5483364083745514 +0.20600000000000002 0.5461277712835912 +0.20800000000000002 0.5439298299603448 +0.21 0.5417424305044161 +0.212 0.5395654226711465 +0.214 0.5373986597511848 +0.216 0.53524199845511 +0.218 0.5330952988028499 +0.22 0.530958424017657 +0.222 0.5288312404244102 +0.224 0.5267136173520307 +0.226 0.5246054270398115 +0.228 0.522506544547467 +0.23 0.5204168476687281 +0.232 0.5183362168483081 +0.234 0.516264535102087 +0.23600000000000002 0.5142016879403553 +0.23800000000000002 0.5121475632939813 +0.24 0.5101020514433644 +0.242 0.5080650449500463 +0.244 0.5060364385908612 +0.246 0.5040161292945102 +0.248 0.5020040160804506 +0.25 0.5 +0.252 0.4980039840795547 +0.254 0.49601587326583385 +0.256 0.49403557437305934 +0.258 0.4920629960319882 +0.26 0.4900980486407215 +0.262 0.48814064431721094 +0.264 0.4861906968533948 +0.266 0.4842481216708949 +0.268 0.4823128357782086 +0.27 0.48038475772933675 +0.272 0.47846380758378804 +0.274 0.476549906867904 +0.276 0.4746429785374521 +0.278 0.47274294694143726 +0.28 0.47084973778708183 +0.28200000000000003 0.46896327810592986 +0.28400000000000003 0.46708349622103085 +0.28600000000000003 0.4652103217151624 +0.28800000000000003 0.46334368540005044 +0.29 0.4614835192865496 +0.292 0.4596297565557482 +0.294 0.4577823315309617 +0.296 0.45594117965058223 +0.298 0.4541062374417528 +0.3 0.4522774424948339 +0.302 0.4504547334386365 +0.304 0.4486380499163911 +0.306 0.4468273325624268 +0.308 0.4450225229795357 +0.31 0.4432235637169978 +0.312 0.44143039824924235 +0.314 0.43964297095512406 +0.316 0.4378612270977922 +0.318 0.4360851128051326 +0.32 0.434314575050762 +0.322 0.4325495616355557 +0.324 0.4307900211696917 +0.326 0.4290359030551921 +0.328 0.42728715746894586 +0.33 0.42554373534619716 +0.332 0.4238055883644827 +0.334 0.42207266892800444 +0.336 0.42034493015242247 +0.338 0.41862232585005466 +0.34 0.4169048105154699 +0.342 0.41519233931146216 +0.34400000000000003 0.41348486805539275 +0.34600000000000003 0.4117823532058903 +0.34800000000000003 0.4100847518498949 +0.35000000000000003 0.4083920216900384 +0.352 0.406704121032347 +0.354 0.4050210087742594 +0.356 0.4033426443929481 +0.358 0.40166898793393635 +0.36 0.4 +0.362 0.3983356417403471 +0.364 0.3966758748400657 +0.366 0.39502066150983306 +0.368 0.3933699644758759 +0.37 0.3917237469701781 +0.372 0.3900819727209237 +0.374 0.38844460594317376 +0.376 0.3868116113297644 +0.378 0.3851829540424241 +0.38 0.38355859970310235 +0.382 0.3819385143855023 +0.384 0.3803226646068133 +0.386 0.3787110173196373 +0.388 0.3771035399041025 +0.39 0.37550020016016017 +0.392 0.37390096630005887 +0.394 0.37230580694099136 +0.396 0.3707146910979091 +0.398 0.3691275881764998 +0.4 0.3675444679663241 +0.402 0.3659653006341057 +0.404 0.36439005671717184 +0.406 0.36281870711704034 +0.40800000000000003 0.3612512230931475 +0.41000000000000003 0.3596875762567151 +0.41200000000000003 0.35812773856475144 +0.41400000000000003 0.35657168231418346 +0.41600000000000004 0.355019380136116 +0.418 0.35347080499021544 +0.42 0.35192593015921403 +0.422 0.35038472924353137 +0.424 0.3488471761560118 +0.426 0.3473132451167712 +0.428 0.3457829106481549 +0.43 0.34425614756979994 +0.432 0.34273293099380064 +0.434 0.3412132363199758 +0.436 0.33969703923123284 +0.438 0.33818431568902807 +0.44 0.33667504192892006 +0.442 0.3351691944562135 +0.444 0.3336667500416928 +0.446 0.33216768571744004 +0.448 0.33067197877273957 +0.45 0.3291796067500631 +0.452 0.32769054744113557 +0.454 0.3262047788830793 +0.456 0.3247222793546347 +0.458 0.3232430273724548 +0.46 0.3217670016874732 +0.462 0.3202941812813428 +0.464 0.3188245453629439 +0.466 0.31735807336495947 +0.468 0.31589474494051717 +0.47000000000000003 0.31443453995989556 +0.47200000000000003 0.3129774385072932 +0.47400000000000003 0.3115234208776597 +0.47600000000000003 0.3100724675735864 +0.47800000000000004 0.30862455930225574 +0.48 0.3071796769724491 +0.482 0.3057378016916087 +0.484 0.30429891476295656 +0.486 0.302862997682665 +0.488 0.30143003213708075 +0.49 0.30000000000000004 +0.492 0.29857288332999277 +0.494 0.29714866436777687 +0.496 0.2957273255336397 +0.498 0.294308849424906 +0.5 0.2928932188134524 +0.502 0.29148041664326596 +0.504 0.2900704260280461 +0.506 0.28866323024885043 +0.508 0.28725881275178156 +0.51 0.285857157145715 +0.512 0.2844582472000673 +0.514 0.28306206684260315 +0.516 0.2816686001572811 +0.518 0.2802778313821367 +0.52 0.2788897449072021 +0.522 0.27750432527246227 +0.524 0.27612155716584563 +0.526 0.27474142542125013 +0.528 0.27336391501660195 +0.53 0.2719890110719482 +0.532 0.2706166988475812 +0.534 0.2692469637421956 +0.536 0.26787979129107486 +0.538 0.26651516716431 +0.54 0.26515307716504655 +0.542 0.2637935072277615 +0.544 0.262436443416569 +0.546 0.26108187192355337 +0.548 0.25972977906713013 +0.55 0.2583801512904337 +0.552 0.25703297515973156 +0.554 0.25568823736286417 +0.556 0.25434592470771 +0.558 0.2530060241206761 +0.56 0.25166852264521167 +0.562 0.2503334074403475 +0.5640000000000001 0.2490006657792565 +0.5660000000000001 0.24767028504783883 +0.5680000000000001 0.2463422527433291 +0.5700000000000001 0.24501655647292497 +0.5720000000000001 0.24369318395243844 +0.5740000000000001 0.24237212300496747 +0.5760000000000001 0.2410533615595889 +0.578 0.2397368876500715 +0.58 0.23842268941360922 +0.582 0.23711075508957402 +0.584 0.235801073018288 +0.586 0.23449363163981451 +0.588 0.23318841949276747 +0.59 0.23188542521313915 +0.592 0.23058463753314618 +0.594 0.22928604528009233 +0.596 0.2279896373752487 +0.598 0.2266954028327518 +0.6 0.2254033307585166 +0.602 0.2241134103491671 +0.604 0.22282563089098206 +0.606 0.22153998175885747 +0.608 0.2202564524152829 +0.61 0.21897503240933458 +0.612 0.2176957113756821 +0.614 0.21641847903361067 +0.616 0.2151433251860566 +0.618 0.21387023971865815 +0.62 0.21259921259881887 +0.622 0.2113302338747859 +0.624 0.21006329367474008 +0.626 0.20879838220590075 +0.628 0.207535489753642 +0.63 0.2062746066806228 +0.632 0.20501572342592833 +0.634 0.20375883050422472 +0.636 0.20250391850492455 +0.638 0.20125097809136572 +0.64 0.19999999999999996 +0.642 0.19875097503959482 +0.644 0.19750389409044478 +0.646 0.19625874810359523 +0.648 0.19501552810007572 +0.65 0.19377422517014498 +0.652 0.19253483047254605 +0.654 0.1912973352337708 +0.656 0.19006173074733645 +0.658 0.18882800837307012 +0.66 0.18759615953640396 +0.662 0.18636617572768033 +0.664 0.18513804850146542 +0.666 0.1839117694758734 +0.668 0.182687330331898 +0.67 0.18146472281275494 +0.672 0.18024393872323208 +0.674 0.17902496992904826 +0.676 0.17780780835622134 +0.678 0.17659244599044388 +0.68 0.17537887487646786 +0.682 0.17416708711749684 +0.684 0.17295707487458667 +0.686 0.1717488303660537 +0.6880000000000001 0.1705423458668911 +0.6900000000000001 0.16933761370819245 +0.6920000000000001 0.16813462627658315 +0.6940000000000001 0.16693337601365876 +0.6960000000000001 0.1657338554154315 +0.6980000000000001 0.1645360570317831 +0.7000000000000001 0.16333997346592444 +0.7020000000000001 0.16214559737386347 +0.704 0.16095292146387874 +0.706 0.15976193849599984 +0.708 0.15857264128149484 +0.71 0.1573850226823642 +0.712 0.15619907561084057 +0.714 0.15501479302889565 +0.716 0.15383216794775278 +0.718 0.15265119342740563 +0.72 0.15147186257614298 +0.722 0.15029416855007993 +0.724 0.14911810455269414 +0.726 0.1479436638343683 +0.728 0.14677083969193838 +0.73 0.1455996254682469 +0.732 0.14443001455170246 +0.734 0.14326200037584425 +0.736 0.14209557641891135 +0.738 0.14093073620341878 +0.74 0.13976747329573735 +0.742 0.1386057813056788 +0.744 0.13744565388608698 +0.746 0.13628708473243267 +0.748 0.13513006758241386 +0.75 0.1339745962155614 +0.752 0.13282066445284801 +0.754 0.13166826615630356 +0.756 0.1305173952286337 +0.758 0.12936804561284332 +0.76 0.12822021129186534 +0.762 0.12707388628819216 +0.764 0.12592906466351372 +0.766 0.12478574051835745 +0.768 0.12364390799173419 +0.77 0.12250356126078776 +0.772 0.12136469454044818 +0.774 0.12022730208308918 +0.776 0.11909137817819038 +0.778 0.11795691715200218 +0.78 0.11682391336721532 +0.782 0.11569236122263427 +0.784 0.11456225515285379 +0.786 0.11343358962793992 +0.788 0.11230635915311415 +0.79 0.11118055826844109 +0.792 0.11005618154852037 +0.794 0.10893322360218138 +0.796 0.10781167907218148 +0.798 0.10669154263490821 +0.8 0.10557280900008414 +0.802 0.10445547291047552 +0.804 0.10333952914160416 +0.806 0.10222497250146234 +0.808 0.10111179783023072 +0.81 0.09999999999999998 +0.812 0.09888957391449515 +0.8140000000000001 0.0977805145088031 +0.8160000000000001 0.09667281674910277 +0.8180000000000001 0.09556647563239895 +0.8200000000000001 0.09446148618625827 +0.8220000000000001 0.09335784346854903 +0.8240000000000001 0.0922555425671826 +0.8260000000000001 0.09115457859985887 +0.8280000000000001 0.09005494671381387 +0.8300000000000001 0.08895664208557008 +0.8320000000000001 0.08785965992068956 +0.834 0.08676399545353009 +0.836 0.08566964394700316 +0.838 0.08457660069233541 +0.84 0.08348486100883201 +0.842 0.08239442024364307 +0.844 0.08130527377153185 +0.846 0.08021741699464646 +0.848 0.07913084534229298 +0.85 0.07804555427071125 +0.852 0.07696153926285387 +0.854 0.07587879582816626 +0.856 0.07479731950236979 +0.858 0.07371710584724711 +0.86 0.07263815045042965 +0.862 0.0715604489251872 +0.864 0.07048399691022 +0.866 0.06940879006945266 +0.868 0.06833482409183078 +0.87 0.06726209469111855 +0.872 0.06619059760569979 +0.874 0.06512032859838057 +0.876 0.06405128345619282 +0.878 0.06298345799020177 +0.88 0.061916848035314054 +0.882 0.06085144945008836 +0.884 0.05978725811654728 +0.886 0.05872426993999258 +0.888 0.05766248084882031 +0.89 0.05660188679433964 +0.892 0.05554248375059245 +0.894 0.05448426771417492 +0.896 0.05342723470406141 +0.898 0.05237138076142933 +0.9 0.05131670194948623 +0.902 0.050263194353298735 +0.904 0.049210854079623 +0.906 0.04815967725673653 +0.908 0.047109660034272305 +0.91 0.04606079858305434 +0.912 0.04501308909493418 +0.914 0.04396652778263044 +0.916 0.04292111087956807 +0.918 0.04187683463972125 +0.92 0.040833695337456066 +0.922 0.03979168926737564 +0.924 0.038750812744166696 +0.926 0.037711062102447346 +0.928 0.036672433696616324 +0.93 0.03563492390070444 +0.932 0.03459852910822636 +0.934 0.0335632457320344 +0.936 0.03252907020417406 +0.9380000000000001 0.03149599897573985 +0.9400000000000001 0.030464028516734132 +0.9420000000000001 0.02943315531592572 +0.9440000000000001 0.028403375880710402 +0.9460000000000001 0.02737468673697374 +0.9480000000000001 0.02634708442895317 +0.9500000000000001 0.025320565519103555 +0.9520000000000001 0.024295126587962512 +0.9540000000000001 0.023270764234017527 +0.9560000000000001 0.022247475073574607 +0.9580000000000001 0.021225255740627502 +0.96 0.020204102886728803 +0.962 0.019184013180861714 +0.964 0.01816498330931382 +0.966 0.017147009975550853 +0.968 0.01613008990009257 +0.97 0.015114219820389518 +0.972 0.014099396490701022 +0.974 0.013085616681973833 +0.976 0.012072877181722452 +0.978 0.011061174793910777 +0.98 0.01005050633883342 +0.982 0.009040868653000356 +0.984 0.008032258589020458 +0.986 0.007024673015487259 +0.988 0.006018108816865819 +0.99 0.005012562893380035 +0.992 0.004008032160901398 +0.994 0.003004513550838639 +0.996 0.0020020040100280356 +0.998 0.0010005005006258338 +1.0 0.0 \ No newline at end of file diff --git a/resources/MOPReference/T2_250.txt b/resources/MOPReference/T2_250.txt new file mode 100644 index 00000000..f4bcd4cf --- /dev/null +++ b/resources/MOPReference/T2_250.txt @@ -0,0 +1,252 @@ +x1 x2 +0.0 1.0 +0.0040 0.999984 +0.0080 0.999936 +0.012 0.999856 +0.016 0.999744 +0.02 0.9996 +0.024 0.999424 +0.028 0.999216 +0.032 0.998976 +0.036000000000000004 0.998704 +0.04 0.9984 +0.044 0.998064 +0.048 0.997696 +0.052000000000000005 0.997296 +0.056 0.996864 +0.06 0.9964 +0.064 0.995904 +0.068 0.995376 +0.07200000000000001 0.994816 +0.076 0.994224 +0.08 0.9936 +0.084 0.992944 +0.088 0.992256 +0.092 0.991536 +0.096 0.990784 +0.1 0.99 +0.10400000000000001 0.989184 +0.108 0.988336 +0.112 0.987456 +0.116 0.986544 +0.12 0.9856 +0.124 0.984624 +0.128 0.983616 +0.132 0.982576 +0.136 0.981504 +0.14 0.9804 +0.14400000000000002 0.979264 +0.148 0.978096 +0.152 0.976896 +0.156 0.975664 +0.16 0.9744 +0.164 0.973104 +0.168 0.971776 +0.17200000000000001 0.970416 +0.176 0.969024 +0.18 0.9676 +0.184 0.966144 +0.188 0.964656 +0.192 0.963136 +0.196 0.961584 +0.2 0.96 +0.20400000000000001 0.958384 +0.20800000000000002 0.956736 +0.212 0.955056 +0.216 0.953344 +0.22 0.9516 +0.224 0.949824 +0.228 0.948016 +0.232 0.946176 +0.23600000000000002 0.944304 +0.24 0.9424 +0.244 0.940464 +0.248 0.938496 +0.252 0.936496 +0.256 0.934464 +0.26 0.9324 +0.264 0.930304 +0.268 0.928176 +0.272 0.926016 +0.276 0.923824 +0.28 0.9216 +0.28400000000000003 0.9193439999999999 +0.28800000000000003 0.917056 +0.292 0.914736 +0.296 0.912384 +0.3 0.91 +0.304 0.907584 +0.308 0.9051359999999999 +0.312 0.902656 +0.316 0.900144 +0.32 0.8976 +0.324 0.895024 +0.328 0.892416 +0.332 0.889776 +0.336 0.887104 +0.34 0.8844 +0.34400000000000003 0.881664 +0.34800000000000003 0.878896 +0.352 0.876096 +0.356 0.873264 +0.36 0.8704000000000001 +0.364 0.867504 +0.368 0.864576 +0.372 0.8616159999999999 +0.376 0.858624 +0.38 0.8556 +0.384 0.852544 +0.388 0.849456 +0.392 0.846336 +0.396 0.8431839999999999 +0.4 0.84 +0.404 0.836784 +0.40800000000000003 0.8335359999999999 +0.41200000000000003 0.830256 +0.41600000000000004 0.8269439999999999 +0.42 0.8236 +0.424 0.8202240000000001 +0.428 0.816816 +0.432 0.813376 +0.436 0.809904 +0.44 0.8064 +0.444 0.802864 +0.448 0.799296 +0.452 0.795696 +0.456 0.792064 +0.46 0.7884 +0.464 0.784704 +0.468 0.780976 +0.47200000000000003 0.7772159999999999 +0.47600000000000003 0.773424 +0.48 0.7696000000000001 +0.484 0.765744 +0.488 0.761856 +0.492 0.7579359999999999 +0.496 0.753984 +0.5 0.75 +0.504 0.745984 +0.508 0.7419359999999999 +0.512 0.7378560000000001 +0.516 0.733744 +0.52 0.7296 +0.524 0.725424 +0.528 0.721216 +0.532 0.716976 +0.536 0.712704 +0.54 0.7083999999999999 +0.544 0.704064 +0.548 0.6996959999999999 +0.552 0.6952959999999999 +0.556 0.6908639999999999 +0.56 0.6863999999999999 +0.5640000000000001 0.681904 +0.5680000000000001 0.677376 +0.5720000000000001 0.6728159999999999 +0.5760000000000001 0.6682239999999999 +0.58 0.6636 +0.584 0.658944 +0.588 0.6542560000000001 +0.592 0.6495360000000001 +0.596 0.644784 +0.6 0.64 +0.604 0.635184 +0.608 0.630336 +0.612 0.625456 +0.616 0.620544 +0.62 0.6155999999999999 +0.624 0.6106240000000001 +0.628 0.6056159999999999 +0.632 0.600576 +0.636 0.595504 +0.64 0.5904 +0.644 0.585264 +0.648 0.580096 +0.652 0.574896 +0.656 0.569664 +0.66 0.5644 +0.664 0.5591039999999999 +0.668 0.5537759999999999 +0.672 0.548416 +0.676 0.543024 +0.68 0.5375999999999999 +0.684 0.532144 +0.6880000000000001 0.5266559999999999 +0.6920000000000001 0.5211359999999999 +0.6960000000000001 0.5155839999999999 +0.7000000000000001 0.5099999999999999 +0.704 0.504384 +0.708 0.49873600000000007 +0.712 0.49305600000000005 +0.716 0.487344 +0.72 0.48160000000000003 +0.724 0.475824 +0.728 0.470016 +0.732 0.46417600000000003 +0.736 0.45830400000000004 +0.74 0.4524 +0.744 0.44646399999999997 +0.748 0.440496 +0.752 0.434496 +0.756 0.42846399999999996 +0.76 0.4224 +0.764 0.416304 +0.768 0.410176 +0.772 0.40401599999999993 +0.776 0.39782399999999996 +0.78 0.39159999999999995 +0.784 0.3853439999999999 +0.788 0.37905599999999995 +0.792 0.37273599999999996 +0.796 0.36638399999999993 +0.8 0.3599999999999999 +0.804 0.3535839999999999 +0.808 0.3471359999999999 +0.812 0.34065599999999996 +0.8160000000000001 0.3341439999999999 +0.8200000000000001 0.3275999999999999 +0.8240000000000001 0.32102399999999987 +0.8280000000000001 0.3144159999999999 +0.8320000000000001 0.3077759999999998 +0.836 0.30110400000000004 +0.84 0.2944000000000001 +0.844 0.28766400000000003 +0.848 0.28089600000000003 +0.852 0.274096 +0.856 0.26726400000000006 +0.86 0.2604000000000001 +0.864 0.25350400000000006 +0.868 0.24657600000000002 +0.872 0.23961600000000005 +0.876 0.23262400000000005 +0.88 0.22560000000000002 +0.884 0.21854399999999996 +0.888 0.21145599999999998 +0.892 0.20433599999999996 +0.896 0.19718399999999991 +0.9 0.18999999999999995 +0.904 0.18278399999999995 +0.908 0.17553599999999991 +0.912 0.16825599999999996 +0.916 0.16094399999999998 +0.92 0.15359999999999996 +0.924 0.1462239999999999 +0.928 0.13881599999999994 +0.932 0.13137599999999994 +0.936 0.1239039999999999 +0.9400000000000001 0.11639999999999984 +0.9440000000000001 0.10886399999999985 +0.9480000000000001 0.10129599999999983 +0.9520000000000001 0.09369599999999989 +0.9560000000000001 0.08606399999999981 +0.96 0.07840000000000003 +0.964 0.0707040000000001 +0.968 0.06297600000000003 +0.972 0.05521600000000004 +0.976 0.04742400000000002 +0.98 0.03960000000000008 +0.984 0.031743999999999994 +0.988 0.02385599999999999 +0.992 0.01593600000000006 +0.996 0.007983999999999991 +1.0 0.0 \ No newline at end of file diff --git a/resources/MOPReference/T2_500.txt b/resources/MOPReference/T2_500.txt new file mode 100644 index 00000000..74db50d0 --- /dev/null +++ b/resources/MOPReference/T2_500.txt @@ -0,0 +1,502 @@ +x1 x2 +0.0 1.0 +0.0020 0.999996 +0.0040 0.999984 +0.0060 0.999964 +0.0080 0.999936 +0.01 0.9999 +0.012 0.999856 +0.014 0.999804 +0.016 0.999744 +0.018000000000000002 0.999676 +0.02 0.9996 +0.022 0.999516 +0.024 0.999424 +0.026000000000000002 0.999324 +0.028 0.999216 +0.03 0.9991 +0.032 0.998976 +0.034 0.998844 +0.036000000000000004 0.998704 +0.038 0.998556 +0.04 0.9984 +0.042 0.998236 +0.044 0.998064 +0.046 0.997884 +0.048 0.997696 +0.05 0.9975 +0.052000000000000005 0.997296 +0.054 0.997084 +0.056 0.996864 +0.058 0.996636 +0.06 0.9964 +0.062 0.996156 +0.064 0.995904 +0.066 0.995644 +0.068 0.995376 +0.07 0.9951 +0.07200000000000001 0.994816 +0.074 0.994524 +0.076 0.994224 +0.078 0.993916 +0.08 0.9936 +0.082 0.993276 +0.084 0.992944 +0.08600000000000001 0.992604 +0.088 0.992256 +0.09 0.9919 +0.092 0.991536 +0.094 0.991164 +0.096 0.990784 +0.098 0.990396 +0.1 0.99 +0.10200000000000001 0.989596 +0.10400000000000001 0.989184 +0.106 0.988764 +0.108 0.988336 +0.11 0.9879 +0.112 0.987456 +0.114 0.987004 +0.116 0.986544 +0.11800000000000001 0.986076 +0.12 0.9856 +0.122 0.985116 +0.124 0.984624 +0.126 0.984124 +0.128 0.983616 +0.13 0.9831 +0.132 0.982576 +0.134 0.982044 +0.136 0.981504 +0.138 0.980956 +0.14 0.9804 +0.14200000000000002 0.979836 +0.14400000000000002 0.979264 +0.146 0.978684 +0.148 0.978096 +0.15 0.9775 +0.152 0.976896 +0.154 0.976284 +0.156 0.975664 +0.158 0.975036 +0.16 0.9744 +0.162 0.973756 +0.164 0.973104 +0.166 0.972444 +0.168 0.971776 +0.17 0.9711 +0.17200000000000001 0.970416 +0.17400000000000002 0.969724 +0.176 0.969024 +0.178 0.968316 +0.18 0.9676 +0.182 0.966876 +0.184 0.966144 +0.186 0.965404 +0.188 0.964656 +0.19 0.9639 +0.192 0.963136 +0.194 0.962364 +0.196 0.961584 +0.198 0.960796 +0.2 0.96 +0.202 0.9591959999999999 +0.20400000000000001 0.958384 +0.20600000000000002 0.957564 +0.20800000000000002 0.956736 +0.21 0.9559 +0.212 0.955056 +0.214 0.954204 +0.216 0.953344 +0.218 0.952476 +0.22 0.9516 +0.222 0.950716 +0.224 0.949824 +0.226 0.948924 +0.228 0.948016 +0.23 0.9471 +0.232 0.946176 +0.234 0.945244 +0.23600000000000002 0.944304 +0.23800000000000002 0.943356 +0.24 0.9424 +0.242 0.941436 +0.244 0.940464 +0.246 0.939484 +0.248 0.938496 +0.25 0.9375 +0.252 0.936496 +0.254 0.935484 +0.256 0.934464 +0.258 0.933436 +0.26 0.9324 +0.262 0.931356 +0.264 0.930304 +0.266 0.929244 +0.268 0.928176 +0.27 0.9271 +0.272 0.926016 +0.274 0.924924 +0.276 0.923824 +0.278 0.922716 +0.28 0.9216 +0.28200000000000003 0.920476 +0.28400000000000003 0.9193439999999999 +0.28600000000000003 0.918204 +0.28800000000000003 0.917056 +0.29 0.9159 +0.292 0.914736 +0.294 0.913564 +0.296 0.912384 +0.298 0.911196 +0.3 0.91 +0.302 0.908796 +0.304 0.907584 +0.306 0.906364 +0.308 0.9051359999999999 +0.31 0.9039 +0.312 0.902656 +0.314 0.901404 +0.316 0.900144 +0.318 0.898876 +0.32 0.8976 +0.322 0.896316 +0.324 0.895024 +0.326 0.893724 +0.328 0.892416 +0.33 0.8911 +0.332 0.889776 +0.334 0.888444 +0.336 0.887104 +0.338 0.885756 +0.34 0.8844 +0.342 0.8830359999999999 +0.34400000000000003 0.881664 +0.34600000000000003 0.880284 +0.34800000000000003 0.878896 +0.35000000000000003 0.8775 +0.352 0.876096 +0.354 0.874684 +0.356 0.873264 +0.358 0.871836 +0.36 0.8704000000000001 +0.362 0.8689560000000001 +0.364 0.867504 +0.366 0.866044 +0.368 0.864576 +0.37 0.8631 +0.372 0.8616159999999999 +0.374 0.860124 +0.376 0.858624 +0.378 0.857116 +0.38 0.8556 +0.382 0.8540760000000001 +0.384 0.852544 +0.386 0.851004 +0.388 0.849456 +0.39 0.8479 +0.392 0.846336 +0.394 0.844764 +0.396 0.8431839999999999 +0.398 0.841596 +0.4 0.84 +0.402 0.8383959999999999 +0.404 0.836784 +0.406 0.835164 +0.40800000000000003 0.8335359999999999 +0.41000000000000003 0.8319 +0.41200000000000003 0.830256 +0.41400000000000003 0.828604 +0.41600000000000004 0.8269439999999999 +0.418 0.825276 +0.42 0.8236 +0.422 0.821916 +0.424 0.8202240000000001 +0.426 0.818524 +0.428 0.816816 +0.43 0.8151 +0.432 0.813376 +0.434 0.811644 +0.436 0.809904 +0.438 0.808156 +0.44 0.8064 +0.442 0.804636 +0.444 0.802864 +0.446 0.801084 +0.448 0.799296 +0.45 0.7975 +0.452 0.795696 +0.454 0.793884 +0.456 0.792064 +0.458 0.7902359999999999 +0.46 0.7884 +0.462 0.786556 +0.464 0.784704 +0.466 0.782844 +0.468 0.780976 +0.47000000000000003 0.7790999999999999 +0.47200000000000003 0.7772159999999999 +0.47400000000000003 0.7753239999999999 +0.47600000000000003 0.773424 +0.47800000000000004 0.771516 +0.48 0.7696000000000001 +0.482 0.767676 +0.484 0.765744 +0.486 0.763804 +0.488 0.761856 +0.49 0.7599 +0.492 0.7579359999999999 +0.494 0.755964 +0.496 0.753984 +0.498 0.751996 +0.5 0.75 +0.502 0.747996 +0.504 0.745984 +0.506 0.7439640000000001 +0.508 0.7419359999999999 +0.51 0.7399 +0.512 0.7378560000000001 +0.514 0.735804 +0.516 0.733744 +0.518 0.731676 +0.52 0.7296 +0.522 0.727516 +0.524 0.725424 +0.526 0.723324 +0.528 0.721216 +0.53 0.7191 +0.532 0.716976 +0.534 0.714844 +0.536 0.712704 +0.538 0.710556 +0.54 0.7083999999999999 +0.542 0.706236 +0.544 0.704064 +0.546 0.701884 +0.548 0.6996959999999999 +0.55 0.6975 +0.552 0.6952959999999999 +0.554 0.6930839999999999 +0.556 0.6908639999999999 +0.558 0.6886359999999999 +0.56 0.6863999999999999 +0.562 0.684156 +0.5640000000000001 0.681904 +0.5660000000000001 0.6796439999999999 +0.5680000000000001 0.677376 +0.5700000000000001 0.6750999999999999 +0.5720000000000001 0.6728159999999999 +0.5740000000000001 0.6705239999999999 +0.5760000000000001 0.6682239999999999 +0.578 0.6659160000000001 +0.58 0.6636 +0.582 0.661276 +0.584 0.658944 +0.586 0.656604 +0.588 0.6542560000000001 +0.59 0.6519 +0.592 0.6495360000000001 +0.594 0.6471640000000001 +0.596 0.644784 +0.598 0.642396 +0.6 0.64 +0.602 0.637596 +0.604 0.635184 +0.606 0.632764 +0.608 0.630336 +0.61 0.6279 +0.612 0.625456 +0.614 0.623004 +0.616 0.620544 +0.618 0.6180760000000001 +0.62 0.6155999999999999 +0.622 0.613116 +0.624 0.6106240000000001 +0.626 0.608124 +0.628 0.6056159999999999 +0.63 0.6031 +0.632 0.600576 +0.634 0.598044 +0.636 0.595504 +0.638 0.592956 +0.64 0.5904 +0.642 0.587836 +0.644 0.585264 +0.646 0.582684 +0.648 0.580096 +0.65 0.5774999999999999 +0.652 0.574896 +0.654 0.572284 +0.656 0.569664 +0.658 0.567036 +0.66 0.5644 +0.662 0.5617559999999999 +0.664 0.5591039999999999 +0.666 0.5564439999999999 +0.668 0.5537759999999999 +0.67 0.5510999999999999 +0.672 0.548416 +0.674 0.5457239999999999 +0.676 0.543024 +0.678 0.540316 +0.68 0.5375999999999999 +0.682 0.5348759999999999 +0.684 0.532144 +0.686 0.529404 +0.6880000000000001 0.5266559999999999 +0.6900000000000001 0.5238999999999999 +0.6920000000000001 0.5211359999999999 +0.6940000000000001 0.5183639999999999 +0.6960000000000001 0.5155839999999999 +0.6980000000000001 0.5127959999999999 +0.7000000000000001 0.5099999999999999 +0.7020000000000001 0.507196 +0.704 0.504384 +0.706 0.5015640000000001 +0.708 0.49873600000000007 +0.71 0.4959 +0.712 0.49305600000000005 +0.714 0.4902040000000001 +0.716 0.487344 +0.718 0.484476 +0.72 0.48160000000000003 +0.722 0.47871600000000003 +0.724 0.475824 +0.726 0.472924 +0.728 0.470016 +0.73 0.46710000000000007 +0.732 0.46417600000000003 +0.734 0.461244 +0.736 0.45830400000000004 +0.738 0.455356 +0.74 0.4524 +0.742 0.44943600000000006 +0.744 0.44646399999999997 +0.746 0.443484 +0.748 0.440496 +0.75 0.4375 +0.752 0.434496 +0.754 0.431484 +0.756 0.42846399999999996 +0.758 0.42543600000000004 +0.76 0.4224 +0.762 0.41935599999999995 +0.764 0.416304 +0.766 0.41324399999999994 +0.768 0.410176 +0.77 0.4071 +0.772 0.40401599999999993 +0.774 0.40092399999999995 +0.776 0.39782399999999996 +0.778 0.39471599999999996 +0.78 0.39159999999999995 +0.782 0.38847599999999993 +0.784 0.3853439999999999 +0.786 0.382204 +0.788 0.37905599999999995 +0.79 0.3758999999999999 +0.792 0.37273599999999996 +0.794 0.3695639999999999 +0.796 0.36638399999999993 +0.798 0.36319599999999996 +0.8 0.3599999999999999 +0.802 0.3567959999999999 +0.804 0.3535839999999999 +0.806 0.3503639999999999 +0.808 0.3471359999999999 +0.81 0.3438999999999999 +0.812 0.34065599999999996 +0.8140000000000001 0.3374039999999999 +0.8160000000000001 0.3341439999999999 +0.8180000000000001 0.33087599999999995 +0.8200000000000001 0.3275999999999999 +0.8220000000000001 0.32431599999999994 +0.8240000000000001 0.32102399999999987 +0.8260000000000001 0.3177239999999999 +0.8280000000000001 0.3144159999999999 +0.8300000000000001 0.31109999999999993 +0.8320000000000001 0.3077759999999998 +0.834 0.30444400000000005 +0.836 0.30110400000000004 +0.838 0.297756 +0.84 0.2944000000000001 +0.842 0.2910360000000001 +0.844 0.28766400000000003 +0.846 0.2842840000000001 +0.848 0.28089600000000003 +0.85 0.2775000000000001 +0.852 0.274096 +0.854 0.27068400000000004 +0.856 0.26726400000000006 +0.858 0.26383600000000007 +0.86 0.2604000000000001 +0.862 0.2569560000000001 +0.864 0.25350400000000006 +0.866 0.25004400000000004 +0.868 0.24657600000000002 +0.87 0.24309999999999998 +0.872 0.23961600000000005 +0.874 0.236124 +0.876 0.23262400000000005 +0.878 0.229116 +0.88 0.22560000000000002 +0.882 0.22207599999999994 +0.884 0.21854399999999996 +0.886 0.21500399999999997 +0.888 0.21145599999999998 +0.89 0.20789999999999997 +0.892 0.20433599999999996 +0.894 0.20076399999999994 +0.896 0.19718399999999991 +0.898 0.193596 +0.9 0.18999999999999995 +0.902 0.186396 +0.904 0.18278399999999995 +0.906 0.179164 +0.908 0.17553599999999991 +0.91 0.17189999999999994 +0.912 0.16825599999999996 +0.914 0.16460399999999997 +0.916 0.16094399999999998 +0.918 0.15727599999999997 +0.92 0.15359999999999996 +0.922 0.14991599999999994 +0.924 0.1462239999999999 +0.926 0.14252399999999987 +0.928 0.13881599999999994 +0.93 0.1350999999999999 +0.932 0.13137599999999994 +0.934 0.12764399999999987 +0.936 0.1239039999999999 +0.9380000000000001 0.12015599999999993 +0.9400000000000001 0.11639999999999984 +0.9420000000000001 0.11263599999999985 +0.9440000000000001 0.10886399999999985 +0.9460000000000001 0.10508399999999984 +0.9480000000000001 0.10129599999999983 +0.9500000000000001 0.09749999999999992 +0.9520000000000001 0.09369599999999989 +0.9540000000000001 0.08988399999999985 +0.9560000000000001 0.08606399999999981 +0.9580000000000001 0.08223599999999986 +0.96 0.07840000000000003 +0.962 0.07455600000000007 +0.964 0.0707040000000001 +0.966 0.06684400000000001 +0.968 0.06297600000000003 +0.97 0.05910000000000004 +0.972 0.05521600000000004 +0.974 0.051324000000000036 +0.976 0.04742400000000002 +0.978 0.043516 +0.98 0.03960000000000008 +0.982 0.03567600000000004 +0.984 0.031743999999999994 +0.986 0.02780400000000005 +0.988 0.02385599999999999 +0.99 0.01990000000000003 +0.992 0.01593600000000006 +0.994 0.011963999999999975 +0.996 0.007983999999999991 +0.998 0.0039959999999999996 +1.0 0.0 \ No newline at end of file diff --git a/resources/MOPReference/T6_50.txt b/resources/MOPReference/T6_50.txt new file mode 100644 index 00000000..0cfaca6e --- /dev/null +++ b/resources/MOPReference/T6_50.txt @@ -0,0 +1,52 @@ +x1 x2 +0.0 1.0 +0.02 0.9996 +0.04 0.9984 +0.06 0.9964 +0.08 0.9936 +0.1 0.99 +0.12 0.9856 +0.14 0.9804 +0.16 0.9744 +0.18 0.9676 +0.2 0.96 +0.22 0.9516 +0.24 0.9424 +0.26 0.9324 +0.28 0.9216 +0.3 0.91 +0.32 0.8976 +0.34 0.8844 +0.36 0.8704000000000001 +0.38 0.8556 +0.4 0.84 +0.42 0.8236 +0.44 0.8064 +0.46 0.7884 +0.48 0.7696000000000001 +0.5 0.75 +0.52 0.7296 +0.54 0.7083999999999999 +0.56 0.6863999999999999 +0.58 0.6636 +0.6 0.64 +0.62 0.6155999999999999 +0.64 0.5904 +0.66 0.5644 +0.68 0.5375999999999999 +0.7000000000000001 0.5099999999999999 +0.72 0.48160000000000003 +0.74 0.4524 +0.76 0.4224 +0.78 0.39159999999999995 +0.8 0.3599999999999999 +0.8200000000000001 0.3275999999999999 +0.84 0.2944000000000001 +0.86 0.2604000000000001 +0.88 0.22560000000000002 +0.9 0.18999999999999995 +0.92 0.15359999999999996 +0.9400000000000001 0.11639999999999984 +0.96 0.07840000000000003 +0.98 0.03960000000000008 +1.0 0.0 \ No newline at end of file diff --git a/resources/MOPReference/T6_500.txt b/resources/MOPReference/T6_500.txt new file mode 100644 index 00000000..74db50d0 --- /dev/null +++ b/resources/MOPReference/T6_500.txt @@ -0,0 +1,502 @@ +x1 x2 +0.0 1.0 +0.0020 0.999996 +0.0040 0.999984 +0.0060 0.999964 +0.0080 0.999936 +0.01 0.9999 +0.012 0.999856 +0.014 0.999804 +0.016 0.999744 +0.018000000000000002 0.999676 +0.02 0.9996 +0.022 0.999516 +0.024 0.999424 +0.026000000000000002 0.999324 +0.028 0.999216 +0.03 0.9991 +0.032 0.998976 +0.034 0.998844 +0.036000000000000004 0.998704 +0.038 0.998556 +0.04 0.9984 +0.042 0.998236 +0.044 0.998064 +0.046 0.997884 +0.048 0.997696 +0.05 0.9975 +0.052000000000000005 0.997296 +0.054 0.997084 +0.056 0.996864 +0.058 0.996636 +0.06 0.9964 +0.062 0.996156 +0.064 0.995904 +0.066 0.995644 +0.068 0.995376 +0.07 0.9951 +0.07200000000000001 0.994816 +0.074 0.994524 +0.076 0.994224 +0.078 0.993916 +0.08 0.9936 +0.082 0.993276 +0.084 0.992944 +0.08600000000000001 0.992604 +0.088 0.992256 +0.09 0.9919 +0.092 0.991536 +0.094 0.991164 +0.096 0.990784 +0.098 0.990396 +0.1 0.99 +0.10200000000000001 0.989596 +0.10400000000000001 0.989184 +0.106 0.988764 +0.108 0.988336 +0.11 0.9879 +0.112 0.987456 +0.114 0.987004 +0.116 0.986544 +0.11800000000000001 0.986076 +0.12 0.9856 +0.122 0.985116 +0.124 0.984624 +0.126 0.984124 +0.128 0.983616 +0.13 0.9831 +0.132 0.982576 +0.134 0.982044 +0.136 0.981504 +0.138 0.980956 +0.14 0.9804 +0.14200000000000002 0.979836 +0.14400000000000002 0.979264 +0.146 0.978684 +0.148 0.978096 +0.15 0.9775 +0.152 0.976896 +0.154 0.976284 +0.156 0.975664 +0.158 0.975036 +0.16 0.9744 +0.162 0.973756 +0.164 0.973104 +0.166 0.972444 +0.168 0.971776 +0.17 0.9711 +0.17200000000000001 0.970416 +0.17400000000000002 0.969724 +0.176 0.969024 +0.178 0.968316 +0.18 0.9676 +0.182 0.966876 +0.184 0.966144 +0.186 0.965404 +0.188 0.964656 +0.19 0.9639 +0.192 0.963136 +0.194 0.962364 +0.196 0.961584 +0.198 0.960796 +0.2 0.96 +0.202 0.9591959999999999 +0.20400000000000001 0.958384 +0.20600000000000002 0.957564 +0.20800000000000002 0.956736 +0.21 0.9559 +0.212 0.955056 +0.214 0.954204 +0.216 0.953344 +0.218 0.952476 +0.22 0.9516 +0.222 0.950716 +0.224 0.949824 +0.226 0.948924 +0.228 0.948016 +0.23 0.9471 +0.232 0.946176 +0.234 0.945244 +0.23600000000000002 0.944304 +0.23800000000000002 0.943356 +0.24 0.9424 +0.242 0.941436 +0.244 0.940464 +0.246 0.939484 +0.248 0.938496 +0.25 0.9375 +0.252 0.936496 +0.254 0.935484 +0.256 0.934464 +0.258 0.933436 +0.26 0.9324 +0.262 0.931356 +0.264 0.930304 +0.266 0.929244 +0.268 0.928176 +0.27 0.9271 +0.272 0.926016 +0.274 0.924924 +0.276 0.923824 +0.278 0.922716 +0.28 0.9216 +0.28200000000000003 0.920476 +0.28400000000000003 0.9193439999999999 +0.28600000000000003 0.918204 +0.28800000000000003 0.917056 +0.29 0.9159 +0.292 0.914736 +0.294 0.913564 +0.296 0.912384 +0.298 0.911196 +0.3 0.91 +0.302 0.908796 +0.304 0.907584 +0.306 0.906364 +0.308 0.9051359999999999 +0.31 0.9039 +0.312 0.902656 +0.314 0.901404 +0.316 0.900144 +0.318 0.898876 +0.32 0.8976 +0.322 0.896316 +0.324 0.895024 +0.326 0.893724 +0.328 0.892416 +0.33 0.8911 +0.332 0.889776 +0.334 0.888444 +0.336 0.887104 +0.338 0.885756 +0.34 0.8844 +0.342 0.8830359999999999 +0.34400000000000003 0.881664 +0.34600000000000003 0.880284 +0.34800000000000003 0.878896 +0.35000000000000003 0.8775 +0.352 0.876096 +0.354 0.874684 +0.356 0.873264 +0.358 0.871836 +0.36 0.8704000000000001 +0.362 0.8689560000000001 +0.364 0.867504 +0.366 0.866044 +0.368 0.864576 +0.37 0.8631 +0.372 0.8616159999999999 +0.374 0.860124 +0.376 0.858624 +0.378 0.857116 +0.38 0.8556 +0.382 0.8540760000000001 +0.384 0.852544 +0.386 0.851004 +0.388 0.849456 +0.39 0.8479 +0.392 0.846336 +0.394 0.844764 +0.396 0.8431839999999999 +0.398 0.841596 +0.4 0.84 +0.402 0.8383959999999999 +0.404 0.836784 +0.406 0.835164 +0.40800000000000003 0.8335359999999999 +0.41000000000000003 0.8319 +0.41200000000000003 0.830256 +0.41400000000000003 0.828604 +0.41600000000000004 0.8269439999999999 +0.418 0.825276 +0.42 0.8236 +0.422 0.821916 +0.424 0.8202240000000001 +0.426 0.818524 +0.428 0.816816 +0.43 0.8151 +0.432 0.813376 +0.434 0.811644 +0.436 0.809904 +0.438 0.808156 +0.44 0.8064 +0.442 0.804636 +0.444 0.802864 +0.446 0.801084 +0.448 0.799296 +0.45 0.7975 +0.452 0.795696 +0.454 0.793884 +0.456 0.792064 +0.458 0.7902359999999999 +0.46 0.7884 +0.462 0.786556 +0.464 0.784704 +0.466 0.782844 +0.468 0.780976 +0.47000000000000003 0.7790999999999999 +0.47200000000000003 0.7772159999999999 +0.47400000000000003 0.7753239999999999 +0.47600000000000003 0.773424 +0.47800000000000004 0.771516 +0.48 0.7696000000000001 +0.482 0.767676 +0.484 0.765744 +0.486 0.763804 +0.488 0.761856 +0.49 0.7599 +0.492 0.7579359999999999 +0.494 0.755964 +0.496 0.753984 +0.498 0.751996 +0.5 0.75 +0.502 0.747996 +0.504 0.745984 +0.506 0.7439640000000001 +0.508 0.7419359999999999 +0.51 0.7399 +0.512 0.7378560000000001 +0.514 0.735804 +0.516 0.733744 +0.518 0.731676 +0.52 0.7296 +0.522 0.727516 +0.524 0.725424 +0.526 0.723324 +0.528 0.721216 +0.53 0.7191 +0.532 0.716976 +0.534 0.714844 +0.536 0.712704 +0.538 0.710556 +0.54 0.7083999999999999 +0.542 0.706236 +0.544 0.704064 +0.546 0.701884 +0.548 0.6996959999999999 +0.55 0.6975 +0.552 0.6952959999999999 +0.554 0.6930839999999999 +0.556 0.6908639999999999 +0.558 0.6886359999999999 +0.56 0.6863999999999999 +0.562 0.684156 +0.5640000000000001 0.681904 +0.5660000000000001 0.6796439999999999 +0.5680000000000001 0.677376 +0.5700000000000001 0.6750999999999999 +0.5720000000000001 0.6728159999999999 +0.5740000000000001 0.6705239999999999 +0.5760000000000001 0.6682239999999999 +0.578 0.6659160000000001 +0.58 0.6636 +0.582 0.661276 +0.584 0.658944 +0.586 0.656604 +0.588 0.6542560000000001 +0.59 0.6519 +0.592 0.6495360000000001 +0.594 0.6471640000000001 +0.596 0.644784 +0.598 0.642396 +0.6 0.64 +0.602 0.637596 +0.604 0.635184 +0.606 0.632764 +0.608 0.630336 +0.61 0.6279 +0.612 0.625456 +0.614 0.623004 +0.616 0.620544 +0.618 0.6180760000000001 +0.62 0.6155999999999999 +0.622 0.613116 +0.624 0.6106240000000001 +0.626 0.608124 +0.628 0.6056159999999999 +0.63 0.6031 +0.632 0.600576 +0.634 0.598044 +0.636 0.595504 +0.638 0.592956 +0.64 0.5904 +0.642 0.587836 +0.644 0.585264 +0.646 0.582684 +0.648 0.580096 +0.65 0.5774999999999999 +0.652 0.574896 +0.654 0.572284 +0.656 0.569664 +0.658 0.567036 +0.66 0.5644 +0.662 0.5617559999999999 +0.664 0.5591039999999999 +0.666 0.5564439999999999 +0.668 0.5537759999999999 +0.67 0.5510999999999999 +0.672 0.548416 +0.674 0.5457239999999999 +0.676 0.543024 +0.678 0.540316 +0.68 0.5375999999999999 +0.682 0.5348759999999999 +0.684 0.532144 +0.686 0.529404 +0.6880000000000001 0.5266559999999999 +0.6900000000000001 0.5238999999999999 +0.6920000000000001 0.5211359999999999 +0.6940000000000001 0.5183639999999999 +0.6960000000000001 0.5155839999999999 +0.6980000000000001 0.5127959999999999 +0.7000000000000001 0.5099999999999999 +0.7020000000000001 0.507196 +0.704 0.504384 +0.706 0.5015640000000001 +0.708 0.49873600000000007 +0.71 0.4959 +0.712 0.49305600000000005 +0.714 0.4902040000000001 +0.716 0.487344 +0.718 0.484476 +0.72 0.48160000000000003 +0.722 0.47871600000000003 +0.724 0.475824 +0.726 0.472924 +0.728 0.470016 +0.73 0.46710000000000007 +0.732 0.46417600000000003 +0.734 0.461244 +0.736 0.45830400000000004 +0.738 0.455356 +0.74 0.4524 +0.742 0.44943600000000006 +0.744 0.44646399999999997 +0.746 0.443484 +0.748 0.440496 +0.75 0.4375 +0.752 0.434496 +0.754 0.431484 +0.756 0.42846399999999996 +0.758 0.42543600000000004 +0.76 0.4224 +0.762 0.41935599999999995 +0.764 0.416304 +0.766 0.41324399999999994 +0.768 0.410176 +0.77 0.4071 +0.772 0.40401599999999993 +0.774 0.40092399999999995 +0.776 0.39782399999999996 +0.778 0.39471599999999996 +0.78 0.39159999999999995 +0.782 0.38847599999999993 +0.784 0.3853439999999999 +0.786 0.382204 +0.788 0.37905599999999995 +0.79 0.3758999999999999 +0.792 0.37273599999999996 +0.794 0.3695639999999999 +0.796 0.36638399999999993 +0.798 0.36319599999999996 +0.8 0.3599999999999999 +0.802 0.3567959999999999 +0.804 0.3535839999999999 +0.806 0.3503639999999999 +0.808 0.3471359999999999 +0.81 0.3438999999999999 +0.812 0.34065599999999996 +0.8140000000000001 0.3374039999999999 +0.8160000000000001 0.3341439999999999 +0.8180000000000001 0.33087599999999995 +0.8200000000000001 0.3275999999999999 +0.8220000000000001 0.32431599999999994 +0.8240000000000001 0.32102399999999987 +0.8260000000000001 0.3177239999999999 +0.8280000000000001 0.3144159999999999 +0.8300000000000001 0.31109999999999993 +0.8320000000000001 0.3077759999999998 +0.834 0.30444400000000005 +0.836 0.30110400000000004 +0.838 0.297756 +0.84 0.2944000000000001 +0.842 0.2910360000000001 +0.844 0.28766400000000003 +0.846 0.2842840000000001 +0.848 0.28089600000000003 +0.85 0.2775000000000001 +0.852 0.274096 +0.854 0.27068400000000004 +0.856 0.26726400000000006 +0.858 0.26383600000000007 +0.86 0.2604000000000001 +0.862 0.2569560000000001 +0.864 0.25350400000000006 +0.866 0.25004400000000004 +0.868 0.24657600000000002 +0.87 0.24309999999999998 +0.872 0.23961600000000005 +0.874 0.236124 +0.876 0.23262400000000005 +0.878 0.229116 +0.88 0.22560000000000002 +0.882 0.22207599999999994 +0.884 0.21854399999999996 +0.886 0.21500399999999997 +0.888 0.21145599999999998 +0.89 0.20789999999999997 +0.892 0.20433599999999996 +0.894 0.20076399999999994 +0.896 0.19718399999999991 +0.898 0.193596 +0.9 0.18999999999999995 +0.902 0.186396 +0.904 0.18278399999999995 +0.906 0.179164 +0.908 0.17553599999999991 +0.91 0.17189999999999994 +0.912 0.16825599999999996 +0.914 0.16460399999999997 +0.916 0.16094399999999998 +0.918 0.15727599999999997 +0.92 0.15359999999999996 +0.922 0.14991599999999994 +0.924 0.1462239999999999 +0.926 0.14252399999999987 +0.928 0.13881599999999994 +0.93 0.1350999999999999 +0.932 0.13137599999999994 +0.934 0.12764399999999987 +0.936 0.1239039999999999 +0.9380000000000001 0.12015599999999993 +0.9400000000000001 0.11639999999999984 +0.9420000000000001 0.11263599999999985 +0.9440000000000001 0.10886399999999985 +0.9460000000000001 0.10508399999999984 +0.9480000000000001 0.10129599999999983 +0.9500000000000001 0.09749999999999992 +0.9520000000000001 0.09369599999999989 +0.9540000000000001 0.08988399999999985 +0.9560000000000001 0.08606399999999981 +0.9580000000000001 0.08223599999999986 +0.96 0.07840000000000003 +0.962 0.07455600000000007 +0.964 0.0707040000000001 +0.966 0.06684400000000001 +0.968 0.06297600000000003 +0.97 0.05910000000000004 +0.972 0.05521600000000004 +0.974 0.051324000000000036 +0.976 0.04742400000000002 +0.978 0.043516 +0.98 0.03960000000000008 +0.982 0.03567600000000004 +0.984 0.031743999999999994 +0.986 0.02780400000000005 +0.988 0.02385599999999999 +0.99 0.01990000000000003 +0.992 0.01593600000000006 +0.994 0.011963999999999975 +0.996 0.007983999999999991 +0.998 0.0039959999999999996 +1.0 0.0 \ No newline at end of file diff --git a/resources/MutationCMA.html b/resources/MutationCMA.html new file mode 100644 index 00000000..904189c3 --- /dev/null +++ b/resources/MutationCMA.html @@ -0,0 +1,13 @@ + + +CMA Mutation + + +  +

CMA Mutation

+
+

+Please read the JavaEvA manual for a detailed description. + + + \ No newline at end of file diff --git a/resources/MutationMSRGlobal.html b/resources/MutationMSRGlobal.html new file mode 100644 index 00000000..8c4d66b4 --- /dev/null +++ b/resources/MutationMSRGlobal.html @@ -0,0 +1,13 @@ + + +f_1 : Sphere function + + +  +

MutationMSRGlobal

+
+

+Please read the JavaEvA manual for a detailed description. + + + \ No newline at end of file diff --git a/resources/MutationMSRSeperate.html b/resources/MutationMSRSeperate.html new file mode 100644 index 00000000..fbae40db --- /dev/null +++ b/resources/MutationMSRSeperate.html @@ -0,0 +1,15 @@ + + +f_1 : Sphere function + + +  +

MutationMSRSeperate

+
+

+
+

+Please read the JavaEvA manual for a detailed description. + + + \ No newline at end of file diff --git a/resources/MutationMVA.html b/resources/MutationMVA.html new file mode 100644 index 00000000..25dd4445 --- /dev/null +++ b/resources/MutationMVA.html @@ -0,0 +1,13 @@ + + +MVA Mutation + + +  +

MVA Mutation

+
+

+Please read the JavaEvA manual for a detailed description. + + + \ No newline at end of file diff --git a/resources/MutationRandom.html b/resources/MutationRandom.html new file mode 100644 index 00000000..ac4d0f79 --- /dev/null +++ b/resources/MutationRandom.html @@ -0,0 +1,13 @@ + + +Random Mutation + + +  +

Random Mutation

+
+

+Please read the JavaEvA manual for a detailed description. + + + \ No newline at end of file diff --git a/resources/MutationSuccessRule.html b/resources/MutationSuccessRule.html new file mode 100644 index 00000000..97a71182 --- /dev/null +++ b/resources/MutationSuccessRule.html @@ -0,0 +1,13 @@ + + +Success Rule Mutation + + +  +

Success Rule

+
+

+Please read the JavaEvA manual for a detailed description. + + + \ No newline at end of file diff --git a/resources/NU_SVM.html b/resources/NU_SVM.html new file mode 100644 index 00000000..b3925b74 --- /dev/null +++ b/resources/NU_SVM.html @@ -0,0 +1,13 @@ + + +NU SV-Regression + + +  +

NU SV-Regression

+
+

+Please read the JavaEvA manual for a detailed description. + + + \ No newline at end of file diff --git a/resources/ParticleSwarmOptimization.html b/resources/ParticleSwarmOptimization.html new file mode 100644 index 00000000..66bf080e --- /dev/null +++ b/resources/ParticleSwarmOptimization.html @@ -0,0 +1,23 @@ + + +Particle Swarm Optimization - PSO + + +

Particle Swarm Optimization - PSO

+
+

+The Particle Swarm Optimization by Kennedy and Eberhardt is inspired by swarm intelligent +behaviour seen in animals like birds or ants. A swarm of particles is a set of individual agents +"flying" across the search space with individual velocity vectors. There is no selection as in +classic Evolutionary Algorithms. Instead, the individuals exchange knowledge about the space they +have come across. Each one is attracted to the best position the individual has seen so far (cognitive +component) and to the best position known by its neighbors (social component).
+The neighborhood is defined by the swarm velocity, which may be a linear ordering, a grid and some others. +The influence of the velocity of the last time-step is taken into account using an inertness/ +constriction parameter, which controls the convergence behaviour of the swarm. +The influence of social and cognitive attraction are weighed using the phi parameters. In the +constriction variant there is a dependence enforced between constriction and the phi, making sure that +the swarm converges slowly but steadily, see the publications of Clerc, e.g.
+ + + \ No newline at end of file diff --git a/resources/Poly.html b/resources/Poly.html new file mode 100644 index 00000000..4f0ae20d --- /dev/null +++ b/resources/Poly.html @@ -0,0 +1,13 @@ + + +Poly model + + +  +

Poly model

+
+

+Please read the JavaEvA manual for a detailed description. + + + \ No newline at end of file diff --git a/resources/PolyRBFJama.html b/resources/PolyRBFJama.html new file mode 100644 index 00000000..46dddbeb --- /dev/null +++ b/resources/PolyRBFJama.html @@ -0,0 +1,18 @@ + + +f_1 : Sphere function + + +  +

PolyRBFJama

+
+

+ESPara contains the information describing the Evolution Strategy: + + + \ No newline at end of file diff --git a/resources/RBF.html b/resources/RBF.html new file mode 100644 index 00000000..1cf144c1 --- /dev/null +++ b/resources/RBF.html @@ -0,0 +1,13 @@ + + +RBF model + + +  +

RBF model

+
+

+Please read the JavaEvA manual for a detailed description. + + + \ No newline at end of file diff --git a/resources/StatisticsParameterImpl.html b/resources/StatisticsParameterImpl.html new file mode 100644 index 00000000..68655f95 --- /dev/null +++ b/resources/StatisticsParameterImpl.html @@ -0,0 +1,17 @@ + + +Statistics Parameter Panel + + +  +

Statistics Parameter Panel

+
+

+Here you can edit the : + + + \ No newline at end of file diff --git a/resources/Tribes.html b/resources/Tribes.html new file mode 100644 index 00000000..dcab24c5 --- /dev/null +++ b/resources/Tribes.html @@ -0,0 +1,22 @@ + + +TRIBES + + +

TRIBES

+
+

+TRIBES is a parameter-free PSO implementation by Maurice Clerc. It combines several adaptive +mechanisms to achieve good performance in different domains. It uses a dynamic number of particles, +starting usually with 3 and adding new ones during optimization. Therefore, the number of generations +is not directly connected to the number of fitness calls, +because the population may grow (and seldomly shrink).
+ +Also, there are different initialization +methods implemented which are chosen randomly when particles are created. The particles are organized +in loosely connected groups or tribes (therefore the name), creating a kind of small-world topology. +
+As TRIBES uses an error approximation to steer the adaptations, a target value should be given, so far in the first +dimension only. + + \ No newline at end of file diff --git a/resources/images/Add24.gif b/resources/images/Add24.gif new file mode 100644 index 00000000..69909d5b Binary files /dev/null and b/resources/images/Add24.gif differ diff --git a/resources/images/Export24.gif b/resources/images/Export24.gif new file mode 100644 index 00000000..ee523416 Binary files /dev/null and b/resources/images/Export24.gif differ diff --git a/resources/images/Import24.gif b/resources/images/Import24.gif new file mode 100644 index 00000000..6a34d20b Binary files /dev/null and b/resources/images/Import24.gif differ diff --git a/resources/images/Information24.gif b/resources/images/Information24.gif new file mode 100644 index 00000000..16cb3def Binary files /dev/null and b/resources/images/Information24.gif differ diff --git a/resources/images/JavaEvAIcon.gif b/resources/images/JavaEvAIcon.gif new file mode 100644 index 00000000..efca5368 Binary files /dev/null and b/resources/images/JavaEvAIcon.gif differ diff --git a/resources/images/JavaEvAIcon_2.gif b/resources/images/JavaEvAIcon_2.gif new file mode 100644 index 00000000..47963d9d Binary files /dev/null and b/resources/images/JavaEvAIcon_2.gif differ diff --git a/resources/images/JavaEvAIcon_3.gif b/resources/images/JavaEvAIcon_3.gif new file mode 100644 index 00000000..bcdf3491 Binary files /dev/null and b/resources/images/JavaEvAIcon_3.gif differ diff --git a/resources/images/JavaEvaSplashScreen.png b/resources/images/JavaEvaSplashScreen.png new file mode 100644 index 00000000..76ef87c8 Binary files /dev/null and b/resources/images/JavaEvaSplashScreen.png differ diff --git a/resources/images/Play24.gif b/resources/images/Play24.gif new file mode 100644 index 00000000..572467c5 Binary files /dev/null and b/resources/images/Play24.gif differ diff --git a/resources/images/QueenB.gif b/resources/images/QueenB.gif new file mode 100644 index 00000000..e23ce075 Binary files /dev/null and b/resources/images/QueenB.gif differ diff --git a/resources/images/QueenW.gif b/resources/images/QueenW.gif new file mode 100644 index 00000000..8491260c Binary files /dev/null and b/resources/images/QueenW.gif differ diff --git a/resources/images/Refresh24.gif b/resources/images/Refresh24.gif new file mode 100644 index 00000000..577c4627 Binary files /dev/null and b/resources/images/Refresh24.gif differ diff --git a/resources/images/Stop24.gif b/resources/images/Stop24.gif new file mode 100644 index 00000000..90515c8a Binary files /dev/null and b/resources/images/Stop24.gif differ diff --git a/resources/images/Sub24.gif b/resources/images/Sub24.gif new file mode 100644 index 00000000..bf4cbf1f Binary files /dev/null and b/resources/images/Sub24.gif differ diff --git a/resources/images/ackley.jpg b/resources/images/ackley.jpg new file mode 100644 index 00000000..d68fda16 Binary files /dev/null and b/resources/images/ackley.jpg differ diff --git a/resources/images/ackleyopt.jpg b/resources/images/ackleyopt.jpg new file mode 100644 index 00000000..07788878 Binary files /dev/null and b/resources/images/ackleyopt.jpg differ diff --git a/resources/images/ackleytex.jpg b/resources/images/ackleytex.jpg new file mode 100644 index 00000000..2a5946be Binary files /dev/null and b/resources/images/ackleytex.jpg differ diff --git a/resources/images/f1.jpg b/resources/images/f1.jpg new file mode 100644 index 00000000..9abcf4d9 Binary files /dev/null and b/resources/images/f1.jpg differ diff --git a/resources/images/f1tex.jpg b/resources/images/f1tex.jpg new file mode 100644 index 00000000..44b2deeb Binary files /dev/null and b/resources/images/f1tex.jpg differ diff --git a/resources/images/f2.jpg b/resources/images/f2.jpg new file mode 100644 index 00000000..2d78d951 Binary files /dev/null and b/resources/images/f2.jpg differ diff --git a/resources/images/f2tex.jpg b/resources/images/f2tex.jpg new file mode 100644 index 00000000..e2a045bc Binary files /dev/null and b/resources/images/f2tex.jpg differ diff --git a/resources/images/f81.jpg b/resources/images/f81.jpg new file mode 100644 index 00000000..75e1b250 Binary files /dev/null and b/resources/images/f81.jpg differ diff --git a/resources/images/f85.jpg b/resources/images/f85.jpg new file mode 100644 index 00000000..0587d8ed Binary files /dev/null and b/resources/images/f85.jpg differ diff --git a/resources/images/grie100.jpg b/resources/images/grie100.jpg new file mode 100644 index 00000000..484278e2 Binary files /dev/null and b/resources/images/grie100.jpg differ diff --git a/resources/images/rastrigin1.jpg b/resources/images/rastrigin1.jpg new file mode 100644 index 00000000..4fbdd39a Binary files /dev/null and b/resources/images/rastrigin1.jpg differ diff --git a/resources/images/rastrigin20.jpg b/resources/images/rastrigin20.jpg new file mode 100644 index 00000000..322658aa Binary files /dev/null and b/resources/images/rastrigin20.jpg differ diff --git a/resources/images/rastrigin5.jpg b/resources/images/rastrigin5.jpg new file mode 100644 index 00000000..8c7fb261 Binary files /dev/null and b/resources/images/rastrigin5.jpg differ diff --git a/resources/images/rastrigintex.jpg b/resources/images/rastrigintex.jpg new file mode 100644 index 00000000..c22d129e Binary files /dev/null and b/resources/images/rastrigintex.jpg differ diff --git a/resources/images/rosenbrocktex.jpg b/resources/images/rosenbrocktex.jpg new file mode 100644 index 00000000..540cec54 Binary files /dev/null and b/resources/images/rosenbrocktex.jpg differ diff --git a/resources/images/schwefelsymmetrie.jpg b/resources/images/schwefelsymmetrie.jpg new file mode 100644 index 00000000..3f6018b0 Binary files /dev/null and b/resources/images/schwefelsymmetrie.jpg differ diff --git a/resources/images/step5.jpg b/resources/images/step5.jpg new file mode 100644 index 00000000..78b591f7 Binary files /dev/null and b/resources/images/step5.jpg differ diff --git a/resources/images/stepopt.jpg b/resources/images/stepopt.jpg new file mode 100644 index 00000000..46869d70 Binary files /dev/null and b/resources/images/stepopt.jpg differ diff --git a/resources/images/steptex.jpg b/resources/images/steptex.jpg new file mode 100644 index 00000000..7f786fcd Binary files /dev/null and b/resources/images/steptex.jpg differ diff --git a/resources/rvm.html b/resources/rvm.html new file mode 100644 index 00000000..5d2b98ea --- /dev/null +++ b/resources/rvm.html @@ -0,0 +1,13 @@ + + +RVM model + + +  +

RVM model

+
+

+Please read the JavaEvA manual for a detailed description. + + + \ No newline at end of file diff --git a/src/jalopy.format.convention.xml b/src/jalopy.format.convention.xml new file mode 100644 index 00000000..f871f8ab --- /dev/null +++ b/src/jalopy.format.convention.xml @@ -0,0 +1,398 @@ + + + + + 1 + + + + + false + + + [A-Z][a-zA-Z0-9]+ + [A-Z][a-zA-Z0-9]+ + + + [a-z][\w]+ + [a-z][\w]+ + [a-zA-Z][\w]+ + [a-z][\w]+ + [a-z][\w]+ + [a-zA-Z][\w]+ + [a-z][\w]+ + [a-z][\w]+ + [a-zA-Z][\w]+ + [a-z][\w]+ + [a-z][\w]+ + [a-zA-Z][\w]+ + + [A-Z][a-zA-Z0-9]+ + \w+ + + [a-z][\w]+ + [a-z][\w]+ + [a-z][\w]+ + [a-z][\w]+ + [a-z][\w]+ + [a-z][\w]+ + [a-z][\w]+ + [a-z][\w]+ + [a-z][\w]+ + [a-z][\w]+ + [a-z][\w]+ + [a-z][\w]+ + + [a-z]+(?:\.[a-z]+)* + + [a-z][\w]+ + [a-z][\w]+ + + [a-z][\w]* + + + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + false + + + + 6 + + + + 30000 + 30000 + 30000 + 30000 + 30000 + 30000 + + true + + + 1 + + + + true + false + true + false + false + + + bak + 0 + + + + 1 + 1 + 1 + 0 +
1
+
0
+ 1 + 2 + 1 + 1 +
+ + 1 + 0 + 1 + + 1 + 1 + 1 + + 1 + 1 +
0
+
0
+
+ 1 +
+ + + false + false + + + true + true + true + true + + + true + false + false + false + false + + + false + false + + + + true + true + + + + false + + + + false + false + false + + true + + 1 + 0 + 0 + 0 + + false + + + + + + + */ + * @throws $exceptionType$ DOCUMENT ME! + * @param $paramType$ DOCUMENT ME! + * @return DOCUMENT ME! + /**| * DOCUMENT ME! + + + + + false + false + false + + + / + true + false + + Inner Classes + Constructors + Instance fields + Instance initializers + Inner Interfaces + Methods + Static fields/initializers + + + + +
+ + 5 + /////////////////////////////////////////////////////////////////////////////// +// END OF FILE. +/////////////////////////////////////////////////////////////////////////////// + true +
+ + +
+ JavaEVA header + 5 + /////////////////////////////////////////////////////////////////////////////// +// Filename: $RCSfile$ +// Language: Java +// Compiler: JDK 1.4 +// Authors: Holger Ulmer, Felix Streichert, Hannes Planatscher +// Version: $Revision: 10 $ +// $Date: 2006-01-18 11:02:22 +0100 (Wed, 18 Jan 2006) $ +// $Author: streiche $ +// +// Copyright (c) Dept. Computer Architecture, University of Tuebingen, Germany +/////////////////////////////////////////////////////////////////////////////// + false +
+ + disabled + + + + 3 + *:1|gnu:2|java:2|javax:2|org:2|com:2|net:2|joelib:2 + + expand + true + + + + false + + true + false + + true + + + false + + + 1 + 0 + 0 + 1 + 4 + 55 + -1 + 4 + -1 + 0 + 8 + -1 + 1 + + + false + false + + + + false + true + true + true + true + false + + + + false + true + false + false + false + static|field|initializer|constructor|method|interface|class + true + + + false + public|protected|private|abstract|static|final|synchronized|transient|volatile|native|strictfp + + + + + + true + true + true + + + false + false + false + false + + false + + + false + false + true + + + + false + false + + true + true + true + true + true + true + + false + false + + + + + + 0 + true + false + false + + false + + false + false + + false + + + false + false + false + false + + + false + false + false + + + + false + true + 80 + + + + false + false + false + + false + false + false + + + + false + + false + + +
+
+ + diff --git a/src/javaeva/client/AppExitAction.java b/src/javaeva/client/AppExitAction.java new file mode 100644 index 00000000..cb142afc --- /dev/null +++ b/src/javaeva/client/AppExitAction.java @@ -0,0 +1,35 @@ +package javaeva.client; + +import javaeva.gui.ExtAction; + +import javax.swing.*; +import java.awt.event.WindowListener; +import java.awt.event.ActionEvent; +import java.awt.event.WindowEvent; + +/** + * Created by IntelliJ IDEA. + * User: streiche + * Date: 12.05.2003 + * Time: 18:28:54 + * To change this template use Options | File Templates. + */ +/** + * + */ +class AppExitAction extends ExtAction implements WindowListener{ + public AppExitAction(String s, String toolTip, KeyStroke key){ + super(s, toolTip, key); + } + private void exit(){ + System.exit(1); + } + public void actionPerformed(ActionEvent e){exit();} + public void windowOpened(WindowEvent e){} + public void windowClosed(WindowEvent e){} + public void windowIconified(WindowEvent e){ } + public void windowDeiconified(WindowEvent e){ } + public void windowActivated(WindowEvent e){ } + public void windowDeactivated(WindowEvent e){ } + public void windowClosing(WindowEvent e){exit();} +} diff --git a/src/javaeva/client/EvAClient.java b/src/javaeva/client/EvAClient.java new file mode 100644 index 00000000..8461d73b --- /dev/null +++ b/src/javaeva/client/EvAClient.java @@ -0,0 +1,726 @@ +package javaeva.client; + +/* + * Title: JavaEvA + * Description: + * Copyright: Copyright (c) 2003 + * Company: University of Tuebingen, Computer Architecture + * @author Holger Ulmer, Felix Streichert, Hannes Planatscher + * @version: $Revision: 322 $ + * $Date: 2007-12-11 17:24:07 +0100 (Tue, 11 Dec 2007) $ + * $Author: mkron $ + */ +/*==========================================================================* + * IMPORTS + *==========================================================================*/ +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.Event; +import java.awt.Toolkit; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.KeyEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.io.Serializable; +import java.util.Properties; + +import javaeva.gui.ExtAction; +import javaeva.gui.JEFrame; +import javaeva.gui.JEFrameRegister; +import javaeva.gui.JExtMenu; +import javaeva.gui.JTabbedModuleFrame; +import javaeva.gui.LogPanel; +import javaeva.server.EvAServer; +import javaeva.server.modules.ModuleAdapter; +import javaeva.tools.EVAERROR; +import javaeva.tools.EVAHELP; +import javaeva.tools.Serializer; + +import javax.swing.ButtonGroup; +import javax.swing.ImageIcon; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JMenuBar; +import javax.swing.JMenuItem; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JProgressBar; +import javax.swing.JRadioButtonMenuItem; +import javax.swing.JWindow; +import javax.swing.KeyStroke; +import javax.swing.SwingUtilities; +import javax.swing.UIManager; +import javax.swing.UnsupportedLookAndFeelException; +import javax.swing.event.MenuEvent; +import javax.swing.event.MenuListener; + +import wsi.ra.jproxy.RemoteStateListener; +import wsi.ra.tool.BasicResourceLoader; + +/** +///////////////////////////////// +// -Xrunhprof:cpu=samples +///////////////////////////////////////////////// + /*==========================================================================* + * CLASS DECLARATION + *==========================================================================*/ +/** + * + */ +public class EvAClient implements RemoteStateListener, Serializable { + public static final String EVA_PROPERTY_FILE = "resources/JavaEvA.props"; + private static Properties EVA_PROPERTIES; + public static final String iconLocation = "resources/images/JavaEvAIcon_3.gif"; + + public static boolean TRACE = false; + private static String m_ProductName = "JavaEvA"; +// private int PREFERRED_WIDTH = 680; +// private int PREFERRED_HEIGHT = 550; + private JWindow m_splashScreen; + public JEFrame m_Frame; + + private EvAComAdapter m_ComAdapter; +// private JExtDesktopPane m_Desktop; + private transient JMenuBar m_barMenu; + private transient JExtMenu m_mnuAbout; + private transient JExtMenu m_mnuSelHosts; + private transient JExtMenu m_mnuModule; + private transient JExtMenu m_mnuWindow; + private transient JExtMenu m_mnuOptions; + private transient JProgressBar m_ProgressBar; + +// public ArrayList m_ModulGUIContainer = new ArrayList(); + // LogPanel + private LogPanel m_LogPanel; + + // Module: + private ExtAction m_actModuleLoad; + // GUI: + + // Hosts: + private ExtAction m_actHost; + private ExtAction m_actAvailableHost; + private ExtAction m_actKillHost; + private ExtAction m_actKillAllHosts; +// private ArrayList m_ModuleAdapterList = new ArrayList(); + // About: + private ExtAction m_actAbout; + +// private JPanel m_panelTool; +// private FrameCloseListener m_frameCloseListener; +// private JFileChooser m_FileChooser; + +// if not null, the module is loaded automatically and no other can be selected + private String useDefaultModule = null;//"Genetic_Optimization"; + private boolean showLoadModules = false; + private boolean localMode = false; + // This variable says whether, if running locally, a local server should be addressed by RMI. + // False should be preferred here to avoid overhead + private boolean useLocalRMI = false; + // measuring optimization runtime + private long startTime = 0; + // remember the module in use + private transient String currentModule = null; + + public static String getProperty(String key) { + String myVal = EVA_PROPERTIES.getProperty(key); + return myVal; + } + + public static Properties getProperties() { + return EVA_PROPERTIES; + } + + public static void setProperty(String key, String value) { + EVA_PROPERTIES.setProperty(key, value); + } + + /** + * Statically loading Properties. + */ + static { + try { + EVA_PROPERTIES = BasicResourceLoader.readProperties(EVA_PROPERTY_FILE); + } catch (Exception ex) { + System.err.println("Could not read the configuration file "+ EVA_PROPERTY_FILE); + ex.printStackTrace(); + } + } + + /** + * Constructor of GUI of JavaEva. + * Works as client for the JavaEva server. + * + */ + public EvAClient(String hostName) { + createSplashScreen(); + currentModule = null; + + m_ComAdapter = EvAComAdapter.getInstance(); + SwingUtilities.invokeLater(new Runnable() { + public void run() { + if (m_splashScreen != null) m_splashScreen.setVisible(true); + } + }); + + SwingUtilities.invokeLater(new Runnable() { + public void run() { + //init(); + try { + Thread.sleep(6000); + } catch (Exception e) { + System.out.println("error" + e.getMessage()); + } + if (m_splashScreen != null) m_splashScreen.setVisible(false); + m_splashScreen = null; + } + }); + init(hostName); + + } + + /** + * + */ + private void init(String hostName) { + //EVA_EDITOR_PROPERTIES + useDefaultModule = getProperty("DefaultModule"); + + if (useDefaultModule != null) { + useDefaultModule = useDefaultModule.trim(); + if (useDefaultModule.length() < 1) useDefaultModule = null; + } + + + m_Frame = new JEFrame(); + BasicResourceLoader loader = BasicResourceLoader.instance(); + byte[] bytes = loader.getBytesFromResourceLocation(iconLocation); + try { + m_Frame.setIconImage(Toolkit.getDefaultToolkit().createImage(bytes)); + } catch (java.lang.NullPointerException e) { + System.out.println("Could not find JavaEvA icon, please move rescoure folder to working directory!"); + } + m_Frame.setTitle("JavaEvA workbench"); + + try { + Thread.sleep(200); + } catch (Exception e) { + System.out.println("Error" + e.getMessage()); + } + + m_Frame.getContentPane().setLayout(new BorderLayout()); + m_LogPanel = new LogPanel(); + m_Frame.getContentPane().add(m_LogPanel, BorderLayout.CENTER); + m_ProgressBar = new JProgressBar(); + m_Frame.getContentPane().add(m_ProgressBar, BorderLayout.SOUTH); + + if (getProperty("ShowModules") != null) showLoadModules = true; + else showLoadModules = false; // may be set to true again if default module couldnt be loaded + + createActions(); + + if (useDefaultModule != null) { + loadModuleFromServer(useDefaultModule);//loadSpecificModule + } + + buildMenu(); + + m_Frame.addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + System.out.println("Closing JavaEvA Client. Bye!"); + System.exit(1); + } + }); + + if (m_ComAdapter != null) { + if (hostName != null) selectHost(hostName); + m_ComAdapter.setLogPanel(m_LogPanel); + logMessage("Selected Host: " + m_ComAdapter.getHostName()); + } +// m_mnuModule.setText("Select module"); +// m_mnuModule.repaint(); + + m_LogPanel.logMessage("Class path is: " + System.getProperty("java.class.path",".")); + + if (!(m_Frame.isVisible())) { + m_Frame.pack(); + m_Frame.setVisible(true); + } + } + + /** + * Create the JavaEvA splash screen. + */ + public void createSplashScreen() { + BasicResourceLoader loader = BasicResourceLoader.instance(); + byte[] bytes = loader.getBytesFromResourceLocation("resources/images/JavaEvaSplashScreen.png"); + try { + ImageIcon ii = new ImageIcon(Toolkit.getDefaultToolkit().createImage(bytes)); + JLabel splashLabel = new JLabel(ii); + m_splashScreen = new JWindow(); + m_splashScreen.getContentPane().add(splashLabel); + m_splashScreen.pack(); + Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); + //splashScreen.setSize(screenSize); + m_splashScreen.setLocation(screenSize.width / 2 - m_splashScreen.getSize().width / 2, screenSize.height / 2 - m_splashScreen.getSize().height / 2); + } catch (java.lang.NullPointerException e) { + System.err.println("Could not find JavaEvA splash screen, please move rescoure folder to working directory!"); + } + + } + + /** + * The one and only main of the client programm. + * + * @param args command line parameters + */ + public static void main(String[] args) { + if (TRACE) { + System.out.println(EVAHELP.getSystemPropertyString()); + } + EvAClient Client = new EvAClient((args.length == 1) ? args[0] : null); + } + +// /** +// * +// */ +// public void addInternalFrame(JInternalFrame newFrame) { +// m_Desktop.add(newFrame); +// newFrame.toFront(); +// } + + /** + * + */ + private void createActions() { + ////////////////////////////////////////////////////////////// + // Module: + ///////////////////////////////////////////////////////////// + m_actModuleLoad = new ExtAction("&Load", "Load Module", + KeyStroke.getKeyStroke(KeyEvent.VK_L, Event.CTRL_MASK)) { + public void actionPerformed(ActionEvent e) { + loadModuleFromServer(null); + } + }; + + m_actAbout = new ExtAction("&About...", "Product Information", + KeyStroke.getKeyStroke(KeyEvent.VK_A, Event.CTRL_MASK)) { + public void actionPerformed(ActionEvent e) { + logMessage(e.getActionCommand()); + showAboutDialog(); + } + }; + m_actHost = new ExtAction("&List of all servers", "All servers in list", + KeyStroke.getKeyStroke(KeyEvent.VK_A, Event.CTRL_MASK)) { + public void actionPerformed(ActionEvent e) { + logMessage(e.getActionCommand()); + selectAvailableHost(m_ComAdapter.getHostNameList()); + } + }; + m_actAvailableHost = new ExtAction("Available &Server", "Available server", + KeyStroke.getKeyStroke(KeyEvent.VK_H, Event.CTRL_MASK)) { + public void actionPerformed(ActionEvent e) { + logMessage(e.getActionCommand()); + showPleaseWaitDialog(); + Thread xx = new Thread() { + public void run() { + selectAvailableHost(m_ComAdapter.getAvailableHostNameList()); + } + }; + xx.start(); + } + }; + m_actKillHost = new ExtAction("&Kill server", "Kill server process on selected host", + KeyStroke.getKeyStroke(KeyEvent.VK_K, Event.CTRL_MASK)) { + public void actionPerformed(ActionEvent e) { + logMessage(e.getActionCommand()); + showPleaseWaitDialog(); + Thread xx = new Thread() { + public void run() { + selectAvailableHostToKill(m_ComAdapter.getAvailableHostNameList()); + } + }; + xx.start(); + } + }; + m_actKillAllHosts = new ExtAction("Kill &all server", "Kill all server", + KeyStroke.getKeyStroke(KeyEvent.VK_K, Event.CTRL_MASK)) { + public void actionPerformed(ActionEvent e) { + logMessage(e.getActionCommand()); + showPleaseWaitDialog(); + Thread xx = new Thread() { + public void run() { + selectAllAvailableHostToKill(m_ComAdapter.getAvailableHostNameList()); + } + }; + xx.start(); + } + }; + /* m_actStartServerManager = new ExtAction("Start &Server Manager", "Start &Server Manager", + KeyStroke.getKeyStroke(KeyEvent.VK_S, Event.CTRL_MASK)){ + public void actionPerformed(ActionEvent e){ + m_LogPanel.logMessage(e.getActionCommand()); + ServerStartFrame sm = new ServerStartFrame(m_ComAdapter.getHostNameList()); + } + }; + */ + } + + /** + * + */ + private void buildMenu() { + m_barMenu = new JMenuBar(); + m_Frame.setJMenuBar(m_barMenu); + //////////////////////////////////////////////////////////////////////////// + JExtMenu mnuLookAndFeel = new JExtMenu("&Look and Feel"); + ButtonGroup grpLookAndFeel = new ButtonGroup(); + UIManager.LookAndFeelInfo laf[] = UIManager.getInstalledLookAndFeels(); +// if (TRACE) { +// for (int i=0;i<3;i++) +// System.out.println(laf[i].getName()); +// System.out.println ("->"+UIManager.getLookAndFeel().getClass().getName()); +// } + + String LAF = Serializer.loadString("LookAndFeel.ser"); + + boolean lafSelected = false; + for (int i = 0; i < laf.length; i++) { + JRadioButtonMenuItem mnuItem = new JRadioButtonMenuItem(laf[i].getName()); + mnuItem.setActionCommand(laf[i].getClassName()); + if (!lafSelected && laf[i].getClassName().equals(UIManager.getLookAndFeel().getClass().getName())) { +// if (!lafSelected && laf[i].getClassName().equals(UIManager.getSystemLookAndFeelClassName())) { +// if (LAF==null) {// do this only if no older selection one could be loaded +// LAF = laf[i].getClassName(); // set for later selection +// } // this causes problems with my gnome! + if (LAF == null) { + lafSelected = true; + mnuItem.setSelected(true); + } + } + mnuItem.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + try { + UIManager.setLookAndFeel(e.getActionCommand()); + SwingUtilities.updateComponentTreeUI(m_Frame); + // hier noch reinhacken dass alle frame geupdated werden. + m_Frame.pack(); +// m_Frame.setSize(new Dimension(900, 700)); +// m_Frame.setVisible(true); + Serializer.storeString("LookAndFeel.ser", e.getActionCommand()); + } catch (ClassNotFoundException exc) {} catch (InstantiationException exc) {} catch (UnsupportedLookAndFeelException exc) {} catch ( + IllegalAccessException exc) {} + } + }); + mnuLookAndFeel.add(mnuItem); + grpLookAndFeel.add(mnuItem); + } + if (LAF != null) { + try { + UIManager.setLookAndFeel(LAF); + SwingUtilities.updateComponentTreeUI(m_Frame); + m_Frame.pack(); +// m_Frame.setSize(new Dimension(900, 700)); +// m_Frame.setVisible(true); + } catch (ClassNotFoundException exc) {} catch (InstantiationException exc) {} catch (UnsupportedLookAndFeelException exc) {} catch ( + IllegalAccessException exc) {} + } + m_mnuModule = new JExtMenu("Select &module"); + m_mnuModule.add(m_actModuleLoad); + + //////////////////////////////////////////////////////////////// + + m_mnuWindow = new JExtMenu("&Window"); + m_mnuWindow.addMenuListener(new MenuListener() { + public void menuSelected(MenuEvent e) { +// System.out.println("Selected"); + m_mnuWindow.removeAll(); + Object[] framelist = JEFrameRegister.getFrameList(); + for (int i = 0; i < framelist.length; i++) { + JMenuItem act = new JMenuItem((i + 1) + ". " + ((JEFrame) framelist[i]).getTitle()); + final JFrame x = ((JEFrame) framelist[i]); + act.addActionListener((new ActionListener() { + public void actionPerformed(ActionEvent e) { + x.setExtendedState(JFrame.NORMAL); + x.toFront(); + } + } + ) + ); + m_mnuWindow.add(act); + } + + } + + public void menuCanceled(MenuEvent e) { + + } + + public void menuDeselected(MenuEvent e) { + + } + } + ); + + //////////////////////////////////////////////////////////////// + m_mnuSelHosts = new JExtMenu("&Select Hosts"); + m_mnuSelHosts.setToolTipText("Select a host for the server application"); + //if (EvAClient.LITE_VERSION == false) + m_mnuSelHosts.add(m_actHost); + m_mnuSelHosts.add(m_actAvailableHost); + m_mnuSelHosts.addSeparator(); + m_mnuSelHosts.add(m_actKillHost); + m_mnuSelHosts.add(m_actKillAllHosts); +// m_mnuOptions.add(m_actStartServerManager); + //////////////////////////////////////////////////////////////// + m_mnuAbout = new JExtMenu("&About"); + m_mnuAbout.add(m_actAbout); + ////////////////////////////////////////////////////////////// + // m_barMenu.add(m_Desktop.getWindowMenu()); + + m_mnuOptions = new JExtMenu("&Options"); + m_mnuOptions.add(mnuLookAndFeel); + m_mnuOptions.add(m_mnuSelHosts); + //m_barMenu.add(m_mnuSelHosts); + // this is accessible if no default module is given + if (showLoadModules) { + m_barMenu.add(m_mnuModule); + } + + m_barMenu.add(m_mnuOptions); + m_barMenu.add(m_mnuWindow); + m_barMenu.add(m_mnuAbout); + + } + + protected void logMessage(String msg) { + if (TRACE || m_LogPanel == null) System.out.println(msg); + if (m_LogPanel != null) m_LogPanel.logMessage(msg); + } + + /** + * + */ + private void loadModuleFromServer(String selectedModule) { + if (m_ComAdapter.getHostName() == null) { + System.err.println("error in loadModuleFromServer!"); + return; + } + if (m_ComAdapter.getHostName().equals("localhost")) { + localMode = true; + if (useLocalRMI) { + EvAServer Server = new EvAServer(true, false); + m_ComAdapter.setLocalRMIServer(Server.getRMIServer()); + logMessage("Local EvAServer started"); + m_ComAdapter.setRunLocally(false); // this is not quite true but should have the desired effect + } else { + logMessage("Working locally"); + m_ComAdapter.setLocalRMIServer(null); + m_ComAdapter.setRunLocally(true); + } + } else { + localMode = false; + if (TRACE) logMessage("Using RMI on m_ComAdapter.getHostName()"); + m_ComAdapter.setRunLocally(false); + } + if (selectedModule == null) { // show a dialog and ask for a module + String[] ModuleNameList = m_ComAdapter.getModuleNameList(); + if (ModuleNameList == null) { + JOptionPane.showMessageDialog(m_Frame.getContentPane(), "No modules available on " + m_ComAdapter.getHostName(), "JavaEvA Information", 1); + } else { + String LastModuleName = Serializer.loadString("lastmodule.ser"); + if (LastModuleName == null) LastModuleName = ModuleNameList[0]; + selectedModule = (String) JOptionPane.showInputDialog(m_Frame.getContentPane(), + "Which module do you want \n to load on host: " + m_ComAdapter.getHostName() + " ?", "Load optimization module on host", + JOptionPane.QUESTION_MESSAGE, + null, + ModuleNameList, + LastModuleName); + } + } + if (selectedModule == null) { + System.err.println("not loading any module"); + } else { + Serializer.storeString("lastmodule.ser", selectedModule); + + loadSpecificModule(selectedModule); + + m_actHost.setEnabled(true); + m_actAvailableHost.setEnabled(true); + logMessage("Selected Module: " + selectedModule); +// m_LogPanel.statusMessage("Selected Module: " + selectedModule); + } + } + + private void loadSpecificModule(String selectedModule) { + ModuleAdapter newModuleAdapter = null; + // + try { + newModuleAdapter = m_ComAdapter.getModuleAdapter(selectedModule); + } catch (Exception e) { + logMessage("Error while m_ComAdapter.GetModuleAdapter Host: " + e.getMessage()); + e.printStackTrace(); + EVAERROR.EXIT("Error while m_ComAdapter.GetModuleAdapter Host: " + e.getMessage()); + } + if (newModuleAdapter == null) showLoadModules = true; + else { + newModuleAdapter.setConnection(!localMode); + if (m_ComAdapter.isRunLocally()) { + // TODO in rmi-mode this doesnt work yet! + newModuleAdapter.addRemoteStateListener((RemoteStateListener)this); + } + try { + // this (or rather: JModuleGeneralPanel) is where the start button etc come from! + JTabbedModuleFrame Temp = newModuleAdapter.getModuleFrame(); +// newModuleAdapter.setLogPanel(m_LogPanel); + + JPanel moduleContainer = Temp.createContentPane(); // MK the frame is actually painted in here + // m_Frame.setLayout(new BorderLayout()); + m_Frame.setVisible(false); + m_Frame.getContentPane().removeAll(); + + // nested info-panel so that we can stay with simple borderlayouts + JPanel infoPanel = new JPanel(); + infoPanel.setLayout(new BorderLayout()); + infoPanel.add(m_ProgressBar, BorderLayout.SOUTH); + infoPanel.add(m_LogPanel, BorderLayout.NORTH); + + m_Frame.add(Temp.getToolBar(), BorderLayout.NORTH); + m_Frame.add(moduleContainer, BorderLayout.CENTER); + //m_Frame.add(m_ProgressBar, BorderLayout.CENTER); + //m_Frame.add(m_LogPanel, BorderLayout.SOUTH); + m_Frame.add(infoPanel, BorderLayout.SOUTH); + + m_Frame.pack(); + m_Frame.setVisible(true); + + currentModule = selectedModule; + // m_ModulGUIContainer.add(Temp); + } catch (Exception e) { + currentModule = null; + e.printStackTrace(); + logMessage("Error while newModulAdapter.getModulFrame(): " + e.getMessage()); + EVAERROR.EXIT("Error while newModulAdapter.getModulFrame(): " + e.getMessage()); + } +// try { TODO whats this? +// newModuleAdapter.setConnection(true); +// } catch (Exception e) { +// e.printStackTrace(); +// m_LogPanel.logMessage("Error while m_ComAdapter.AddRMIPlotListener Host: " + e.getMessage()); +// EVAERROR.EXIT("Error while m_ComAdapter.AddRMIPlotListener: " + e.getMessage()); +// } + // set mode (rmi or not) + + // ModuladapterListe adden +// m_ModuleAdapterList.add(newModuleAdapter); + } + } + + /** + * + */ + private void selectAvailableHost(String[] HostNames) { + if (TRACE) System.out.println("SelectAvailableHost"); + if (HostNames == null || HostNames.length == 0) { + showNoHostFoundDialog(); + } else { + String HostName = (String) JOptionPane.showInputDialog(m_Frame.getContentPane(), + "Which active host do you want to connect to?", "Host", JOptionPane.QUESTION_MESSAGE, null, + HostNames, m_ComAdapter.getHostName()); + if (HostName != null) selectHost(HostName); + } + } + + private void selectHost(String hostName) { + m_ComAdapter.setHostName(hostName); + logMessage("Selected Host: " + hostName); + if (currentModule != null) { + logMessage("Reloading module from server..."); + loadModuleFromServer(currentModule); + } + +// m_mnuModule.setText("Select module"); +// m_mnuModule.repaint(); + // System.out.println(HostName + " selected"); + } + + private void showPleaseWaitDialog() { + JOptionPane.showMessageDialog(m_Frame.getContentPane(), "Please wait one moment.", "JavaEvA Information", 1); + } + + private void showAboutDialog() { + JOptionPane.showMessageDialog + (m_Frame, + m_ProductName + + "\n University of Tuebingen\n Computer Architecture\n Holger Ulmer & Felix Streichert & Hannes Planatscher \n Prof. Dr. Andreas Zell \n (c) 2007 \n Version " + + EvAServer.Version + " \n http://www-ra.informatik.uni-tuebingen.de/software/JavaEvA/", "JavaEvA Information", 1); + } + + private void showNoHostFoundDialog() { + JOptionPane.showMessageDialog(m_Frame.getContentPane(), "No host with running EVASERVER found. Please start one or \nadd the correct address to the properties list.", "JavaEvA Information", 1); + } + + /** + * + */ + private void selectAvailableHostToKill(String[] HostNames) { + if (TRACE) System.out.println("SelectAvailableHostToKill"); + if (HostNames == null || HostNames.length == 0) { + showNoHostFoundDialog(); + return; + } + String HostName = (String) JOptionPane.showInputDialog(m_Frame.getContentPane(), + "Which server do you want to be killed ?", "Host", JOptionPane.QUESTION_MESSAGE, null, + HostNames, m_ComAdapter.getHostName()); + if (HostName == null) + return; + logMessage("Kill host process on = " + HostName); + m_ComAdapter.killServer(HostName); +// m_LogPanel.statusMessage(""); + } + + /** + * + */ + private void selectAllAvailableHostToKill(String[] HostNames) { + System.out.println("SelectAllAvailableHostToKill"); + if (HostNames == null || HostNames.length == 0) { + System.out.println("no host is running"); + return; + } + m_ComAdapter.killAllServers(); + } + + public void performedRestart(String infoString) { + logMessage("Restarted " + infoString); + startTime = System.currentTimeMillis(); + } + + public void performedStart(String infoString) { + logMessage("Started " + infoString); + startTime = System.currentTimeMillis(); + } + + public void performedStop() { + long t = (System.currentTimeMillis() - startTime); + logMessage(String.format("Stopped after %1$d.%2$tL s", (t / 1000), (t % 1000))); + } + + /** + * When the worker needs to update the GUI we do so by queuing + * a Runnable for the event dispatching thread with + * SwingUtilities.invokeLater(). In this case we're just + * changing the progress bars value. + */ + public void updateProgress(final int percent) { + if (this.m_ProgressBar != null) { + Runnable doSetProgressBarValue = new Runnable() { + public void run() { + m_ProgressBar.setValue(percent); + } + }; + SwingUtilities.invokeLater(doSetProgressBarValue); + } + } +} diff --git a/src/javaeva/client/EvAComAdapter.java b/src/javaeva/client/EvAComAdapter.java new file mode 100644 index 00000000..28917b6b --- /dev/null +++ b/src/javaeva/client/EvAComAdapter.java @@ -0,0 +1,137 @@ +package javaeva.client; + +/* + * Title: JavaEvA + * Description: + * Copyright: Copyright (c) 2003 + * Company: University of Tuebingen, Computer Architecture + * @author Holger Ulmer, Felix Streichert, Hannes Planatscher + * @version: $Revision: 320 $ + * $Date: 2007-12-06 16:05:11 +0100 (Thu, 06 Dec 2007) $ + * $Author: mkron $ + */ +/*==========================================================================* + * IMPORTS + *==========================================================================*/ + +import java.rmi.RemoteException; +import java.rmi.registry.Registry; +import java.util.ArrayList; +import javaeva.gui.LogPanel; +import javaeva.server.EvAMainAdapter; +import javaeva.server.EvAMainAdapterImpl; +import javaeva.server.RMIServerEvA; +import javaeva.server.modules.ModuleAdapter; + +import wsi.ra.jproxy.ComAdapter; +import wsi.ra.jproxy.MainAdapter; +import wsi.ra.jproxy.MainAdapterClient; +import wsi.ra.jproxy.MainAdapterClientImpl; +import wsi.ra.jproxy.RMIConnection; +import wsi.ra.jproxy.RMIInvocationHandler; +import wsi.ra.jproxy.RMIProxyLocal; +/*==========================================================================* + * CLASS DECLARATION + *==========================================================================*/ +/** + * + */ +public class EvAComAdapter extends ComAdapter { + private LogPanel m_LogPanel; + private EvAMainAdapterImpl localMainAdapter; + private boolean runLocally = false; + + /** + * + */ + public void setLogPanel(LogPanel OutputFrame) { + m_LogPanel = OutputFrame; + } + /** + * + */ + public static EvAComAdapter getInstance() { + if (m_instance==null) { + m_instance = new EvAComAdapter(); + m_instance.addServersFromProperties(EvAClient.getProperties()); + } + return (EvAComAdapter)m_instance; + } + + /** + * Creates the ModulAdapters RMI Object on the server + * @return + */ + public ModuleAdapter getModuleAdapter(String str) { + ModuleAdapter newModuleAdapter; + if ((m_RMIServer == null) && isRunLocally()) { + //ret = evaAdapter.getModuleAdapter(Modul, hostAdd, this.m_MainAdapterClient); + newModuleAdapter = getLocalMainAdapter().getModuleAdapter(str, true, getHostName(), null); + } else { + newModuleAdapter = ((RMIConnectionEvA)getConnection(getHostName())).getModuleAdapter(str); + if (newModuleAdapter == null) System.err.println("RMI Error for getting ModuleAdapterObject : " + str); + } + return newModuleAdapter; + } + + private EvAMainAdapter getLocalMainAdapter() { + if (localMainAdapter == null) localMainAdapter = new EvAMainAdapterImpl(); + return localMainAdapter; + } + + /** + * Returns a list of modules available on the server. + * @return + */ + public String[] getModuleNameList() { + String[] list; + if (TRACE) System.out.println("ComAdapter.GetModuleNameList()"); + + if ((m_RMIServer == null) && isRunLocally()) { + list = getLocalMainAdapter().getModuleNameList(); + } else { + RMIConnectionEvA Connection = (RMIConnectionEvA)getConnection(getHostName()); + if (Connection == null) { + System.err.println("Couldnt create RMIConnection in EvAComAdapter.getModuleNameList"); + return null; + } + list = ((EvAMainAdapter)Connection.getMainAdapter()).getModuleNameList(); + } + if (m_LogPanel != null) + m_LogPanel.logMessage("List of modules on server:"); + if (list != null) + for (int i = 0; i < list.length; i++) { + if ( (String) list[i] != null && m_LogPanel != null) + m_LogPanel.logMessage( (String) list[i]); + } + return list; + } + + protected MainAdapter getMainAdapter(RMIInvocationHandler invocHandler) throws RemoteException { + return (EvAMainAdapter) invocHandler.getWrapper(); + } + + protected void logInfo(String msg) { + if (m_LogPanel != null) { + m_LogPanel.logMessage(msg); + } else super.logInfo(msg); + } + + protected RMIConnection createRMIConnection(String Host, MainAdapter mainRemoteObject, MainAdapterClient client) { + return new RMIConnectionEvA(Host, mainRemoteObject, client); + } + /** + * @return the runLocally + */ + public boolean isRunLocally() { + return runLocally; + } + /** + * @param runLocally the runLocally to set + */ + public void setRunLocally(boolean runLocally) { + this.runLocally = runLocally; + } +} +// + diff --git a/src/javaeva/client/RMIConnectionEvA.java b/src/javaeva/client/RMIConnectionEvA.java new file mode 100644 index 00000000..98bb7dde --- /dev/null +++ b/src/javaeva/client/RMIConnectionEvA.java @@ -0,0 +1,53 @@ +package javaeva.client; + +import java.lang.reflect.InvocationHandler; +import java.net.InetAddress; +import java.net.UnknownHostException; + +import javaeva.server.EvAMainAdapter; +import javaeva.server.modules.ModuleAdapter; +import wsi.ra.jproxy.MainAdapter; +import wsi.ra.jproxy.MainAdapterClient; +import wsi.ra.jproxy.RMIConnection; + +/** + * + */ +class RMIConnectionEvA extends RMIConnection { + /** + * + */ + public RMIConnectionEvA(String HostName, MainAdapter Adapter, + MainAdapterClient AdapterClient) { + super(HostName, Adapter, AdapterClient); + } + /** + * + */ + public ModuleAdapter getModuleAdapter(String Modul) { + if (m_MainAdapter instanceof EvAMainAdapter) { + EvAMainAdapter evaAdapter = (EvAMainAdapter)m_MainAdapter; + ModuleAdapter ret = null; + if (TRACE) System.out.println("ComAdapter.getModuleAdapter(" + Modul + ")"); + String hostAdd = ""; + try { + hostAdd = InetAddress.getLocalHost().getHostAddress(); + } catch (UnknownHostException e) { + hostAdd = "unknown host"; + } + if (TRACE) { + System.out.println(" Client is = " + hostAdd); + } + m_MainAdapter.setBuf("Test_1"); + + ret = evaAdapter.getModuleAdapter(Modul, false, hostAdd, this.m_MainAdapterClient); + + return ret; + } else { + System.err.println("error, couldnt get module adapter in EvAComAdapter.getModuleAdapter. Main adapter is not of type EvAMainAdapter!"); + return null; + } + + } + +} diff --git a/src/javaeva/gui/BeanTest.java b/src/javaeva/gui/BeanTest.java new file mode 100644 index 00000000..2a4f47e3 --- /dev/null +++ b/src/javaeva/gui/BeanTest.java @@ -0,0 +1,309 @@ +package javaeva.gui; +/* + * Title: JavaEvA + * Description: + * Copyright: Copyright (c) 2003 + * Company: University of Tuebingen, Computer Architecture + * @author Holger Ulmer, Felix Streichert, Hannes Planatscher + * @version: $Revision: 202 $ + * $Date: 2007-10-25 16:12:49 +0200 (Thu, 25 Oct 2007) $ + * $Author: mkron $ + */ +/*==========================================================================* + * IMPORTS + *==========================================================================*/ +import java.beans.*; +import java.lang.reflect.Method; +//import javaeva.server.oa.es.mutation.*; +import javaeva.tools.*; +import javaeva.server.EvAServer; +/* + * ==========================================================================* + * CLASS DECLARATION + * ========================================================================== + */ +public class BeanTest { + public static boolean TRACE = false; + + public static int step = 0; + public static String check(String s) { + + s=s.replace('$','_'); + s=s.replace(';','_'); +// String ret = null; +// try { +// RE r = new RE("\\["); +// ret = r.subst(s,""); +// //ret.substring(); +// //ret +// } catch (Exception e) {e.getMessage();}; +// System.out.println("s="+s+" ret"+ret); + if (s.equals("[D")) return "Double_Array"; + if (s.startsWith("[D")) return s.substring(2); + if (s.startsWith("[L")) return s.substring(2); + + return s; + } + + public static boolean equalProperties(Object Target_1, Object Target_2) { + if (Target_1 == null || Target_2 == null) { + System.out.println(""); + return false; + } + System.out.println("equalProperties: " + Target_1.getClass().getName() + " " + Target_2.getClass().getName()); + if (Target_1.getClass().getName().equals(Target_2.getClass().getName()) == false) { + System.out.println(""); + return false; + } + // compare each of the properties !! + BeanInfo Info_1 = null; + BeanInfo Info_2 = null; + PropertyDescriptor[] Properties_1 = null; + PropertyDescriptor[] Properties_2 = null; + MethodDescriptor[] Methods_1 = null; + MethodDescriptor[] Methods_2 = null; + try { + + Info_1 = Introspector.getBeanInfo(Target_1.getClass()); + Info_2 = Introspector.getBeanInfo(Target_2.getClass()); + Properties_1 = Info_1.getPropertyDescriptors(); + Properties_2 = Info_2.getPropertyDescriptors(); + Methods_1 = Info_1.getMethodDescriptors(); + } catch (IntrospectionException ex) { + System.out.println("BeanTest: Couldn't introspect !!!!!!!!!"); + return false; + } + boolean BeansInside = false; + boolean BeansEqual = true; + for (int i = 0; i < Properties_1.length; i++) { + if (Properties_1[i].isHidden() || Properties_1[i].isExpert()) { + continue; + } + //String name = Properties_1[i].getDisplayName(); //System.out.println("name = "+name ); + //Class type = Properties_1[i].getPropertyType(); //System.out.println("type = "+type.getName() ); + Method getter_1 = Properties_1[i].getReadMethod(); + Method getter_2 = Properties_2[i].getReadMethod(); + Method setter_1 = Properties_1[i].getWriteMethod(); + // Only display read/write properties. + if (getter_1 == null || setter_1 == null) { + continue; + } + System.out.println("getter_1 = " + getter_1.getName() + " getter_2 = " + getter_2.getName()); + //System.out.println("type = "+type.getName() ); + Object args_1[] = {}; + Object args_2[] = {}; + //System.out.println("m_Target"+m_Target.toString()); + try { + Object value_1 = getter_1.invoke(Target_1, args_1); + Object value_2 = getter_2.invoke(Target_2, args_2); + BeansInside = true; + if (BeanTest.equalProperties(value_1, value_2) == false) { + BeansEqual = false; + } + } catch (Exception e) { + System.out.println(" BeanTest.equalProperties " + e.getMessage()); + } + } + if (BeansInside == true) { + return BeansEqual; + } + // here we have Integer or Double ... + if (Target_1 instanceof Integer || + Target_1 instanceof Boolean || + Target_1 instanceof Float || + Target_1 instanceof Double || + Target_1 instanceof Long || + Target_1 instanceof String) { + return Target_1.equals(Target_2); + } + + System.out.println(" Attention no match !!!"); + return true; + } + + + /** + *@param Target Description of the Parameter + *@return Description of the Return Value + */ + public static String toString(Object Target) { + String ret = ""; + // object itself + try { + Method[] methods = Target.getClass().getDeclaredMethods(); + for (int ii = 0; ii < methods.length; ii++) { + if (methods[ii].getName().equals("toString") == true) { + ret = (String) methods[ii].invoke(Target, (Object[])null); + //System.out.println("calling to String off: "+Target.getClass().getName()+"=="+s); + } + } + } catch (Exception e) { + //System.out.println(" ERROR +"+ e.getMessage()); + } + // then the properties + BeanInfo Info = null; + PropertyDescriptor[] Properties = null; + MethodDescriptor[] Methods = null; + try { + Info = Introspector.getBeanInfo(Target.getClass()); + Properties = Info.getPropertyDescriptors(); + Methods = Info.getMethodDescriptors(); + } catch (IntrospectionException ex) { + System.out.println("BeanTest: Couldn't introspect"); + return ret; + } + for (int i = 0; i < Methods.length; i++) { + String name = Methods[i].getDisplayName(); + Method meth = Methods[i].getMethod(); + } + for (int i = 0; i < Properties.length; i++) { + if (Properties[i].isHidden() || Properties[i].isExpert()) { + continue; + } + String name = Properties[i].getDisplayName(); + //System.out.println("name = "+name ); + Class type = Properties[i].getPropertyType(); + //System.out.println("type = "+type.getName() ); + Method getter = Properties[i].getReadMethod(); + Method setter = Properties[i].getWriteMethod(); + // Only display read/write properties. + if (getter == null || setter == null) { + continue; + } + //System.out.println("name = "+name ); + //System.out.println("type = "+type.getName() ); + Object args[] = {}; + //System.out.println("m_Target"+m_Target.toString()); + + try { + Object value = getter.invoke(Target, args); + ret = ret + toString(value); + } catch (Exception e) { + //System.out.println("BeanTest ERROR +"+ e.getMessage()); + return ret; + } + } + return ret; + } + + + /** + *@param Target Description of the Parameter + */ + public static void showInfo(Object Target) { + System.out.println("Inspecting " + Target.getClass().getName()); + // object itself + try { + if (Target instanceof java.lang.Integer) { + System.out.println(" Prop = Integer" + Target.toString()); + } + if (Target instanceof java.lang.Boolean) { + System.out.println(" Prop = Boolean" + Target.toString()); + } + if (Target instanceof java.lang.Long) { + System.out.println(" Prop = Long" + Target.toString()); + } + if (Target instanceof java.lang.Double) { + System.out.println(" Prop = Long" + Target.toString()); + } + } catch (Exception e) { + //System.out.println(" ERROR +"+ e.getMessage()); + } + // then the properties + BeanInfo Info = null; + PropertyDescriptor[] Properties = null; + MethodDescriptor[] Methods = null; + try { + Info = Introspector.getBeanInfo(Target.getClass()); + Properties = Info.getPropertyDescriptors(); + Methods = Info.getMethodDescriptors(); + } catch (IntrospectionException ex) { + System.err.println("BeanTest: Couldn't introspect"); + return; + } + for (int i = 0; i < Methods.length; i++) { + String name = Methods[i].getDisplayName(); + Method meth = Methods[i].getMethod(); + } + for (int i = 0; i < Properties.length; i++) { + if (Properties[i].isHidden() || Properties[i].isExpert()) { + continue; + } + String name = Properties[i].getDisplayName(); + //System.out.println("name = "+name ); + Class type = Properties[i].getPropertyType(); + //System.out.println("type = "+type.getName() ); + Method getter = Properties[i].getReadMethod(); + Method setter = Properties[i].getWriteMethod(); + // Only display read/write properties. + if (getter == null || setter == null) { + continue; + } + //System.out.println("name = "+name ); + //System.out.println("type = "+type.getName() ); + Object args[] = {}; + //System.out.println("m_Target"+m_Target.toString()); + try { + Object value = getter.invoke(Target, args); + System.out.println("Inspecting name = " + name); + if (value instanceof Integer) { + Object args2[] = {new Integer(999)}; + setter.invoke(Target, args2); + } + showInfo(value); + } catch (Exception e) { + System.out.println("BeanTest ERROR +" + e.getMessage()); + } + } + } + + + /** + *@param args The command line arguments + */ +// public static void main(String[] args) { +// Tag t= new Tag(); +// System.out.println("name ========"+t.getClass().getName()); +// System.setProperty("java.security.policy","server.policy"); +// ESPopulation x = new ESPopulation(); +// x.add(new ESIndividual()); +// x.add(new ESIndividual()); +// x.add(new ESIndividual()); +// x.add(new ESIndividual()); +// x.add(new ESIndividual()); +// +// ESPopulation y = new ESPopulation(); +// ESIndividual es = new ESIndividual(); +// MutationCMA ca = new MutationCMA(); +// es.setMutation(ca); +// ca.setConstraints(true); +// y.setIndividualTemplate(es); +// System.out.println("***********"); +// //BeanTest.showInfo(x); +// EvAServer xxx = new EvAServer(false,false); +// //ObjectTOXML test = new ObjectTOXML(); +//// Element el = test.getXML(xxx,xxx.getClass(),false); +//// Document doc = new Document(el); +//// HTEFile f = HTEFile.getInstance(); +//// f.writeXMLFile(doc); +//// System.out.println("***********"); +//// try{ +//// XMLEncoder e = new XMLEncoder( +//// new BufferedOutputStream( +//// new FileOutputStream("Test.xml"))); +//// e.writeObject(x); +//// e.close(); +//// } catch (Exception ee ) {} +// +// //StandardESPopulation x = BeanTest.getRandomInstance(Class.forName("javaeva.server.oa.es.StandardESPopulation")); +// //System.out.println("equal ??" + BeanTest.equalProperties(x, y)); +// } +} + +class mySecurityManager extends SecurityManager { + public void checkMemberAccess( Class c, int which ) { +System.out.println("KAKA") ; }// This is called only for + // getDeclaredFields() and not for Field.get( ) + + public void checkPackageAccess( String p ) {} + } diff --git a/src/javaeva/gui/BigStringEditor.java b/src/javaeva/gui/BigStringEditor.java new file mode 100644 index 00000000..43fd7430 --- /dev/null +++ b/src/javaeva/gui/BigStringEditor.java @@ -0,0 +1,210 @@ +package javaeva.gui; +/* + * Title: JavaEvA + * Description: + * Copyright: Copyright (c) 2003 + * Company: University of Tuebingen, Computer Architecture + * @author Holger Ulmer, Felix Streichert, Hannes Planatscher + * @version: $Revision: 194 $ + * $Date: 2007-10-23 13:43:24 +0200 (Tue, 23 Oct 2007) $ + * $Author: mkron $ + */ +/*==========================================================================* + * IMPORTS + *==========================================================================*/ +import java.beans.*; +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; + +/*==========================================================================* + * CLASS DECLARATION + *==========================================================================*/ +public class BigStringEditor implements PropertyEditor { + private PropertyChangeSupport m_Support = new PropertyChangeSupport(this); + private PropertyEditor m_ElementEditor; + private JTextArea m_TextArea; + private JScrollPane m_ScrollPane; + private JPanel m_Panel; +// private Source m_Source; + private JButton m_SetButton; + static private boolean m_finished = false; + /** + * + */ + public static void editSource (String file) { + + try { + m_finished=false; + BigStringEditor editor = new BigStringEditor(); + //Source so = new Source ("\\javaeva\\server\\problems\\bench\\Problem_f1.java"); +// Source so = new Source (file); +// editor.setValue(so); + PropertyDialog frame = new PropertyDialog(editor,file, 50, 50); + //frame.setSize(200, 200); + frame.addWindowListener(new WindowAdapter() { + public void windowClosing (WindowEvent e) { + m_finished=true; + } + }); + while (m_finished==false) { + try {Thread.sleep(1000);} + catch (Exception e) { + System.out.println("e+"+e.getMessage()); + } + } + + + } catch (Exception e) { + e.printStackTrace(); + System.out.println(e.getMessage()); + } + } + /** + * + */ + public BigStringEditor () { + super(); +// m_TextArea = new JEditTextArea(); +// m_TextArea.setTokenMarker(new JavaTokenMarker()); + m_TextArea = new JTextArea(60,60); + m_TextArea.setEditable(true); + m_TextArea.setBorder(BorderFactory.createEmptyBorder(4,4,4,4)); + m_ScrollPane = new JScrollPane(m_TextArea); + m_Panel = new JPanel(); + m_Panel.setBorder(BorderFactory.createTitledBorder("Sourcecode")); + m_Panel.setLayout(new BorderLayout()); + m_SetButton = new JButton("SET"); + m_SetButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + setValue(m_TextArea.getText()); + } + }); + m_Panel.add(m_ScrollPane, BorderLayout.CENTER); + m_Panel.add(m_SetButton, BorderLayout.SOUTH); + } + /** + * + */ + public void setValue (Object value) { + m_ElementEditor = null; + if (value instanceof String) { +// m_Source.setString((String)value); + m_TextArea.setText((String)value); + + } +/* if (value instanceof Source) { + // m_Source = (Source) value; + m_TextArea.setText(((Source)value).getString()); + }*/ + m_Support.firePropertyChange("", null, null); + } + /** + * + */ + public Object getValue () { + // m_Source.setString(m_TextArea.getText()); + return null; + } + /** + * + */ + public String getJavaInitializationString () { + return "null"; + } + + /** + * Returns true to indicate that we can paint a representation of the + * string array + * + * @return true + */ + public boolean isPaintable () { + return true; + } + + /** + * Paints a representation of the current classifier. + * + * @param gfx the graphics context to use + * @param box the area we are allowed to paint into + */ + public void paintValue (Graphics gfx, Rectangle box) { + FontMetrics fm = gfx.getFontMetrics(); + int vpad = (box.height - fm.getAscent())/2; + //String rep = EVAHELP.cutClassName(m_ElementClass.getName()); + gfx.drawString("BigStringEditor", 2, fm.getHeight() + vpad - 3); + } + + /** + * + */ + public String getAsText () { + return null; + } + + /** + * + */ + public void setAsText (String text) throws IllegalArgumentException { + throw new IllegalArgumentException(text); + } + + /** + * + */ + public String[] getTags () { + return null; + } + + /** + * + */ + public boolean supportsCustomEditor () { + return true; + } + /** + * + */ + public Component getCustomEditor () { + return m_Panel; + } + + /** + * + */ + public void addPropertyChangeListener (PropertyChangeListener l) { + m_Support.addPropertyChangeListener(l); + } + /** + * + */ + public void removePropertyChangeListener (PropertyChangeListener l) { + m_Support.removePropertyChangeListener(l); + } + + /** + * + */ + public static void main (String[] args) { + try { + BigStringEditor editor = new BigStringEditor(); +// Source so = new Source ("\\javaeva\\server\\problems\\bench\\Problem_f1.java"); +// editor.setValue(so); + PropertyDialog frame = new PropertyDialog(editor, "test", 50, 50); + frame.setSize(200, 200); + frame.addWindowListener(new WindowAdapter() { + public void windowClosing (WindowEvent e) { + System.exit(0); + } + }); +// editor.setValue(so); + } catch (Exception e) { + e.printStackTrace(); + System.out.println(e.getMessage()); + } + } +} + + + diff --git a/src/javaeva/gui/Chart2DDPointContentSelectable.java b/src/javaeva/gui/Chart2DDPointContentSelectable.java new file mode 100644 index 00000000..55b0f412 --- /dev/null +++ b/src/javaeva/gui/Chart2DDPointContentSelectable.java @@ -0,0 +1,123 @@ +package javaeva.gui; + +import wsi.ra.chart2d.DPointIcon; +import wsi.ra.chart2d.DBorder; +import javaeva.server.go.individuals.AbstractEAIndividual; +import javaeva.server.go.mocco.paretofrontviewer.InterfaceRefSolutionListener; +import javaeva.server.go.problems.InterfaceOptimizationProblem; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; + +/** + * Created by IntelliJ IDEA. + * User: streiche + * Date: 08.09.2005 + * Time: 10:15:30 + * To change this template use File | Settings | File Templates. + */ +public class Chart2DDPointContentSelectable implements InterfaceDPointWithContent, InterfaceSelectablePointIcon, DPointIcon { + + AbstractEAIndividual m_Indy; + InterfaceOptimizationProblem m_Problem; + private InterfaceRefSolutionListener m_Listener; + private Color m_Border = Color.BLACK; + private Color m_Fill = null; + private int m_Size = 4; + + /** this method has to be overridden to paint the icon. The point itself lies + * at coordinates (0, 0) + */ + public void paint( Graphics g ){ + Color prev = g.getColor(); + if (this.m_Indy.isMarked()) this.m_Fill = Color.RED; + else this.m_Fill = Color.LIGHT_GRAY; + g.setColor(m_Fill); + g.fillOval(-this.m_Size, -this.m_Size, 2*this.m_Size +1, 2*this.m_Size +1); + if (this.m_Border != null) g.setColor(m_Border); + g.drawOval(-this.m_Size, -this.m_Size, 2*this.m_Size, 2*this.m_Size); + g.setColor(prev); + } + + /** the border which is necessary to be paint around the DPoint that the whole + * icon is visible + * @return the border + */ + public DBorder getDBorder() { + return new DBorder(4, 4, 4, 4); + } + + public void setBorderColor(Color c) { + this.m_Border = c; + } + public void setFillColor(Color c) { + this.m_Fill = c; + } + public void setSize(int d) { + this.m_Size = d; + } + + /********************************************************************************************* + * The InterfaceSelectablePointIcon + */ + + /** This method allows to add a selection listner to the PointIcon + * it should need more than one listener to this abstruse event + * @param a The selection listener + */ + public void addSelectionListener(InterfaceRefSolutionListener a) { + this.m_Listener = a; + } + + /** This method returns the selection listner to the PointIcon + * @return InterfaceSelectionListener + */ + public InterfaceRefSolutionListener getSelectionListener() { + return this.m_Listener; + } + + /** This method allows to remove the selection listner to the PointIcon + */ + public void removeSelectionListeners() { + this.m_Listener = null; + } + + /** This method allows you to set the according individual + * @param indy AbstractEAIndividual + */ + public void setEAIndividual(AbstractEAIndividual indy) { + this.m_Indy = indy; + } + public AbstractEAIndividual getEAIndividual() { + return this.m_Indy; + } + + /** This method allows you to set the according optimization problem + * @param problem InterfaceOptimizationProblem + */ + public void setProblem(InterfaceOptimizationProblem problem) { + this.m_Problem = problem; + } + public InterfaceOptimizationProblem getProblem() { + return this.m_Problem; + } + + /** This method allows you to draw additional data of the individual + */ + public void showIndividual() { + JFrame newFrame = new JFrame(); + newFrame.setTitle(this.m_Indy.getName()+": "+this.m_Indy); + newFrame.addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent ev) { + System.gc(); + } + }); + newFrame.getContentPane().add(this.m_Problem.drawIndividual(this.m_Indy)); + newFrame.setSize(200, 300); + newFrame.pack(); + newFrame.validate(); + newFrame.setVisible(true); + } +} \ No newline at end of file diff --git a/src/javaeva/gui/Chart2DDPointIconCircle.java b/src/javaeva/gui/Chart2DDPointIconCircle.java new file mode 100644 index 00000000..279dbc84 --- /dev/null +++ b/src/javaeva/gui/Chart2DDPointIconCircle.java @@ -0,0 +1,55 @@ +package javaeva.gui; + +import wsi.ra.chart2d.DPointIcon; +import wsi.ra.chart2d.DBorder; +import java.awt.*; + +/** + * Created by IntelliJ IDEA. + * User: streiche + * Date: 01.04.2004 + * Time: 09:55:30 + * To change this template use File | Settings | File Templates. + */ +public class Chart2DDPointIconCircle implements DPointIcon { + + private Color m_Border = Color.BLACK; + private Color m_Fill = null; + private int m_Size = 4; + + /** + * this method has to be overridden to paint the icon. The point itself lies + * at coordinates (0, 0) + */ + public void paint( Graphics g ){ + Color prev = g.getColor(); + if (m_Fill != null) { + g.setColor(m_Fill); + g.fillOval(-this.m_Size, -this.m_Size, 2*this.m_Size +1, 2*this.m_Size +1); + } + if (this.m_Border != null) g.setColor(m_Border); + g.drawOval(-this.m_Size, -this.m_Size, 2*this.m_Size, 2*this.m_Size); + g.setColor(prev); + } + + /** + * the border which is necessary to be paint around the DPoint that the whole + * icon is visible + * + * @return the border + */ + public DBorder getDBorder() { + return new DBorder(4, 4, 4, 4); + } + + public void setBorderColor(Color c) { + this.m_Border = c; + } + public void setFillColor(Color c) { + this.m_Fill = c; + } + public void setSize(int d) { + this.m_Size = d; + } + +} diff --git a/src/javaeva/gui/Chart2DDPointIconContent.java b/src/javaeva/gui/Chart2DDPointIconContent.java new file mode 100644 index 00000000..a9ac9d97 --- /dev/null +++ b/src/javaeva/gui/Chart2DDPointIconContent.java @@ -0,0 +1,88 @@ +package javaeva.gui; + +import wsi.ra.chart2d.DBorder; +import wsi.ra.chart2d.DPointIcon; + +import java.awt.*; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; + +import javaeva.server.go.individuals.AbstractEAIndividual; +import javaeva.server.go.problems.InterfaceOptimizationProblem; + +import javax.swing.*; + +/** + * Created by IntelliJ IDEA. + * User: streiche + * Date: 13.04.2004 + * Time: 13:31:48 + * To change this template use File | Settings | File Templates. + */ +public class Chart2DDPointIconContent implements InterfaceDPointWithContent, DPointIcon { + + AbstractEAIndividual m_Indy; + InterfaceOptimizationProblem m_Problem; + + /** + * this method has to be overridden to paint the icon. The point itself lies + * at coordinates (0, 0) + */ + public void paint( Graphics g ){ + g.drawOval(-4, -4, 8, 8); + g.drawLine(-2, 2, 2,-2); + g.drawLine(-2,-2, 2, 2); + } + + /** + * the border which is necessary to be paint around the DPoint that the whole + * icon is visible + * + * @return the border + */ + public DBorder getDBorder() { + return new DBorder(4, 4, 4, 4); + } + + /** This method allows you to set the according individual + * @param indy AbstractEAIndividual + */ + public void setEAIndividual(AbstractEAIndividual indy) { + this.m_Indy = indy; + } + public AbstractEAIndividual getEAIndividual() { + return this.m_Indy; + } + + /** This method allows you to set the according optimization problem + * @param problem InterfaceOptimizationProblem + */ + public void setProblem(InterfaceOptimizationProblem problem) { + this.m_Problem = problem; + } + public InterfaceOptimizationProblem getProblem() { + return this.m_Problem; + } + + /** This method allows you to draw additional data of the individual + */ + public void showIndividual() { + JFrame newFrame = new JFrame(); + if (this.m_Indy == null) { + System.out.println("No individual!"); + return; + } + newFrame.setTitle(this.m_Indy.getName()+": "+this.m_Indy); + newFrame.addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent ev) { + System.gc(); + } + }); + newFrame.getContentPane().add(this.m_Problem.drawIndividual(this.m_Indy)); + newFrame.setSize(200, 300); + newFrame.pack(); + newFrame.validate(); + newFrame.setVisible(true); + newFrame.show(); + } +} \ No newline at end of file diff --git a/src/javaeva/gui/Chart2DDPointIconCross.java b/src/javaeva/gui/Chart2DDPointIconCross.java new file mode 100644 index 00000000..5ef211fd --- /dev/null +++ b/src/javaeva/gui/Chart2DDPointIconCross.java @@ -0,0 +1,44 @@ +package javaeva.gui; + +import wsi.ra.chart2d.DBorder; +import wsi.ra.chart2d.DPointIcon; + +import java.awt.*; + +/** + * Created by IntelliJ IDEA. + * User: streiche + * Date: 01.04.2004 + * Time: 10:00:50 + * To change this template use File | Settings | File Templates. + */ +public class Chart2DDPointIconCross implements DPointIcon { + + private Color m_Color; + + /** + * this method has to be overridden to paint the icon. The point itself lies + * at coordinates (0, 0) + */ + public void paint( Graphics g ){ + Color prev = g.getColor(); + g.setColor(this.m_Color); + g.drawLine(-1, 1, 1,-1); + g.drawLine(-1,-1, 1, 1); + g.setColor(prev); + } + + /** + * the border which is necessary to be paint around the DPoint that the whole + * icon is visible + * + * @return the border + */ + public DBorder getDBorder() { + return new DBorder(4, 4, 4, 4); + } + + public void setColor(Color c) { + this.m_Color = c; + } +} diff --git a/src/javaeva/gui/Chart2DDPointIconPoint.java b/src/javaeva/gui/Chart2DDPointIconPoint.java new file mode 100644 index 00000000..6be2683c --- /dev/null +++ b/src/javaeva/gui/Chart2DDPointIconPoint.java @@ -0,0 +1,56 @@ +package javaeva.gui; + +import wsi.ra.chart2d.DPointIcon; +import wsi.ra.chart2d.DBorder; + +import java.awt.*; + +/** + * Created by IntelliJ IDEA. + * User: streiche + * Date: 17.08.2005 + * Time: 16:52:34 + * To change this template use File | Settings | File Templates. + */ +public class Chart2DDPointIconPoint implements DPointIcon { + + private Color m_Border = Color.BLACK; + private Color m_Fill = Color.BLACK; + private int m_Size = 2; + + /** + * this method has to be overridden to paint the icon. The point itself lies + * at coordinates (0, 0) + */ + public void paint( Graphics g ){ + Color prev = g.getColor(); + if (m_Fill != null) { + g.setColor(m_Fill); + g.fillOval(-this.m_Size, -this.m_Size, 2*this.m_Size, 2*this.m_Size); + } + if (this.m_Border != null) g.setColor(m_Border); + g.drawOval(-this.m_Size, -this.m_Size, (2*this.m_Size)-1, (2*this.m_Size)-1); + g.setColor(prev); + } + + /** + * the border which is necessary to be paint around the DPoint that the whole + * icon is visible + * + * @return the border + */ + public DBorder getDBorder() { + return new DBorder(4, 4, 4, 4); + } + + public void setBorderColor(Color c) { + this.m_Border = c; + } + public void setFillColor(Color c) { + this.m_Fill = c; + } + public void setSize(int d) { + this.m_Size = d; + } + +} diff --git a/src/javaeva/gui/Chart2DDPointIconText.java b/src/javaeva/gui/Chart2DDPointIconText.java new file mode 100644 index 00000000..0777aa3e --- /dev/null +++ b/src/javaeva/gui/Chart2DDPointIconText.java @@ -0,0 +1,49 @@ +package javaeva.gui; + +import wsi.ra.chart2d.DPointIcon; +import wsi.ra.chart2d.DBorder; + +import java.awt.*; + +/** + * Created by IntelliJ IDEA. + * User: streiche + * Date: 01.04.2004 + * Time: 16:08:15 + * To change this template use File | Settings | File Templates. + */ +public class Chart2DDPointIconText implements DPointIcon { + + private DPointIcon m_Icon = new Chart2DDPointIconCross(); + private String m_Text = " "; + + public Chart2DDPointIconText(String s) { + m_Text = s; + } + + /** This method allows you to set an icon + * @param icon The new icon + */ + public void setIcon(DPointIcon icon) { + this.m_Icon = icon; + } + + /** + * this method has to be overridden to paint the icon. The point itself lies + * at coordinates (0, 0) + */ + public void paint( Graphics g ){ + this.m_Icon.paint(g); + g.drawString(this.m_Text, 4, 4); + } + + /** + * the border which is necessary to be paint around the DPoint that the whole + * icon is visible + * + * @return the border + */ + public DBorder getDBorder() { + return new DBorder(4, 4, 4, 4); + } +} \ No newline at end of file diff --git a/src/javaeva/gui/ComponentFilter.java b/src/javaeva/gui/ComponentFilter.java new file mode 100644 index 00000000..545039c9 --- /dev/null +++ b/src/javaeva/gui/ComponentFilter.java @@ -0,0 +1,17 @@ +package javaeva.gui; +/* + * Title: JavaEvA + * 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 + *==========================================================================*/ +public interface ComponentFilter{ + public boolean accept(java.awt.Component c); +} diff --git a/src/javaeva/gui/DPointSetMultiIcon.java b/src/javaeva/gui/DPointSetMultiIcon.java new file mode 100644 index 00000000..d51bfe9f --- /dev/null +++ b/src/javaeva/gui/DPointSetMultiIcon.java @@ -0,0 +1,504 @@ +package javaeva.gui; + +import wsi.ra.chart2d.*; + +import wsi.ra.tool.IntegerArrayList; + +import java.awt.*; + +import java.util.ArrayList; + + +/** + * Created by IntelliJ IDEA. + * User: streiche + * Date: 01.04.2004 + * Time: 16:17:35 + * To change this template use File | Settings | File Templates. + */ +public class DPointSetMultiIcon extends DComponent +{ + //~ Instance fields //////////////////////////////////////////////////////// + + protected ArrayList m_IconsMI = new ArrayList(); + protected DIntDoubleMap xMI; + protected DIntDoubleMap yMI; + protected DPointIcon iconMI = null; + protected DPointSetMultiIcon.JumpManager jumperMI = new DPointSetMultiIcon.JumpManager(); + protected Stroke strokeMI = new BasicStroke(); + protected boolean connectedMI; + + //~ Constructors /////////////////////////////////////////////////////////// + + public DPointSetMultiIcon() + { + this(10, 2); + } + + public DPointSetMultiIcon(int initial_capacity) + { + this(initial_capacity, 2); + } + + public DPointSetMultiIcon(int initial_capacity, int length_multiplier) + { + this(new DArray(initial_capacity, length_multiplier), + new DArray(initial_capacity, length_multiplier)); + } + + public DPointSetMultiIcon(DIntDoubleMap x_values, DIntDoubleMap y_values) + { + if (x_values.getSize() != y_values.getSize()) + { + throw new IllegalArgumentException( + "The number of x-values has to be the same than the number of y-values"); + } + + xMI = x_values; + yMI = y_values; + restore(); + setDBorder(new DBorder(1, 1, 1, 1)); + } + + //~ Methods //////////////////////////////////////////////////////////////// + + public void setConnected(boolean aFlag) + { + boolean changed = !(aFlag == connectedMI); + connectedMI = aFlag; + + if (changed) + { + repaint(); + } + } + + /** + * method puts the given DPoint at the given position in the set + * + * @param index the index of the point + * @param p the point to insert + */ + public void setDPoint(int index, DPoint p) + { + if (index >= xMI.getSize()) + { + throw new ArrayIndexOutOfBoundsException(index); + } + + rectangle.insert(p); + xMI.setImage(index, p.x); + yMI.setImage(index, p.y); + m_IconsMI.set(index, p.getIcon()); + restore(); + repaint(); + } + + /** + * method returns the DPoint at the given index + * + * @param index the index of the DPoint + * @return the DPoint at the given index + */ + public DPoint getDPoint(int index) + { + if (index >= xMI.getSize()) + { + throw new ArrayIndexOutOfBoundsException(index); + } + + DPoint p = new DPoint(xMI.getImage(index), yMI.getImage(index)); + p.setIcon(iconMI); + p.setColor(color); + + return p; + } + + public DPointSet getDPointSet() + { + return new DPointSet(xMI, yMI); + } + + public ArrayList getIconsMI() { + return this.m_IconsMI; + } + + /** + * method sets an icon for a better displaying of the point set + * + * @param icon the DPointIcon + */ + public void setIcon(DPointIcon icon) + { + this.iconMI = icon; + + if (icon == null) + { + setDBorder(new DBorder(1, 1, 1, 1)); + } + else + { + setDBorder(icon.getDBorder()); + } + } + + /** + * method returns the current icon of the point set + * + * @return the DPointIcon + */ + public DPointIcon getIcon() + { + return iconMI; + } + + /** + * method returns the nearest DPoint in this DPointSet. + * + * @return the nearest DPoint + */ + public DPoint getNearestDPoint(DPoint point) + { + int minIndex = getNearestDPointIndex(point); + + if (minIndex == -1) + { + return null; + } + else + { + DPoint result = new DPoint(xMI.getImage(minIndex), + yMI.getImage(minIndex)); + result.setIcon((DPointIcon) this.m_IconsMI.get(minIndex)); + + return result; + } + } + + /** method returns the index to the nearest DPoint in this DPointSet. + * @return the index to the nearest DPoint. -1 if no nearest DPoint was found. + */ + public int getNearestDPointIndex(DPoint point) + { + double minValue = Double.MAX_VALUE; + int minIndex = -1; + + for (int i = 0; i < xMI.getSize(); i++) + { + double dx = point.x - xMI.getImage(i); + double dy = point.y - yMI.getImage(i); + double dummy = (dx * dx) + (dy * dy); + + if (dummy < minValue) + { + minValue = dummy; + minIndex = i; + } + } + + return minIndex; + } + + public int getSize() + { + int size = Math.min(xMI.getSize(), yMI.getSize()); + + // int size = x.getSize(); + // if( size != y.getSize() ) throw + // new ArrayStoreException( + // "The number of x-values is not equal to the number of y-values.\n" + // +"The size of the DPointSet isn�t clear." + // ); + return size; + } + + /** + * method sets the stroke of the line + * if the points were not connected, they now will be connected + * + * @param s the new stroke + */ + public void setStroke(Stroke s) + { + if (s == null) + { + s = new BasicStroke(); + } + + strokeMI = s; + repaint(); + } + + /** + * method returns the current stroke of the line + * + * @return the stroke + */ + public Stroke getStroke() + { + return strokeMI; + } + + public void addDPoint(DPoint p) + { + xMI.addImage(p.x); + yMI.addImage(p.y); + m_IconsMI.add(p.getIcon()); + rectangle.insert(p); + repaint(); + } + + public void addDPoint(double x, double y) + { + addDPoint(new DPoint(x, y)); + } + + /** + * This method causes the DPointSet to interupt the connected painting at the + * current position. + */ + public void jump() + { + jumperMI.addJump(); + } + + public void paint(DMeasures m) + { + try + { + Graphics2D g = (Graphics2D) m.getGraphics(); + g.setStroke(strokeMI); + + if (color != null) + { + g.setColor(color); + } + + int size = getSize(); + + if (connectedMI && (size > 1)) + { + jumperMI.restore(); + + while (jumperMI.hasMoreIntervals()) + { + int[] interval = jumperMI.nextInterval(); + Point p1 = null; + Point p2; + + for (int i = interval[0]; i < interval[1]; i++) + { + p2 = m.getPoint(xMI.getImage(i), yMI.getImage(i)); + + if (p1 != null) + { + try + { + g.drawLine(p1.x, p1.y, p2.x, p2.y); + } + catch (java.lang.NullPointerException e) + { + // pff + } + } + + if ((i < this.m_IconsMI.size()) && (this.m_IconsMI.get(i) != null)) + { + g.setStroke(new BasicStroke()); + g.translate(p2.x, p2.y); + ((DPointIcon) this.m_IconsMI.get(i)).paint(g); + g.translate(-p2.x, -p2.y); + g.setStroke(strokeMI); + } + else + { + if (iconMI != null) + { + g.setStroke(new BasicStroke()); + g.translate(p2.x, p2.y); + iconMI.paint(g); + g.translate(-p2.x, -p2.y); + g.setStroke(strokeMI); + } + } + + p1 = p2; + } + } + } + else + { + Point p; + + //for (int i = 0; i < size; i++) + // @todo Streiche: Mal wieder eine index out of bounds exception, dass ist einfach mist... + for (int i = 0; i < this.m_IconsMI.size(); i++) + { + try + { + p = m.getPoint(xMI.getImage(i), yMI.getImage(i)); + + if (this.m_IconsMI.get(i) != null) + { + g.setStroke(new BasicStroke()); + g.translate(p.x, p.y); + ((DPointIcon) this.m_IconsMI.get(i)).paint(g); + g.translate(-p.x, -p.y); + g.setStroke(strokeMI); + } + else + { + if (iconMI == null) + { + g.drawLine(p.x - 1, p.y - 1, p.x + 1, p.y + 1); + g.drawLine(p.x + 1, p.y - 1, p.x - 1, p.y + 1); + } + else + { + g.setStroke(new BasicStroke()); + g.translate(p.x, p.y); + iconMI.paint(g); + g.translate(-p.x, -p.y); + } + } + } + catch (java.lang.IllegalArgumentException e) + { + System.out.println( + "The rectangle lies not in the currently painted rectangle."); + } + } + } + + g.setStroke(new BasicStroke()); + } + catch (java.lang.ArrayIndexOutOfBoundsException e) + { + // *pff* + } + } + + public void removeAllPoints() + { + if (xMI.getSize() == 0) + { + return; + } + + xMI.reset(); + yMI.reset(); + jumperMI.reset(); + repaint(); + rectangle = DRectangle.getEmpty(); + } + + /** + * method removes all jump positions + * if the DPointSet is connected, all points will be painted connected to + * their following point + */ + public void removeJumps() + { + jumperMI.reset(); + } + + public String toString() + { + String text = "wsi.ra.chart2d.DPointSet[size:" + getSize(); + + for (int i = 0; i < xMI.getSize(); i++) + { + text += (",(" + xMI.getImage(i) + "," + yMI.getImage(i) + ")"); + } + + text += "]"; + + return text; + } + + protected void restore() + { + if (getSize() == 0) + { + rectangle = DRectangle.getEmpty(); + + return; + } + + double min_x = xMI.getMinImageValue(); + double max_x = xMI.getMaxImageValue(); + double min_y = yMI.getMinImageValue(); + double max_y = yMI.getMaxImageValue(); + rectangle = new DRectangle(min_x, min_y, max_x - min_x, max_y - min_y); + } + + //~ Inner Classes ////////////////////////////////////////////////////////// + + /** + * this class stores the jump positions (see this.jump) + */ + class JumpManager + { + protected IntegerArrayList jumps = new IntegerArrayList(); + protected int index = -1; + + public void addJump() + { + jumps.add(getSize()); + } + + public boolean hasMoreIntervals() + { + return index < jumps.size(); + } + + public int[] nextInterval() + { + int no_jumps = jumps.size(); + + if (index >= no_jumps) + { + throw new ArrayIndexOutOfBoundsException( + "No more intervals in JumpManager"); + } + + int[] inter = new int[2]; + + if (index == -1) + { + inter[0] = 0; + } + else + { + inter[0] = jumps.get(index); + } + + index++; + + if (index < no_jumps) + { + inter[1] = jumps.get(index); + } + else + { + inter[1] = getSize(); + } + + return inter; + } + + public void reset() + { + index = -1; + jumps.clear(); + } + + public void restore() + { + index = -1; + } + } +} +/////////////////////////////////////////////////////////////////////////////// +// END OF FILE. +/////////////////////////////////////////////////////////////////////////////// diff --git a/src/javaeva/gui/DataViewer.java b/src/javaeva/gui/DataViewer.java new file mode 100644 index 00000000..449ef7ac --- /dev/null +++ b/src/javaeva/gui/DataViewer.java @@ -0,0 +1,145 @@ +package javaeva.gui; +/* + * Title: JavaEvA + * Description: + * Copyright: Copyright (c) 2003 + * Company: University of Tuebingen, Computer Architecture + * @author Holger Ulmer, Felix Streichert, Hannes Planatscher + * @version: $Revision: 320 $ + * $Date: 2007-12-06 16:05:11 +0100 (Thu, 06 Dec 2007) $ + * $Author: mkron $ + */ +/*==========================================================================* + * IMPORTS + *==========================================================================*/ +import java.net.InetAddress; +import java.util.ArrayList; + +import wsi.ra.jproxy.MainAdapterClient; +import wsi.ra.jproxy.RMIProxyRemote; +/*==========================================================================* + * CLASS DECLARATION + *==========================================================================*/ +/** + * It represents one plot window in the client GUI. + */ +public class DataViewer implements DataViewerInterface { + public static boolean TRACE = false; + + static private int m_GraphCounter = -1; + static private ViewContainer m_ViewContainer; + private MainAdapterClient m_MainAdapterClient; + private static String m_MyHostName; + private PlotInterface m_Plotter; + private String m_Name; + private Plot m_Plot; + /** + * + */ + public static DataViewerInterface getInstance (MainAdapterClient client,String GraphWindowName) { + if (m_ViewContainer == null) + m_ViewContainer = new ViewContainer(); + DataViewerInterface ret =null; + try { + if (!m_ViewContainer.containsName(GraphWindowName)) { + //////////////////////////////////////////////// + try { + m_MyHostName = InetAddress.getLocalHost().getHostName(); + } catch (Exception e) { + System.out.println("InetAddress.getLocalHost().getHostAddress() --> ERROR" + e.getMessage()); + e.printStackTrace(); + } + if (client != null && client.getHostName().equals(m_MyHostName)== true) { + if (TRACE) System.out.println("no RMI"); + ret = new DataViewer(GraphWindowName,true); + } + else { + ret = (DataViewerInterface) RMIProxyRemote.newInstance(new DataViewer(GraphWindowName,false), client); + ret.init(); + if (TRACE) System.out.println("with RMI"); + } + + + //////////////////////////////////// + m_ViewContainer.add(ret); + } + else { + ret = m_ViewContainer.getPlot(GraphWindowName); + } + } catch (Exception ee) { + System.out.println("GraphWindow ERROR : "+ee.getMessage()); + ee.printStackTrace(); + } + return ret; + } + /** + * + */ + private DataViewer(String PlotName,boolean initflag){ + if (TRACE) System.out.println("Constructor DataViewer"); + m_Name = PlotName; + if(initflag) + this.init(); + } + /** + * + */ + public String getName () { + return m_Name; + } + /** + * + */ + public Graph getNewGraph(String InfoString) { + m_GraphCounter++; + if (TRACE) System.out.println("Graph.getNewGraph No:"+m_GraphCounter); + return new Graph (InfoString,m_Plot,m_GraphCounter); + } + /** + * + */ + public void init() { + m_Plot = new Plot(m_Name,"x","y", true); + } + +} +/** + * + */ +class ViewContainer extends ArrayList { + private DataViewer m_actualPlot; + /** + * + */ + public ViewContainer() {} + /** + * + */ + public boolean containsName (String name) { + DataViewer temp = null; + for (int i=0;i 0; } + public double getImageOf( double source ){ return Math.exp( source ); } + public double getSourceOf( double target ){ + if( target <= 0 ) { throw + new IllegalArgumentException( + "Can not calculate log on values smaller than or equal 0 --> target = "+target + ); + } + return Math.log( target ); + } +} + diff --git a/src/javaeva/gui/ExtAction.java b/src/javaeva/gui/ExtAction.java new file mode 100644 index 00000000..0a9a7e4f --- /dev/null +++ b/src/javaeva/gui/ExtAction.java @@ -0,0 +1,69 @@ +package javaeva.gui; +/* + * Title: JavaEvA + * 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 javax.swing.AbstractAction; +import javax.swing.Icon; +import javax.swing.KeyStroke; +import javax.swing.Action; +/** + * + */ +public abstract class ExtAction extends AbstractAction { + public final static String CAPTION = "Caption"; + public final static String MNEMONIC = "Mnemonic"; + public final static String TOOLTIP = "ToolTip"; + public final static String KEYSTROKE = "KeyStroke"; + /** + * + */ + private void setValues(String s, String toolTip){ + Mnemonic m = new Mnemonic(s); + putValue(MNEMONIC, new Character(m.getMnemonic())); + putValue(Action.NAME, m.getText()); + putValue(TOOLTIP, toolTip); + } + /** + * + */ + public ExtAction(String s, Icon i, String toolTip, KeyStroke key){ + this(s, i, toolTip); + if (i==null) + System.out.println("Icon == null"); + putValue(KEYSTROKE, key); + } + /** + * + */ + public ExtAction(String s, Icon i, String toolTip){ + super(null, i); + if (i==null) + System.out.println("Icon == null"); + setValues(s, toolTip); + } + /** + * + */ + public ExtAction(String s, String toolTip, KeyStroke key){ + this(s, toolTip); + putValue(KEYSTROKE, key); + } + /** + * + */ + public ExtAction(String s, String toolTip){ + super(); + setValues(s, toolTip); + } +} + diff --git a/src/javaeva/gui/ExtActionChangedListener.java b/src/javaeva/gui/ExtActionChangedListener.java new file mode 100644 index 00000000..d1a4fc37 --- /dev/null +++ b/src/javaeva/gui/ExtActionChangedListener.java @@ -0,0 +1,40 @@ +package javaeva.gui; +/* + * Title: JavaEvA + * 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.beans.PropertyChangeListener; +import java.beans.PropertyChangeEvent; +import javax.swing.JComponent; +/** + * + */ +public abstract class ExtActionChangedListener implements PropertyChangeListener{ + protected JComponent component; + /** + * + */ + ExtActionChangedListener(JComponent c){ + super(); + setTarget(c); + } + /** + * + */ + public abstract void propertyChange(PropertyChangeEvent e); + /** + * + */ + public void setTarget(JComponent c){ + component = c; + } +} diff --git a/src/javaeva/gui/ExtDesktopManager.java b/src/javaeva/gui/ExtDesktopManager.java new file mode 100644 index 00000000..e3f38e5a --- /dev/null +++ b/src/javaeva/gui/ExtDesktopManager.java @@ -0,0 +1,70 @@ +package javaeva.gui; +/* + * Title: JavaEvA + * 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 javax.swing.*; +import java.awt.*; +/** + * + */ +public class ExtDesktopManager extends DefaultDesktopManager{ + int WINDOW_LIST_START; + public final static String INDEX = "Index"; + public final static String FRAME = "Frame"; + private JInternalFrame activeFrame = null; + private JExtDesktopPane desktop; + public ExtDesktopManager(JExtDesktopPane desktop){ + this.desktop = desktop; + } + public void activateFrame(JInternalFrame f){ + super.activateFrame(f); + activeFrame = f; + } + public void deactivateFrame(JInternalFrame f){ + super.deactivateFrame(f); + if(activeFrame == f) activeFrame = null; + } + public JInternalFrame getActiveFrame(){ + return activeFrame; + } + public void closeFrame(JInternalFrame f){ + System.out.println("closed internalframe called"); + super.closeFrame(f); + int index = ((Integer)f.getClientProperty(INDEX)).intValue() + WINDOW_LIST_START - 1; + int i; + desktop.m_mnuWindow.remove(index); + for(i = index; i < Math.min(WINDOW_LIST_START + 9, desktop.m_mnuWindow.getItemCount()); i++){ + JMenuItem m = desktop.m_mnuWindow.getItem(i); + JInternalFrame frame = (JInternalFrame)m.getClientProperty(FRAME); + frame.putClientProperty(INDEX, new Integer(((Integer)frame.getClientProperty(INDEX)).intValue() - 1)); + int winIndex = i - WINDOW_LIST_START + 1; + m.setText((winIndex) + " " + frame.getTitle()); + m.setMnemonic((char)(0x30 + winIndex)); + m.setAccelerator(KeyStroke.getKeyStroke(0x30 + winIndex, Event.ALT_MASK)); + } + + if(f.isSelected()){ + Component tmp = null; + boolean found = false; + for(i = 0; i < desktop.getComponentCount() && !found; i++){ + tmp = desktop.getComponent(i); + if(tmp instanceof JInternalFrame) found = true; + } + + if(found) desktop.selectFrame((JInternalFrame)tmp); + else activeFrame = null; + } + } +} + + diff --git a/src/javaeva/gui/FunctionArea.java b/src/javaeva/gui/FunctionArea.java new file mode 100644 index 00000000..a3a11b4a --- /dev/null +++ b/src/javaeva/gui/FunctionArea.java @@ -0,0 +1,702 @@ +package javaeva.gui; + +/* + * Title: JavaEvA + * Description: + * Copyright: Copyright (c) 2003 + * Company: University of Tuebingen, Computer Architecture + * @author Holger Ulmer, Felix Streichert, Hannes Planatscher + * @version: $Revision: 306 $ + * $Date: 2007-12-04 14:22:52 +0100 (Tue, 04 Dec 2007) $ + * $Author: mkron $ + */ +/*==========================================================================* + * IMPORTS + *==========================================================================*/ +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.InputEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.PrintWriter; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Date; +import java.text.SimpleDateFormat; + +import javax.swing.JFileChooser; +import javax.swing.JMenuItem; +import javax.swing.JOptionPane; +import javax.swing.JPopupMenu; + +import wsi.ra.chart2d.DArea; +import wsi.ra.chart2d.DBorder; +import wsi.ra.chart2d.DPoint; +import wsi.ra.chart2d.DPointIcon; +import wsi.ra.chart2d.DPointSet; +import wsi.ra.chart2d.ScaledBorder; +import javaeva.server.go.individuals.AbstractEAIndividual; +import javaeva.server.go.mocco.paretofrontviewer.InterfaceRefPointListener; + +/*==========================================================================* + * CLASS DECLARATION + *==========================================================================*/ +/** + * + */ +public class FunctionArea extends DArea implements Serializable { + private InterfaceRefPointListener m_RefPointListener; + private JFileChooser m_FileChooser; + private ArrayList m_PointSetContainer; + private ScaledBorder m_Border; + private boolean m_log = false; + private boolean notifyNegLog = true; + private int m_x; + private int m_y; + + private DPointIcon m_CurrentPointIcon; + /** + * + */ + public FunctionArea() {} + + /** + * + */ + public FunctionArea(String xname, String yname) { + super(); + setPreferredSize(new Dimension(600, 500)); + setVisibleRectangle(1, 1, 100000, 1000); + setAutoFocus(true); + setMinRectangle(0, 0, 1, 1); + //setAutoFocus(true); + m_Border = new ScaledBorder(); + m_Border.x_label = xname; //"App. " + Name + " func. calls"; + m_Border.y_label = yname; //"fitness"; + setBorder(m_Border); + setAutoGrid(true); + setGridVisible(true); + m_PointSetContainer = new ArrayList(20); + //new DMouseZoom( this ); + addPopup(); + repaint(); + notifyNegLog = true; + } + + /** + * + */ + public String getGraphInfo(int x, int y) { + String ret = ""; + if ((m_PointSetContainer == null) || (m_PointSetContainer.size() == 0)) + return ret; + int minindex = getNearestGraphIndex(x, y); + ret = ((GraphPointSet) (m_PointSetContainer.get(minindex))).getInfoString(); + return ret; + } + + /** + * + */ + public boolean isStatisticsGraph(int x, int y) { + boolean ret = false; + if ((m_PointSetContainer == null) || (m_PointSetContainer.size() == 0)) + return ret; + int minindex = getNearestGraphIndex(x, y); + ret = ((GraphPointSet) (m_PointSetContainer.get(minindex))).isStatisticsGraph(); + return ret; + } + + + /** + * + */ + private int getNearestGraphIndex(int x, int y) { + // get index of nearest Graph + double distmin = 10000000; + int minindex = -1; + DPoint point1 = getDMeasures().getDPoint(x, y); + DPoint point2 = null; + double dist = 0; + for (int i = 0; i < m_PointSetContainer.size(); i++) { + if (m_PointSetContainer.get(i)instanceof GraphPointSet) { + GraphPointSet pointset = (GraphPointSet) (m_PointSetContainer.get(i)); + point2 = pointset.getNearestDPoint(point1); + if (point2 == null) + continue; + if (point1 == null) + System.err.println("point1 == null"); + + dist = (point1.x - point2.x) * (point1.x - point2.x) + (point1.y - point2.y) * (point1.y - point2.y); + //System.out.println("dist="+dist+"i="+i); + if (dist < distmin) { + distmin = dist; + minindex = i; + } + } + } + return minindex; + } + + /** + * + */ + private DPoint getNearestDPoint(int x, int y) { + // get index of nearest Graph + double distmin = 10000000; + DPoint ret = null; + DPoint point1 = getDMeasures().getDPoint(x, y); + DPoint point2 = null; + double dist = 0; + for (int i = 0; i < m_PointSetContainer.size(); i++) { + if (m_PointSetContainer.get(i)instanceof GraphPointSet) { + GraphPointSet pointset = (GraphPointSet) (m_PointSetContainer.get(i)); + point2 = pointset.getNearestDPoint(point1); + if (point2 == null) + continue; + dist = (point1.x - point2.x) * (point1.x - point2.x) + (point1.y - point2.y) * (point1.y - point2.y); + //System.out.println("dist="+dist+"i="+i); + if (dist < distmin) { + distmin = dist; + ret = point2; + } + if ((dist == distmin) && !(ret.getIcon()instanceof Chart2DDPointIconContent) && !(ret.getIcon()instanceof InterfaceSelectablePointIcon)) { + distmin = dist; + ret = point2; + } + } + } + return ret; + } + + /** + * + */ + public void exportToAscii() { + String[] s = null; + for (int i = 0; i < m_PointSetContainer.size(); i++) { + if (m_PointSetContainer.get(i)instanceof GraphPointSet) { + GraphPointSet set = (GraphPointSet) m_PointSetContainer.get(i); + String info = set.getInfoString(); + DPointSet pset = set.getConnectedPointSet(); + if (s == null) { + s = new String[pset.getSize() + 1]; + s[0] = "calls"; + } + s[0] = s[0] + " " + info; + for (int j = 1; j < s.length; j++) { + if (i == 0) + s[j] = "" + pset.getDPoint(j - 1).x; + try { + s[j] = s[j] + " " + pset.getDPoint(j - 1).y; + } catch (Exception e) { + s[j] += " "; + } + } + } + } + for (int j = 0; j < s.length; j++) { + System.out.println("s=" + s[j]); + } + // todo: Steichert hat einfach einen default namen genommen + SimpleDateFormat formatter = new SimpleDateFormat("E'_'yyyy.MM.dd'_'HH.mm.ss"); + String fname = "PlotExport_"+formatter.format(new Date()); +// System.out.println("Filename ??"); +// String fname = null; +// BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); +// try { +// fname = in.readLine(); +// } catch (Exception e) { +// System.out.println("" + e.getMessage()); +// } + try { + File f = new File(fname + ".txt"); + f.createNewFile(); + PrintWriter Out = new PrintWriter(new FileOutputStream(f)); + for (int j = 0; j < s.length; j++) + Out.println(s[j]); + Out.flush(); + Out.close(); + } catch (Exception e) { + System.err.println("Error:" + e.getMessage()); + } + + } + + /** + * + */ + public void setConnectedPoint(double x, double y, int GraphLabel) { + if (m_log == true && y <= 0.0) { + y = 1; +// y = Double.MIN_VALUE; + if (notifyNegLog) { + System.err.println("Warning: trying to plot value (" + x + "/" + y + ") with y < 0 in logarithmic mode! Setting y to " + y); + notifyNegLog = false; + } + } + getGraphPointSet(GraphLabel).addDPoint(x, y); + + } + + public void addGraphPointSet(GraphPointSet d) { + this.m_PointSetContainer.add(d); + } + + + /** + * + */ + public void addGraph(int GraphLabel_1, int GraphLabel_2, boolean forceAdd) { + getGraphPointSet(GraphLabel_1).addGraph(getGraphPointSet(GraphLabel_2), this.getDMeasures(), forceAdd); + notifyNegLog = true; + } + + /** + * + */ + public void clearGraph(int GraphLabel) { + getGraphPointSet(GraphLabel).removeAllPoints(); + m_PointSetContainer.remove(getGraphPointSet(GraphLabel)); + repaint(); + notifyNegLog = true; + } + + /** + * + */ + public void changeColorGraph(int GraphLabel) { + Color col = getGraphPointSet(GraphLabel).getColor(); + if (col == Color.black) + col = Color.red; + else + if (col == Color.red) + col = Color.blue; + else + if (col == Color.blue) + col = Color.red; + else + if (col == Color.red) + col = Color.black; + getGraphPointSet(GraphLabel).setColor(col); + repaint(); + } + + /** + * + */ + public void clearGraph(int x, int y) { + int index = getNearestGraphIndex(x, y); + if (index == -1) + return; + int GraphLabel = ((GraphPointSet) (this.m_PointSetContainer.get(index))).getGraphLabel(); + clearGraph(GraphLabel); + } + + /** + * + */ + public void changeColorGraph(int x, int y) { + int index = getNearestGraphIndex(x, y); + if (index == -1) + return; + int GraphLabel = ((GraphPointSet) (this.m_PointSetContainer.get(index))).getGraphLabel(); + changeColorGraph(GraphLabel); + } + + /** + * + */ + public void removePoint(int x, int y) { + DPoint point = getNearestDPoint(x, y); + int index = getNearestGraphIndex(x, y); + if (index == -1 || point == null) + return; + GraphPointSet pointset = (GraphPointSet) (this.m_PointSetContainer.get(index)); + pointset.removePoint(point); + } + + /** + * + */ + public void setInfoString(int GraphLabel, String Info, float stroke) { + getGraphPointSet(GraphLabel).setInfoString(Info, stroke); + } + + /** + * + */ + public void clearAll() { + this.removeAllDElements(); + for (int i = 0; i < m_PointSetContainer.size(); i++) + ((GraphPointSet) (m_PointSetContainer.get(i))).removeAllPoints(); + m_PointSetContainer.clear(); + notifyNegLog = true; + } + + /** + * + */ + private GraphPointSet getGraphPointSet(int GraphLabel) { +// System.out.println("looping through " + m_PointSetContainer.size() + " point sets..."); + for (int i = 0; i < m_PointSetContainer.size(); i++) { + if (m_PointSetContainer.get(i) instanceof GraphPointSet) { + GraphPointSet xx = (GraphPointSet) (m_PointSetContainer.get(i)); +// System.out.println("looking at "+xx.getGraphLabel()); + if (xx.getGraphLabel() == GraphLabel) { +// System.out.println("match!"); + return xx; + } + } + } + // create new GraphPointSet + GraphPointSet NewPointSet = new GraphPointSet(GraphLabel, this); +// System.out.println("adding new point set " + GraphLabel); + //NewPointSet.setStroke(new BasicStroke( (float)1.0 )); + //addGraphPointSet(NewPointSet); already done within GraphPointSet!!! + return NewPointSet; + } + + /** + * + */ + public void setUnconnectedPoint(double x, double y, int GraphLabel) { + if (m_log == true && y <= 0.0) { + if (notifyNegLog) { + System.err.println("Warning: trying to plot value (" + x + "/" + y + ") with y < 0 in logarithmic mode! Setting y to " + y ); + notifyNegLog = false; + } + y = 1; + } + this.getGraphPointSet(GraphLabel).addDPoint(x, y); + this.getGraphPointSet(GraphLabel).setConnectedMode(false); + repaint(); + } + + Color[] Colors = new Color[] {Color.black, Color.red, Color.blue, Color.green,Color.magenta, Color.orange, Color.pink, Color.yellow}; + + public void setGraphColor(int GraphLabel,int colorindex) { + this.getGraphPointSet(GraphLabel).setColor(Colors[colorindex%Colors.length]); + } + + /** + * Returns the number of points within the graph of the given label. + * + * @param index + * @return + */ + public int getPointCount(int label) { + return getGraphPointSet(label).getPointCount(); + } + + /** + * + */ + public int getContainerSize() { + return m_PointSetContainer.size(); + } + + /** + * + */ + public DPointSet[] printPoints() { + DPointSet[] ret = new DPointSet[m_PointSetContainer.size()]; + for (int i = 0; i < m_PointSetContainer.size(); i++) { + System.out.println(""); + System.out.println("GraphPointSet No " + i); + + ret[i] = ((GraphPointSet) m_PointSetContainer.get(i)).printPoints(); + } + return ret; + + } + + public DPointSet printPoints(int i) { + //for (int i = 0; i < m_PointSetContainer.size();i++) { + System.out.println(""); + System.out.println("GraphPointSet No " + i); + + return ((GraphPointSet) m_PointSetContainer.get(i)).printPoints(); + //} + } + + /** + * + */ + public void toggleLog() { + //System.out.println("ToggleLog log was: "+m_log); + if (m_log == false) { + setMinRectangle(0.001, 0.001, 1, 1); + //setVisibleRectangle( 0.001, 0.001, 100000, 1000 ); + setYScale(new Exp()); + m_Border.setSrcdY(Math.log(10)); + ((java.text.DecimalFormat) m_Border.format_y).applyPattern("0.###E0"); + m_log = true; + } else { + m_log = false; + setYScale(null); + ScaledBorder buffer = m_Border; + m_Border = new ScaledBorder(); + m_Border.x_label = buffer.x_label; //"App. " + Name + " func. calls"; + m_Border.y_label = buffer.y_label; //"fitness"; + setBorder(m_Border); + } + repaint(); + } + + /** + * Causes all PointSets to interupt the connected painting at the + * current position. + */ + public void jump() { + for (int i = 0; i < m_PointSetContainer.size(); i++) + ((GraphPointSet) (m_PointSetContainer.get(i))).jump(); + } + + /** + */ + public Object openObject() { + if (m_FileChooser == null) + createFileChooser(); + int returnVal = m_FileChooser.showOpenDialog(this); + if (returnVal == JFileChooser.APPROVE_OPTION) { + File selected = m_FileChooser.getSelectedFile(); + try { + ObjectInputStream oi = new ObjectInputStream(new BufferedInputStream(new FileInputStream(selected))); + Object obj = oi.readObject(); + oi.close(); + + Object[] objects = (Object[]) obj; + for (int i = 0; i < objects.length; i++) { + GraphPointSet xx = ((GraphPointSet.SerPointSet) objects[i]).getGraphPointSet(); + xx.initGraph(this); + addGraphPointSet(xx); + } + repaint(); + return obj; + } catch (Exception ex) { + JOptionPane.showMessageDialog(this, + "Couldn't read object: " + + selected.getName() + + "\n" + ex.getMessage(), + "Open object file", + JOptionPane.ERROR_MESSAGE); + } + } + return null; + } + + /** + * + */ + public void saveObject() { + Object[] object = new Object[m_PointSetContainer.size()]; + for (int i = 0; i < m_PointSetContainer.size(); i++) { + object[i] = ((GraphPointSet) m_PointSetContainer.get(i)).getSerPointSet(); + } + if (m_FileChooser == null) + createFileChooser(); + int returnVal = m_FileChooser.showSaveDialog(this); + if (returnVal == JFileChooser.APPROVE_OPTION) { + File sFile = m_FileChooser.getSelectedFile(); + try { + ObjectOutputStream oo = new ObjectOutputStream(new BufferedOutputStream(new FileOutputStream(sFile))); + oo.writeObject(object); + oo.close(); + } catch (IOException ex) { + JOptionPane.showMessageDialog(this, + "Couldn't write to file: " + + sFile.getName() + + "\n" + ex.getMessage(), + "Save object", + JOptionPane.ERROR_MESSAGE); + } + } + } + + /** + * + */ + protected void createFileChooser() { + m_FileChooser = new JFileChooser(new File("/resources")); + m_FileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); + } + + /** Add a popup menu for displaying certain information. + */ + private void addPopup() { + addMouseListener(new MouseAdapter() { + public void mouseClicked(MouseEvent e) { + if ((e.getModifiers() & InputEvent.BUTTON1_MASK) == InputEvent.BUTTON1_MASK) { + // do nothing + } else { + JPopupMenu GraphMenu = new JPopupMenu(); + m_x = e.getX(); + m_y = e.getY(); + + // The first info element + JMenuItem Info = new JMenuItem("Graph Info: " + getGraphInfo(e.getX(), e.getY())); + Info.addActionListener(new ActionListener() { + // + public void actionPerformed(ActionEvent ee) { + DPoint temp = FunctionArea.this.getDMeasures().getDPoint(FunctionArea.this.m_x, FunctionArea.this.m_y); + DPointIcon icon1 = new DPointIcon() { + public void paint(Graphics g) { + g.drawLine( -2, 0, 2, 0); + g.drawLine(0, 0, 0, 4); + } + + public DBorder getDBorder() { + return new DBorder(4, 4, 4, 4); + } + }; + temp.setIcon(icon1); + FunctionArea.this.addDElement(temp); + } + }); + GraphMenu.add(Info); + if (m_RefPointListener != null) { + DPoint temp = getDMeasures().getDPoint(m_x, m_y); + JMenuItem refPoint = new JMenuItem("Reference Point:("+temp.x+"/"+temp.y+")"); + refPoint.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent ee) { + DPoint temp = getDMeasures().getDPoint(m_x, m_y); + double[] point = new double[2]; + point[0] = temp.x; + point[1] = temp.y; + m_RefPointListener.refPointGiven(point); + } + }); + GraphMenu.add(refPoint); + } + + // darn this point is an empty copy !! + DPoint point = getNearestDPoint(e.getX(), e.getY()); + + if (point != null) { + JMenuItem InfoXY = new JMenuItem("(" + point.x + "/" + point.y+")"); + Info.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent ee) { + } + }); + GraphMenu.add(InfoXY); + + if (point.getIcon()instanceof InterfaceSelectablePointIcon) { + m_CurrentPointIcon = point.getIcon(); + if (((InterfaceSelectablePointIcon)m_CurrentPointIcon).getSelectionListener() != null) { + JMenuItem select; + AbstractEAIndividual indy = ((InterfaceSelectablePointIcon)m_CurrentPointIcon).getEAIndividual(); + if (indy.isMarked()) select = new JMenuItem("Deselect individual"); + else select = new JMenuItem("Select individual"); + select.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent ee) { + ((InterfaceSelectablePointIcon)m_CurrentPointIcon).getSelectionListener().individualSelected(((InterfaceSelectablePointIcon)m_CurrentPointIcon).getEAIndividual()); + } + }); + GraphMenu.add(select); + } + } + + if (point.getIcon()instanceof InterfaceDPointWithContent) { + m_CurrentPointIcon = point.getIcon(); + JMenuItem drawIndy = new JMenuItem("Show individual"); + drawIndy.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent ee) { + ((InterfaceDPointWithContent)m_CurrentPointIcon).showIndividual(); + } + }); + GraphMenu.add(drawIndy); + } + + } + if (FunctionArea.this.m_PointSetContainer.size() > 0) { + JMenuItem removeGraph = new JMenuItem("Remove graph"); + removeGraph.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent ee) { + clearGraph(FunctionArea.this.m_x, FunctionArea.this.m_y); + } + }); + GraphMenu.add(removeGraph); + } + if (FunctionArea.this.m_PointSetContainer.size() > 0) { + JMenuItem changecolorGraph = new JMenuItem("Change color"); + changecolorGraph.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent ee) { + changeColorGraph(FunctionArea.this.m_x, FunctionArea.this.m_y); + } + }); + GraphMenu.add(changecolorGraph); + } + if (FunctionArea.this.m_PointSetContainer.size() > 0) { + JMenuItem removePoint = new JMenuItem("Remove point"); + removePoint.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent ee) { + removePoint(FunctionArea.this.m_x, FunctionArea.this.m_y); + } + }); + GraphMenu.add(removePoint); + } +// if (isStatisticsGraph(e.getX(),e.getY())==true) { +// if (getVar(e.getX(),e.getY())==false) { +// JMenuItem showVar = new JMenuItem("Show varianz "); +// showVar.addActionListener(new ActionListener() { +// // +// public void actionPerformed(ActionEvent ee) { +// setVar(m_x,m_y,true); +// } +// }); +// GraphMenu.add(showVar); +// +// } +// else { +// JMenuItem hideVar = new JMenuItem("Hide varianz "); +// hideVar.addActionListener(new ActionListener() { +// // +// public void actionPerformed(ActionEvent ee) { +// setVar(m_x,m_y,false); +// } +// }); +// GraphMenu.add(hideVar); +// } +// } + GraphMenu.show(FunctionArea.this, e.getX(), e.getY()); + } + } + }); + } + + /** This method allows to add a selection listner to the PointIcon + * it should need more than one listener to this abstruse event + * @param a The selection listener + */ + public void addRefPointSelectionListener(InterfaceRefPointListener a) { + this.m_RefPointListener = a; + } + + /** This method returns the selection listner to the PointIcon + * @return InterfaceSelectionListener + */ + public InterfaceRefPointListener getRefPointSelectionListener() { + return this.m_RefPointListener; + } + + /** This method allows to remove the selection listner to the PointIcon + */ + public void removeRefPointSelectionListeners() { + this.m_RefPointListener = null; + } + +} diff --git a/src/javaeva/gui/GenericAreaEditor.java b/src/javaeva/gui/GenericAreaEditor.java new file mode 100644 index 00000000..8d90ca00 --- /dev/null +++ b/src/javaeva/gui/GenericAreaEditor.java @@ -0,0 +1,168 @@ +package javaeva.gui; + +import javaeva.tools.EVAHELP; +import javaeva.server.go.individuals.codings.gp.AbstractGPNode; +import javaeva.server.go.individuals.codings.gp.GPArea; + +import javax.swing.*; +import java.beans.PropertyEditorSupport; +import java.beans.PropertyEditor; +import java.beans.PropertyChangeListener; +import java.beans.PropertyChangeSupport; +import java.awt.*; +import java.awt.event.ActionListener; +import java.awt.event.ActionEvent; +import java.lang.reflect.Array; +import java.util.ArrayList; + +/** + * Created by IntelliJ IDEA. + * User: streiche + * Date: 27.06.2003 + * Time: 11:41:01 + * To change this template use Options | File Templates. + */ +public class GenericAreaEditor extends JPanel implements PropertyEditor { + + /** Handles property change notification */ + private PropertyChangeSupport m_Support = new PropertyChangeSupport(this); + /** The label for when we can't edit that type */ + private JLabel m_Label = new JLabel("Can't edit", SwingConstants.CENTER); + /** The GPArea that is to be edited*/ + private GPArea m_AreaObject; + + /** The gaphix stuff */ + private JPanel m_CustomEditor, m_NodePanel; + private JCheckBox[] m_BlackCheck; + + public GenericAreaEditor() { + // compiled code + } + + /** This method will init the CustomEditor Panel + */ + private void initCustomEditor() { + this.m_CustomEditor = new JPanel(); + this.m_CustomEditor.setLayout(new BorderLayout()); + this.m_CustomEditor.add(new JLabel("Choose the area:"), BorderLayout.NORTH); + this.m_NodePanel = new JPanel(); + this.m_CustomEditor.add(new JScrollPane(this.m_NodePanel), BorderLayout.CENTER); + this.updateEditor(); + } + + /** The object may have changed update the editor. + */ + private void updateEditor() { + if (this.m_NodePanel != null) { + + ArrayList GPNodes = this.m_AreaObject.getCompleteList(); + ArrayList Allowed = this.m_AreaObject.getBlackList(); + this.m_NodePanel.removeAll(); + this.m_NodePanel.setLayout(new GridLayout(GPNodes.size(), 1)); + this.m_BlackCheck = new JCheckBox[GPNodes.size()]; + for (int i = 0; i < GPNodes.size(); i++) { + this.m_BlackCheck[i] = new JCheckBox((((AbstractGPNode)GPNodes.get(i))).getName(), ((Boolean)Allowed.get(i)).booleanValue()); + this.m_BlackCheck[i].addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent ev) { + makeNodeList(); + } + }); + this.m_NodePanel.add(this.m_BlackCheck[i]); + } + } + } + + /** This method checks the current BlackList and compiles it + * to a new ReducedList. + */ + private void makeNodeList() { + for (int i = 0; i < this.m_BlackCheck.length; i++) { + this.m_AreaObject.setBlackListElement(i, this.m_BlackCheck[i].isSelected()); + } + this.m_AreaObject.compileReducedList(); + } + + /** This method will set the value of object that is to be edited. + * @param o an object that must be an array. + */ + public void setValue(Object o) { + if (o instanceof GPArea) { + this.m_AreaObject = (GPArea) o; + this.updateEditor(); + } + } + + /** Retruns the current object. + * @return the current object + */ + public Object getValue() { + return this.m_AreaObject; + } + + public String getJavaInitializationString() { + return "TEST"; + } + + /** + * + */ + public String getAsText() { + return null; + } + /** + * + */ + public void setAsText(String text) throws IllegalArgumentException { + throw new IllegalArgumentException(text); + } + /** + * + */ + public String[] getTags() { + return null; + } + /** + * + */ + public void addPropertyChangeListener(PropertyChangeListener l) { + m_Support.addPropertyChangeListener(l); + } + /** + * + */ + public void removePropertyChangeListener(PropertyChangeListener l) { + m_Support.removePropertyChangeListener(l); + } + /** Returns true since the Object can be shown + * @return true + */ + public boolean isPaintable() { + return true; + } + /** + * Paints a representation of the current classifier. + * + * @param gfx the graphics context to use + * @param box the area we are allowed to paint into + */ + public void paintValue(Graphics gfx, Rectangle box) { + FontMetrics fm = gfx.getFontMetrics(); + int vpad = (box.height - fm.getAscent()) / 2; + String rep = "Select from available GPNodes"; + gfx.drawString(rep, 2, fm.getHeight() + vpad - 3 ); + } + /** Returns true because we do support a custom editor. + * @return true + */ + public boolean supportsCustomEditor() { + return true; + } + + /** Returns the array editing component. + * @return a value of type 'java.awt.Component' + */ + public Component getCustomEditor() { + if (this.m_CustomEditor == null) this.initCustomEditor(); + return m_CustomEditor; + } +} \ No newline at end of file diff --git a/src/javaeva/gui/GenericArrayEditor.java b/src/javaeva/gui/GenericArrayEditor.java new file mode 100644 index 00000000..5b79316e --- /dev/null +++ b/src/javaeva/gui/GenericArrayEditor.java @@ -0,0 +1,434 @@ +package javaeva.gui; +/* + * Title: JavaEvA + * Description: + * Copyright: Copyright (c) 2003 + * Company: University of Tuebingen, Computer Architecture + * @author Holger Ulmer, Felix Streichert, Hannes Planatscher + * @version: $Revision: 235 $ + * $Date: 2007-11-08 13:53:51 +0100 (Thu, 08 Nov 2007) $ + * $Author: mkron $ + */ +/*==========================================================================* + * IMPORTS + *==========================================================================*/ + +import javaeva.tools.EVAHELP; +import javaeva.tools.SelectedTag; + +import java.awt.*; +import java.awt.event.*; +import javax.swing.JPanel; +import javax.swing.JLabel; +import javax.swing.JList; +import javax.swing.JButton; +import javax.swing.event.ListSelectionListener; + +import javax.swing.ListCellRenderer; +import javax.swing.event.ListSelectionEvent; +import javax.swing.SwingConstants; +import javax.swing.JOptionPane; +import javax.swing.DefaultListModel; +import javax.swing.JScrollPane; +import javax.swing.DefaultListCellRenderer; +import java.beans.PropertyEditor; +import java.beans.PropertyChangeSupport; +import java.beans.PropertyChangeListener; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyEditorManager; +import java.lang.reflect.Array; +/*==========================================================================* + * CLASS DECLARATION + *==========================================================================*/ +public class GenericArrayEditor extends JPanel +implements PropertyEditor { + /** Handles property change notification */ + private PropertyChangeSupport m_Support = new PropertyChangeSupport(this); + /** The label for when we can't edit that type */ + private JLabel m_Label = new JLabel("Can't edit", SwingConstants.CENTER); + /** The list component displaying current values */ + private JList m_ElementList = new JList(); + /** The class of objects allowed in the array */ + private Class m_ElementClass = String.class; + /** The defaultlistmodel holding our data */ + private DefaultListModel m_ListModel; + /** The property editor for the class we are editing */ + private PropertyEditor m_ElementEditor; + /** Click this to delete the selected array values */ + private JButton m_DeleteBut = new JButton("Delete"); + /** Click to add the current object configuration to the array */ + private JButton m_AddBut = new JButton("Add"); + /** Listens to buttons being pressed and taking the appropriate action */ + private ActionListener m_InnerActionListener = + new ActionListener() { + // + public void actionPerformed(ActionEvent e) { + if (e.getSource() == m_DeleteBut) { + int [] selected = m_ElementList.getSelectedIndices(); + if (selected != null) { + for (int i = 0; i < selected.length; i++) { + int current = selected[i]; + m_ListModel.removeElementAt(current); + if (m_ListModel.size() > current) { + m_ElementList.setSelectedIndex(current); + } + } + m_Support.firePropertyChange("", null, null); + } + if (m_ElementList.getSelectedIndex() == -1) { + m_DeleteBut.setEnabled(false); + } + } else if (e.getSource() == m_AddBut) { + int selected = m_ElementList.getSelectedIndex(); + Object addObj = m_ElementEditor.getValue(); + + // Make a full copy of the object using serialization + try { + SerializedObject so = new SerializedObject(addObj); + addObj = so.getObject(); + if (selected != -1) { + m_ListModel.insertElementAt(addObj, selected); + } else { + m_ListModel.addElement(addObj); + } + m_Support.firePropertyChange("", null, null); + } catch (Exception ex) { + JOptionPane.showMessageDialog(GenericArrayEditor.this,"Could not create an object copy",null,JOptionPane.ERROR_MESSAGE); + } + } + } + }; + + /** Listens to list items being selected and takes appropriate action */ + private ListSelectionListener m_InnerSelectionListener = + new ListSelectionListener() { + // + public void valueChanged(ListSelectionEvent e) { + + if (e.getSource() == m_ElementList) { + // Enable the delete button + //System.out.println("m_ElementList.getSelectedIndex()"+m_ElementList.getSelectedIndex()); + if (m_ElementList.getSelectedIndex() != -1) { + m_DeleteBut.setEnabled(true); + } + } + } + }; + + + /** + * Sets up the array editor. + */ + public GenericArrayEditor() { + setLayout(new BorderLayout()); + add(m_Label, BorderLayout.CENTER); + m_DeleteBut.addActionListener(m_InnerActionListener); + m_AddBut.addActionListener(m_InnerActionListener); + m_ElementList.addListSelectionListener(m_InnerSelectionListener); + m_AddBut.setToolTipText("Add the current item to the list"); + m_DeleteBut.setToolTipText("Delete the selected list item"); + } + + /* This class handles the creation of list cell renderers from the + * property editors. + */ + private class EditorListCellRenderer implements ListCellRenderer { + /** The class of the property editor for array objects */ + private Class m_EditorClass; + /** The class of the array values */ + private Class m_ValueClass; + /** + * Creates the list cell renderer. + * + * @param editorClass The class of the property editor for array objects + * @param valueClass The class of the array values + */ + public EditorListCellRenderer(Class editorClass, Class valueClass) { + m_EditorClass = editorClass; + m_ValueClass = valueClass; + } + /** + * Creates a cell rendering component. + * + * @param JList the list that will be rendered in + * @param Object the cell value + * @param int which element of the list to render + * @param boolean true if the cell is selected + * @param boolean true if the cell has the focus + * @return the rendering component + */ + public Component getListCellRendererComponent(final JList list, + final Object value, + final int index, + final boolean isSelected, + final boolean cellHasFocus) { + try { + final PropertyEditor e = (PropertyEditor)m_EditorClass.newInstance(); + if (e instanceof GenericObjectEditor) { + // ((GenericObjectEditor) e).setDisplayOnly(true); + ((GenericObjectEditor) e).setClassType(m_ValueClass); + } + e.setValue(value); + return new JPanel() { + /** + * + */ + public void paintComponent(Graphics g) { + Insets i = this.getInsets(); + Rectangle box = new Rectangle(i.left,i.top, + this.getWidth(), //- i.right, + this.getHeight() );//- i.bottom +20); + g.setColor(isSelected ? list.getSelectionBackground() : list.getBackground()); + g.fillRect(0, 0, this.getWidth(), this.getHeight()); + g.setColor(isSelected ? list.getSelectionForeground(): list.getForeground()); + e.paintValue(g, box); + } + /** + * + */ + public Dimension getPreferredSize() { +// Dimension newPref = getPreferredSize(); +// newPref.height = getFontMetrics(getFont()).getHeight() * 6 / 4; //6 / 4; +// newPref.width = newPref.height * 6; //5 +// setPreferredSize(newPref); + + +// Font f = this.getFont(); +// FontMetrics fm = this.getFontMetrics(f); +// return new Dimension(0, fm.getHeight()); + + Font f = this.getFont(); + FontMetrics fm = this.getFontMetrics(f); + Dimension newPref = new Dimension(0, fm.getHeight()); + newPref.height = getFontMetrics(getFont()).getHeight() * 6 / 4; //6 / 4; + newPref.width = newPref.height * 6; //5 + return newPref; + } + }; + } catch (Exception ex) { + return null; + } + } + } + + /** + * Updates the type of object being edited, so attempts to find an + * appropriate propertyeditor. + * + * @param o a value of type 'Object' + */ + private void updateEditorType(Object o) { + + // Determine if the current object is an array + m_ElementEditor = null; m_ListModel = null; + removeAll(); + + if ((o != null) && (o.getClass().isArray())) { + Class elementClass = o.getClass().getComponentType(); + PropertyEditor editor = PropertyEditorProvider.findEditor(elementClass); + Component view = null; + ListCellRenderer lcr = new DefaultListCellRenderer(); + if (editor != null) { + if (editor instanceof GenericObjectEditor) { + ((GenericObjectEditor) editor).setClassType(elementClass); + } + if (editor.isPaintable() && editor.supportsCustomEditor()) { + view = new PropertyPanel(editor); + lcr = new EditorListCellRenderer(editor.getClass(), elementClass); + } else if (editor.getTags() != null) { + view = new PropertyValueSelector(editor); + } else if (editor.getAsText() != null) { + view = new PropertyText(editor); + } + } + if (view == null) { + System.err.println("No property editor for class: " + + elementClass.getName()); + } else { + m_ElementEditor = editor; + + // Create the ListModel and populate it + m_ListModel = new DefaultListModel(); + m_ElementClass = elementClass; + for (int i = 0; i < Array.getLength(o); i++) { + m_ListModel.addElement(Array.get(o,i)); + } + m_ElementList.setCellRenderer(lcr); + m_ElementList.setModel(m_ListModel); + if (m_ListModel.getSize() > 0) { + m_ElementList.setSelectedIndex(0); + m_DeleteBut.setEnabled(true); + } else { + m_DeleteBut.setEnabled(false); + } + + try { + if (m_ListModel.getSize() > 0) { + m_ElementEditor.setValue(m_ListModel.getElementAt(0)); + } else { + if (m_ElementEditor instanceof GenericObjectEditor) { + ((GenericObjectEditor)m_ElementEditor).setDefaultValue(); + } else { + m_ElementEditor.setValue(m_ElementClass.newInstance()); + } + } + + JPanel panel = new JPanel(); + panel.setLayout(new BorderLayout()); + panel.add(view, BorderLayout.CENTER); + panel.add(m_AddBut, BorderLayout.EAST); + add(panel, BorderLayout.NORTH); + add(new JScrollPane(m_ElementList), BorderLayout.CENTER); + add(m_DeleteBut, BorderLayout.SOUTH); + m_ElementEditor.addPropertyChangeListener(new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent e) { + repaint(); + } + }); + } catch (Exception ex) { + System.err.println(ex.getMessage()); + m_ElementEditor = null; + } + } + } + if (m_ElementEditor == null) { + add(m_Label, BorderLayout.CENTER); + } + m_Support.firePropertyChange("", null, null); + validate(); + } + /** + * Sets the current object array. + * + * @param o an object that must be an array. + */ + public void setValue(Object o) { + // Create a new list model, put it in the list and resize? + updateEditorType(o); + } + + /** + * Gets the current object array. + * + * @return the current object array + */ + public Object getValue() { + + if (m_ListModel == null) { + return null; + } + // Convert the listmodel to an array of strings and return it. + int length = m_ListModel.getSize(); + Object result = Array.newInstance(m_ElementClass, length); + for (int i = 0; i < length; i++) { + Array.set(result, i, m_ListModel.elementAt(i)); + } + return result; + } + + /** + * Supposedly returns an initialization string to create a classifier + * identical to the current one, including it's state, but this doesn't + * appear possible given that the initialization string isn't supposed to + * contain multiple statements. + * + * @return the java source code initialisation string + */ + public String getJavaInitializationString() { + return "null"; + } + + /** + * Returns true to indicate that we can paint a representation of the + * string array + * + * @return true + */ + public boolean isPaintable() { + return true; + } + + /** + * Paints a representation of the current classifier. + * + * @param gfx the graphics context to use + * @param box the area we are allowed to paint into + */ + public void paintValue(Graphics gfx, Rectangle box) { + FontMetrics fm = gfx.getFontMetrics(); + int vpad = (box.height - fm.getAscent()) / 2; +// System.out.println(m_ListModel + " --- " + m_ElementClass); + String rep = m_ListModel.getSize() + " " + EVAHELP.cutClassName(m_ElementClass.getName()); + gfx.drawString(rep, 2, fm.getHeight() + vpad - 3 ); + } + /** + * + */ + public String getAsText() { + return null; + } + /** + * + */ + public void setAsText(String text) throws IllegalArgumentException { + throw new IllegalArgumentException(text); + } + /** + * + */ + public String[] getTags() { + return null; + } + /** + * + */ + public boolean supportsCustomEditor() { + return true; + } + /** + * + */ + public Component getCustomEditor() { + return this; + } + /** + * + */ + public void addPropertyChangeListener(PropertyChangeListener l) { + m_Support.addPropertyChangeListener(l); + } + /** + * + */ + public void removePropertyChangeListener(PropertyChangeListener l) { + m_Support.removePropertyChangeListener(l); + } + + /** + * + */ + public static void main(String [] args) { + try { + java.beans.PropertyEditorManager.registerEditor(SelectedTag.class,TagEditor.class); + java.beans.PropertyEditorManager.registerEditor(String [].class,GenericArrayEditor.class); + java.beans.PropertyEditorManager.registerEditor(double [].class,GenericArrayEditor.class); + GenericArrayEditor editor = new GenericArrayEditor(); + + double [] initial = { 1, 2, 34,656,46 }; + PropertyDialog pd = new PropertyDialog(editor,EVAHELP.cutClassName(editor.getClass().getName()) + , 100, 100); + pd.setSize(200,200); + pd.addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent e) { + System.exit(0); + } + }); + editor.setValue(initial); + //ce.validate(); + } catch (Exception ex) { + ex.printStackTrace(); + System.err.println(ex.getMessage()); + } + } +} + diff --git a/src/javaeva/gui/GenericDoubleArrayEditor.java b/src/javaeva/gui/GenericDoubleArrayEditor.java new file mode 100644 index 00000000..1af18b82 --- /dev/null +++ b/src/javaeva/gui/GenericDoubleArrayEditor.java @@ -0,0 +1,279 @@ +package javaeva.gui; + +import javax.swing.*; +import java.beans.PropertyEditor; +import java.beans.PropertyChangeSupport; +import java.beans.PropertyChangeListener; +import java.awt.*; +import java.awt.event.ActionListener; +import java.awt.event.ActionEvent; +import java.awt.event.KeyListener; +import java.awt.event.KeyEvent; +import java.io.File; + +/** + * Created by IntelliJ IDEA. + * User: streiche + * Date: 05.03.2004 + * Time: 13:51:14 + * To change this template use File | Settings | File Templates. + */ +public class GenericDoubleArrayEditor extends JPanel implements PropertyEditor { + + /** Handles property change notification */ + private PropertyChangeSupport m_Support = new PropertyChangeSupport(this); + /** The label for when we can't edit that type */ + private JLabel m_Label = new JLabel("Can't edit", SwingConstants.CENTER); + /** The FilePath that is to be edited*/ + private PropertyDoubleArray m_DoubleArray; + + /** The gaphix stuff */ + private JPanel m_CustomEditor, m_DataPanel, m_ButtonPanel; + private JTextField[] m_InputTextField; + private JButton m_OKButton, m_AddButton, m_DeleteButton, m_NormalizeButton; + + public GenericDoubleArrayEditor() { + // compiled code + } + + /** This method will init the CustomEditor Panel + */ + private void initCustomEditor() { + this.m_CustomEditor = new JPanel(); + this.m_CustomEditor.setLayout(new BorderLayout()); + + this.m_CustomEditor.add(new JLabel("Current Double Array:"), BorderLayout.NORTH); + + // init data panel + this.m_DataPanel = new JPanel(); + this.updateDataPanel(); + this.m_CustomEditor.add(this.m_DataPanel, BorderLayout.CENTER); + + // init button panel + this.m_ButtonPanel = new JPanel(); + this.m_AddButton = new JButton("Add"); + this.m_AddButton.addActionListener(this.addAction); + this.m_DeleteButton = new JButton("Delete"); + this.m_DeleteButton.addActionListener(this.deleteAction); + this.m_NormalizeButton = new JButton("Normalize"); + this.m_NormalizeButton.addActionListener(this.mormalizeAction); + this.m_OKButton = new JButton("OK"); + this.m_OKButton.setEnabled(true); + this.m_OKButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + //m_Backup = copyObject(m_Object); + if ((m_CustomEditor.getTopLevelAncestor() != null) && (m_CustomEditor.getTopLevelAncestor() instanceof Window)) { + Window w = (Window) m_CustomEditor.getTopLevelAncestor(); + w.dispose(); + } + } + }); + this.m_ButtonPanel.add(this.m_AddButton); + this.m_ButtonPanel.add(this.m_DeleteButton); + this.m_ButtonPanel.add(this.m_NormalizeButton); + this.m_ButtonPanel.add(this.m_OKButton); + this.m_CustomEditor.add(this.m_ButtonPanel, BorderLayout.SOUTH); + this.updateEditor(); + } + + /** This action listener adds an element to DoubleArray + */ + ActionListener addAction = new ActionListener() { + public void actionPerformed(ActionEvent event) { + double[] tmpD = m_DoubleArray.getDoubleArray(); + double[] newD = new double[tmpD.length+1]; + + for (int i = 0; i < newD.length; i++) newD[i] = 1.0; + for (int i = 0; i < tmpD.length; i++) newD[i] = tmpD[i]; + m_DoubleArray.setDoubleArray(newD); + updateEditor(); + } + }; + /** This action listener removes an element to DoubleArray + */ + ActionListener deleteAction = new ActionListener() { + public void actionPerformed(ActionEvent event) { + double[] tmpD = m_DoubleArray.getDoubleArray(); + double[] newD = new double[tmpD.length-1]; + + for (int i = 0; i < newD.length; i++) newD[i] = tmpD[i]; + m_DoubleArray.setDoubleArray(newD); + updateEditor(); + } + }; + /** This action listener nomalizes the values of the DoubleArray + */ + ActionListener mormalizeAction = new ActionListener() { + public void actionPerformed(ActionEvent event) { + double[] tmpD = m_DoubleArray.getDoubleArray(); + double sum = 0; + + for (int i = 0; i < tmpD.length; i++) sum += tmpD[i]; + if (sum == 0) return; + for (int i = 0; i < tmpD.length; i++) tmpD[i] = tmpD[i]/sum; + m_DoubleArray.setDoubleArray(tmpD); + updateEditor(); + } + }; + + /** This action listener reads all values + */ + KeyListener readDoubleArrayAction = new KeyListener() { + public void keyPressed(KeyEvent event) { + } + public void keyTyped(KeyEvent event) { + } + + public void keyReleased(KeyEvent event) { + double[] tmpD = new double[m_InputTextField.length]; + + for (int i = 0; i < tmpD.length; i++) { + + try { + double d = 0; + d = new Double(m_InputTextField[i].getText()).doubleValue(); + tmpD[i] = d; + } catch (Exception e) { + + } + //tmpD[i] = new Double(m_InputTextField[i].getText()).doubleValue(); + } + + m_DoubleArray.setDoubleArray(tmpD); + //updateEditor(); + } + }; + + /** The object may have changed update the editor. + */ + private void updateEditor() { + if (this.m_CustomEditor != null) { + this.updateDataPanel(); + this.m_CustomEditor.validate(); + this.m_CustomEditor.repaint(); + } + } + + /** This method updates the data panel + */ + private void updateDataPanel() { + double[] tmpD = this.m_DoubleArray.getDoubleArray(); + + this.m_DataPanel.removeAll(); + this.m_DataPanel.setLayout(new GridLayout(tmpD.length, 2)); + this.m_InputTextField = new JTextField[tmpD.length]; + for (int i = 0; i < tmpD.length; i++) { + JLabel label = new JLabel("Value X"+i+": "); + this.m_DataPanel.add(label); + this.m_InputTextField[i] = new JTextField(); + this.m_InputTextField[i].setText(""+tmpD[i]); + this.m_InputTextField[i].addKeyListener(this.readDoubleArrayAction); + this.m_DataPanel.add(this.m_InputTextField[i]); + } + } + + + /** This method will set the value of object that is to be edited. + * @param o an object that must be an array. + */ + public void setValue(Object o) { + if (o instanceof PropertyDoubleArray) { + this.m_DoubleArray = (PropertyDoubleArray) o; + this.updateEditor(); + } + } + + /** Returns the current object. + * @return the current object + */ + public Object getValue() { + return this.m_DoubleArray; + } + + public String getJavaInitializationString() { + return "TEST"; + } + + /** + * + */ + public String getAsText() { + return null; + } + + /** + * + */ + public void setAsText(String text) throws IllegalArgumentException { + throw new IllegalArgumentException(text); + } + + /** + * + */ + public String[] getTags() { + return null; + } + + /** + * + */ + public void addPropertyChangeListener(PropertyChangeListener l) { + m_Support.addPropertyChangeListener(l); + } + + /** + * + */ + public void removePropertyChangeListener(PropertyChangeListener l) { + m_Support.removePropertyChangeListener(l); + } + + /** This is used to hook an action listener to the ok button + * @param a The action listener. + */ + public void addOkListener(ActionListener a) { + m_OKButton.addActionListener(a); + } + + /** This is used to remove an action listener from the ok button + * @param a The action listener + */ + public void removeOkListener(ActionListener a) { + m_OKButton.removeActionListener(a); + } + + /** Returns true since the Object can be shown + * @return true + */ + public boolean isPaintable() { + return true; + } + + /** Paints a representation of the current classifier. + * + * @param gfx the graphics context to use + * @param box the area we are allowed to paint into + */ + public void paintValue(Graphics gfx, Rectangle box) { + FontMetrics fm = gfx.getFontMetrics(); + int vpad = (box.height - fm.getAscent()) / 2; + String rep = "Edit double[]"; + gfx.drawString(rep, 2, fm.getHeight() + vpad - 3 ); + } + + /** Returns true because we do support a custom editor. + * @return true + */ + public boolean supportsCustomEditor() { + return true; + } + + /** Returns the array editing component. + * @return a value of type 'java.awt.Component' + */ + public Component getCustomEditor() { + if (this.m_CustomEditor == null) this.initCustomEditor(); + return m_CustomEditor; + } +} \ No newline at end of file diff --git a/src/javaeva/gui/GenericEpsilonConstraintEditor.java b/src/javaeva/gui/GenericEpsilonConstraintEditor.java new file mode 100644 index 00000000..cbffd159 --- /dev/null +++ b/src/javaeva/gui/GenericEpsilonConstraintEditor.java @@ -0,0 +1,246 @@ +package javaeva.gui; + +import javax.swing.*; +import java.beans.PropertyEditor; +import java.beans.PropertyChangeSupport; +import java.beans.PropertyChangeListener; +import java.awt.*; +import java.awt.event.*; + +/** + * Created by IntelliJ IDEA. + * User: streiche + * Date: 14.07.2005 + * Time: 16:33:45 + * To change this template use File | Settings | File Templates. + */ +public class GenericEpsilonConstraintEditor extends JPanel implements PropertyEditor { + + /** Handles property change notification */ + private PropertyChangeSupport m_Support = new PropertyChangeSupport(this); + /** The label for when we can't edit that type */ + private JLabel m_Label = new JLabel("Can't edit", SwingConstants.CENTER); + /** The FilePath that is to be edited*/ + private PropertyEpsilonConstraint m_EpsilonConstraint; + + /** The gaphix stuff */ + private JPanel m_CustomEditor, m_DataPanel, m_ButtonPanel, m_TargetPanel; + private JTextField[] m_TargetTextField; + private JComboBox m_Objective; + private JButton m_OKButton; + + public GenericEpsilonConstraintEditor() { + // compiled code + } + + /** This method will init the CustomEditor Panel + */ + private void initCustomEditor() { + this.m_CustomEditor = new JPanel(); + this.m_CustomEditor.setLayout(new BorderLayout()); + + // target panel + this.m_TargetPanel = new JPanel(); + this.m_TargetPanel.setLayout(new GridLayout(1, 2)); + this.m_TargetPanel.add(new JLabel("Optimize:")); + this.m_Objective = new JComboBox(); + for (int i = 0; i < this.m_EpsilonConstraint.m_TargetValue.length; i++) this.m_Objective.addItem("Objective "+i); + this.m_TargetPanel.add(this.m_Objective); + this.m_Objective.addItemListener(this.objectiveAction); + this.m_CustomEditor.add(this.m_TargetPanel, BorderLayout.NORTH); + + // init data panel + this.m_DataPanel = new JPanel(); + this.updateDataPanel(); + this.m_CustomEditor.add(this.m_DataPanel, BorderLayout.CENTER); + + // init button panel + this.m_ButtonPanel = new JPanel(); + this.m_OKButton = new JButton("OK"); + this.m_OKButton.setEnabled(true); + this.m_OKButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + //m_Backup = copyObject(m_Object); + if ((m_CustomEditor.getTopLevelAncestor() != null) && (m_CustomEditor.getTopLevelAncestor() instanceof Window)) { + Window w = (Window) m_CustomEditor.getTopLevelAncestor(); + w.dispose(); + } + } + }); + this.m_ButtonPanel.add(this.m_OKButton); + this.m_CustomEditor.add(this.m_ButtonPanel, BorderLayout.SOUTH); + this.updateEditor(); + } + + /** This action listener adds an element to DoubleArray + */ + ItemListener objectiveAction = new ItemListener() { + public void itemStateChanged(ItemEvent event) { + m_EpsilonConstraint.m_OptimizeObjective = m_Objective.getSelectedIndex(); + updateEditor(); + } + }; + + /** This action listener reads all values + */ + KeyListener readDoubleArrayAction = new KeyListener() { + public void keyPressed(KeyEvent event) { + } + public void keyTyped(KeyEvent event) { + } + + public void keyReleased(KeyEvent event) { + double[] tmpT = m_EpsilonConstraint.m_TargetValue; + + for (int i = 0; i < tmpT.length; i++) { + + try { + double d = 0; + d = new Double(m_TargetTextField[i].getText()).doubleValue(); + tmpT[i] = d; + } catch (Exception e) { + + } + } + + m_EpsilonConstraint.m_TargetValue = tmpT; + } + }; + + /** The object may have changed update the editor. + */ + private void updateEditor() { + if (this.m_CustomEditor != null) { + this.updateDataPanel(); + this.m_CustomEditor.validate(); + this.m_CustomEditor.repaint(); + } + } + + /** This method updates the data panel + */ + private void updateDataPanel() { + double[] tmpT = this.m_EpsilonConstraint.m_TargetValue; + int obj = this.m_EpsilonConstraint.m_OptimizeObjective; + + this.m_DataPanel.removeAll(); + this.m_DataPanel.setLayout(new GridLayout(tmpT.length+1, 2)); + this.m_DataPanel.add(new JLabel()); + this.m_DataPanel.add(new JLabel("Target Value")); + this.m_TargetTextField = new JTextField[tmpT.length]; + for (int i = 0; i < tmpT.length; i++) { + JLabel label = new JLabel("Objective "+i+": "); + this.m_DataPanel.add(label); + this.m_TargetTextField[i] = new JTextField(); + this.m_TargetTextField[i].setText(""+tmpT[i]); + this.m_TargetTextField[i].addKeyListener(this.readDoubleArrayAction); + this.m_DataPanel.add(this.m_TargetTextField[i]); + } + this.m_TargetTextField[obj].setEditable(false); + } + + + /** This method will set the value of object that is to be edited. + * @param o an object that must be an array. + */ + public void setValue(Object o) { + if (o instanceof PropertyEpsilonConstraint) { + this.m_EpsilonConstraint = (PropertyEpsilonConstraint) o; + this.updateEditor(); + } + } + + /** Returns the current object. + * @return the current object + */ + public Object getValue() { + return this.m_EpsilonConstraint; + } + + public String getJavaInitializationString() { + return "TEST"; + } + + /** + * + */ + public String getAsText() { + return null; + } + + /** + * + */ + public void setAsText(String text) throws IllegalArgumentException { + throw new IllegalArgumentException(text); + } + + /** + * + */ + public String[] getTags() { + return null; + } + + /** + * + */ + public void addPropertyChangeListener(PropertyChangeListener l) { + m_Support.addPropertyChangeListener(l); + } + + /** + * + */ + public void removePropertyChangeListener(PropertyChangeListener l) { + m_Support.removePropertyChangeListener(l); + } + + /** This is used to hook an action listener to the ok button + * @param a The action listener. + */ + public void addOkListener(ActionListener a) { + m_OKButton.addActionListener(a); + } + + /** This is used to remove an action listener from the ok button + * @param a The action listener + */ + public void removeOkListener(ActionListener a) { + m_OKButton.removeActionListener(a); + } + + /** Returns true since the Object can be shown + * @return true + */ + public boolean isPaintable() { + return true; + } + + /** Paints a representation of the current classifier. + * + * @param gfx the graphics context to use + * @param box the area we are allowed to paint into + */ + public void paintValue(Graphics gfx, Rectangle box) { + FontMetrics fm = gfx.getFontMetrics(); + int vpad = (box.height - fm.getAscent()) / 2; + String rep = "Edit Epsilon Constraint"; + gfx.drawString(rep, 2, fm.getHeight() + vpad - 3 ); + } + + /** Returns true because we do support a custom editor. + * @return true + */ + public boolean supportsCustomEditor() { + return true; + } + + /** Returns the array editing component. + * @return a value of type 'java.awt.Component' + */ + public Component getCustomEditor() { + if (this.m_CustomEditor == null) this.initCustomEditor(); + return m_CustomEditor; + } +} \ No newline at end of file diff --git a/src/javaeva/gui/GenericEpsilonThresholdEditor.java b/src/javaeva/gui/GenericEpsilonThresholdEditor.java new file mode 100644 index 00000000..a2d1eb86 --- /dev/null +++ b/src/javaeva/gui/GenericEpsilonThresholdEditor.java @@ -0,0 +1,263 @@ +package javaeva.gui; + +import javax.swing.*; +import java.beans.PropertyEditor; +import java.beans.PropertyChangeSupport; +import java.beans.PropertyChangeListener; +import java.awt.*; +import java.awt.event.*; + +/** + * Created by IntelliJ IDEA. + * User: streiche + * Date: 05.03.2004 + * Time: 15:17:09 + * To change this template use File | Settings | File Templates. + */ +public class GenericEpsilonThresholdEditor extends JPanel implements PropertyEditor { + + /** Handles property change notification */ + private PropertyChangeSupport m_Support = new PropertyChangeSupport(this); + /** The label for when we can't edit that type */ + private JLabel m_Label = new JLabel("Can't edit", SwingConstants.CENTER); + /** The FilePath that is to be edited*/ + private PropertyEpsilonThreshold m_EpsilonThreshhold; + + /** The gaphix stuff */ + private JPanel m_CustomEditor, m_DataPanel, m_ButtonPanel, m_TargetPanel; + private JTextField[] m_TargetTextField, m_PunishTextField; + private JComboBox m_Objective; + private JButton m_OKButton; + + public GenericEpsilonThresholdEditor() { + // compiled code + } + + /** This method will init the CustomEditor Panel + */ + private void initCustomEditor() { + this.m_CustomEditor = new JPanel(); + this.m_CustomEditor.setLayout(new BorderLayout()); + + // target panel + this.m_TargetPanel = new JPanel(); + this.m_TargetPanel.setLayout(new GridLayout(1, 2)); + this.m_TargetPanel.add(new JLabel("Optimize:")); + this.m_Objective = new JComboBox(); + for (int i = 0; i < this.m_EpsilonThreshhold.m_TargetValue.length; i++) this.m_Objective.addItem("Objective "+i); + this.m_TargetPanel.add(this.m_Objective); + this.m_Objective.addItemListener(this.objectiveAction); + this.m_CustomEditor.add(this.m_TargetPanel, BorderLayout.NORTH); + + // init data panel + this.m_DataPanel = new JPanel(); + this.updateDataPanel(); + this.m_CustomEditor.add(this.m_DataPanel, BorderLayout.CENTER); + + // init button panel + this.m_ButtonPanel = new JPanel(); + this.m_OKButton = new JButton("OK"); + this.m_OKButton.setEnabled(true); + this.m_OKButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + //m_Backup = copyObject(m_Object); + if ((m_CustomEditor.getTopLevelAncestor() != null) && (m_CustomEditor.getTopLevelAncestor() instanceof Window)) { + Window w = (Window) m_CustomEditor.getTopLevelAncestor(); + w.dispose(); + } + } + }); + this.m_ButtonPanel.add(this.m_OKButton); + this.m_CustomEditor.add(this.m_ButtonPanel, BorderLayout.SOUTH); + this.updateEditor(); + } + + /** This action listener adds an element to DoubleArray + */ + ItemListener objectiveAction = new ItemListener() { + public void itemStateChanged(ItemEvent event) { + m_EpsilonThreshhold.m_OptimizeObjective = m_Objective.getSelectedIndex(); + updateEditor(); + } + }; + + /** This action listener reads all values + */ + KeyListener readDoubleArrayAction = new KeyListener() { + public void keyPressed(KeyEvent event) { + } + public void keyTyped(KeyEvent event) { + } + + public void keyReleased(KeyEvent event) { + double[] tmpT = m_EpsilonThreshhold.m_TargetValue; + double[] tmpP = m_EpsilonThreshhold.m_Punishment; + + for (int i = 0; i < tmpT.length; i++) { + + try { + double d = 0; + d = new Double(m_TargetTextField[i].getText()).doubleValue(); + tmpT[i] = d; + } catch (Exception e) { + + } + try { + double d = 0; + d = new Double(m_PunishTextField[i].getText()).doubleValue(); + tmpP[i] = d; + } catch (Exception e) { + + } + } + + m_EpsilonThreshhold.m_TargetValue = tmpT; + m_EpsilonThreshhold.m_Punishment = tmpP; + } + }; + + /** The object may have changed update the editor. + */ + private void updateEditor() { + if (this.m_CustomEditor != null) { + this.updateDataPanel(); + this.m_CustomEditor.validate(); + this.m_CustomEditor.repaint(); + } + } + + /** This method updates the data panel + */ + private void updateDataPanel() { + double[] tmpT = this.m_EpsilonThreshhold.m_TargetValue; + double[] tmpP = this.m_EpsilonThreshhold.m_Punishment; + int obj = this.m_EpsilonThreshhold.m_OptimizeObjective; + + this.m_DataPanel.removeAll(); + this.m_DataPanel.setLayout(new GridLayout(tmpT.length+1, 3)); + this.m_DataPanel.add(new JLabel()); + this.m_DataPanel.add(new JLabel("Target Value")); + this.m_DataPanel.add(new JLabel("Punishment")); + this.m_TargetTextField = new JTextField[tmpT.length]; + this.m_PunishTextField = new JTextField[tmpT.length]; + for (int i = 0; i < tmpT.length; i++) { + JLabel label = new JLabel("Objective "+i+": "); + this.m_DataPanel.add(label); + this.m_TargetTextField[i] = new JTextField(); + this.m_TargetTextField[i].setText(""+tmpT[i]); + this.m_TargetTextField[i].addKeyListener(this.readDoubleArrayAction); + this.m_DataPanel.add(this.m_TargetTextField[i]); + this.m_PunishTextField[i] = new JTextField(); + this.m_PunishTextField[i].setText(""+tmpP[i]); + this.m_PunishTextField[i].addKeyListener(this.readDoubleArrayAction); + this.m_DataPanel.add(this.m_PunishTextField[i]); + } + this.m_TargetTextField[obj].setEditable(false); + this.m_PunishTextField[obj].setEditable(false); + } + + + /** This method will set the value of object that is to be edited. + * @param o an object that must be an array. + */ + public void setValue(Object o) { + if (o instanceof PropertyEpsilonThreshold) { + this.m_EpsilonThreshhold = (PropertyEpsilonThreshold) o; + this.updateEditor(); + } + } + + /** Returns the current object. + * @return the current object + */ + public Object getValue() { + return this.m_EpsilonThreshhold; + } + + public String getJavaInitializationString() { + return "TEST"; + } + + /** + * + */ + public String getAsText() { + return null; + } + + /** + * + */ + public void setAsText(String text) throws IllegalArgumentException { + throw new IllegalArgumentException(text); + } + + /** + * + */ + public String[] getTags() { + return null; + } + + /** + * + */ + public void addPropertyChangeListener(PropertyChangeListener l) { + m_Support.addPropertyChangeListener(l); + } + + /** + * + */ + public void removePropertyChangeListener(PropertyChangeListener l) { + m_Support.removePropertyChangeListener(l); + } + + /** This is used to hook an action listener to the ok button + * @param a The action listener. + */ + public void addOkListener(ActionListener a) { + m_OKButton.addActionListener(a); + } + + /** This is used to remove an action listener from the ok button + * @param a The action listener + */ + public void removeOkListener(ActionListener a) { + m_OKButton.removeActionListener(a); + } + + /** Returns true since the Object can be shown + * @return true + */ + public boolean isPaintable() { + return true; + } + + /** Paints a representation of the current classifier. + * + * @param gfx the graphics context to use + * @param box the area we are allowed to paint into + */ + public void paintValue(Graphics gfx, Rectangle box) { + FontMetrics fm = gfx.getFontMetrics(); + int vpad = (box.height - fm.getAscent()) / 2; + String rep = "Edit Epsilon Threshhold"; + gfx.drawString(rep, 2, fm.getHeight() + vpad - 3 ); + } + + /** Returns true because we do support a custom editor. + * @return true + */ + public boolean supportsCustomEditor() { + return true; + } + + /** Returns the array editing component. + * @return a value of type 'java.awt.Component' + */ + public Component getCustomEditor() { + if (this.m_CustomEditor == null) this.initCustomEditor(); + return m_CustomEditor; + } +} \ No newline at end of file diff --git a/src/javaeva/gui/GenericFilePathEditor.java b/src/javaeva/gui/GenericFilePathEditor.java new file mode 100644 index 00000000..5539a981 --- /dev/null +++ b/src/javaeva/gui/GenericFilePathEditor.java @@ -0,0 +1,154 @@ +package javaeva.gui; + +import javax.swing.*; +import java.beans.PropertyEditor; +import java.beans.PropertyChangeSupport; +import java.beans.PropertyChangeListener; +import java.awt.*; +import java.awt.event.ActionListener; +import java.awt.event.ActionEvent; +import java.awt.event.ComponentListener; +import java.io.File; +import java.beans.PropertyChangeEvent; + +/** + * Created by IntelliJ IDEA. + * User: streiche + * Date: 28.08.2003 + * Time: 11:11:59 + * To change this template use Options | File Templates. + */ +public class GenericFilePathEditor extends JPanel implements PropertyEditor { + + /** Handles property change notification */ + private PropertyChangeSupport m_Support = new PropertyChangeSupport(this); + /** The label for when we can't edit that type */ + private JLabel m_Label = new JLabel("Can't edit", SwingConstants.CENTER); + /** The FilePath that is to be edited*/ + private PropertyFilePath m_FilePath; + + /** The gaphix stuff */ + private JFileChooser m_FileChooser; + private JPanel m_Panel; + + public GenericFilePathEditor() { + // compiled code + } + + /** This method will set the value of object that is to be edited. + * @param o an object that must be an array. + */ + public void setValue(Object o) { + if (o instanceof PropertyFilePath) { + this.m_FilePath = (PropertyFilePath) o; + } + } + + /** Returns the current object. + * @return the current object + */ + public Object getValue() { + return this.m_FilePath; + } + + public String getJavaInitializationString() { + return "TEST"; + } + + /** + * + */ + public String getAsText() { + return null; + } + + /** + * + */ + public void setAsText(String text) throws IllegalArgumentException { + throw new IllegalArgumentException(text); + } + + /** + * + */ + public String[] getTags() { + return null; + } + + /** + * + */ + public void addPropertyChangeListener(PropertyChangeListener l) { + m_Support.addPropertyChangeListener(l); + } + + /** + * + */ + public void removePropertyChangeListener(PropertyChangeListener l) { + m_Support.removePropertyChangeListener(l); + } + + /** Returns true since the Object can be shown + * @return true + */ + public boolean isPaintable() { + return true; + } + + /** Paints a representation of the current classifier. + * + * @param gfx the graphics context to use + * @param box the area we are allowed to paint into + */ + public void paintValue(Graphics gfx, Rectangle box) { + FontMetrics fm = gfx.getFontMetrics(); + int vpad = (box.height - fm.getAscent()) / 2; + String rep = this.m_FilePath.FileName; + gfx.drawString(rep, 2, fm.getHeight() + vpad - 3 ); + } + + /** Returns true because we do support a custom editor. + * @return true + */ + public boolean supportsCustomEditor() { + return true; + } + + /** Returns the array editing component. + * @return a value of type 'java.awt.Component' + */ + public Component getCustomEditor() { + this.m_Panel = new JPanel(); + this.m_FileChooser = new JFileChooser(); + File file = new File(this.m_FilePath.getCompleteFilePath()); + this.m_FileChooser.setSelectedFile(file); + this.m_FileChooser.setMultiSelectionEnabled(false); + this.m_Panel.add(this.m_FileChooser); + this.m_FileChooser.addActionListener(this.fileChooserAction); + return this.m_Panel; + } + + /** This action listener, called by the "train" button, causes + * the SOM to recalculate the mapping. + */ + ActionListener fileChooserAction = new ActionListener() { + public void actionPerformed(ActionEvent event) { + if (event.getActionCommand() == "ApproveSelection") { + m_FilePath.setCompleteFilePath(m_FileChooser.getSelectedFile().getAbsolutePath()); + m_Support.firePropertyChange("", m_FilePath, null); + Window w = (Window) m_FileChooser.getTopLevelAncestor(); + w.dispose(); + m_Panel = null; + } + if (event.getActionCommand() == "CancelSelection") { + m_FilePath.setCompleteFilePath(m_FileChooser.getSelectedFile().getAbsolutePath()); + m_Support.firePropertyChange("", m_FilePath, null); + Window w = (Window) m_FileChooser.getTopLevelAncestor(); + if (w != null) w.dispose(); + m_Panel = null; + } + } + }; +} diff --git a/src/javaeva/gui/GenericIntArrayEditor.java b/src/javaeva/gui/GenericIntArrayEditor.java new file mode 100644 index 00000000..ba35b9a6 --- /dev/null +++ b/src/javaeva/gui/GenericIntArrayEditor.java @@ -0,0 +1,225 @@ +package javaeva.gui; + +import javax.swing.*; +import java.beans.PropertyEditor; +import java.beans.PropertyChangeSupport; +import java.beans.PropertyChangeListener; +import java.awt.*; +import java.awt.event.ActionListener; +import java.awt.event.ActionEvent; +import java.awt.event.KeyListener; +import java.awt.event.KeyEvent; + +/** + * Created by IntelliJ IDEA. + * User: streiche + * Date: 12.09.2005 + * Time: 10:20:30 + * To change this template use File | Settings | File Templates. + */ +public class GenericIntArrayEditor extends JPanel implements PropertyEditor { + + /** Handles property change notification */ + private PropertyChangeSupport m_Support = new PropertyChangeSupport(this); + /** The label for when we can't edit that type */ + private JLabel m_Label = new JLabel("Can't edit", SwingConstants.CENTER); + /** The FilePath that is to be edited*/ + private PropertyIntArray m_IntArray; + + /** The gaphix stuff */ + private JPanel m_CustomEditor, m_DataPanel, m_ButtonPanel; + private JTextField[] m_InputTextField; + private JButton m_OKButton; + + public GenericIntArrayEditor() { + // compiled code + } + + /** This method will init the CustomEditor Panel + */ + private void initCustomEditor() { + this.m_CustomEditor = new JPanel(); + this.m_CustomEditor.setLayout(new BorderLayout()); + + this.m_CustomEditor.add(new JLabel("Current Int Array:"), BorderLayout.NORTH); + + // init data panel + this.m_DataPanel = new JPanel(); + this.updateDataPanel(); + this.m_CustomEditor.add(this.m_DataPanel, BorderLayout.CENTER); + + // init button panel + this.m_ButtonPanel = new JPanel(); + this.m_OKButton = new JButton("OK"); + this.m_OKButton.setEnabled(true); + this.m_OKButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + //m_Backup = copyObject(m_Object); + if ((m_CustomEditor.getTopLevelAncestor() != null) && (m_CustomEditor.getTopLevelAncestor() instanceof Window)) { + Window w = (Window) m_CustomEditor.getTopLevelAncestor(); + w.dispose(); + } + } + }); + this.m_ButtonPanel.add(this.m_OKButton); + this.m_CustomEditor.add(this.m_ButtonPanel, BorderLayout.SOUTH); + this.updateEditor(); + } + + /** This action listener reads all values + */ + KeyListener readIntArrayAction = new KeyListener() { + public void keyPressed(KeyEvent event) { + } + public void keyTyped(KeyEvent event) { + } + + public void keyReleased(KeyEvent event) { + int[] tmpD = new int[m_InputTextField.length]; + + for (int i = 0; i < tmpD.length; i++) { + try { + int d = 0; + d = new Integer(m_InputTextField[i].getText()).intValue(); + tmpD[i] = d; + } catch (Exception e) { + + } + } + m_IntArray.setIntArray(tmpD); + } + }; + + /** The object may have changed update the editor. + */ + private void updateEditor() { + if (this.m_CustomEditor != null) { + this.updateDataPanel(); + this.m_CustomEditor.validate(); + this.m_CustomEditor.repaint(); + } + } + + /** This method updates the data panel + */ + private void updateDataPanel() { + int[] tmpD = this.m_IntArray.getIntArray(); + + this.m_DataPanel.removeAll(); + this.m_DataPanel.setLayout(new GridLayout(tmpD.length, 2)); + this.m_InputTextField = new JTextField[tmpD.length]; + for (int i = 0; i < tmpD.length; i++) { + JLabel label = new JLabel("Value X"+i+": "); + this.m_DataPanel.add(label); + this.m_InputTextField[i] = new JTextField(); + this.m_InputTextField[i].setText(""+tmpD[i]); + this.m_InputTextField[i].addKeyListener(this.readIntArrayAction); + this.m_DataPanel.add(this.m_InputTextField[i]); + } + } + + + /** This method will set the value of object that is to be edited. + * @param o an object that must be an array. + */ + public void setValue(Object o) { + if (o instanceof PropertyIntArray) { + this.m_IntArray = (PropertyIntArray) o; + this.updateEditor(); + } + } + + /** Returns the current object. + * @return the current object + */ + public Object getValue() { + return this.m_IntArray; + } + + public String getJavaInitializationString() { + return "TEST"; + } + + /** + * + */ + public String getAsText() { + return null; + } + + /** + * + */ + public void setAsText(String text) throws IllegalArgumentException { + throw new IllegalArgumentException(text); + } + + /** + * + */ + public String[] getTags() { + return null; + } + + /** + * + */ + public void addPropertyChangeListener(PropertyChangeListener l) { + m_Support.addPropertyChangeListener(l); + } + + /** + * + */ + public void removePropertyChangeListener(PropertyChangeListener l) { + m_Support.removePropertyChangeListener(l); + } + + /** This is used to hook an action listener to the ok button + * @param a The action listener. + */ + public void addOkListener(ActionListener a) { + m_OKButton.addActionListener(a); + } + + /** This is used to remove an action listener from the ok button + * @param a The action listener + */ + public void removeOkListener(ActionListener a) { + m_OKButton.removeActionListener(a); + } + + /** Returns true since the Object can be shown + * @return true + */ + public boolean isPaintable() { + return true; + } + + /** Paints a representation of the current classifier. + * + * @param gfx the graphics context to use + * @param box the area we are allowed to paint into + */ + public void paintValue(Graphics gfx, Rectangle box) { + FontMetrics fm = gfx.getFontMetrics(); + int vpad = (box.height - fm.getAscent()) / 2; + String rep = "Edit int[]"; + gfx.drawString(rep, 2, fm.getHeight() + vpad - 3 ); + } + + /** Returns true because we do support a custom editor. + * @return true + */ + public boolean supportsCustomEditor() { + return true; + } + + /** Returns the array editing component. + * @return a value of type 'java.awt.Component' + */ + public Component getCustomEditor() { + if (this.m_CustomEditor == null) this.initCustomEditor(); + return m_CustomEditor; + } +} \ No newline at end of file diff --git a/src/javaeva/gui/GenericObjectEditor.java b/src/javaeva/gui/GenericObjectEditor.java new file mode 100644 index 00000000..7e35016f --- /dev/null +++ b/src/javaeva/gui/GenericObjectEditor.java @@ -0,0 +1,871 @@ +package javaeva.gui; +/* + * Title: JavaEvA + * Description: + * Copyright: Copyright (c) 2003 + * Company: University of Tuebingen, Computer Architecture + * @author Holger Ulmer, Felix Streichert, Hannes Planatscher + * @version: $Revision: 266 $ + * $Date: 2007-11-20 14:33:48 +0100 (Tue, 20 Nov 2007) $ + * $Author: mkron $ + */ + + +import java.beans.BeanInfo; +import java.beans.IntrospectionException; +import java.beans.Introspector; +import java.beans.MethodDescriptor; +import java.beans.PropertyDescriptor; + +import java.awt.*; +import java.awt.event.*; +import java.beans.PropertyEditor; +import java.beans.PropertyChangeSupport; +import java.beans.PropertyChangeListener; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyEditorManager; +import java.io.File; +import java.io.ObjectInputStream; +import java.io.BufferedInputStream; +import java.io.ObjectOutputStream; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.BufferedOutputStream; +import java.lang.reflect.Modifier; +import java.lang.reflect.Proxy; +import java.util.*; +import javax.swing.*; +import javax.swing.border.LineBorder; + +import wsi.ra.jproxy.RMIProxyLocal; + +//import wsi.ra.tool.DummyCategory; + +import javaeva.client.EvAClient; +import javaeva.tools.CompileAndLoad; +import javaeva.tools.EVAHELP; +import javaeva.tools.ReflectPackage; +import javaeva.tools.Tag; +import javaeva.tools.SelectedTag; +import javaeva.tools.Serializer; +import javaeva.server.stat.StatisticsParameter; +import javaeva.server.stat.StatisticsParameterImpl; + + +/*==========================================================================* + * CLASS DECLARATION + *==========================================================================*/ +public class GenericObjectEditor implements PropertyEditor { + static final public boolean TRACE = false; + + private Object m_Object; + private Object m_Backup; + private PropertyChangeSupport m_Support = new PropertyChangeSupport(this); + private Class m_ClassType; + private GOEPanel m_EditorComponent; + private boolean m_Enabled = true; + /** + * + */ + public class GOEPanel extends JPanel implements ItemListener { + /** The chooser component */ + private JComboBox m_ObjectChooser; + /** The component that performs classifier customization */ + private PropertySheetPanel m_ChildPropertySheet; + /** The model containing the list of names to select from */ + private DefaultComboBoxModel m_ObjectNames; + /** Open object from disk */ + private JButton m_OpenBut; + /** Save object to disk */ + private JButton m_SaveBut; + /** ok button */ + public JButton m_okBut; + /** cancel button */ + private JButton m_cancelBut; + /** edit source button */ +// private JButton m_editSourceBut; + /** The filechooser for opening and saving object files */ + private JFileChooser m_FileChooser; + /** Creates the GUI editor component */ + private Vector m_ClassesLongName; +// private String[] m_ClassesShortName; +// private SourceCodeEditor m_SourceCodeEditor; +// private PropertyDialog m_SourceCodeEditorFrame; + + /** + * + */ + public GOEPanel() { + //System.out.println("GOEPanel.Constructor !!"); + if (!(Proxy.isProxyClass(m_Object.getClass()))) m_Backup = copyObject(m_Object); + m_ObjectNames = new DefaultComboBoxModel(new String [0]); + m_ObjectChooser = new JComboBox(m_ObjectNames); + m_ObjectChooser.setEditable(false); + m_ChildPropertySheet = new PropertySheetPanel(); + m_ChildPropertySheet.addPropertyChangeListener( + new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent evt) { + m_Support.firePropertyChange("", m_Backup, m_Object); + } + }); + m_OpenBut = new JButton("Open..."); + m_OpenBut.setToolTipText("Load a configured object"); + m_OpenBut.setEnabled(true); + m_OpenBut.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + Object object = openObject(); + if (object != null) { + // setValue takes care of: Making sure obj is of right type, + // and firing property change. + setValue(object); + // Need a second setValue to get property values filled in OK. + // Not sure why. + setValue(object); // <- Hannes ?!?!? + } + } + }); + + m_SaveBut = new JButton("Save..."); + m_SaveBut.setToolTipText("Save the current configured object"); + m_SaveBut.setEnabled(true); + m_SaveBut.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + saveObject(m_Object); + } + }); +// +// m_editSourceBut = new JButton("Edit Source"); +// m_editSourceBut.setToolTipText("Edit the Source"); +// m_editSourceBut.setEnabled(false); +// m_editSourceBut.addActionListener(new ActionListener() { +// public void actionPerformed(ActionEvent e) { +// m_editSourceBut.setEnabled(false); +// m_SourceCodeEditor = new SourceCodeEditor(); +// String className = m_Object.getClass().getName(); +// m_SourceCodeEditor.editSource(EvAClient.DYNAMICCLASSES_PROPERTIES.getProperty(className)); +// m_SourceCodeEditorFrame = new PropertyDialog(m_SourceCodeEditor, "test", 50, 50); +// m_SourceCodeEditorFrame.pack(); +// m_SourceCodeEditorFrame.addWindowListener(new WindowAdapter() { +// public void windowClosing (WindowEvent e) { +// m_SourceCodeEditor = null; +// m_editSourceBut.setEnabled(true); +// } +// }); +// m_SourceCodeEditor.addPropertyChangeListener(new +// PropertyChangeListener() { +// public void propertyChange(PropertyChangeEvent evt) { +// sourceChanged(); +// } +// } +// ); +// } +// }); + + m_okBut = new JButton("OK"); + m_okBut.setEnabled(true); + m_okBut.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + m_Backup = copyObject(m_Object); + if ((getTopLevelAncestor() != null) && (getTopLevelAncestor() instanceof Window)) { + Window w = (Window) getTopLevelAncestor(); + w.dispose(); + } + } + }); + + m_cancelBut = new JButton("Cancel"); + m_cancelBut.setEnabled(false); + m_cancelBut.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + if (m_Backup != null) { + m_Object = copyObject(m_Backup); + setObject(m_Object); + updateClassType(); + updateChooser(); + updateChildPropertySheet(); + } + if ((getTopLevelAncestor() != null) + && (getTopLevelAncestor() instanceof Window)) { + Window w = (Window) getTopLevelAncestor(); + w.dispose(); + } + } + }); + + setLayout(new BorderLayout()); + add(m_ObjectChooser, BorderLayout.NORTH); // important + add(m_ChildPropertySheet, BorderLayout.CENTER); + // Since we resize to the size of the property sheet, a scrollpane isn't + // typically needed + // add(new JScrollPane(m_ChildPropertySheet), BorderLayout.CENTER); + + JPanel okcButs = new JPanel(); + okcButs.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); + okcButs.setLayout(new GridLayout(1, 4, 5, 5)); + okcButs.add(m_OpenBut); + okcButs.add(m_SaveBut); + okcButs.add(m_okBut); +// okcButs.add(m_editSourceBut); + //okcButs.add(m_cancelBut); + add(okcButs, BorderLayout.SOUTH); + + if (m_ClassType != null) { + updateClassType(); + updateChooser(); + updateChildPropertySheet(); + } + m_ObjectChooser.addItemListener(this); + } + + /** + * Opens an object from a file selected by the user. + * + * @return the loaded object, or null if the operation was cancelled + */ + protected Object openObject() { + if (m_FileChooser == null) { + createFileChooser(); + } + int returnVal = m_FileChooser.showOpenDialog(this); + if (returnVal == JFileChooser.APPROVE_OPTION) { + File selected = m_FileChooser.getSelectedFile(); + try { + ObjectInputStream oi = new ObjectInputStream(new BufferedInputStream(new FileInputStream(selected))); + Object obj = oi.readObject(); + oi.close(); + if (!m_ClassType.isAssignableFrom(obj.getClass())) { + throw new Exception("Object not of type: " + m_ClassType.getName()); + } + return obj; + } catch (Exception ex) { + JOptionPane.showMessageDialog(this, + "Couldn't read object: " + + selected.getName() + + "\n" + ex.getMessage(), + "Open object file", + JOptionPane.ERROR_MESSAGE); + } + } + return null; + } + + /** Saves the current object to a file selected by the user. + * @param object The object to save. + */ + protected void saveObject(Object object) { + + if (m_FileChooser == null) { + createFileChooser(); + } + int returnVal = m_FileChooser.showSaveDialog(this); + if (returnVal == JFileChooser.APPROVE_OPTION) { + File sFile = m_FileChooser.getSelectedFile(); + try { + ObjectOutputStream oo = new ObjectOutputStream(new BufferedOutputStream(new FileOutputStream(sFile))); + oo.writeObject(object); + oo.close(); + } catch (Exception ex) { + JOptionPane.showMessageDialog(this, + "Couldn't write to file: " + + sFile.getName() + + "\n" + ex.getMessage(), + "Save object", + JOptionPane.ERROR_MESSAGE); + } + } + } + protected void createFileChooser() { + m_FileChooser = new JFileChooser(new File("/resources")); + m_FileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); + } + + /** + * Makes a copy of an object using serialization + * @param source the object to copy + * @return a copy of the source object + */ + protected Object copyObject(Object source) { + Object result = null; + try { + SerializedObject so = new SerializedObject(source); + result = so.getObject(); + } catch (Exception ex) { + System.err.println("GenericObjectEditor: Problem making backup object"); + System.err.println(source.getClass().getName()); + ex.printStackTrace(); + } + return result; + } + + /** + * This is used to hook an action listener to the ok button + * @param a The action listener. + */ + public void addOkListener(ActionListener a) { + m_okBut.addActionListener(a); + } + + /** + * This is used to hook an action listener to the cancel button + * @param a The action listener. + */ + public void addCancelListener(ActionListener a) { + m_cancelBut.addActionListener(a); + } + + /** + * This is used to remove an action listener from the ok button + * @param a The action listener + */ + public void removeOkListener(ActionListener a) { + m_okBut.removeActionListener(a); + } + + /** + * This is used to remove an action listener from the cancel button + * @param a The action listener + */ + public void removeCancelListener(ActionListener a) { + m_cancelBut.removeActionListener(a); + } + /** + * + */ + protected void updateClassType() { + if (TRACE) System.out.println("# updating class "+m_ClassType.getName()); + + if (Proxy.isProxyClass(m_ClassType)) { + if (TRACE) System.out.println("PROXY! original was " + ((RMIProxyLocal)Proxy.getInvocationHandler(((Proxy)m_Object))).getOriginalClass().getName()); + m_ClassesLongName = new Vector(getClassesFromProperties(((RMIProxyLocal)Proxy.getInvocationHandler(((Proxy)m_Object))).getOriginalClass().getName())); + } else { + m_ClassesLongName = new Vector(getClassesFromProperties(m_ClassType.getName())); + } + m_ObjectChooser.setModel(new DefaultComboBoxModel(m_ClassesLongName)); + if (m_ClassesLongName.size() > 1) // testhu + add(m_ObjectChooser, BorderLayout.NORTH); + else + remove(m_ObjectChooser); + if (TRACE) System.out.println("# done updating class "+m_ClassType.getName()); + } + + protected void updateChooser() { + String objectName = /*EVAHELP.cutClassName*/ (m_Object.getClass().getName()); + boolean found = false; + for (int i = 0; i < m_ObjectNames.getSize(); i++) { + if (TRACE) System.out.println("in updateChooser: looking at "+(String)m_ObjectNames.getElementAt(i)); + if (objectName.equals((String)m_ObjectNames.getElementAt(i))) { + found = true; + break; + } + } + if (!found) + m_ObjectNames.addElement(objectName); + m_ObjectChooser.getModel().setSelectedItem(objectName); + } + + + /** Updates the child property sheet, and creates if needed */ + public void updateChildPropertySheet() { + //System.err.println("GOE::updateChildPropertySheet()"); + // Set the object as the target of the propertysheet + m_ChildPropertySheet.setTarget(m_Object); + // Adjust size of containing window if possible + if ((getTopLevelAncestor() != null) + && (getTopLevelAncestor() instanceof Window)) { + ((Window) getTopLevelAncestor()).pack(); + } + } + +// +// public void sourceChanged() { +// +// //System.out.println("SOURCESTATECHANGED!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! "); +// String className = (String) m_ObjectChooser.getSelectedItem(); +// +//// @todohannes: hack! ausbessern +// className = (String) m_ObjectChooser.getSelectedItem(); +// try { +// if (m_userdefclasses == true) { +// className = m_Object.getClass().getName(); +// Object[] para = new Object[] {}; +// Object n = (Object) CompileAndLoad.getInstanceFull( +// EvAClient.DYNAMICCLASSES_PROPERTIES.getProperty(className), +// className, +// para); +// setObject(n); +// } +// else { +// System.out.println("m_userdefclasses == false!!!!!"); +// } +// } +// catch (Exception ex) { +// } +// +// } + + + /** + * When the chooser selection is changed, ensures that the Object + * is changed appropriately. + * + * @param e a value of type 'ItemEvent' + */ + + public void itemStateChanged(ItemEvent e) { + String className = (String)m_ObjectChooser.getSelectedItem(); +// m_editSourceBut.setEnabled(false); +// @todohannes: hack! ausbessern +// try { +// if (EvAClient.DYNAMICCLASSES_PROPERTIES.containsKey(className) && m_userdefclasses) { +// m_editSourceBut.setEnabled(true); +// } +// } catch (Exception e1) { +// System.out.println("Fehler !!! " + e1); +// } + +// @todohannes: hack! ausbessern +// +// if (this.m_SourceCodeEditorFrame != null) { +// m_SourceCodeEditorFrame.setVisible(false); +// m_SourceCodeEditorFrame = null; +// m_SourceCodeEditor = null; +// } + + if (TRACE) System.out.println("Event-Quelle: " + e.getSource().toString()); + if ((e.getSource() == m_ObjectChooser) && (e.getStateChange() == ItemEvent.SELECTED)){ + className = (String)m_ObjectChooser.getSelectedItem(); + try { +// if (EvAClient.DYNAMICCLASSES_PROPERTIES.containsKey(className) && m_userdefclasses) { +// Object[] para = new Object[] {}; +// String source = EvAClient.DYNAMICCLASSES_PROPERTIES.getProperty(className); +// Object dummy = CompileAndLoad.getInstanceFull(source,className,para); +// setObject(dummy); +// } else { + if (TRACE) System.out.println(className); + Object n = (Object)Class.forName(className, true, ClassLoader.getSystemClassLoader()).newInstance(); + n = (Object)Class.forName(className).newInstance(); + setObject(n); +// } + } catch (Exception ex) { + System.out.println("Exeption in itemStateChanged "+ex.getMessage()); + ex.printStackTrace(); + m_ObjectChooser.hidePopup(); + m_ObjectChooser.setSelectedIndex(0); + JOptionPane.showMessageDialog(this, + "Could not create an example of\n" + + className + "\n" + + "from the current classpath. Is it abstract? Is the default constructor missing?", + "GenericObjectEditor", + JOptionPane.ERROR_MESSAGE); + EVAHELP.getSystemPropertyString(); + } + } + } + } // end of inner class + + /** + * Read the classes available for user selection from the properties or the classpath respectively + */ + public static ArrayList getClassesFromProperties(String className) { + if (TRACE) System.out.println("getClassesFromProperties - requesting className: "+className); + + // Try to read the predefined classes from the props file. + String typeOptions = EvAClient.getProperty(className); + if (typeOptions == null) { + // If none are defined, all assignable classes are searched the hard way, using the ReflectPackage + return getClassesFromClassPath(className); + } else { + StringTokenizer st = new StringTokenizer(typeOptions, ", "); + ArrayList classes = new ArrayList(); + while (st.hasMoreTokens()) { + String current = st.nextToken().trim(); + //System.out.println("current ="+current); + try { + Class.forName(current); // test for instantiability + classes.add(current); + } catch (Exception ex) { + System.err.println("Couldn't load class with name: " + current); + System.err.println("ex:"+ex.getMessage()); + ex.printStackTrace(); + } + } + return classes; + } + } + + public static ArrayList getClassesFromClassPath(String className) { + ArrayList classes = new ArrayList(); + int dotIndex = className.lastIndexOf('.'); + if (dotIndex <= 0) { + System.err.println("warning: " + className + " is not a package!"); + } else { + String pckg = className.substring(0, className.lastIndexOf('.')); + Class[] clsArr; + try { + clsArr = ReflectPackage.getAssignableClassesInPackage(pckg, Class.forName(className), true, true); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + clsArr = null; + } + if (clsArr == null) { + System.out.println("Warning: No configuration property found in: " + +EvAClient.EVA_PROPERTY_FILE + " "+"for "+className); + classes.add(className); + } else { + for (Class class1 : clsArr) { + int m = class1.getModifiers(); + if (!Modifier.isAbstract(m) && !class1.isInterface()) { // dont take abstract classes or interfaces + try { + Class[] params = new Class[0]; + class1.getConstructor(params); + classes.add(class1.getName()); + } catch (NoSuchMethodException e) { + System.err.println("GOE warning: Class " + class1.getName() + " has no default constructor, skipping..."); + } + } + } + } + } + return classes; + } + + /** + * Hide or show the editable property of a class, this makes sense for classes + * which are represented visually using the GenericObjectEditor. + * Returns false, if an error occurs, else true. + * An instance may call this statically on itself by means of this.getClass(). + * Actually this only sets the hidden property of the java bean which is checked in the + * wasModified method of PropertySheetPanel. + * + * @param cls class the property belongs to + * @param property string name of the property + * @param hide desired value to set, true for hidden, false for visible + * @return false, if an error occurs, else true + */ + public static boolean setExpertProperty(Class cls, String property, boolean expertValue) { + try { + BeanInfo bi = Introspector.getBeanInfo(cls); + PropertyDescriptor[] props = bi.getPropertyDescriptors(); + for (int i=0; i