aboutsummaryrefslogtreecommitdiffstats
path: root/src/jcgp/gui/population
diff options
context:
space:
mode:
Diffstat (limited to 'src/jcgp/gui/population')
-rw-r--r--src/jcgp/gui/population/ChromosomePane.java9
-rw-r--r--src/jcgp/gui/population/GUIGene.java2
-rw-r--r--src/jcgp/gui/population/PopulationPane.java20
3 files changed, 23 insertions, 8 deletions
diff --git a/src/jcgp/gui/population/ChromosomePane.java b/src/jcgp/gui/population/ChromosomePane.java
index 0279d09..4a47f34 100644
--- a/src/jcgp/gui/population/ChromosomePane.java
+++ b/src/jcgp/gui/population/ChromosomePane.java
@@ -26,12 +26,13 @@ public class ChromosomePane extends ScrollPane {
private int rows, columns;
private boolean target = false;
- private boolean evaluating = false;
+ private PopulationPane parent;
- public ChromosomePane(Chromosome chromosome, GUI gui) {
+ public ChromosomePane(Chromosome chromosome, GUI gui, PopulationPane parent) {
super();
final Resources resources = gui.getExperiment().getResources();
+ this.parent = parent;
rows = resources.rows();
columns = resources.columns();
@@ -143,7 +144,6 @@ public class ChromosomePane extends ScrollPane {
}
public void setInputs(Object[] values) {
- evaluating = true;
for (int i = 0; i < guiInputs.length; i++) {
guiInputs[i].setValue(values[i]);
guiInputs[i].updateText();
@@ -167,7 +167,6 @@ public class ChromosomePane extends ScrollPane {
}
public void hideValues() {
- evaluating = false;
for (int i = 0; i < guiInputs.length; i++) {
guiInputs[i].updateText();
}
@@ -185,6 +184,6 @@ public class ChromosomePane extends ScrollPane {
* @return the evaluating
*/
public boolean isEvaluating() {
- return evaluating;
+ return parent.isEvaluating();
}
}
diff --git a/src/jcgp/gui/population/GUIGene.java b/src/jcgp/gui/population/GUIGene.java
index 5ce839e..c41261d 100644
--- a/src/jcgp/gui/population/GUIGene.java
+++ b/src/jcgp/gui/population/GUIGene.java
@@ -12,7 +12,7 @@ import jcgp.backend.population.Gene;
public abstract class GUIGene extends Group {
- public static final double NODE_RADIUS = 30;
+ public static final double NODE_RADIUS = 35;
public static final double SPACING = 15;
public static final double THETA = Math.PI / 1.4;
diff --git a/src/jcgp/gui/population/PopulationPane.java b/src/jcgp/gui/population/PopulationPane.java
index 64b61c4..28b0ad9 100644
--- a/src/jcgp/gui/population/PopulationPane.java
+++ b/src/jcgp/gui/population/PopulationPane.java
@@ -10,6 +10,8 @@ import jcgp.gui.GUI;
public class PopulationPane extends TabPane {
private GUI gui;
+ private TestCase<Object> currentTestCase;
+ private boolean evaluating = false;
public PopulationPane(GUI gui) {
super();
@@ -25,7 +27,7 @@ public class PopulationPane extends TabPane {
Tab tab;
ChromosomePane cp;
for (int i = 0; i < jcgp.getResources().populationSize(); i++) {
- cp = new ChromosomePane(jcgp.getPopulation().getChromosome(i), gui);
+ cp = new ChromosomePane(jcgp.getPopulation().getChromosome(i), gui, this);
tab = new Tab("Chr " + i);
tab.setContent(cp);
getTabs().add(tab);
@@ -33,6 +35,9 @@ public class PopulationPane extends TabPane {
}
public void updateGenes() {
+ if (evaluating) {
+ evaluateTestCase(currentTestCase);
+ }
for (int i = 0; i < getChildrenUnmodifiable().size(); i++) {
((ChromosomePane) getTabs().get(i).getContent()).updateGenes();
}
@@ -51,8 +56,10 @@ public class PopulationPane extends TabPane {
}
public void evaluateTestCase(TestCase<Object> testCase) {
- if (gui.getExperiment().getProblem() instanceof TestCaseProblem) {
+ if (gui.getExperiment().getProblem() instanceof TestCaseProblem && testCase != null) {
+ currentTestCase = testCase;
if (testCase.getInputs().length == gui.getExperiment().getResources().inputs()) {
+ evaluating = true;
for (int i = 0; i < getTabs().size(); i++) {
((ChromosomePane) getTabs().get(i).getContent()).setInputs(testCase.getInputs());
}
@@ -64,8 +71,17 @@ public class PopulationPane extends TabPane {
}
public void hideValues() {
+ evaluating = false;
for (int i = 0; i < getTabs().size(); i++) {
((ChromosomePane) getTabs().get(i).getContent()).hideValues();
}
}
+
+ public boolean isEvaluating() {
+ return evaluating;
+ }
+
+ public void setEvaluating(boolean value) {
+ evaluating = value;
+ }
}