diff --git a/resources/html/GOParameters.html b/resources/html/OptimizationParameters.html
similarity index 100%
rename from resources/html/GOParameters.html
rename to resources/html/OptimizationParameters.html
diff --git a/src/eva2/gui/BeanInspector.java b/src/eva2/gui/BeanInspector.java
index 3a6c920c..6286e545 100644
--- a/src/eva2/gui/BeanInspector.java
+++ b/src/eva2/gui/BeanInspector.java
@@ -7,9 +7,11 @@ import eva2.tools.SelectedTag;
import eva2.tools.StringTools;
import eva2.tools.Tag;
import eva2.util.annotation.Description;
+import eva2.util.annotation.Parameter;
import java.beans.*;
import java.lang.reflect.Array;
+import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
@@ -994,6 +996,16 @@ public class BeanInspector {
String result = "";
String tipName = name + "TipText";
+ // Find by annotation
+ Parameter[] parameters= target.getClass().getAnnotationsByType(Parameter.class);
+ for (Field field : target.getClass().getDeclaredFields()) {
+ if (field.isAnnotationPresent(Parameter.class) && field.getName().equals(name)) {
+ Parameter parameter = field.getAnnotation(Parameter.class);
+ return parameter.description();
+ }
+ }
+
+ // Find by deprecated TipText method
for (int j = 0; j < methods.length; j++) {
String mname = methods[j].getDisplayName();
Method meth = methods[j].getMethod();
diff --git a/src/eva2/gui/Main.java b/src/eva2/gui/Main.java
index 9892a19b..d22f8ad9 100644
--- a/src/eva2/gui/Main.java
+++ b/src/eva2/gui/Main.java
@@ -1,14 +1,11 @@
package eva2.gui;
import eva2.EvAInfo;
+import eva2.optimization.modules.*;
import eva2.util.ClassPreloader;
import eva2.util.EvAComAdapter;
import eva2.optimization.OptimizationStateListener;
import eva2.optimization.go.InterfaceOptimizationParameters;
-import eva2.optimization.modules.AbstractModuleAdapter;
-import eva2.optimization.modules.GenericModuleAdapter;
-import eva2.optimization.modules.ModuleAdapter;
-import eva2.optimization.modules.OptimizationParameters;
import eva2.optimization.stat.AbstractStatistics;
import eva2.optimization.stat.InterfaceStatisticsListener;
import eva2.optimization.stat.InterfaceStatisticsParameter;
@@ -772,7 +769,8 @@ public class Main extends JFrame implements OptimizationStateListener {
ModuleAdapter newModuleAdapter = null;
//
try {
- newModuleAdapter = comAdapter.getModuleAdapter(selectedModule, optimizationParameters, withGUI ? null : "EvA2");
+ newModuleAdapter = new GOModuleAdapter(selectedModule, OptimizationParameters.getInstance(), withGUI ? null : "EvA2");
+ //newModuleAdapter = comAdapter.getModuleAdapter(selectedModule, optimizationParameters, withGUI ? null : "EvA2");
} catch (Exception e) {
LOGGER.log(Level.SEVERE, "Error loading module.", e);
EVAERROR.EXIT("Error while comAdapter.GetModuleAdapter Host: " + e.getMessage());
diff --git a/src/eva2/gui/PropertySheetPanel.java b/src/eva2/gui/PropertySheetPanel.java
index 84d78204..b28da3ee 100644
--- a/src/eva2/gui/PropertySheetPanel.java
+++ b/src/eva2/gui/PropertySheetPanel.java
@@ -8,9 +8,11 @@ import javax.swing.*;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableCellEditor;
import javax.swing.table.TableCellRenderer;
+import javax.swing.table.TableModel;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
+import java.awt.event.MouseEvent;
import java.beans.*;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
@@ -82,7 +84,7 @@ public class PropertySheetPanel extends JPanel implements PropertyChangeListener
*/
// If true, tool tips are used up to the first point only.
boolean stripToolTipToFirstPoint = false;
- private JTable propertyTable;
+ private ToolTipTable propertyTable;
private DefaultTableModel propertyTableModel;
/**
@@ -155,6 +157,38 @@ public class PropertySheetPanel extends JPanel implements PropertyChangeListener
return view;
}
+ /**
+ * JTable extended to show ToolTips
+ */
+ class ToolTipTable extends JTable {
+ private String[] toolTips;
+
+ public ToolTipTable(TableModel model) {
+ super(model);
+ }
+
+ public void setToolTips(String[] toolTips) {
+ this.toolTips = toolTips;
+ }
+
+ //Implement table cell tool tips.
+ public String getToolTipText(MouseEvent e) {
+ String tip = null;
+ java.awt.Point p = e.getPoint();
+ int rowIndex = rowAtPoint(p);
+
+ try {
+ if(this.toolTips != null && rowIndex <= this.toolTips.length){
+ tip = this.toolTips[rowIndex];
+ }
+ } catch (RuntimeException e1) {
+ //catch null pointer exception if mouse is over an empty line
+ }
+
+ return tip;
+ }
+ }
+
/**
* Sets a new target object for customisation.
*
@@ -164,7 +198,7 @@ public class PropertySheetPanel extends JPanel implements PropertyChangeListener
propertyTableModel = new DefaultTableModel();
propertyTableModel.addColumn("Key");
propertyTableModel.addColumn("Value");
- propertyTable = new JTable(propertyTableModel);
+ propertyTable = new ToolTipTable(propertyTableModel);
propertyTable.setDefaultRenderer(Object.class, new PropertyCellRenderer());
propertyTable.setDefaultEditor(Object.class, new PropertyCellEditor());
propertyTable.setRowHeight(20);
@@ -237,7 +271,7 @@ public class PropertySheetPanel extends JPanel implements PropertyChangeListener
propertyLabels = new JLabel[propertyDescriptors.length];
toolTips = new String[propertyDescriptors.length];
-
+ int itemIndex = 0;
for (int i = 0; i < propertyDescriptors.length; i++) {
// For each property do this
// Don't display hidden or expert properties.
@@ -253,8 +287,9 @@ public class PropertySheetPanel extends JPanel implements PropertyChangeListener
if (propertyEditors[i] == null) {
continue;
}
- toolTips[i] = BeanInspector.getToolTipText(name, methodDescriptors, targetObject, stripToolTipToFirstPoint, tipTextLineLen);
+ toolTips[itemIndex] = BeanInspector.getToolTipText(name, methodDescriptors, targetObject, stripToolTipToFirstPoint, tipTextLineLen);
+ itemIndex++;
newView = getView(propertyEditors[i]);
if (newView == null) {
System.err.println("Warning: Property \"" + name + "\" has non-displayabale editor. Skipping.");
@@ -272,6 +307,8 @@ public class PropertySheetPanel extends JPanel implements PropertyChangeListener
propertyTableModel.addRow(new Object[]{name, newView});
}
+ propertyTable.setToolTips(toolTips);
+
JScrollPane scrollableTable = new JScrollPane(propertyTable, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
gbConstraints.gridx = 0;
gbConstraints.gridy = 1;
@@ -359,27 +396,6 @@ public class PropertySheetPanel extends JPanel implements PropertyChangeListener
return values;
}
- /**
- * Create a label to be shown if no other properties are shown.
- *
- * @param componentOffset
- * @param gbLayout
- * @return
- */
- private JLabel createDummyLabel(int componentOffset, GridBagLayout gbLayout) {
- JLabel empty = new JLabel("No editable properties", SwingConstants.CENTER);
- Dimension d = empty.getPreferredSize();
- empty.setPreferredSize(new Dimension(d.width * 2, d.height * 2));
- empty.setBorder(BorderFactory.createEmptyBorder(10, 5, 0, 10));
- GridBagConstraints gbConstraints = new GridBagConstraints();
- gbConstraints.anchor = GridBagConstraints.CENTER;
- gbConstraints.fill = GridBagConstraints.HORIZONTAL;
- gbConstraints.gridy = componentOffset;
- gbConstraints.gridx = 0;
- gbLayout.setConstraints(empty, gbConstraints);
- return empty;
- }
-
private PropertyEditor makeEditor(PropertyDescriptor property, String name, Object value) {
PropertyEditor editor = PropertyEditorProvider.findEditor(property, value);
if (editor == null) {
@@ -397,67 +413,10 @@ public class PropertySheetPanel extends JPanel implements PropertyChangeListener
}
editor.setValue(value);
-// System.out.println("PSP editor class: " + editor.getClass());
-
editor.addPropertyChangeListener(this);
return editor;
}
- private void addLabelView(int componentOffset, GridBagLayout gbLayout,
- int i, String name, JComponent newView) {
-
- propertyLabels[i] = makeLabel(name);
- views[i] = newView;
- viewWrappers[i] = new JPanel();
- viewWrappers[i].setLayout(new BorderLayout());
-
- gbLayout.setConstraints(propertyLabels[i], makeLabelConstraints(i + componentOffset));
- add(propertyLabels[i]);
- JPanel newPanel = makeViewPanel(toolTips[i], propertyLabels[i], views[i], viewWrappers[i]);
- gbLayout.setConstraints(newPanel, makeViewConstraints(i + componentOffset));
- add(newPanel);
- }
-
- private JLabel makeLabel(String name) {
- JLabel label = new JLabel(name, SwingConstants.RIGHT);
- label.setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 5));
- return label;
- }
-
- private static JPanel makeViewPanel(String tipText, JLabel label,
- JComponent view, JComponent viewWrapper) {
- JPanel newPanel = new JPanel();
- if (tipText != null) {
- label.setToolTipText(tipText);
- view.setToolTipText(tipText);
- }
- newPanel.setBorder(BorderFactory.createEmptyBorder(10, 5, 0, 10));
- newPanel.setLayout(new BorderLayout());
- // @todo: Streiche here i could add the ViewWrapper
- viewWrapper.add(view, BorderLayout.CENTER);
- newPanel.add(viewWrapper, BorderLayout.CENTER);
- return newPanel;
- }
-
- private GridBagConstraints makeLabelConstraints(int componentIndex) {
- GridBagConstraints gbConstraints = new GridBagConstraints();
- gbConstraints.anchor = GridBagConstraints.EAST;
- gbConstraints.fill = GridBagConstraints.HORIZONTAL;
- gbConstraints.gridy = componentIndex;
- gbConstraints.gridx = 0;
- return gbConstraints;
- }
-
- private GridBagConstraints makeViewConstraints(int componentIndex) {
- GridBagConstraints gbConstraints = new GridBagConstraints();
- gbConstraints.anchor = GridBagConstraints.WEST;
- gbConstraints.fill = GridBagConstraints.BOTH;
- gbConstraints.gridy = componentIndex;
- gbConstraints.gridx = 1;
- gbConstraints.weightx = 100;
- return gbConstraints;
- }
-
/**
* Be sure to give a clone
*
@@ -543,8 +502,6 @@ public class PropertySheetPanel extends JPanel implements PropertyChangeListener
}
private JPanel makeInfoPanel(String infoText, Object targ, int rowHeight) {
- Object args[] = {};
-
className = targ.getClass().getName();
helpButton = new JButton("Help");
helpButton.setToolTipText("More information about " + className);
@@ -1038,9 +995,7 @@ class PropertyCellRenderer implements TableCellRenderer {
}
throw new UnsupportedOperationException("Not supported yet.");
-
}
-
}
class PropertyCellEditor extends AbstractCellEditor implements TableCellEditor {
diff --git a/src/eva2/optimization/modules/GOModuleAdapter.java b/src/eva2/optimization/modules/GOModuleAdapter.java
index 7f0b785d..5343a83d 100644
--- a/src/eva2/optimization/modules/GOModuleAdapter.java
+++ b/src/eva2/optimization/modules/GOModuleAdapter.java
@@ -23,8 +23,7 @@ public class GOModuleAdapter extends GenericModuleAdapter implements ModuleAdapt
/**
* Starts a statistics GUI and the GOProcessor thread.
*
- * @param AdapterName the title of the ModulAdapter
- * @param Client the client instance
+ * @param adapterName the title of the ModuleAdapter
*/
public GOModuleAdapter(String adapterName) {
super(adapterName, "", OptimizationParameters.getInstance(), false);
@@ -33,10 +32,11 @@ public class GOModuleAdapter extends GenericModuleAdapter implements ModuleAdapt
/**
* Starts a statistics GUI and the GOProcessor thread with a given OptimizationParameters file.
*
- * @param AdapterName the title of the ModulAdapter
- * @param Client the client instance
+ * @param adapterName the title of the ModuleAdapter
+ * @param optimizationParameters the client instance
+ * @param noGuiLogFile
*/
- public GOModuleAdapter(String adapterName, InterfaceOptimizationParameters goParams, String noGuiLogFile) {
- super(adapterName, "", goParams, false, noGuiLogFile);
+ public GOModuleAdapter(String adapterName, InterfaceOptimizationParameters optimizationParameters, String noGuiLogFile) {
+ super(adapterName, "", optimizationParameters, false, noGuiLogFile);
}
}
\ No newline at end of file
diff --git a/src/eva2/optimization/strategies/DifferentialEvolution.java b/src/eva2/optimization/strategies/DifferentialEvolution.java
index 5eacad1a..40b595c6 100644
--- a/src/eva2/optimization/strategies/DifferentialEvolution.java
+++ b/src/eva2/optimization/strategies/DifferentialEvolution.java
@@ -583,7 +583,7 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial
}
public void optimizeSteadyState() {
- AbstractEAIndividual indy = null, orig;
+ AbstractEAIndividual indy, orig;
int index;
int nextDoomed = getNextDoomed(population, 0);
@@ -591,7 +591,6 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial
// required for dynamic problems especially
optimizationProblem.evaluatePopulationStart(population);
-
/**
* Reevalutation mechanism for dynamically changing problems
*/
@@ -654,7 +653,7 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial
*
* @param pop Population to search
* @param startIndex index to start the search from
- * @return index of an overaged individual or -1
+ * @return index of an over aged individual or -1
*/
protected int getNextDoomed(Population pop, int startIndex) {
if (maximumAge > 0) {
@@ -689,12 +688,12 @@ public class DifferentialEvolution implements InterfaceOptimizer, java.io.Serial
/**
* Something has changed
*
- * @param name
+ * @param name Event name
*/
protected void firePropertyChangedEvent(String name) {
if (this.populationChangedEventListeners != null) {
- for (int i = 0; i < this.populationChangedEventListeners.size(); i++) {
- this.populationChangedEventListeners.get(i).registerPopulationStateChanged(this, name);
+ for (InterfacePopulationChangedEventListener listener : this.populationChangedEventListeners) {
+ listener.registerPopulationStateChanged(this, name);
}
}
}