diff options
author | Eduardo Pedroni <ep625@york.ac.uk> | 2014-03-31 20:32:59 +0100 |
---|---|---|
committer | Eduardo Pedroni <ep625@york.ac.uk> | 2014-03-31 20:32:59 +0100 |
commit | a757deacded0d7357a9f68462d3f2051e16004ee (patch) | |
tree | 4706e867ed7686a155f0c8ee16ffb3eeb74daac4 /src/jcgp/gui/settings/parameters | |
parent | 04b35ccdad6e18701ede823e333118b0b22907c2 (diff) |
Need to do a few tests on windows
Diffstat (limited to 'src/jcgp/gui/settings/parameters')
4 files changed, 167 insertions, 0 deletions
diff --git a/src/jcgp/gui/settings/parameters/GUIBooleanParameter.java b/src/jcgp/gui/settings/parameters/GUIBooleanParameter.java new file mode 100644 index 0000000..a9f6753 --- /dev/null +++ b/src/jcgp/gui/settings/parameters/GUIBooleanParameter.java @@ -0,0 +1,40 @@ +package jcgp.gui.settings.parameters; + +import javafx.scene.control.CheckBox; +import jcgp.parameters.BooleanParameter; + +public class GUIBooleanParameter extends GUIParameter { + + public GUIBooleanParameter(BooleanParameter parameter) { + super(); + + this.parameter = parameter; + + value = new CheckBox(parameter.getName()); + ((CheckBox) value).setSelected(parameter.get()); + + value.setDisable(!parameter.isEditable()); + + getChildren().add(value); + + } + +// @Override +// public void doBindings() { +// ((CheckBox) value).selectedProperty().bind(((BooleanParameter) parameter).valueProperty()); +// } +// +// @Override +// public void undoBindings() { +// ((CheckBox) value).selectedProperty().unbind(); +// } + + @Override + public void refreshValue() { + if (!((CheckBox) value).selectedProperty().isBound()) { + ((CheckBox) value).setSelected(((BooleanParameter) parameter).get()); + } + + } + +} diff --git a/src/jcgp/gui/settings/parameters/GUIDoubleParameter.java b/src/jcgp/gui/settings/parameters/GUIDoubleParameter.java new file mode 100644 index 0000000..25d5b9f --- /dev/null +++ b/src/jcgp/gui/settings/parameters/GUIDoubleParameter.java @@ -0,0 +1,48 @@ +package jcgp.gui.settings.parameters; + +import javafx.geometry.Pos; +import javafx.scene.control.TextField; +import javafx.scene.layout.Priority; +import javafx.scene.text.Text; +import jcgp.GUI; +import jcgp.parameters.DoubleParameter; + +public class GUIDoubleParameter extends GUIParameter { + + public GUIDoubleParameter(DoubleParameter parameter) { + super(); + + this.parameter = parameter; + + name = new Text(parameter.getName()); + value = new TextField(String.valueOf(parameter.get())); + + ((TextField) value).setAlignment(Pos.CENTER_RIGHT); + + setHgrow(value, Priority.ALWAYS); + + name.setWrappingWidth(GUI.WRAP_WIDTH); + + ((TextField) value).setEditable(parameter.isEditable()); + + getChildren().addAll(name, value); + } + +// @Override +// public void doBindings() { +// ((TextField) value).textProperty().bind(((DoubleParameter) parameter).valueProperty().asString()); +// } +// +// @Override +// public void undoBindings() { +// ((TextField) value).textProperty().unbind(); +// } + + @Override + public void refreshValue() { + if (!((TextField) value).textProperty().isBound()) { + ((TextField) value).setText(String.valueOf(((DoubleParameter) parameter).get())); + } + } + +} diff --git a/src/jcgp/gui/settings/parameters/GUIIntegerParameter.java b/src/jcgp/gui/settings/parameters/GUIIntegerParameter.java new file mode 100644 index 0000000..6bcfd55 --- /dev/null +++ b/src/jcgp/gui/settings/parameters/GUIIntegerParameter.java @@ -0,0 +1,49 @@ +package jcgp.gui.settings.parameters; + +import javafx.geometry.Pos; +import javafx.scene.control.TextField; +import javafx.scene.layout.Priority; +import javafx.scene.text.Text; +import jcgp.GUI; +import jcgp.parameters.IntegerParameter; + +public class GUIIntegerParameter extends GUIParameter { + + public GUIIntegerParameter(IntegerParameter parameter) { + super(); + + this.parameter = parameter; + + name = new Text(parameter.getName()); + value = new TextField(String.valueOf(parameter.get())); + + ((TextField) value).setAlignment(Pos.CENTER_RIGHT); + + setHgrow(value, Priority.ALWAYS); + + name.setWrappingWidth(GUI.WRAP_WIDTH); + + ((TextField) value).setEditable(parameter.isEditable()); + + getChildren().addAll(name, value); + } + +// @Override +// public void doBindings() { +// ((TextField) value).textProperty().bind(((IntegerParameter) parameter).valueProperty().asString()); +// } +// +// @Override +// public void undoBindings() { +// ((TextField) value).textProperty().unbind(); +// } + + public TextField getTextField() { + return (TextField) value; + } + + @Override + public void refreshValue() { + ((TextField) value).setText(String.valueOf(((IntegerParameter) parameter).get())); + } +} diff --git a/src/jcgp/gui/settings/parameters/GUIParameter.java b/src/jcgp/gui/settings/parameters/GUIParameter.java new file mode 100644 index 0000000..a2f2f9c --- /dev/null +++ b/src/jcgp/gui/settings/parameters/GUIParameter.java @@ -0,0 +1,30 @@ +package jcgp.gui.settings.parameters; + +import javafx.geometry.Pos; +import javafx.scene.control.Control; +import javafx.scene.layout.HBox; +import javafx.scene.text.Text; +import jcgp.parameters.Parameter; + +public abstract class GUIParameter extends HBox { + + protected Parameter parameter; + protected Text name; + protected Control value; + + public GUIParameter() { + setAlignment(Pos.CENTER_LEFT); + setSpacing(5); + } + + public Parameter getParameter() { + return parameter; + } + +// public abstract void doBindings(); +// +// public abstract void undoBindings(); + + public abstract void refreshValue(); + +} |