From e1301a38e8f3d22d3a3eeee878ee489f2b7224d8 Mon Sep 17 00:00:00 2001 From: Fabian Becker Date: Thu, 10 Dec 2015 12:22:51 +0100 Subject: [PATCH] Remove unneccesary EvA class prefixes from GUI classes. --- src/eva2/gui/MainFrame.java | 12 +++--- ...Maker.java => ModuleButtonPanelMaker.java} | 6 +-- src/eva2/gui/OptimizationEditorPanel.java | 2 +- ...dFrameMaker.java => TabbedFrameMaker.java} | 14 +++---- .../gui/{EvATreeNode.java => TreeNode.java} | 8 ++-- ...stener.java => TreeSelectionListener.java} | 13 +++---- .../modules/GenericModuleAdapter.java | 14 +++---- .../optimization/modules/ModuleAdapter.java | 4 +- .../operator/postprocess/PostProcess.java | 38 ++++++++----------- 9 files changed, 52 insertions(+), 59 deletions(-) rename src/eva2/gui/{EvAModuleButtonPanelMaker.java => ModuleButtonPanelMaker.java} (95%) rename src/eva2/gui/{EvATabbedFrameMaker.java => TabbedFrameMaker.java} (95%) rename src/eva2/gui/{EvATreeNode.java => TreeNode.java} (89%) rename src/eva2/gui/{EvATreeSelectionListener.java => TreeSelectionListener.java} (78%) diff --git a/src/eva2/gui/MainFrame.java b/src/eva2/gui/MainFrame.java index 794e4067..4b8369b1 100644 --- a/src/eva2/gui/MainFrame.java +++ b/src/eva2/gui/MainFrame.java @@ -68,7 +68,7 @@ public class MainFrame extends JFrame implements OptimizationStateListener { private long startTime = 0; private boolean withGUI = true; private boolean withTreeView = false; - private EvATabbedFrameMaker frameMaker = null; + private TabbedFrameMaker frameMaker = null; private Window parentWindow; private java.util.List superListenerList = null; @@ -719,7 +719,7 @@ public class MainFrame extends JFrame implements OptimizationStateListener { newModuleAdapter.addOptimizationStateListener(this); try { 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(); /* 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. * * @param goPanel * @param title * @param object * @return - * @see eva2.gui.EvATreeNode + * @see TreeNode */ 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); 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 // state of the tree (to update the parameter panel) and to changes in the // parameters to update the tree diff --git a/src/eva2/gui/EvAModuleButtonPanelMaker.java b/src/eva2/gui/ModuleButtonPanelMaker.java similarity index 95% rename from src/eva2/gui/EvAModuleButtonPanelMaker.java rename to src/eva2/gui/ModuleButtonPanelMaker.java index 905bfbf2..9f9e141d 100644 --- a/src/eva2/gui/EvAModuleButtonPanelMaker.java +++ b/src/eva2/gui/ModuleButtonPanelMaker.java @@ -16,9 +16,9 @@ import java.util.logging.Logger; * Contains the GUI elements of start and stop buttons and optionally a help * 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 ModuleAdapter moduleAdapter; 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"; runningState = state; moduleAdapter = adapter; diff --git a/src/eva2/gui/OptimizationEditorPanel.java b/src/eva2/gui/OptimizationEditorPanel.java index b2e462cd..8662fdea 100644 --- a/src/eva2/gui/OptimizationEditorPanel.java +++ b/src/eva2/gui/OptimizationEditorPanel.java @@ -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. * * @param iconSrc Source path of icon diff --git a/src/eva2/gui/EvATabbedFrameMaker.java b/src/eva2/gui/TabbedFrameMaker.java similarity index 95% rename from src/eva2/gui/EvATabbedFrameMaker.java rename to src/eva2/gui/TabbedFrameMaker.java index 525c6270..83313a88 100644 --- a/src/eva2/gui/EvATabbedFrameMaker.java +++ b/src/eva2/gui/TabbedFrameMaker.java @@ -15,16 +15,16 @@ import java.util.logging.Logger; /** * 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 ArrayList pmContainer = null; private JExtToolBar extToolBar; - EvAModuleButtonPanelMaker butPanelMkr = null; + ModuleButtonPanelMaker butPanelMkr = null; private JTabbedPane tabbedPane; - public EvATabbedFrameMaker() { + public TabbedFrameMaker() { pmContainer = null; } @@ -59,9 +59,9 @@ public class EvATabbedFrameMaker implements Serializable, PanelMaker, InterfaceN for (PanelMaker element : pmContainer) { JComponent panel = element.makePanel(); - if (element instanceof EvAModuleButtonPanelMaker) { + if (element instanceof ModuleButtonPanelMaker) { extToolBar.add(panel); - butPanelMkr = (EvAModuleButtonPanelMaker) element; + butPanelMkr = (ModuleButtonPanelMaker) element; } else if (element instanceof JParaPanel) { tabbedPane.addTab(((JParaPanel) element).getName(), panel); } @@ -95,7 +95,7 @@ public class EvATabbedFrameMaker implements Serializable, PanelMaker, InterfaceN if (butPanelMkr != null) { butPanelMkr.onUserStart(); } else { - System.err.println("Error: button panel was null (EvATabbedFrameMaker)"); + System.err.println("Error: button panel was null (TabbedFrameMaker)"); } } diff --git a/src/eva2/gui/EvATreeNode.java b/src/eva2/gui/TreeNode.java similarity index 89% rename from src/eva2/gui/EvATreeNode.java rename to src/eva2/gui/TreeNode.java index ca43454f..ef9c6efb 100644 --- a/src/eva2/gui/EvATreeNode.java +++ b/src/eva2/gui/TreeNode.java @@ -13,10 +13,10 @@ import javax.swing.tree.DefaultMutableTreeNode; * @see PropertySheetPanel * @see eva2.optimization.OptimizationParameters */ -public class EvATreeNode extends DefaultMutableTreeNode { +public class TreeNode extends DefaultMutableTreeNode { private String[] childrenNames = null; private Object[] childrenValues = null; - private String myName = "EvATreeNode"; + private String myName = "TreeNode"; private boolean doListPrimitives = false; /** @@ -28,7 +28,7 @@ public class EvATreeNode extends DefaultMutableTreeNode { * @param name title of the node * @param target */ - public EvATreeNode(String name, Object target) { + public TreeNode(String name, Object target) { super(target); myName = name; setObject(target, true); @@ -67,7 +67,7 @@ public class EvATreeNode extends DefaultMutableTreeNode { for (int i = 0; i < childrenValues.length; i++) { if (childrenValues[i] != null) { if (doListPrimitives || !(BeanInspector.isJavaPrimitive(childrenValues[i].getClass()))) { - super.add(new EvATreeNode(childrenNames[i], childrenValues[i])); + super.add(new TreeNode(childrenNames[i], childrenValues[i])); } } } diff --git a/src/eva2/gui/EvATreeSelectionListener.java b/src/eva2/gui/TreeSelectionListener.java similarity index 78% rename from src/eva2/gui/EvATreeSelectionListener.java rename to src/eva2/gui/TreeSelectionListener.java index 84d0d399..0dc3fe88 100644 --- a/src/eva2/gui/EvATreeSelectionListener.java +++ b/src/eva2/gui/TreeSelectionListener.java @@ -2,7 +2,6 @@ package eva2.gui; import javax.swing.*; import javax.swing.event.TreeSelectionEvent; -import javax.swing.event.TreeSelectionListener; import javax.swing.tree.DefaultTreeModel; import javax.swing.tree.TreePath; import java.awt.*; @@ -11,16 +10,16 @@ import java.beans.PropertyChangeListener; 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), * and the property change listener to * react to changes in the parameters (and update the tree). * * @author mkron */ -public class EvATreeSelectionListener implements TreeSelectionListener, PropertyChangeListener { +public class TreeSelectionListener implements javax.swing.event.TreeSelectionListener, PropertyChangeListener { private PropertyEditor goe = null; - private EvATreeNode root = null; + private TreeNode root = null; private JTree jtree = null; /** @@ -31,7 +30,7 @@ public class EvATreeSelectionListener implements TreeSelectionListener, Property * @param goEditor the editor containing the parameter panel * @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; root = rootNode; jtree = jt; @@ -48,13 +47,13 @@ public class EvATreeSelectionListener implements TreeSelectionListener, Property public void valueChanged(TreeSelectionEvent e) { TreePath tp = e.getPath(); - EvATreeNode leafNode = (EvATreeNode) tp.getLastPathComponent(); + TreeNode leafNode = (TreeNode) tp.getLastPathComponent(); Component editComp = goe.getCustomEditor(); if (editComp instanceof OptimizationEditorPanel) { // update the object in the main OptimizationEditorPanel ((OptimizationEditorPanel) editComp).setTarget(leafNode.getUserObject()); } 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)"); } } diff --git a/src/eva2/optimization/modules/GenericModuleAdapter.java b/src/eva2/optimization/modules/GenericModuleAdapter.java index 1f5a55cd..e1491032 100644 --- a/src/eva2/optimization/modules/GenericModuleAdapter.java +++ b/src/eva2/optimization/modules/GenericModuleAdapter.java @@ -1,8 +1,8 @@ package eva2.optimization.modules; -import eva2.gui.EvAModuleButtonPanelMaker; -import eva2.gui.EvATabbedFrameMaker; +import eva2.gui.ModuleButtonPanelMaker; +import eva2.gui.TabbedFrameMaker; import eva2.gui.JParaPanel; import eva2.gui.editor.GenericObjectEditor; 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 * desired (and this method should not be called). * - * @return the EvATabbedFrameMaker + * @return the TabbedFrameMaker * @see JParaPanel - * @see EvAModuleButtonPanelMaker + * @see ModuleButtonPanelMaker * @see StatisticsWithGUI */ @Override - public EvATabbedFrameMaker getModuleFrame() { + public TabbedFrameMaker getModuleFrame() { if (!(statisticsModule instanceof StatisticsWithGUI)) { System.err.println("Error: Unable to create Frame when started with noGUI option (GenericModuleAdapter)!"); return null; } - EvATabbedFrameMaker frmMkr = new EvATabbedFrameMaker(); + TabbedFrameMaker frmMkr = new TabbedFrameMaker(); InterfaceStatisticsParameters Stat = statisticsModule.getStatisticsParameters(); - EvAModuleButtonPanelMaker buttonPanel = new EvAModuleButtonPanelMaker(remoteModuleAdapter, ((Processor) processor).isOptimizationRunning()); + ModuleButtonPanelMaker buttonPanel = new ModuleButtonPanelMaker(remoteModuleAdapter, ((Processor) processor).isOptimizationRunning()); buttonPanel.setHelperFilename(helperFilename); frmMkr.addPanelMaker(buttonPanel); InterfaceOptimizationParameters optimizationParameters = ((Processor) processor).getOptimizationParameters(); diff --git a/src/eva2/optimization/modules/ModuleAdapter.java b/src/eva2/optimization/modules/ModuleAdapter.java index 39d30fce..e5d89095 100644 --- a/src/eva2/optimization/modules/ModuleAdapter.java +++ b/src/eva2/optimization/modules/ModuleAdapter.java @@ -1,5 +1,5 @@ package eva2.optimization.modules; -import eva2.gui.EvATabbedFrameMaker; +import eva2.gui.TabbedFrameMaker; import eva2.optimization.OptimizationStateListener; import eva2.optimization.statistics.OptimizationJob; @@ -8,7 +8,7 @@ import eva2.optimization.statistics.OptimizationJob; */ public interface ModuleAdapter extends OptimizationStateListener { - EvATabbedFrameMaker getModuleFrame(); + TabbedFrameMaker getModuleFrame(); void startOptimization(); // called from client diff --git a/src/eva2/optimization/operator/postprocess/PostProcess.java b/src/eva2/optimization/operator/postprocess/PostProcess.java index 525d04eb..d81bc581 100644 --- a/src/eva2/optimization/operator/postprocess/PostProcess.java +++ b/src/eva2/optimization/operator/postprocess/PostProcess.java @@ -120,7 +120,7 @@ public class PostProcess { * @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 * @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) { 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. * - * @param pop + * @param pop A population of possible solutions. * @param sigmaCluster * @param returnQuota * @param lonerMode @@ -265,9 +265,9 @@ public class PostProcess { * Returns shallow copies! * * @param pop - * @param fitNorm - * @param bSmaller 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 fitThresh + * @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 * @return */ 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 */ 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(); processWithHC(pop, problem, new EvaluationTerminator(pop.getFunctionCalls() + maxSteps), new MutateESMutativeStepSizeControl(stepSize, minStepSize, stepSize)); return pop.getFunctionCalls() - stepsBef; @@ -377,7 +375,7 @@ public class PostProcess { * @param problem * @param maxSteps * @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) { 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)"); } hc.setPopulation(pop); -// hc.initializeByPopulation(pop, false); OptimizerRunnable ppRunnable = new OptimizerRunnable(OptimizerFactory.makeParams(hc, pop, problem, 0, term), true); runPP(ppRunnable); @@ -528,7 +525,7 @@ public class PostProcess { * @param initPerturbation * @param prob * @return - * @see NelderMeadSimplex.createNMSPopulation(candidate, perturbRatio, range, includeCand) + * @see NelderMeadSimplex#createNMSPopulation(candidate, perturbRatio, range, includeCand) */ public static Pair localSolverNMS(AbstractEAIndividual cand, int hcSteps, double initPerturbation, AbstractOptimizationProblem prob) { @@ -549,10 +546,10 @@ public class PostProcess { * @param problem * @param candidates * @param index index of the individual for which to produce the sub population - * @param maxPerturbation + * @param maxRelativePerturbation * @param includeCand * @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) { Population subPop = null; @@ -980,7 +977,6 @@ public class PostProcess { * @param prob * @param hist * @param accuracy - * @param maxPPEvalsPerIndy * @return */ public static Population clusterBestUpdateHistogram(Population pop, AbstractOptimizationProblem prob, SolutionHistogram hist, int crit, double accuracy) { @@ -1137,8 +1133,8 @@ public class PostProcess { * @param treatAsUnknown * @param listener * @return - * @see {@link AbstractOptimizationProblem.extractPotentialOptima} - * @see AbstractOptimizationProblem.isPotentialOptimumNMS(AbstractEAIndividual, double, double, int) + * @see {@link AbstractOptimizationProblem#extractPotentialOptima} + * @see AbstractOptimizationProblem#isPotentialOptimumNMS(AbstractEAIndividual, double, double, int) */ public static int[] checkAccuracy(AbstractOptimizationProblem prob, Population sols, double[] epsilonPhenoSpace, 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. * The maxPerturb can be given as upper bound of the perturbation if it is > 0. * - * @param candidates population of solutions 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 candidates population of solutions to look at + * @param i index of the individual in the population to look at + * @param maxAbsPerturb optional upper bound of the returned perturbation * @return */ public static double findNMSPerturb(Population candidates, int i, double maxAbsPerturb) { @@ -1400,9 +1396,7 @@ public class PostProcess { */ public static void stopAllPP() { synchronized (ppRunnables) { - for (OptimizerRunnable rnbl : ppRunnables) { - rnbl.stopOpt(); - } + ppRunnables.forEach(OptimizerRunnable::stopOpt); } } }