diff options
author | Eduardo Pedroni <ep625@york.ac.uk> | 2014-04-07 15:58:30 +0100 |
---|---|---|
committer | Eduardo Pedroni <ep625@york.ac.uk> | 2014-04-07 15:58:30 +0100 |
commit | 226365bd6a0f56143ffbce7379857ff3e126fbaf (patch) | |
tree | 4582b16a5519c94b121a369104157859dc97cba1 /src/jcgp/gui | |
parent | 67ace66f66ffaa00e1bd1495c0d406c801e59c5c (diff) |
Refactoring resources for (hopefully) the last time
Diffstat (limited to 'src/jcgp/gui')
-rw-r--r-- | src/jcgp/gui/GUI.java | 5 | ||||
-rw-r--r-- | src/jcgp/gui/console/GUIConsole.java | 5 | ||||
-rw-r--r-- | src/jcgp/gui/dragresize/HorizontalDragResize.java | 1 | ||||
-rw-r--r-- | src/jcgp/gui/dragresize/VerticalDragResize.java | 1 | ||||
-rw-r--r-- | src/jcgp/gui/population/ChromosomePane.java | 1 | ||||
-rw-r--r-- | src/jcgp/gui/settings/SettingsPane.java | 64 | ||||
-rw-r--r-- | src/jcgp/gui/settings/parameters/GUIDoubleParameter.java | 2 | ||||
-rw-r--r-- | src/jcgp/gui/settings/parameters/GUIIntegerParameter.java | 2 |
8 files changed, 47 insertions, 34 deletions
diff --git a/src/jcgp/gui/GUI.java b/src/jcgp/gui/GUI.java index 8f28884..eaca077 100644 --- a/src/jcgp/gui/GUI.java +++ b/src/jcgp/gui/GUI.java @@ -174,14 +174,15 @@ public class GUI extends Application { jcgp.reset(); populationPane.remakeTabs(jcgp.getPopulation(), jcgp.getResources()); settingsPane.revalidateParameters(); + settingsPane.updateControls(false, jcgp.isFinished()); console.flush(); } } private void runningMode(boolean value) { populationPane.setDisable(value); - settingsPane.runningMode(value); - + settingsPane.updateControls(value, jcgp.isFinished()); + if (value) { populationPane.unlockOutputs(); if (settingsPane.isResetRequired()) { diff --git a/src/jcgp/gui/console/GUIConsole.java b/src/jcgp/gui/console/GUIConsole.java index 694f1a5..55291aa 100644 --- a/src/jcgp/gui/console/GUIConsole.java +++ b/src/jcgp/gui/console/GUIConsole.java @@ -7,7 +7,7 @@ import jcgp.gui.GUI; public class GUIConsole extends AnchorPane implements Console { - private TextArea textArea = new TextArea("Welcome to JCGP!"); + private TextArea textArea = new TextArea("Welcome to JCGP!\n"); private StringBuffer printBuffer = new StringBuffer(); @@ -24,12 +24,11 @@ public class GUIConsole extends AnchorPane implements Console { setPrefHeight(GUI.CONSOLE_HEIGHT); getChildren().add(textArea); - } @Override public void println(String s) { - printBuffer.append("\n" + s); + printBuffer.append(s + "\n"); } @Override diff --git a/src/jcgp/gui/dragresize/HorizontalDragResize.java b/src/jcgp/gui/dragresize/HorizontalDragResize.java index d580878..3acfd4a 100644 --- a/src/jcgp/gui/dragresize/HorizontalDragResize.java +++ b/src/jcgp/gui/dragresize/HorizontalDragResize.java @@ -10,7 +10,6 @@ import jcgp.gui.GUI; * * http://andrewtill.blogspot.co.uk/2012/12/dragging-to-resize-javafx-region.html * - * @author eddy * */ public class HorizontalDragResize { diff --git a/src/jcgp/gui/dragresize/VerticalDragResize.java b/src/jcgp/gui/dragresize/VerticalDragResize.java index 32a7526..8d79a2e 100644 --- a/src/jcgp/gui/dragresize/VerticalDragResize.java +++ b/src/jcgp/gui/dragresize/VerticalDragResize.java @@ -10,7 +10,6 @@ import jcgp.gui.GUI; * * http://andrewtill.blogspot.co.uk/2012/12/dragging-to-resize-javafx-region.html * - * @author eddy * */ public class VerticalDragResize { diff --git a/src/jcgp/gui/population/ChromosomePane.java b/src/jcgp/gui/population/ChromosomePane.java index cba58d2..841c18a 100644 --- a/src/jcgp/gui/population/ChromosomePane.java +++ b/src/jcgp/gui/population/ChromosomePane.java @@ -63,7 +63,6 @@ public class ChromosomePane extends ScrollPane { } content.getChildren().addAll(guiNodes[r]); } - // outputs guiOutputs = new GUIOutput[resources.getInt("outputs")]; for (int i = 0; i < guiOutputs.length; i++) { diff --git a/src/jcgp/gui/settings/SettingsPane.java b/src/jcgp/gui/settings/SettingsPane.java index 5b23bdd..d7ffd79 100644 --- a/src/jcgp/gui/settings/SettingsPane.java +++ b/src/jcgp/gui/settings/SettingsPane.java @@ -17,7 +17,7 @@ import javafx.scene.text.Font; import javafx.scene.text.Text; import jcgp.JCGP; import jcgp.backend.function.FunctionSet; -import jcgp.backend.modules.ea.EvolutionaryAlgorithm; +import jcgp.backend.modules.es.EvolutionaryStrategy; import jcgp.backend.modules.fitness.Problem; import jcgp.backend.modules.mutator.Mutator; import jcgp.backend.resources.parameters.Parameter; @@ -103,26 +103,26 @@ public class SettingsPane extends AnchorPane { private void initialiseEAParameters(final JCGP cgp) { eaPane = new VBox(2); - Text header = new Text("Evolutionary Algorithm"); + Text header = new Text("Evolutionary Strategy"); header.setFont(Font.font("Arial", 14)); header.setUnderline(true); - final ComboBox<EvolutionaryAlgorithm> eaCBox = new ComboBox<EvolutionaryAlgorithm>(); - eaCBox.getItems().addAll(cgp.getEvolutionaryAlgorithms()); - eaCBox.getSelectionModel().select(cgp.getEvolutionaryAlgorithm()); + final ComboBox<EvolutionaryStrategy> eaCBox = new ComboBox<EvolutionaryStrategy>(); + eaCBox.getItems().addAll(cgp.getEvolutionaryStrategies()); + eaCBox.getSelectionModel().select(cgp.getEvolutionaryStrategy()); eaCBox.prefWidthProperty().bind(mainContainer.widthProperty()); final VBox eaParameters = new VBox(); eaParameters.setSpacing(2); - if (cgp.getEvolutionaryAlgorithm().getLocalParameters() != null) { - refreshParameters(cgp.getEvolutionaryAlgorithm().getLocalParameters(), eaParameters); + if (cgp.getEvolutionaryStrategy().getLocalParameters() != null) { + refreshParameters(cgp.getEvolutionaryStrategy().getLocalParameters(), eaParameters); } eaCBox.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { - cgp.setEvolutionaryAlgorithm(eaCBox.getSelectionModel().getSelectedIndex()); + cgp.setEvolutionaryStrategy(eaCBox.getSelectionModel().getSelectedIndex()); if (eaCBox.getSelectionModel().getSelectedItem().getLocalParameters() != null) { refreshParameters(eaCBox.getSelectionModel().getSelectedItem().getLocalParameters(), eaParameters); } @@ -147,7 +147,7 @@ public class SettingsPane extends AnchorPane { final VBox mutatorParameters = new VBox(); mutatorParameters.setSpacing(2); - if (cgp.getEvolutionaryAlgorithm().getLocalParameters() != null) { + if (cgp.getEvolutionaryStrategy().getLocalParameters() != null) { refreshParameters(cgp.getMutator().getLocalParameters(), mutatorParameters); } @@ -168,7 +168,7 @@ public class SettingsPane extends AnchorPane { private void initialiseProblemTypeParameters(final JCGP cgp, final GUI gui) { problemPane= new VBox(2); - Text header = new Text("Problem type"); + Text header = new Text("Problem Type"); header.setFont(Font.font("Arial", 14)); header.setUnderline(true); @@ -205,6 +205,10 @@ public class SettingsPane extends AnchorPane { } private void createControls(final JCGP cgp, final GUI gui) { + Text header = new Text("Experiment controls"); + header.setFont(Font.font("Arial", 14)); + header.setUnderline(true); + final VBox controls = new VBox(2); controls.setFillWidth(true); @@ -241,7 +245,7 @@ public class SettingsPane extends AnchorPane { HBox.setHgrow(reset, Priority.ALWAYS); reset.setMaxWidth(Double.MAX_VALUE); - controls.getChildren().add(flowButtons); + controls.getChildren().addAll(header, flowButtons); mainContainer.getChildren().add(controls); } @@ -255,7 +259,6 @@ public class SettingsPane extends AnchorPane { vb.getChildren().clear(); for (int i = 0; i < newParameters.length; i++) { GUIParameter gp = GUIParameter.create(newParameters[i], this); - parameters.add(gp); vb.getChildren().add(gp); } @@ -289,17 +292,17 @@ public class SettingsPane extends AnchorPane { - public void runningMode(boolean value) { - baseParameterPane.setDisable(value); - eaPane.setDisable(value); - mutatorPane.setDisable(value); - problemPane.setDisable(value); - step.setDisable(value); - reset.setDisable(value); - - runPause.setText(value ? "Pause" : "Run"); - } - +// public void runningMode(boolean value) { +// baseParameterPane.setDisable(value); +// eaPane.setDisable(value); +// mutatorPane.setDisable(value); +// problemPane.setDisable(value); +// step.setDisable(value); +// reset.setDisable(value); +// +// runPause.setText(value ? "Pause" : "Run"); +// } +// /** * * @return true if the experiment needs to be reset, false otherwise. @@ -335,6 +338,19 @@ public class SettingsPane extends AnchorPane { public void applyParameters() { for (GUIParameter parameter : parameters) { parameter.applyValue(); - } + } + } + + public void updateControls(boolean running, boolean finished) { + baseParameterPane.setDisable(running); + eaPane.setDisable(running); + mutatorPane.setDisable(running); + problemPane.setDisable(running); + + runPause.setText(running ? "Pause" : "Run"); + runPause.setDisable(finished); + step.setDisable(running || finished); + reset.setDisable(running); + } } diff --git a/src/jcgp/gui/settings/parameters/GUIDoubleParameter.java b/src/jcgp/gui/settings/parameters/GUIDoubleParameter.java index eecff2d..4a8e0e1 100644 --- a/src/jcgp/gui/settings/parameters/GUIDoubleParameter.java +++ b/src/jcgp/gui/settings/parameters/GUIDoubleParameter.java @@ -34,7 +34,7 @@ public class GUIDoubleParameter extends GUIParameter { name.wrappingWidthProperty().bind(widthProperty().divide(2)); - ((TextField) valueControl).setEditable(!parameter.isMonitor()); + ((TextField) valueControl).setDisable(parameter.isMonitor()); // bind if monitor, else set changelistener if (parameter.isMonitor()) { diff --git a/src/jcgp/gui/settings/parameters/GUIIntegerParameter.java b/src/jcgp/gui/settings/parameters/GUIIntegerParameter.java index 9c84c6a..204e7a2 100644 --- a/src/jcgp/gui/settings/parameters/GUIIntegerParameter.java +++ b/src/jcgp/gui/settings/parameters/GUIIntegerParameter.java @@ -34,7 +34,7 @@ public class GUIIntegerParameter extends GUIParameter { name.wrappingWidthProperty().bind(widthProperty().divide(2)); - ((TextField) valueControl).setEditable(!parameter.isMonitor()); + ((TextField) valueControl).setDisable(parameter.isMonitor()); // bind if monitor, else set listeners if (parameter.isMonitor()) { |