aboutsummaryrefslogtreecommitdiffstats
path: root/src/jcgp/gui/settings
diff options
context:
space:
mode:
authorEduardo Pedroni <ep625@york.ac.uk>2014-04-18 09:08:41 +0100
committerEduardo Pedroni <ep625@york.ac.uk>2014-04-18 09:08:41 +0100
commit88314e71f908efcfc38da3b800319c171a6ccceb (patch)
treedf42e3af2652dff815d1269bb81906a7af51e089 /src/jcgp/gui/settings
parente7d7e8506a511d78f9e323ac09587f79ad503f42 (diff)
Added parsers, did a bit of testing, switched to java8
Diffstat (limited to 'src/jcgp/gui/settings')
-rw-r--r--src/jcgp/gui/settings/SettingsPane.java59
-rw-r--r--src/jcgp/gui/settings/parameters/GUIParameter.java2
2 files changed, 42 insertions, 19 deletions
diff --git a/src/jcgp/gui/settings/SettingsPane.java b/src/jcgp/gui/settings/SettingsPane.java
index 2ab9650..4e8c342 100644
--- a/src/jcgp/gui/settings/SettingsPane.java
+++ b/src/jcgp/gui/settings/SettingsPane.java
@@ -1,5 +1,6 @@
package jcgp.gui.settings;
+import java.io.File;
import java.util.ArrayList;
import javafx.event.ActionEvent;
@@ -16,6 +17,8 @@ import javafx.scene.layout.Priority;
import javafx.scene.layout.VBox;
import javafx.scene.text.Font;
import javafx.scene.text.Text;
+import javafx.stage.FileChooser;
+import javafx.stage.FileChooser.ExtensionFilter;
import jcgp.JCGP;
import jcgp.backend.function.FunctionSet;
import jcgp.backend.modules.es.EvolutionaryStrategy;
@@ -31,6 +34,7 @@ public class SettingsPane extends AnchorPane {
private VBox mainContainer;
private VBox baseParameterPane, eaPane, mutatorPane, problemPane;
+ private VBox nodeFunctions;
private Button runPause = new Button("Run"), step = new Button("Step"), reset = new Button("Reset");
private Button loadParameters = new Button("Load parameters"), loadChromosome = new Button("Load chromosome"), saveChromosome = new Button("Save chromosome");
@@ -103,7 +107,7 @@ public class SettingsPane extends AnchorPane {
parameters.add(gp);
parameters.add(GUIParameter.create(jcgp.getResources().getSeedParameter(), this));
- parameters.add(GUIParameter.create(jcgp.getResources().getReportParameter(), this));
+ parameters.add(GUIParameter.create(jcgp.getResources().getReportIntervalParameter(), this));
baseParameterPane.getChildren().addAll(parameters);
mainContainer.getChildren().add(baseParameterPane);
@@ -201,10 +205,10 @@ public class SettingsPane extends AnchorPane {
testCaseTable = new TestCaseTable((TestCaseProblem<Object>) jcgp.getProblem(), gui);
}
- final VBox nodeFunctions = new VBox();
+ nodeFunctions = new VBox();
nodeFunctions.setSpacing(2);
nodeFunctions.setPadding(new Insets(0, 0, 4, 0));
- refreshFunctions(jcgp.getResources().getFunctionSet(), nodeFunctions, gui);
+ refreshFunctions();
problemCBox.setOnAction(new EventHandler<ActionEvent>() {
@Override
@@ -215,7 +219,7 @@ public class SettingsPane extends AnchorPane {
}
testCaseTable.close();
gui.setEvaluating(false);
- refreshFunctions(jcgp.getProblem().getFunctionSet(), nodeFunctions, gui);
+ refreshFunctions();
showTestCaseContainer.getChildren().clear();
if (jcgp.getProblem() instanceof TestCaseProblem) {
showTestCaseContainer.getChildren().add(showTestCaseButton);
@@ -284,14 +288,31 @@ public class SettingsPane extends AnchorPane {
loadParameters.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
- //gui.runPause();
+ FileChooser fc = new FileChooser();
+ fc.setTitle("Open .par file...");
+ fc.getExtensionFilters().add(new ExtensionFilter("CGP parameter files", "*.par"));
+ fc.getExtensionFilters().add(new ExtensionFilter("All files", "*.*"));
+ File parFile = fc.showOpenDialog(gui.getStage());
+ if (parFile != null) {
+ gui.getExperiment().loadParameters(parFile);
+ }
+ gui.reDraw();
+ refreshFunctions();
}
});
loadChromosome.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
- //gui.step();
+ FileChooser fc = new FileChooser();
+ fc.setTitle("Open .chr file...");
+ fc.getExtensionFilters().add(new ExtensionFilter("CGP chromosome files", "*.chr"));
+ fc.getExtensionFilters().add(new ExtensionFilter("All files", "*.*"));
+ File chrFile = fc.showOpenDialog(gui.getStage());
+ if (chrFile != null) {
+ gui.getExperiment().loadChromosome(chrFile);
+ }
+ gui.reDraw();
}
});
saveChromosome.setOnAction(new EventHandler<ActionEvent>() {
@@ -331,31 +352,28 @@ public class SettingsPane extends AnchorPane {
/**
* This method handles a problem type change by updating the list of allowed
* node functions.
- *
- * @param functionSet
- * @param container
- * @param gui
*/
- private void refreshFunctions(final FunctionSet functionSet, VBox container, final GUI gui) {
- container.getChildren().clear();
+ private void refreshFunctions() {
+ nodeFunctions.getChildren().clear();
CheckBox cb;
- for (int i = 0; i < functionSet.getTotalFunctionCount(); i++) {
- cb = new CheckBox(functionSet.getFunction(i).getName());
+ final FunctionSet fs = gui.getExperiment().getResources().getFunctionSet();
+ for (int i = 0; i < fs.getTotalFunctionCount(); i++) {
+ cb = new CheckBox(fs.getFunction(i).getName());
cb.setId(String.valueOf(i));
- cb.setSelected(functionSet.isEnabled(functionSet.getFunction(i)));
+ cb.setSelected(fs.isEnabled(fs.getFunction(i)));
final int index = i;
cb.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
if (((CheckBox) event.getSource()).isSelected()) {
- functionSet.enableFunction(index);
+ fs.enableFunction(index);
} else {
- functionSet.disableFunction(index);
+ fs.disableFunction(index);
}
gui.updateFunctionSelector();
}
});
- container.getChildren().add(cb);
+ nodeFunctions.getChildren().add(cb);
gui.updateFunctionSelector();
}
@@ -436,6 +454,11 @@ public class SettingsPane extends AnchorPane {
step.setDisable(running || finished);
reset.setDisable(running);
+ loadParameters.setDisable(running);
+ loadChromosome.setDisable(running);
+ saveChromosome.setDisable(running);
+
+
testCaseTable.getTable().setDisable(running);
}
diff --git a/src/jcgp/gui/settings/parameters/GUIParameter.java b/src/jcgp/gui/settings/parameters/GUIParameter.java
index a8a8c4a..159e709 100644
--- a/src/jcgp/gui/settings/parameters/GUIParameter.java
+++ b/src/jcgp/gui/settings/parameters/GUIParameter.java
@@ -86,7 +86,7 @@ public abstract class GUIParameter<T> extends HBox {
// the tooltip is the hover-over label containing status information, when appropriate
tooltip = new Tooltip();
- tooltip.setStyle("-fx-background-color: white; -fx-border-color: black; .page-corner {-fx-background-color: transparent;}");
+ tooltip.setStyle("-fx-background-color: white; -fx-border-color: black;");
tooltip.setSkin(null);
valueControl = makeControl();