diff options
Diffstat (limited to 'src/jcgp/gui')
-rw-r--r-- | src/jcgp/gui/GUI.java | 4 | ||||
-rw-r--r-- | src/jcgp/gui/settings/SettingsPane.java | 35 |
2 files changed, 34 insertions, 5 deletions
diff --git a/src/jcgp/gui/GUI.java b/src/jcgp/gui/GUI.java index 91c72e6..27d01b3 100644 --- a/src/jcgp/gui/GUI.java +++ b/src/jcgp/gui/GUI.java @@ -245,4 +245,8 @@ public class GUI extends Application { public Stage getStage() { return stage; } + + public void flushConsole() { + console.flush(); + } } 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(); + } } |