diff options
Diffstat (limited to 'src/jcgp/parameters')
-rw-r--r-- | src/jcgp/parameters/BooleanParameter.java | 18 | ||||
-rw-r--r-- | src/jcgp/parameters/DoubleParameter.java | 23 | ||||
-rw-r--r-- | src/jcgp/parameters/IntegerParameter.java | 21 | ||||
-rw-r--r-- | src/jcgp/parameters/Parameter.java | 27 |
4 files changed, 45 insertions, 44 deletions
diff --git a/src/jcgp/parameters/BooleanParameter.java b/src/jcgp/parameters/BooleanParameter.java index aff0bc5..0f339a1 100644 --- a/src/jcgp/parameters/BooleanParameter.java +++ b/src/jcgp/parameters/BooleanParameter.java @@ -3,34 +3,30 @@ package jcgp.parameters; import javafx.beans.property.SimpleBooleanProperty; public class BooleanParameter extends Parameter { - - SimpleBooleanProperty value; - + public BooleanParameter(boolean value, String name) { + super(name); this.value = new SimpleBooleanProperty(value); - this.name = name; } public BooleanParameter(boolean value, String name, boolean managed, boolean hidden) { + super(name, managed, hidden); this.value = new SimpleBooleanProperty(value); - this.name = name; - this.managed = managed; - this.hidden = hidden; } @Override - public Object getValue() { - return this.value.get(); + public Boolean getValue() { + return ((SimpleBooleanProperty) this.value).get(); } @Override public SimpleBooleanProperty valueProperty() { - return value; + return (SimpleBooleanProperty) value; } @Override public void setValue(Object value) { - this.value.set((boolean) value); + ((SimpleBooleanProperty) this.value).set((boolean) value); } } diff --git a/src/jcgp/parameters/DoubleParameter.java b/src/jcgp/parameters/DoubleParameter.java index 2725457..ade99cc 100644 --- a/src/jcgp/parameters/DoubleParameter.java +++ b/src/jcgp/parameters/DoubleParameter.java @@ -3,37 +3,30 @@ package jcgp.parameters; import javafx.beans.property.SimpleDoubleProperty; public class DoubleParameter extends Parameter { - - SimpleDoubleProperty value; - + public DoubleParameter(double value, String name) { + super(name); this.value = new SimpleDoubleProperty(value); - this.name = name; } public DoubleParameter(double value, String name, boolean managed, boolean hidden) { + super(name, managed, hidden); this.value = new SimpleDoubleProperty(value); - this.name = name; - this.managed = managed; - this.hidden = hidden; - } - - public void setValue(double value) { - this.value.set(value); } @Override - public Object getValue() { - return this.value.get(); + public Double getValue() { + return ((SimpleDoubleProperty) value).get(); } + @Override public SimpleDoubleProperty valueProperty() { - return value; + return (SimpleDoubleProperty) value; } @Override public void setValue(Object value) { - this.value.set((double) value); + ((SimpleDoubleProperty) this.value).set((double) value); } diff --git a/src/jcgp/parameters/IntegerParameter.java b/src/jcgp/parameters/IntegerParameter.java index f0109f7..cc60179 100644 --- a/src/jcgp/parameters/IntegerParameter.java +++ b/src/jcgp/parameters/IntegerParameter.java @@ -3,39 +3,30 @@ package jcgp.parameters; import javafx.beans.property.SimpleIntegerProperty; public class IntegerParameter extends Parameter { - - SimpleIntegerProperty value; public IntegerParameter(int value, String name) { + super(name); this.value = new SimpleIntegerProperty(value); - this.name = name; } public IntegerParameter(int value, String name, boolean managed, boolean hidden) { + super(name, managed, hidden); this.value = new SimpleIntegerProperty(value); - this.name = name; - this.managed = managed; - this.hidden = hidden; - } - - public void setValue(int value) { - this.value.set(value); } @Override - public Object getValue() { - return this.value.get(); + public Integer getValue() { + return ((SimpleIntegerProperty) this.value).get(); } @Override public SimpleIntegerProperty valueProperty() { - return value; + return (SimpleIntegerProperty) value; } @Override public void setValue(Object value) { - this.value.set((int) value); - + ((SimpleIntegerProperty) this.value).set((int) value); } } diff --git a/src/jcgp/parameters/Parameter.java b/src/jcgp/parameters/Parameter.java index 64b19c8..fcff9fd 100644 --- a/src/jcgp/parameters/Parameter.java +++ b/src/jcgp/parameters/Parameter.java @@ -1,13 +1,28 @@ 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 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) { + this.name = name; + } + public void setManaged(boolean value) { managed = value; } @@ -32,6 +47,12 @@ public abstract class Parameter { public abstract void setValue(Object value); - @SuppressWarnings("rawtypes") - public abstract Property valueProperty(); + public Property<?> valueProperty() { + return value; + } + + public void reset() { + hidden = originalHidden; + managed = originalManaged; + } } |