aboutsummaryrefslogtreecommitdiffstats
path: root/src/jcgp/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/jcgp/gui')
-rw-r--r--src/jcgp/gui/GUI.java7
-rw-r--r--src/jcgp/gui/settings/SettingsPane.java12
-rw-r--r--src/jcgp/gui/settings/parameters/GUIBooleanParameter.java4
-rw-r--r--src/jcgp/gui/settings/parameters/GUIDoubleParameter.java4
-rw-r--r--src/jcgp/gui/settings/parameters/GUIIntegerParameter.java4
-rw-r--r--src/jcgp/gui/settings/parameters/GUIParameter.java28
-rw-r--r--src/jcgp/gui/settings/testcase/TestCaseTable.java15
7 files changed, 41 insertions, 33 deletions
diff --git a/src/jcgp/gui/GUI.java b/src/jcgp/gui/GUI.java
index 27d01b3..62a159c 100644
--- a/src/jcgp/gui/GUI.java
+++ b/src/jcgp/gui/GUI.java
@@ -59,7 +59,6 @@ public class GUI extends Application {
private Runnable consoleFlush;
public static void main(String[] args) {
- new GUI();
launch();
}
@@ -117,10 +116,14 @@ public class GUI extends Application {
*
*/
BorderPane leftFrame = new BorderPane();
+ BorderPane experimentLayer = new BorderPane();
populationPane = new PopulationPane(this);
settingsPane = new SettingsPane(this);
+ settingsPane.maxWidthProperty().bind(experimentLayer.widthProperty());
+
+ console.maxHeightProperty().bind(experimentLayer.heightProperty());
HorizontalDragResize.makeDragResizable(settingsPane);
VerticalDragResize.makeDragResizable(console);
@@ -128,8 +131,6 @@ public class GUI extends Application {
leftFrame.setCenter(populationPane);
leftFrame.setBottom(console);
- BorderPane experimentLayer = new BorderPane();
-
experimentLayer.setCenter(leftFrame);
experimentLayer.setRight(settingsPane);
diff --git a/src/jcgp/gui/settings/SettingsPane.java b/src/jcgp/gui/settings/SettingsPane.java
index ba568a7..e3d2096 100644
--- a/src/jcgp/gui/settings/SettingsPane.java
+++ b/src/jcgp/gui/settings/SettingsPane.java
@@ -24,7 +24,7 @@ import jcgp.backend.modules.es.EvolutionaryStrategy;
import jcgp.backend.modules.mutator.Mutator;
import jcgp.backend.modules.problem.Problem;
import jcgp.backend.modules.problem.TestCaseProblem;
-import jcgp.backend.resources.parameters.Parameter;
+import jcgp.backend.parameters.Parameter;
import jcgp.gui.GUI;
import jcgp.gui.settings.parameters.GUIParameter;
import jcgp.gui.settings.testcase.TestCaseTable;
@@ -213,7 +213,9 @@ public class SettingsPane extends AnchorPane {
jcgp.setProblem(problemCBox.getSelectionModel().getSelectedIndex());
updateArity();
refreshParameters(jcgp.getProblem().getLocalParameters(), problemParameters);
- testCaseTable.close();
+ if (testCaseTable != null) {
+ testCaseTable.close();
+ }
gui.setEvaluating(false);
refreshFunctions();
testCaseControlContainer.getChildren().clear();
@@ -366,12 +368,12 @@ public class SettingsPane extends AnchorPane {
* @param cgp
* @param vb
*/
- private void refreshParameters(Parameter<?>[] newParameters, VBox vb) {
+ private void refreshParameters(ArrayList<Parameter<?>> newParameters, VBox vb) {
parameters.removeAll(vb.getChildren());
vb.getChildren().clear();
if (newParameters != null) {
- for (int i = 0; i < newParameters.length; i++) {
- GUIParameter<?> gp = GUIParameter.create(newParameters[i], this);
+ for (int i = 0; i < newParameters.size(); i++) {
+ GUIParameter<?> gp = GUIParameter.create(newParameters.get(i), this);
parameters.add(gp);
vb.getChildren().add(gp);
}
diff --git a/src/jcgp/gui/settings/parameters/GUIBooleanParameter.java b/src/jcgp/gui/settings/parameters/GUIBooleanParameter.java
index cc7113d..eb669bb 100644
--- a/src/jcgp/gui/settings/parameters/GUIBooleanParameter.java
+++ b/src/jcgp/gui/settings/parameters/GUIBooleanParameter.java
@@ -4,8 +4,8 @@ import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.scene.control.CheckBox;
import javafx.scene.control.Control;
-import jcgp.backend.resources.parameters.BooleanParameter;
-import jcgp.backend.resources.parameters.ParameterStatus;
+import jcgp.backend.parameters.BooleanParameter;
+import jcgp.backend.parameters.ParameterStatus;
import jcgp.gui.settings.SettingsPane;
/**
diff --git a/src/jcgp/gui/settings/parameters/GUIDoubleParameter.java b/src/jcgp/gui/settings/parameters/GUIDoubleParameter.java
index 777e739..16a4cd4 100644
--- a/src/jcgp/gui/settings/parameters/GUIDoubleParameter.java
+++ b/src/jcgp/gui/settings/parameters/GUIDoubleParameter.java
@@ -7,8 +7,8 @@ import javafx.beans.value.ObservableValue;
import javafx.geometry.Pos;
import javafx.scene.control.Control;
import javafx.scene.control.TextField;
-import jcgp.backend.resources.parameters.Parameter;
-import jcgp.backend.resources.parameters.ParameterStatus;
+import jcgp.backend.parameters.Parameter;
+import jcgp.backend.parameters.ParameterStatus;
import jcgp.gui.settings.SettingsPane;
/**
diff --git a/src/jcgp/gui/settings/parameters/GUIIntegerParameter.java b/src/jcgp/gui/settings/parameters/GUIIntegerParameter.java
index 6e8b3f1..e8a9183 100644
--- a/src/jcgp/gui/settings/parameters/GUIIntegerParameter.java
+++ b/src/jcgp/gui/settings/parameters/GUIIntegerParameter.java
@@ -5,8 +5,8 @@ import javafx.beans.value.ObservableValue;
import javafx.geometry.Pos;
import javafx.scene.control.Control;
import javafx.scene.control.TextField;
-import jcgp.backend.resources.parameters.Parameter;
-import jcgp.backend.resources.parameters.ParameterStatus;
+import jcgp.backend.parameters.Parameter;
+import jcgp.backend.parameters.ParameterStatus;
import jcgp.gui.settings.SettingsPane;
/**
diff --git a/src/jcgp/gui/settings/parameters/GUIParameter.java b/src/jcgp/gui/settings/parameters/GUIParameter.java
index b675fb5..0a9149f 100644
--- a/src/jcgp/gui/settings/parameters/GUIParameter.java
+++ b/src/jcgp/gui/settings/parameters/GUIParameter.java
@@ -10,11 +10,11 @@ import javafx.scene.control.Control;
import javafx.scene.control.Label;
import javafx.scene.control.Tooltip;
import javafx.scene.layout.HBox;
-import jcgp.backend.resources.parameters.BooleanParameter;
-import jcgp.backend.resources.parameters.DoubleParameter;
-import jcgp.backend.resources.parameters.IntegerParameter;
-import jcgp.backend.resources.parameters.Parameter;
-import jcgp.backend.resources.parameters.ParameterStatus;
+import jcgp.backend.parameters.BooleanParameter;
+import jcgp.backend.parameters.DoubleParameter;
+import jcgp.backend.parameters.IntegerParameter;
+import jcgp.backend.parameters.Parameter;
+import jcgp.backend.parameters.ParameterStatus;
import jcgp.gui.GUI;
import jcgp.gui.settings.SettingsPane;
@@ -63,11 +63,13 @@ public abstract class GUIParameter<T> extends HBox {
private T referenceValue;
/**
- * This protected constructor contains the common elements to all GUIParameters
- * and should be invoked by any subclasses using super().
+ * This protected template constructor contains the common elements to all
+ * GUIParameters and should be invoked by any subclasses using super(). It
+ * defers the creation of the parameter {@code Control} object to the subclass
+ * currently being built (which in turn is defined by the factory method).
*
- * @param parameter a Parameter for which to generate a GUIParameter
- * @param sp a reference to the SettingsPane
+ * @param parameter a Parameter for which to generate a GUIParameter.
+ * @param sp a reference to the SettingsPane.
*/
protected GUIParameter(Parameter<T> parameter, final SettingsPane settingsPane) {
this.parameter = parameter;
@@ -78,7 +80,7 @@ public abstract class GUIParameter<T> extends HBox {
setAlignment(Pos.CENTER_LEFT);
setSpacing(5);
- name = new Label(parameter.getName());
+ name = new Label(parameter.toString());
// set text width to half of the total width of the GUIParameter
name.prefWidthProperty().bind(widthProperty().divide(2));
@@ -107,9 +109,9 @@ public abstract class GUIParameter<T> extends HBox {
* Use this to create an appropriate GUIParameter from any instance of Parameter,
* rather than manually downcasting the Parameter object every time.
*
- * @param parameter a Parameter for which to generate a GUIParameter
- * @param sp a reference to the SettingsPane
- * @return an appropriate instance of GUIParameter
+ * @param parameter a Parameter for which to generate a GUIParameter.
+ * @param sp a reference to the SettingsPane.
+ * @return an appropriate instance of GUIParameter.
*/
public static GUIParameter<?> create(Parameter<?> parameter, SettingsPane sp) {
if (parameter instanceof IntegerParameter) {
diff --git a/src/jcgp/gui/settings/testcase/TestCaseTable.java b/src/jcgp/gui/settings/testcase/TestCaseTable.java
index d7b2e2b..d4c1ff9 100644
--- a/src/jcgp/gui/settings/testcase/TestCaseTable.java
+++ b/src/jcgp/gui/settings/testcase/TestCaseTable.java
@@ -16,6 +16,7 @@ import javafx.stage.WindowEvent;
import javafx.util.Callback;
import jcgp.backend.modules.problem.TestCaseProblem;
import jcgp.backend.modules.problem.TestCaseProblem.TestCase;
+import jcgp.backend.resources.Resources;
import jcgp.gui.GUI;
/**
@@ -31,14 +32,16 @@ public class TestCaseTable extends Stage {
public TestCaseTable(final TestCaseProblem<Object> testCaseProblem, final GUI gui) {
super();
+ Resources resources = gui.getExperiment().getResources();
+
table = new TableView<TestCase<Object>>();
ObservableList<TestCase<Object>> testCaseList = testCaseProblem.getTestCases();
- ArrayList<TableColumn<TestCase<Object>, String>> inputs = new ArrayList<TableColumn<TestCase<Object>, String>>(testCaseProblem.getInputCount());
- ArrayList<TableColumn<TestCase<Object>, String>> outputs = new ArrayList<TableColumn<TestCase<Object>, String>>(testCaseProblem.getOutputCount());
+ ArrayList<TableColumn<TestCase<Object>, String>> inputs = new ArrayList<TableColumn<TestCase<Object>, String>>(resources.inputs());
+ ArrayList<TableColumn<TestCase<Object>, String>> outputs = new ArrayList<TableColumn<TestCase<Object>, String>>(resources.outputs());
TableColumn<TestCase<Object>, String> tc;
- for (int i = 0; i < testCaseProblem.getInputCount(); i++) {
+ for (int i = 0; i < resources.inputs(); i++) {
tc = new TableColumn<TestCase<Object>, String>("I: " + i);
inputs.add(tc);
final int index = i;
@@ -49,10 +52,10 @@ public class TestCaseTable extends Stage {
}
});
tc.setSortable(false);
- tc.prefWidthProperty().bind(table.widthProperty().divide(testCaseProblem.getInputCount() + testCaseProblem.getOutputCount()));
+ tc.prefWidthProperty().bind(table.widthProperty().divide(resources.inputs() + resources.outputs()));
}
- for (int o = 0; o < testCaseProblem.getOutputCount(); o++) {
+ for (int o = 0; o < resources.outputs(); o++) {
tc = new TableColumn<TestCase<Object>, String>("O: " + o);
outputs.add(tc);
final int index = o;
@@ -63,7 +66,7 @@ public class TestCaseTable extends Stage {
}
});
tc.setSortable(false);
- tc.prefWidthProperty().bind(table.widthProperty().divide(testCaseProblem.getInputCount() + testCaseProblem.getOutputCount()));
+ tc.prefWidthProperty().bind(table.widthProperty().divide(resources.inputs() + resources.outputs()));
}
table.getColumns().addAll(inputs);