From d63d3145f0f2abcee1bb88457324f4aaf9b9320e Mon Sep 17 00:00:00 2001 From: Eduardo Pedroni Date: Sat, 8 Mar 2014 14:48:25 +0000 Subject: Slowly refactoring Parameters to fit the GUI a little better... --- src/jcgp/parameters/BooleanParameter.java | 32 +++++++++++++++++++++++++++++++ src/jcgp/parameters/DoubleParameter.java | 32 +++++++++++++++++++++++++++++++ src/jcgp/parameters/IntegerParameter.java | 32 +++++++++++++++++++++++++++++++ src/jcgp/parameters/Parameter.java | 22 +++++++++++++++++++++ src/jcgp/parameters/Parameters.java | 31 ++++++++++++++++++++++++++++++ 5 files changed, 149 insertions(+) create mode 100644 src/jcgp/parameters/BooleanParameter.java create mode 100644 src/jcgp/parameters/DoubleParameter.java create mode 100644 src/jcgp/parameters/IntegerParameter.java create mode 100644 src/jcgp/parameters/Parameter.java create mode 100644 src/jcgp/parameters/Parameters.java (limited to 'src/jcgp/parameters') diff --git a/src/jcgp/parameters/BooleanParameter.java b/src/jcgp/parameters/BooleanParameter.java new file mode 100644 index 0000000..738b733 --- /dev/null +++ b/src/jcgp/parameters/BooleanParameter.java @@ -0,0 +1,32 @@ +package jcgp.parameters; + +import javafx.beans.property.SimpleBooleanProperty; + +public class BooleanParameter extends Parameter { + + private SimpleBooleanProperty value; + + public BooleanParameter(boolean value) { + + this.value.set(value); + + } + + public BooleanParameter(boolean value, boolean managed) { + this.value.set(value); + this.managed = managed; + } + + public void setValue(boolean value) { + this.value.set(value); + } + + public boolean getValue() { + return this.value.get(); + } + + public SimpleBooleanProperty valueProperty() { + return value; + } + +} diff --git a/src/jcgp/parameters/DoubleParameter.java b/src/jcgp/parameters/DoubleParameter.java new file mode 100644 index 0000000..9349502 --- /dev/null +++ b/src/jcgp/parameters/DoubleParameter.java @@ -0,0 +1,32 @@ +package jcgp.parameters; + +import javafx.beans.property.SimpleDoubleProperty; + +public class DoubleParameter extends Parameter { + + private SimpleDoubleProperty value; + + public DoubleParameter(double value) { + + this.value.set(value); + + } + + public DoubleParameter(double value, boolean managed) { + this.value.set(value); + this.managed = managed; + } + + public void setValue(double value) { + this.value.set(value); + } + + public double getValue() { + return this.value.get(); + } + + public SimpleDoubleProperty valueProperty() { + return value; + } + +} diff --git a/src/jcgp/parameters/IntegerParameter.java b/src/jcgp/parameters/IntegerParameter.java new file mode 100644 index 0000000..2aac3e1 --- /dev/null +++ b/src/jcgp/parameters/IntegerParameter.java @@ -0,0 +1,32 @@ +package jcgp.parameters; + +import javafx.beans.property.SimpleIntegerProperty; + +public class IntegerParameter extends Parameter { + + private SimpleIntegerProperty value; + + public IntegerParameter(int value) { + + this.value.set(value); + + } + + public IntegerParameter(int value, boolean managed) { + this.value.set(value); + this.managed = managed; + } + + public void setValue(int value) { + this.value.set(value); + } + + public int getValue() { + return this.value.get(); + } + + public SimpleIntegerProperty valueProperty() { + return value; + } + +} diff --git a/src/jcgp/parameters/Parameter.java b/src/jcgp/parameters/Parameter.java new file mode 100644 index 0000000..8b63868 --- /dev/null +++ b/src/jcgp/parameters/Parameter.java @@ -0,0 +1,22 @@ +package jcgp.parameters; + +public abstract class Parameter { + protected boolean managed = false; + protected boolean hidden = false; + + public void setManaged(boolean value) { + managed = value; + } + + public boolean isManaged() { + return managed; + } + + public void setHidden(boolean value) { + hidden = value; + } + + public boolean isHidden() { + return hidden; + } +} diff --git a/src/jcgp/parameters/Parameters.java b/src/jcgp/parameters/Parameters.java new file mode 100644 index 0000000..54b54e3 --- /dev/null +++ b/src/jcgp/parameters/Parameters.java @@ -0,0 +1,31 @@ +package jcgp.parameters; + +import java.util.HashMap; + +public class Parameters { + + private static HashMap parameters; + + public static void add(String key, Parameter value) { + parameters.put(key, value); + } + + public static Parameter get(String key) { + return parameters.get(key); + } + + public static boolean contains(String key) { + return parameters.containsKey(key); + } + +// private static int rows = 0, columns = 0, inputs = 0, outputs = 0, levelsBack = 0, +// mutationRate = 0, totalGenerations = 0, parents = 0, offspring = 0, +// currentGeneration = 0, totalRuns = 0, currentRun = 0, +// maxArity = 0, maxFitness = 0; + +// private static boolean debug = false; + + + + +} -- cgit v1.2.3