aboutsummaryrefslogtreecommitdiffstats
path: root/src/jcgp/gui/settings/parameters
diff options
context:
space:
mode:
Diffstat (limited to 'src/jcgp/gui/settings/parameters')
-rw-r--r--src/jcgp/gui/settings/parameters/GUIBooleanParameter.java7
-rw-r--r--src/jcgp/gui/settings/parameters/GUIDoubleParameter.java7
-rw-r--r--src/jcgp/gui/settings/parameters/GUIIntegerParameter.java5
-rw-r--r--src/jcgp/gui/settings/parameters/GUIParameter.java19
4 files changed, 18 insertions, 20 deletions
diff --git a/src/jcgp/gui/settings/parameters/GUIBooleanParameter.java b/src/jcgp/gui/settings/parameters/GUIBooleanParameter.java
index bada5d4..e708c53 100644
--- a/src/jcgp/gui/settings/parameters/GUIBooleanParameter.java
+++ b/src/jcgp/gui/settings/parameters/GUIBooleanParameter.java
@@ -6,7 +6,6 @@ import javafx.scene.control.CheckBox;
import javafx.scene.control.Control;
import jcgp.backend.resources.parameters.BooleanParameter;
import jcgp.backend.resources.parameters.ParameterStatus;
-import jcgp.gui.GUI;
import jcgp.gui.settings.SettingsPane;
/**
@@ -40,7 +39,7 @@ public class GUIBooleanParameter extends GUIParameter<Boolean> {
}
@Override
- protected void setControlListeners(final SettingsPane sp) {
+ protected void setControlListeners() {
/* pass the CheckBox value back to the parameter whenever it gets
* modified, provided the experiment isn't running */
checkBox.selectedProperty().addListener(new ChangeListener<Boolean>() {
@@ -48,9 +47,9 @@ public class GUIBooleanParameter extends GUIParameter<Boolean> {
public void changed(
ObservableValue<? extends Boolean> observable,
Boolean oldValue, Boolean newValue) {
- if (!GUI.isWorking()) {
+ if (!settingsPane.isExperimentRunning()) {
parameter.set(newValue);
- sp.revalidateParameters();
+ settingsPane.revalidateParameters();
}
}
});
diff --git a/src/jcgp/gui/settings/parameters/GUIDoubleParameter.java b/src/jcgp/gui/settings/parameters/GUIDoubleParameter.java
index 87e7b69..29648ca 100644
--- a/src/jcgp/gui/settings/parameters/GUIDoubleParameter.java
+++ b/src/jcgp/gui/settings/parameters/GUIDoubleParameter.java
@@ -9,7 +9,6 @@ import javafx.scene.control.TextField;
import javafx.scene.input.KeyEvent;
import jcgp.backend.resources.parameters.Parameter;
import jcgp.backend.resources.parameters.ParameterStatus;
-import jcgp.gui.GUI;
import jcgp.gui.settings.SettingsPane;
/**
@@ -44,7 +43,7 @@ public class GUIDoubleParameter extends GUIParameter<Number> {
}
@Override
- protected void setControlListeners(final SettingsPane sp) {
+ protected void setControlListeners() {
/* filter keypresses and ignore anything that is not a number
* and any decimal point beyond the first ones */
textField.addEventFilter(KeyEvent.KEY_TYPED, new EventHandler<KeyEvent>() {
@@ -63,9 +62,9 @@ public class GUIDoubleParameter extends GUIParameter<Number> {
public void changed(
ObservableValue<? extends String> observable,
String oldValue, String newValue) {
- if (!newValue.isEmpty() && !GUI.isWorking()) {
+ if (!newValue.isEmpty() && !settingsPane.isExperimentRunning()) {
parameter.set(Double.parseDouble(newValue));
- sp.revalidateParameters();
+ settingsPane.revalidateParameters();
}
}
diff --git a/src/jcgp/gui/settings/parameters/GUIIntegerParameter.java b/src/jcgp/gui/settings/parameters/GUIIntegerParameter.java
index 6927f26..da2c11f 100644
--- a/src/jcgp/gui/settings/parameters/GUIIntegerParameter.java
+++ b/src/jcgp/gui/settings/parameters/GUIIntegerParameter.java
@@ -9,7 +9,6 @@ import javafx.scene.control.TextField;
import javafx.scene.input.KeyEvent;
import jcgp.backend.resources.parameters.Parameter;
import jcgp.backend.resources.parameters.ParameterStatus;
-import jcgp.gui.GUI;
import jcgp.gui.settings.SettingsPane;
/**
@@ -44,7 +43,7 @@ public class GUIIntegerParameter extends GUIParameter<Number> {
}
@Override
- protected void setControlListeners(final SettingsPane settingsPane) {
+ protected void setControlListeners() {
/* filter keypresses and ignore anything that is not a number */
textField.addEventFilter(KeyEvent.KEY_TYPED, new EventHandler<KeyEvent>() {
@Override
@@ -62,7 +61,7 @@ public class GUIIntegerParameter extends GUIParameter<Number> {
public void changed(
ObservableValue<? extends String> observable,
String oldValue, String newValue) {
- if (!newValue.isEmpty() && !GUI.isWorking()) {
+ if (!newValue.isEmpty() && !settingsPane.isExperimentRunning()) {
parameter.set(Double.parseDouble(newValue));
settingsPane.revalidateParameters();
}
diff --git a/src/jcgp/gui/settings/parameters/GUIParameter.java b/src/jcgp/gui/settings/parameters/GUIParameter.java
index b7afb74..a8a8c4a 100644
--- a/src/jcgp/gui/settings/parameters/GUIParameter.java
+++ b/src/jcgp/gui/settings/parameters/GUIParameter.java
@@ -49,6 +49,7 @@ public abstract class GUIParameter<T> extends HBox {
private Text name;
private Control valueControl;
+ protected SettingsPane settingsPane;
protected Tooltip tooltip;
protected Parameter<T> parameter;
@@ -70,24 +71,24 @@ public abstract class GUIParameter<T> extends HBox {
* @param parameter a Parameter for which to generate a GUIParameter
* @param sp a reference to the SettingsPane
*/
- protected GUIParameter(Parameter<T> parameter, final SettingsPane sp) {
+ protected GUIParameter(Parameter<T> parameter, final SettingsPane settingsPane) {
this.parameter = parameter;
this.referenceValue = parameter.get();
+ this.settingsPane = settingsPane;
+
setAlignment(Pos.CENTER_LEFT);
setSpacing(5);
name = new Text(parameter.getName());
// set text width to half of the total width of the GUIParameter
name.wrappingWidthProperty().bind(widthProperty().divide(2));
- // allow the text to grow to always fill half of the GUIParameter
// 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.setSkin(null);
-
valueControl = makeControl();
setHgrow(valueControl, Priority.ALWAYS);
@@ -99,7 +100,7 @@ public abstract class GUIParameter<T> extends HBox {
// if parameter is not a monitor, make sure the control is constrained appropriately
if (!parameter.isMonitor()) {
- setControlListeners(sp);
+ setControlListeners();
}
getChildren().addAll(name, valueControl);
@@ -143,7 +144,7 @@ public abstract class GUIParameter<T> extends HBox {
ObservableValue<? extends Object> observable,
Object oldValue, Object newValue) {
// only do this if the experiment is running
- if (GUI.isWorking()) {
+ if (settingsPane.isExperimentRunning()) {
/* here's the catch - atomically get the lock state and set it to true
* the lock will only be false again when the runnable is finished executing,
* preventing multiple runnables to concurrently update the same GUIParameter
@@ -221,11 +222,11 @@ public abstract class GUIParameter<T> extends HBox {
* presses to ensure no invalid characters are inserted, applying the new
* value to the underlying parameter and revalidating the parameters to
* reflect the changes made.
- *
- * @param settingsPane the parent Pane on which revalidateParameters() should
- * be called.
+ * <br><br>
+ * Note that changelisteners registered to the main content property of the
+ * control should always call handleChange() to update the
*/
- protected abstract void setControlListeners(SettingsPane settingsPane);
+ protected abstract void setControlListeners();
/**
* This method is called to style the GUIParameter according to the status of