diff options
author | Eduardo Pedroni <ep625@york.ac.uk> | 2014-04-27 22:23:32 +0100 |
---|---|---|
committer | Eduardo Pedroni <ep625@york.ac.uk> | 2014-04-27 22:23:32 +0100 |
commit | e354311547a5a5f4d817e6af5b7df99813d66ecb (patch) | |
tree | 5cb822d55880815595bf1f306bcc81e45d1f631c /src/jcgp/gui/settings | |
parent | 4c8de2402f2878cde7587c7f3bbf4ffaea86efd4 (diff) |
Changing function set through GUI now triggers a reset if arity changes.
Diffstat (limited to 'src/jcgp/gui/settings')
-rw-r--r-- | src/jcgp/gui/settings/SettingsPane.java | 35 |
1 files changed, 30 insertions, 5 deletions
diff --git a/src/jcgp/gui/settings/SettingsPane.java b/src/jcgp/gui/settings/SettingsPane.java index 7fc5621..ba568a7 100644 --- a/src/jcgp/gui/settings/SettingsPane.java +++ b/src/jcgp/gui/settings/SettingsPane.java @@ -43,6 +43,8 @@ public class SettingsPane extends AnchorPane { private TestCaseTable testCaseTable; private GUI gui; + + private int currentArity; public SettingsPane(GUI gui) { super(); @@ -168,6 +170,8 @@ public class SettingsPane extends AnchorPane { } private void initialiseProblemTypeParameters(final JCGP jcgp, final GUI gui) { + updateArity(); + problemPane= new VBox(2); Text header = new Text("Problem Type"); @@ -207,6 +211,7 @@ public class SettingsPane extends AnchorPane { @Override public void handle(ActionEvent event) { jcgp.setProblem(problemCBox.getSelectionModel().getSelectedIndex()); + updateArity(); refreshParameters(jcgp.getProblem().getLocalParameters(), problemParameters); testCaseTable.close(); gui.setEvaluating(false); @@ -311,6 +316,7 @@ public class SettingsPane extends AnchorPane { gui.reDraw(); refreshFunctions(); } + gui.flushConsole(); } }); @@ -326,6 +332,7 @@ public class SettingsPane extends AnchorPane { gui.getExperiment().loadChromosome(chrFile, 0); gui.reDraw(); } + gui.flushConsole(); } }); saveChromosome.setOnAction(new EventHandler<ActionEvent>() { @@ -339,6 +346,7 @@ public class SettingsPane extends AnchorPane { if (chrFile != null) { gui.getExperiment().saveChromosome(chrFile, 0); } + gui.flushConsole(); } }); @@ -393,6 +401,7 @@ public class SettingsPane extends AnchorPane { fs.disableFunction(index); } gui.updateFunctionSelector(); + revalidateParameters(); } }); nodeFunctions.getChildren().add(cb); @@ -407,7 +416,7 @@ public class SettingsPane extends AnchorPane { /** * - * @return true if the experiment needs to be reset, false otherwise. + * @return true if the experiment needs to be reset, false if otherwise. */ public boolean isResetRequired() { for (GUIParameter<?> parameter : parameters) { @@ -415,6 +424,9 @@ public class SettingsPane extends AnchorPane { return true; } } + if (arityChanged()) { + return true; + } return false; } @@ -436,15 +448,19 @@ public class SettingsPane extends AnchorPane { * changed parameter. */ public void revalidateParameters() { - runPause.setDisable(false); - step.setDisable(false); + boolean disableControls = false; for (GUIParameter<?> parameter : parameters) { parameter.validate(); if (parameter.requiresReset()) { - runPause.setDisable(true); - step.setDisable(true); + disableControls = true; } } + if (arityChanged()) { + disableControls = true; + } + + runPause.setDisable(disableControls); + step.setDisable(disableControls); } /** @@ -455,6 +471,7 @@ public class SettingsPane extends AnchorPane { for (GUIParameter<?> parameter : parameters) { parameter.applyValue(); } + updateArity(); } /** @@ -498,4 +515,12 @@ public class SettingsPane extends AnchorPane { public TestCaseTable getTestCaseTable() { return testCaseTable; } + + private void updateArity() { + currentArity = gui.getExperiment().getProblem().getFunctionSet().getMaxArity(); + } + + private boolean arityChanged() { + return currentArity != gui.getExperiment().getProblem().getFunctionSet().getMaxArity(); + } } |