Remove unneccesary EvA class prefixes from GUI classes.

This commit is contained in:
Fabian Becker 2015-12-10 12:22:51 +01:00
parent f08187d87f
commit e1301a38e8
9 changed files with 52 additions and 59 deletions

View File

@ -68,7 +68,7 @@ public class MainFrame extends JFrame implements OptimizationStateListener {
private long startTime = 0; private long startTime = 0;
private boolean withGUI = true; private boolean withGUI = true;
private boolean withTreeView = false; private boolean withTreeView = false;
private EvATabbedFrameMaker frameMaker = null; private TabbedFrameMaker frameMaker = null;
private Window parentWindow; private Window parentWindow;
private java.util.List<OptimizationStateListener> superListenerList = null; private java.util.List<OptimizationStateListener> superListenerList = null;
@ -719,7 +719,7 @@ public class MainFrame extends JFrame implements OptimizationStateListener {
newModuleAdapter.addOptimizationStateListener(this); newModuleAdapter.addOptimizationStateListener(this);
try { try {
if (withGUI) { if (withGUI) {
// this (or rather: EvAModuleButtonPanelMaker) is where the start button etc come from! // this (or rather: ModuleButtonPanelMaker) is where the start button etc come from!
frameMaker = newModuleAdapter.getModuleFrame(); frameMaker = newModuleAdapter.getModuleFrame();
/* This is the left TabPane on the main frame */ /* This is the left TabPane on the main frame */
@ -772,21 +772,21 @@ public class MainFrame extends JFrame implements OptimizationStateListener {
} }
/** /**
* Create a tree view of an object based on EvATreeNode. It is encapsulated * Create a tree view of an object based on TreeNode. It is encapsulated
* in a JScrollPane. * in a JScrollPane.
* *
* @param goPanel * @param goPanel
* @param title * @param title
* @param object * @param object
* @return * @return
* @see eva2.gui.EvATreeNode * @see TreeNode
*/ */
public JComponent getEvATreeView(JParaPanel goPanel, String title, Object object) { public JComponent getEvATreeView(JParaPanel goPanel, String title, Object object) {
EvATreeNode root = new EvATreeNode(title, object); // the root of the tree TreeNode root = new TreeNode(title, object); // the root of the tree
JTree jtree = new JTree(root); JTree jtree = new JTree(root);
JScrollPane treeView = new JScrollPane(jtree); JScrollPane treeView = new JScrollPane(jtree);
EvATreeSelectionListener treeListener = new EvATreeSelectionListener(root, goPanel.getEditor(), jtree); TreeSelectionListener treeListener = new TreeSelectionListener(root, goPanel.getEditor(), jtree);
// hooks itself up as the tree listener. It reacts both to changes in the selection // hooks itself up as the tree listener. It reacts both to changes in the selection
// state of the tree (to update the parameter panel) and to changes in the // state of the tree (to update the parameter panel) and to changes in the
// parameters to update the tree // parameters to update the tree

View File

@ -16,9 +16,9 @@ import java.util.logging.Logger;
* Contains the GUI elements of start and stop buttons and optionally a help * Contains the GUI elements of start and stop buttons and optionally a help
* button. * button.
*/ */
public class EvAModuleButtonPanelMaker implements OptimizationStateListener, Serializable, PanelMaker { public class ModuleButtonPanelMaker implements OptimizationStateListener, Serializable, PanelMaker {
private static final Logger LOGGER = Logger.getLogger(EvAModuleButtonPanelMaker.class.getName()); private static final Logger LOGGER = Logger.getLogger(ModuleButtonPanelMaker.class.getName());
private String name = "undefined"; private String name = "undefined";
private ModuleAdapter moduleAdapter; private ModuleAdapter moduleAdapter;
private boolean runningState; private boolean runningState;
@ -33,7 +33,7 @@ public class EvAModuleButtonPanelMaker implements OptimizationStateListener, Ser
/** /**
* *
*/ */
public EvAModuleButtonPanelMaker(ModuleAdapter adapter, boolean state) { public ModuleButtonPanelMaker(ModuleAdapter adapter, boolean state) {
name = "GENERAL"; name = "GENERAL";
runningState = state; runningState = state;
moduleAdapter = adapter; moduleAdapter = adapter;

View File

@ -220,7 +220,7 @@ public class OptimizationEditorPanel extends JPanel implements ItemListener {
} }
/** /**
* This method is duplicated from EvAModuleButtonPanelMaker. ToDo: Refactor * This method is duplicated from ModuleButtonPanelMaker. ToDo: Refactor
* this. * this.
* *
* @param iconSrc Source path of icon * @param iconSrc Source path of icon

View File

@ -15,16 +15,16 @@ import java.util.logging.Logger;
/** /**
* Produces the main EvA2 frame and a tool bar instance. * Produces the main EvA2 frame and a tool bar instance.
*/ */
public class EvATabbedFrameMaker implements Serializable, PanelMaker, InterfaceNotifyOnInformers { public class TabbedFrameMaker implements Serializable, PanelMaker, InterfaceNotifyOnInformers {
private static final Logger LOGGER = Logger.getLogger(EvATabbedFrameMaker.class.getName()); private static final Logger LOGGER = Logger.getLogger(TabbedFrameMaker.class.getName());
private static final long serialVersionUID = 2637376545826821423L; private static final long serialVersionUID = 2637376545826821423L;
private ArrayList<PanelMaker> pmContainer = null; private ArrayList<PanelMaker> pmContainer = null;
private JExtToolBar extToolBar; private JExtToolBar extToolBar;
EvAModuleButtonPanelMaker butPanelMkr = null; ModuleButtonPanelMaker butPanelMkr = null;
private JTabbedPane tabbedPane; private JTabbedPane tabbedPane;
public EvATabbedFrameMaker() { public TabbedFrameMaker() {
pmContainer = null; pmContainer = null;
} }
@ -59,9 +59,9 @@ public class EvATabbedFrameMaker implements Serializable, PanelMaker, InterfaceN
for (PanelMaker element : pmContainer) { for (PanelMaker element : pmContainer) {
JComponent panel = element.makePanel(); JComponent panel = element.makePanel();
if (element instanceof EvAModuleButtonPanelMaker) { if (element instanceof ModuleButtonPanelMaker) {
extToolBar.add(panel); extToolBar.add(panel);
butPanelMkr = (EvAModuleButtonPanelMaker) element; butPanelMkr = (ModuleButtonPanelMaker) element;
} else if (element instanceof JParaPanel) { } else if (element instanceof JParaPanel) {
tabbedPane.addTab(((JParaPanel) element).getName(), panel); tabbedPane.addTab(((JParaPanel) element).getName(), panel);
} }
@ -95,7 +95,7 @@ public class EvATabbedFrameMaker implements Serializable, PanelMaker, InterfaceN
if (butPanelMkr != null) { if (butPanelMkr != null) {
butPanelMkr.onUserStart(); butPanelMkr.onUserStart();
} else { } else {
System.err.println("Error: button panel was null (EvATabbedFrameMaker)"); System.err.println("Error: button panel was null (TabbedFrameMaker)");
} }
} }

View File

@ -13,10 +13,10 @@ import javax.swing.tree.DefaultMutableTreeNode;
* @see PropertySheetPanel * @see PropertySheetPanel
* @see eva2.optimization.OptimizationParameters * @see eva2.optimization.OptimizationParameters
*/ */
public class EvATreeNode extends DefaultMutableTreeNode { public class TreeNode extends DefaultMutableTreeNode {
private String[] childrenNames = null; private String[] childrenNames = null;
private Object[] childrenValues = null; private Object[] childrenValues = null;
private String myName = "EvATreeNode"; private String myName = "TreeNode";
private boolean doListPrimitives = false; private boolean doListPrimitives = false;
/** /**
@ -28,7 +28,7 @@ public class EvATreeNode extends DefaultMutableTreeNode {
* @param name title of the node * @param name title of the node
* @param target * @param target
*/ */
public EvATreeNode(String name, Object target) { public TreeNode(String name, Object target) {
super(target); super(target);
myName = name; myName = name;
setObject(target, true); setObject(target, true);
@ -67,7 +67,7 @@ public class EvATreeNode extends DefaultMutableTreeNode {
for (int i = 0; i < childrenValues.length; i++) { for (int i = 0; i < childrenValues.length; i++) {
if (childrenValues[i] != null) { if (childrenValues[i] != null) {
if (doListPrimitives || !(BeanInspector.isJavaPrimitive(childrenValues[i].getClass()))) { if (doListPrimitives || !(BeanInspector.isJavaPrimitive(childrenValues[i].getClass()))) {
super.add(new EvATreeNode(childrenNames[i], childrenValues[i])); super.add(new TreeNode(childrenNames[i], childrenValues[i]));
} }
} }
} }

View File

@ -2,7 +2,6 @@ package eva2.gui;
import javax.swing.*; import javax.swing.*;
import javax.swing.event.TreeSelectionEvent; import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
import javax.swing.tree.DefaultTreeModel; import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreePath; import javax.swing.tree.TreePath;
import java.awt.*; import java.awt.*;
@ -11,16 +10,16 @@ import java.beans.PropertyChangeListener;
import java.beans.PropertyEditor; import java.beans.PropertyEditor;
/** /**
* Listener for use with the EvATreeNode class. It implements both the tree selection listener * Listener for use with the TreeNode class. It implements both the tree selection listener
* to react to selection changes in the tree view (and update the parameter panel), * to react to selection changes in the tree view (and update the parameter panel),
* and the property change listener to * and the property change listener to
* react to changes in the parameters (and update the tree). * react to changes in the parameters (and update the tree).
* *
* @author mkron * @author mkron
*/ */
public class EvATreeSelectionListener implements TreeSelectionListener, PropertyChangeListener { public class TreeSelectionListener implements javax.swing.event.TreeSelectionListener, PropertyChangeListener {
private PropertyEditor goe = null; private PropertyEditor goe = null;
private EvATreeNode root = null; private TreeNode root = null;
private JTree jtree = null; private JTree jtree = null;
/** /**
@ -31,7 +30,7 @@ public class EvATreeSelectionListener implements TreeSelectionListener, Property
* @param goEditor the editor containing the parameter panel * @param goEditor the editor containing the parameter panel
* @param jt the GUI view of the tree * @param jt the GUI view of the tree
*/ */
public EvATreeSelectionListener(EvATreeNode rootNode, PropertyEditor goEditor, JTree jt) { public TreeSelectionListener(TreeNode rootNode, PropertyEditor goEditor, JTree jt) {
goe = goEditor; goe = goEditor;
root = rootNode; root = rootNode;
jtree = jt; jtree = jt;
@ -48,13 +47,13 @@ public class EvATreeSelectionListener implements TreeSelectionListener, Property
public void valueChanged(TreeSelectionEvent e) { public void valueChanged(TreeSelectionEvent e) {
TreePath tp = e.getPath(); TreePath tp = e.getPath();
EvATreeNode leafNode = (EvATreeNode) tp.getLastPathComponent(); TreeNode leafNode = (TreeNode) tp.getLastPathComponent();
Component editComp = goe.getCustomEditor(); Component editComp = goe.getCustomEditor();
if (editComp instanceof OptimizationEditorPanel) { if (editComp instanceof OptimizationEditorPanel) {
// update the object in the main OptimizationEditorPanel // update the object in the main OptimizationEditorPanel
((OptimizationEditorPanel) editComp).setTarget(leafNode.getUserObject()); ((OptimizationEditorPanel) editComp).setTarget(leafNode.getUserObject());
} else { } else {
System.err.println("Error, unable to notify custom editor of type " + editComp.getClass() + ", expected OptimizationEditorPanel (EvATreeSelectionListener)"); System.err.println("Error, unable to notify custom editor of type " + editComp.getClass() + ", expected OptimizationEditorPanel (TreeSelectionListener)");
} }
} }

View File

@ -1,8 +1,8 @@
package eva2.optimization.modules; package eva2.optimization.modules;
import eva2.gui.EvAModuleButtonPanelMaker; import eva2.gui.ModuleButtonPanelMaker;
import eva2.gui.EvATabbedFrameMaker; import eva2.gui.TabbedFrameMaker;
import eva2.gui.JParaPanel; import eva2.gui.JParaPanel;
import eva2.gui.editor.GenericObjectEditor; import eva2.gui.editor.GenericObjectEditor;
import eva2.optimization.InterfaceOptimizationParameters; import eva2.optimization.InterfaceOptimizationParameters;
@ -67,21 +67,21 @@ public class GenericModuleAdapter extends AbstractModuleAdapter implements Seria
* If the statistics are not of type StatisticsWithGUI, it is assumed that no GUI is * If the statistics are not of type StatisticsWithGUI, it is assumed that no GUI is
* desired (and this method should not be called). * desired (and this method should not be called).
* *
* @return the EvATabbedFrameMaker * @return the TabbedFrameMaker
* @see JParaPanel * @see JParaPanel
* @see EvAModuleButtonPanelMaker * @see ModuleButtonPanelMaker
* @see StatisticsWithGUI * @see StatisticsWithGUI
*/ */
@Override @Override
public EvATabbedFrameMaker getModuleFrame() { public TabbedFrameMaker getModuleFrame() {
if (!(statisticsModule instanceof StatisticsWithGUI)) { if (!(statisticsModule instanceof StatisticsWithGUI)) {
System.err.println("Error: Unable to create Frame when started with noGUI option (GenericModuleAdapter)!"); System.err.println("Error: Unable to create Frame when started with noGUI option (GenericModuleAdapter)!");
return null; return null;
} }
EvATabbedFrameMaker frmMkr = new EvATabbedFrameMaker(); TabbedFrameMaker frmMkr = new TabbedFrameMaker();
InterfaceStatisticsParameters Stat = statisticsModule.getStatisticsParameters(); InterfaceStatisticsParameters Stat = statisticsModule.getStatisticsParameters();
EvAModuleButtonPanelMaker buttonPanel = new EvAModuleButtonPanelMaker(remoteModuleAdapter, ((Processor) processor).isOptimizationRunning()); ModuleButtonPanelMaker buttonPanel = new ModuleButtonPanelMaker(remoteModuleAdapter, ((Processor) processor).isOptimizationRunning());
buttonPanel.setHelperFilename(helperFilename); buttonPanel.setHelperFilename(helperFilename);
frmMkr.addPanelMaker(buttonPanel); frmMkr.addPanelMaker(buttonPanel);
InterfaceOptimizationParameters optimizationParameters = ((Processor) processor).getOptimizationParameters(); InterfaceOptimizationParameters optimizationParameters = ((Processor) processor).getOptimizationParameters();

View File

@ -1,5 +1,5 @@
package eva2.optimization.modules; package eva2.optimization.modules;
import eva2.gui.EvATabbedFrameMaker; import eva2.gui.TabbedFrameMaker;
import eva2.optimization.OptimizationStateListener; import eva2.optimization.OptimizationStateListener;
import eva2.optimization.statistics.OptimizationJob; import eva2.optimization.statistics.OptimizationJob;
@ -8,7 +8,7 @@ import eva2.optimization.statistics.OptimizationJob;
*/ */
public interface ModuleAdapter extends OptimizationStateListener { public interface ModuleAdapter extends OptimizationStateListener {
EvATabbedFrameMaker getModuleFrame(); TabbedFrameMaker getModuleFrame();
void startOptimization(); // called from client void startOptimization(); // called from client

View File

@ -120,7 +120,7 @@ public class PostProcess {
* @param epsilon the threshold up to which an optimum is considered found. * @param epsilon the threshold up to which an optimum is considered found.
* @param bTakeFitter if true, the fitter of two close individuals is selected, otherwise the closer one * @param bTakeFitter if true, the fitter of two close individuals is selected, otherwise the closer one
* @return a Population of individuals corresponding to the given optima * @return a Population of individuals corresponding to the given optima
* @see getFoundOptimaArray(Population pop, Population optima, double epsilon, boolean bTakeFitter) * @see #getFoundOptimaArray(Population pop, Population optima, double epsilon, boolean bTakeFitter)
*/ */
public static Population getFoundOptima(Population pop, Population optima, double epsilon, boolean bTakeFitter) { public static Population getFoundOptima(Population pop, Population optima, double epsilon, boolean bTakeFitter) {
Population result = new Population(5); Population result = new Population(5);
@ -136,10 +136,10 @@ public class PostProcess {
} }
/** /**
* Calls clusterBest with a ClusteringDensitiyBased clustering object with the given sigma and a * Calls clusterBest with a ClusteringDensityBased clustering object with the given sigma and a
* minimum group size of 2. * minimum group size of 2.
* *
* @param pop * @param pop A population of possible solutions.
* @param sigmaCluster * @param sigmaCluster
* @param returnQuota * @param returnQuota
* @param lonerMode * @param lonerMode
@ -265,9 +265,9 @@ public class PostProcess {
* Returns shallow copies! * Returns shallow copies!
* *
* @param pop * @param pop
* @param fitNorm * @param fitThresh
* @param bSmaller if true, return individuals with lower or equal, else with higher fitness only * @param bSmallerEq if true, return individuals with lower or equal, else with higher fitness only
* @param crit index of the fitness criterion or -1 to use the norm * @param crit index of the fitness criterion or -1 to use the norm
* @return * @return
*/ */
public static Population filterFitness(Population pop, double fitThresh, boolean bSmallerEq, int crit) { public static Population filterFitness(Population pop, double fitThresh, boolean bSmallerEq, int crit) {
@ -363,8 +363,6 @@ public class PostProcess {
* @return the number of evaluations actually performed * @return the number of evaluations actually performed
*/ */
public static int processWithHC(Population pop, AbstractOptimizationProblem problem, int maxSteps, double stepSize, double minStepSize) { public static int processWithHC(Population pop, AbstractOptimizationProblem problem, int maxSteps, double stepSize, double minStepSize) {
// pop.setFunctionCalls(0); // or else optimization wont restart on an "old" population
// pop.setGeneration(0);
int stepsBef = pop.getFunctionCalls(); int stepsBef = pop.getFunctionCalls();
processWithHC(pop, problem, new EvaluationTerminator(pop.getFunctionCalls() + maxSteps), new MutateESMutativeStepSizeControl(stepSize, minStepSize, stepSize)); processWithHC(pop, problem, new EvaluationTerminator(pop.getFunctionCalls() + maxSteps), new MutateESMutativeStepSizeControl(stepSize, minStepSize, stepSize));
return pop.getFunctionCalls() - stepsBef; return pop.getFunctionCalls() - stepsBef;
@ -377,7 +375,7 @@ public class PostProcess {
* @param problem * @param problem
* @param maxSteps * @param maxSteps
* @return the number of evaluations actually performed * @return the number of evaluations actually performed
* @see processWithHC(Population pop, AbstractOptimizationProblem problem, int maxSteps, double stepSize, double minStepSize) * @see #processWithHC(Population pop, AbstractOptimizationProblem problem, int maxSteps, double stepSize, double minStepSize)
*/ */
public static int processWithHC(Population pop, AbstractOptimizationProblem problem, int maxSteps) { public static int processWithHC(Population pop, AbstractOptimizationProblem problem, int maxSteps) {
return processWithHC(pop, problem, maxSteps, defaultMutationStepSize, minMutationStepSize); return processWithHC(pop, problem, maxSteps, defaultMutationStepSize, minMutationStepSize);
@ -402,7 +400,6 @@ public class PostProcess {
System.err.println("warning: population size and vector size dont match! (PostProcess::processWithHC)"); System.err.println("warning: population size and vector size dont match! (PostProcess::processWithHC)");
} }
hc.setPopulation(pop); hc.setPopulation(pop);
// hc.initializeByPopulation(pop, false);
OptimizerRunnable ppRunnable = new OptimizerRunnable(OptimizerFactory.makeParams(hc, pop, problem, 0, term), true); OptimizerRunnable ppRunnable = new OptimizerRunnable(OptimizerFactory.makeParams(hc, pop, problem, 0, term), true);
runPP(ppRunnable); runPP(ppRunnable);
@ -528,7 +525,7 @@ public class PostProcess {
* @param initPerturbation * @param initPerturbation
* @param prob * @param prob
* @return * @return
* @see NelderMeadSimplex.createNMSPopulation(candidate, perturbRatio, range, includeCand) * @see NelderMeadSimplex#createNMSPopulation(candidate, perturbRatio, range, includeCand)
*/ */
public static Pair<AbstractEAIndividual, Integer> localSolverNMS(AbstractEAIndividual cand, int hcSteps, public static Pair<AbstractEAIndividual, Integer> localSolverNMS(AbstractEAIndividual cand, int hcSteps,
double initPerturbation, AbstractOptimizationProblem prob) { double initPerturbation, AbstractOptimizationProblem prob) {
@ -549,10 +546,10 @@ public class PostProcess {
* @param problem * @param problem
* @param candidates * @param candidates
* @param index index of the individual for which to produce the sub population * @param index index of the individual for which to produce the sub population
* @param maxPerturbation * @param maxRelativePerturbation
* @param includeCand * @param includeCand
* @see #createPopInSubRange(double, AbstractOptimizationProblem, AbstractEAIndividual) * @see #createPopInSubRange(double, AbstractOptimizationProblem, AbstractEAIndividual)
* @see #NelderMeadSimplex.createNMSPopulation(AbstractEAIndividual, double, double[][], boolean) * @see NelderMeadSimplex#createNMSPopulation(AbstractEAIndividual, double, double[][], boolean)
*/ */
public static Population createLSSupPopulation(PostProcessMethod method, AbstractOptimizationProblem problem, Population candidates, int index, double maxRelativePerturbation, boolean includeCand) { public static Population createLSSupPopulation(PostProcessMethod method, AbstractOptimizationProblem problem, Population candidates, int index, double maxRelativePerturbation, boolean includeCand) {
Population subPop = null; Population subPop = null;
@ -980,7 +977,6 @@ public class PostProcess {
* @param prob * @param prob
* @param hist * @param hist
* @param accuracy * @param accuracy
* @param maxPPEvalsPerIndy
* @return * @return
*/ */
public static Population clusterBestUpdateHistogram(Population pop, AbstractOptimizationProblem prob, SolutionHistogram hist, int crit, double accuracy) { public static Population clusterBestUpdateHistogram(Population pop, AbstractOptimizationProblem prob, SolutionHistogram hist, int crit, double accuracy) {
@ -1137,8 +1133,8 @@ public class PostProcess {
* @param treatAsUnknown * @param treatAsUnknown
* @param listener * @param listener
* @return * @return
* @see {@link AbstractOptimizationProblem.extractPotentialOptima} * @see {@link AbstractOptimizationProblem#extractPotentialOptima}
* @see AbstractOptimizationProblem.isPotentialOptimumNMS(AbstractEAIndividual, double, double, int) * @see AbstractOptimizationProblem#isPotentialOptimumNMS(AbstractEAIndividual, double, double, int)
*/ */
public static int[] checkAccuracy(AbstractOptimizationProblem prob, Population sols, double[] epsilonPhenoSpace, public static int[] checkAccuracy(AbstractOptimizationProblem prob, Population sols, double[] epsilonPhenoSpace,
double extrOptEpsFitConf, double extrOptClustSig, int maxEvals, SolutionHistogram[] solHists, boolean treatAsUnknown, double extrOptEpsFitConf, double extrOptClustSig, int maxEvals, SolutionHistogram[] solHists, boolean treatAsUnknown,
@ -1260,9 +1256,9 @@ public class PostProcess {
* In this case, return the third of the minimum distance to the next neighbor in the population. * In this case, return the third of the minimum distance to the next neighbor in the population.
* The maxPerturb can be given as upper bound of the perturbation if it is > 0. * The maxPerturb can be given as upper bound of the perturbation if it is > 0.
* *
* @param candidates population of solutions to look at * @param candidates population of solutions to look at
* @param i index of the individual in the population to look at * @param i index of the individual in the population to look at
* @param maxPerturb optional upper bound of the returned perturbation * @param maxAbsPerturb optional upper bound of the returned perturbation
* @return * @return
*/ */
public static double findNMSPerturb(Population candidates, int i, double maxAbsPerturb) { public static double findNMSPerturb(Population candidates, int i, double maxAbsPerturb) {
@ -1400,9 +1396,7 @@ public class PostProcess {
*/ */
public static void stopAllPP() { public static void stopAllPP() {
synchronized (ppRunnables) { synchronized (ppRunnables) {
for (OptimizerRunnable rnbl : ppRunnables) { ppRunnables.forEach(OptimizerRunnable::stopOpt);
rnbl.stopOpt();
}
} }
} }
} }