diff options
Diffstat (limited to 'src/jcgp/backend/parameters')
-rw-r--r-- | src/jcgp/backend/parameters/BooleanParameter.java | 10 | ||||
-rw-r--r-- | src/jcgp/backend/parameters/DoubleParameter.java | 10 | ||||
-rw-r--r-- | src/jcgp/backend/parameters/IntegerParameter.java | 13 | ||||
-rw-r--r-- | src/jcgp/backend/parameters/Parameter.java | 16 | ||||
-rw-r--r-- | src/jcgp/backend/parameters/ParameterStatus.java | 16 |
5 files changed, 45 insertions, 20 deletions
diff --git a/src/jcgp/backend/parameters/BooleanParameter.java b/src/jcgp/backend/parameters/BooleanParameter.java index d5904cd..db78419 100644 --- a/src/jcgp/backend/parameters/BooleanParameter.java +++ b/src/jcgp/backend/parameters/BooleanParameter.java @@ -2,17 +2,17 @@ package jcgp.backend.parameters; import javafx.beans.property.SimpleBooleanProperty; -public class BooleanParameter extends Parameter { +public abstract class BooleanParameter extends Parameter { private SimpleBooleanProperty value; - public BooleanParameter(boolean value, String name, boolean monitor, boolean hidden, boolean critical) { - super(name, monitor, hidden, critical); + public BooleanParameter(boolean value, String name, boolean monitor, boolean critical) { + super(name, monitor, critical); this.value = new SimpleBooleanProperty(value); } public BooleanParameter(boolean value, String name) { - super(name, false, false, true); + super(name, false, false); this.value = new SimpleBooleanProperty(value); } @@ -26,6 +26,8 @@ public class BooleanParameter extends Parameter { } } + protected abstract void validate(boolean newValue); + public SimpleBooleanProperty valueProperty() { return value; } diff --git a/src/jcgp/backend/parameters/DoubleParameter.java b/src/jcgp/backend/parameters/DoubleParameter.java index 26031be..2b98991 100644 --- a/src/jcgp/backend/parameters/DoubleParameter.java +++ b/src/jcgp/backend/parameters/DoubleParameter.java @@ -2,17 +2,17 @@ package jcgp.backend.parameters; import javafx.beans.property.SimpleDoubleProperty; -public class DoubleParameter extends Parameter { +public abstract class DoubleParameter extends Parameter { protected SimpleDoubleProperty value; - public DoubleParameter(double value, String name, boolean monitor, boolean hidden, boolean critical) { - super(name, monitor, hidden, critical); + public DoubleParameter(double value, String name, boolean monitor, boolean critical) { + super(name, monitor, critical); this.value = new SimpleDoubleProperty(value); } public DoubleParameter(double value, String name) { - super(name, false, false, true); + super(name, false, false); this.value = new SimpleDoubleProperty(value); } @@ -30,4 +30,6 @@ public class DoubleParameter extends Parameter { return value; } + protected abstract void validate(double newValue); + } diff --git a/src/jcgp/backend/parameters/IntegerParameter.java b/src/jcgp/backend/parameters/IntegerParameter.java index dbfa5c5..1127817 100644 --- a/src/jcgp/backend/parameters/IntegerParameter.java +++ b/src/jcgp/backend/parameters/IntegerParameter.java @@ -2,17 +2,17 @@ package jcgp.backend.parameters; import javafx.beans.property.SimpleIntegerProperty; -public class IntegerParameter extends Parameter { +public abstract class IntegerParameter extends Parameter { - protected SimpleIntegerProperty value; + private SimpleIntegerProperty value; - public IntegerParameter(int value, String name, boolean monitor, boolean hidden, boolean critical) { - super(name, monitor, hidden, critical); + public IntegerParameter(int value, String name, boolean monitor, boolean critical) { + super(name, monitor, critical); this.value = new SimpleIntegerProperty(value); } public IntegerParameter(int value, String name) { - super(name, false, false, true); + super(name, false, false); this.value = new SimpleIntegerProperty(value); } @@ -22,6 +22,7 @@ public class IntegerParameter extends Parameter { public void set(int newValue) { if (!value.isBound()) { + validate(newValue); value.set(newValue); } } @@ -30,4 +31,6 @@ public class IntegerParameter extends Parameter { return value; } + protected abstract void validate(int newValue); + } diff --git a/src/jcgp/backend/parameters/Parameter.java b/src/jcgp/backend/parameters/Parameter.java index 2f584a4..26bc8f1 100644 --- a/src/jcgp/backend/parameters/Parameter.java +++ b/src/jcgp/backend/parameters/Parameter.java @@ -4,21 +4,18 @@ import javafx.beans.property.Property; public abstract class Parameter { - protected boolean hidden, monitor, critical; + protected boolean monitor, critical; + + protected ParameterStatus status = ParameterStatus.VALID; protected String name; - public Parameter(String name, boolean monitor, boolean hidden, boolean critical) { + public Parameter(String name, boolean monitor, boolean critical) { this.name = name; - this.hidden = hidden; this.monitor = monitor; this.critical = critical; } - public boolean isHidden() { - return hidden; - } - public boolean isMonitor() { return monitor; } @@ -31,5 +28,10 @@ public abstract class Parameter { return name; } + public ParameterStatus getStatus() { + return status; + } + public abstract Property<?> valueProperty(); + } diff --git a/src/jcgp/backend/parameters/ParameterStatus.java b/src/jcgp/backend/parameters/ParameterStatus.java new file mode 100644 index 0000000..ed235d4 --- /dev/null +++ b/src/jcgp/backend/parameters/ParameterStatus.java @@ -0,0 +1,16 @@ +package jcgp.backend.parameters; + +public enum ParameterStatus { + INVALID, WARNING, VALID; + + private String details; + + public void setDetails(String details) { + this.details = details; + } + + public String getDetails() { + return details; + } + +} |