aboutsummaryrefslogtreecommitdiffstats
path: root/src/jcgp/parameters
diff options
context:
space:
mode:
Diffstat (limited to 'src/jcgp/parameters')
-rw-r--r--src/jcgp/parameters/BooleanParameter.java32
-rw-r--r--src/jcgp/parameters/DoubleParameter.java32
-rw-r--r--src/jcgp/parameters/IntegerParameter.java29
-rw-r--r--src/jcgp/parameters/Parameter.java48
4 files changed, 55 insertions, 86 deletions
diff --git a/src/jcgp/parameters/BooleanParameter.java b/src/jcgp/parameters/BooleanParameter.java
index 0f339a1..63e9c73 100644
--- a/src/jcgp/parameters/BooleanParameter.java
+++ b/src/jcgp/parameters/BooleanParameter.java
@@ -3,30 +3,30 @@ package jcgp.parameters;
import javafx.beans.property.SimpleBooleanProperty;
public class BooleanParameter extends Parameter {
-
- public BooleanParameter(boolean value, String name) {
- super(name);
+
+ private SimpleBooleanProperty value;
+
+ public BooleanParameter(boolean value, String name, boolean editable, boolean hidden) {
+ super(name, editable, hidden);
this.value = new SimpleBooleanProperty(value);
}
- public BooleanParameter(boolean value, String name, boolean managed, boolean hidden) {
- super(name, managed, hidden);
+ public BooleanParameter(boolean value, String name) {
+ super(name, true, false);
this.value = new SimpleBooleanProperty(value);
}
- @Override
- public Boolean getValue() {
- return ((SimpleBooleanProperty) this.value).get();
+ public boolean get() {
+ return value.get();
}
- @Override
- public SimpleBooleanProperty valueProperty() {
- return (SimpleBooleanProperty) value;
- }
-
- @Override
- public void setValue(Object value) {
- ((SimpleBooleanProperty) this.value).set((boolean) value);
+ public void set(boolean newValue) {
+ if (!value.isBound()) {
+ value.set(newValue);
+ }
}
+ public SimpleBooleanProperty valueProperty() {
+ return value;
+ }
}
diff --git a/src/jcgp/parameters/DoubleParameter.java b/src/jcgp/parameters/DoubleParameter.java
index ade99cc..d555452 100644
--- a/src/jcgp/parameters/DoubleParameter.java
+++ b/src/jcgp/parameters/DoubleParameter.java
@@ -3,31 +3,31 @@ package jcgp.parameters;
import javafx.beans.property.SimpleDoubleProperty;
public class DoubleParameter extends Parameter {
-
- public DoubleParameter(double value, String name) {
- super(name);
+
+ protected SimpleDoubleProperty value;
+
+ public DoubleParameter(double value, String name, boolean editable, boolean hidden) {
+ super(name, editable, hidden);
this.value = new SimpleDoubleProperty(value);
}
- public DoubleParameter(double value, String name, boolean managed, boolean hidden) {
- super(name, managed, hidden);
+ public DoubleParameter(double value, String name) {
+ super(name, true, false);
this.value = new SimpleDoubleProperty(value);
}
+
+ public double get() {
+ return value.get();
+ }
- @Override
- public Double getValue() {
- return ((SimpleDoubleProperty) value).get();
+ public void set(double newValue) {
+ if (!value.isBound()) {
+ value.set(newValue);
+ }
}
- @Override
public SimpleDoubleProperty valueProperty() {
- return (SimpleDoubleProperty) value;
- }
-
- @Override
- public void setValue(Object value) {
- ((SimpleDoubleProperty) this.value).set((double) value);
-
+ return value;
}
}
diff --git a/src/jcgp/parameters/IntegerParameter.java b/src/jcgp/parameters/IntegerParameter.java
index cc60179..c743e97 100644
--- a/src/jcgp/parameters/IntegerParameter.java
+++ b/src/jcgp/parameters/IntegerParameter.java
@@ -4,29 +4,30 @@ import javafx.beans.property.SimpleIntegerProperty;
public class IntegerParameter extends Parameter {
- public IntegerParameter(int value, String name) {
- super(name);
+ protected SimpleIntegerProperty value;
+
+ public IntegerParameter(int value, String name, boolean editable, boolean hidden) {
+ super(name, editable, hidden);
this.value = new SimpleIntegerProperty(value);
}
- public IntegerParameter(int value, String name, boolean managed, boolean hidden) {
- super(name, managed, hidden);
+ public IntegerParameter(int value, String name) {
+ super(name, true, false);
this.value = new SimpleIntegerProperty(value);
}
+
+ public int get() {
+ return value.get();
+ }
- @Override
- public Integer getValue() {
- return ((SimpleIntegerProperty) this.value).get();
+ public void set(int newValue) {
+ if (!value.isBound()) {
+ value.set(newValue);
+ }
}
- @Override
public SimpleIntegerProperty valueProperty() {
- return (SimpleIntegerProperty) value;
- }
-
- @Override
- public void setValue(Object value) {
- ((SimpleIntegerProperty) this.value).set((int) value);
+ return value;
}
}
diff --git a/src/jcgp/parameters/Parameter.java b/src/jcgp/parameters/Parameter.java
index fcff9fd..42c70e4 100644
--- a/src/jcgp/parameters/Parameter.java
+++ b/src/jcgp/parameters/Parameter.java
@@ -1,58 +1,26 @@
package jcgp.parameters;
-import javafx.beans.property.Property;
public abstract class Parameter {
- protected boolean managed = false;
- protected boolean hidden = false;
-
- protected boolean originalManaged = false;
- protected boolean originalHidden = false;
-
- protected Property<?> value;
+ protected boolean hidden = false, editable = true;
protected String name;
- public Parameter(String name, boolean managed, boolean hidden) {
- this.name = name;
- this.managed = originalManaged = managed;
- this.hidden = originalHidden = hidden;
- }
-
- public Parameter(String name) {
+ public Parameter(String name, boolean editable, boolean hidden) {
this.name = name;
- }
-
- public void setManaged(boolean value) {
- managed = value;
- }
-
- public boolean isManaged() {
- return managed;
- }
-
- public void setHidden(boolean value) {
- hidden = value;
+ this.hidden = hidden;
+ this.editable = editable;
}
public boolean isHidden() {
return hidden;
}
- public String getName() {
- return name;
+ public boolean isEditable() {
+ return editable;
}
- public abstract Object getValue();
-
- public abstract void setValue(Object value);
-
- public Property<?> valueProperty() {
- return value;
- }
-
- public void reset() {
- hidden = originalHidden;
- managed = originalManaged;
+ public String getName() {
+ return name;
}
}