diff options
Diffstat (limited to 'src/jcgp/backend/resources/parameters')
5 files changed, 172 insertions, 0 deletions
diff --git a/src/jcgp/backend/resources/parameters/BooleanParameter.java b/src/jcgp/backend/resources/parameters/BooleanParameter.java new file mode 100644 index 0000000..cd17649 --- /dev/null +++ b/src/jcgp/backend/resources/parameters/BooleanParameter.java @@ -0,0 +1,42 @@ +package jcgp.backend.resources.parameters; + +import javafx.beans.property.SimpleBooleanProperty; + +public abstract class BooleanParameter extends Parameter { + + private SimpleBooleanProperty value; + + public BooleanParameter(boolean value, String name, boolean monitor, boolean critical) { + super(name, monitor, critical); + this.value = new SimpleBooleanProperty(value); + } + + /** + * Simple BooleanParameter constructor, + * + * + * @param value + * @param name + */ + public BooleanParameter(boolean value, String name) { + super(name, false, false); + this.value = new SimpleBooleanProperty(value); + } + + public boolean get() { + return value.get(); + } + + public void set(boolean newValue) { + if (!value.isBound()) { + value.set(newValue); + } + } + + public abstract void validate(boolean newValue); + + @Override + public SimpleBooleanProperty valueProperty() { + return value; + } +} diff --git a/src/jcgp/backend/resources/parameters/DoubleParameter.java b/src/jcgp/backend/resources/parameters/DoubleParameter.java new file mode 100644 index 0000000..8464c83 --- /dev/null +++ b/src/jcgp/backend/resources/parameters/DoubleParameter.java @@ -0,0 +1,36 @@ +package jcgp.backend.resources.parameters; + +import javafx.beans.property.SimpleDoubleProperty; + +public abstract class DoubleParameter extends Parameter { + + protected SimpleDoubleProperty value; + + 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); + this.value = new SimpleDoubleProperty(value); + } + + public double get() { + return value.get(); + } + + public void set(double newValue) { + if (!value.isBound()) { + value.set(newValue); + } + } + + @Override + public SimpleDoubleProperty valueProperty() { + return value; + } + + public abstract void validate(double newValue); + +} diff --git a/src/jcgp/backend/resources/parameters/IntegerParameter.java b/src/jcgp/backend/resources/parameters/IntegerParameter.java new file mode 100644 index 0000000..2a7b2a7 --- /dev/null +++ b/src/jcgp/backend/resources/parameters/IntegerParameter.java @@ -0,0 +1,37 @@ +package jcgp.backend.resources.parameters; + +import javafx.beans.property.SimpleIntegerProperty; + +public abstract class IntegerParameter extends Parameter { + + private SimpleIntegerProperty value; + + 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); + this.value = new SimpleIntegerProperty(value); + } + + public int get() { + return value.get(); + } + + public void set(int newValue) { + if (!value.isBound()) { + validate(newValue); + value.set(newValue); + } + } + + @Override + public SimpleIntegerProperty valueProperty() { + return value; + } + + public abstract void validate(int newValue); + +} diff --git a/src/jcgp/backend/resources/parameters/Parameter.java b/src/jcgp/backend/resources/parameters/Parameter.java new file mode 100644 index 0000000..7e12ff8 --- /dev/null +++ b/src/jcgp/backend/resources/parameters/Parameter.java @@ -0,0 +1,41 @@ +package jcgp.backend.resources.parameters; + +import javafx.beans.property.Property; + +public abstract class Parameter { + + protected boolean monitor, critical, reset = false; + + protected ParameterStatus status = ParameterStatus.VALID; + + protected String name; + + public Parameter(String name, boolean monitor, boolean critical) { + this.name = name; + this.monitor = monitor; + this.critical = critical; + } + + public boolean isMonitor() { + return monitor; + } + + public boolean isCritical() { + return critical; + } + + public boolean requiresReset() { + return critical || reset; + } + + public String getName() { + return name; + } + + public ParameterStatus getStatus() { + return status; + } + + public abstract Property<?> valueProperty(); + +} diff --git a/src/jcgp/backend/resources/parameters/ParameterStatus.java b/src/jcgp/backend/resources/parameters/ParameterStatus.java new file mode 100644 index 0000000..11da4c2 --- /dev/null +++ b/src/jcgp/backend/resources/parameters/ParameterStatus.java @@ -0,0 +1,16 @@ +package jcgp.backend.resources.parameters; + +public enum ParameterStatus { + INVALID, WARNING, WARNING_RESET, VALID; + + private String details; + + public void setDetails(String details) { + this.details = details; + } + + public String getDetails() { + return details; + } + +} |