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.java41
-rw-r--r--src/jcgp/gui/population/GUIGene.java6
-rw-r--r--src/jcgp/gui/population/GUIInput.java3
-rw-r--r--src/jcgp/gui/population/GUINode.java18
-rw-r--r--src/jcgp/gui/population/GUIOutput.java15
-rw-r--r--src/jcgp/gui/population/PopulationPane.java6
6 files changed, 40 insertions, 49 deletions
diff --git a/src/jcgp/gui/population/ChromosomePane.java b/src/jcgp/gui/population/ChromosomePane.java
index 4a47f34..d40de2e 100644
--- a/src/jcgp/gui/population/ChromosomePane.java
+++ b/src/jcgp/gui/population/ChromosomePane.java
@@ -25,6 +25,8 @@ public class ChromosomePane extends ScrollPane {
private int rows, columns;
+ private Object[] testInputs;
+
private boolean target = false;
private PopulationPane parent;
@@ -111,20 +113,21 @@ public class ChromosomePane extends ScrollPane {
target = newValue;
}
- public void updateGenes() {
+ public void updateGenes(Chromosome chr) {
for (int r = 0; r < rows; r++) {
for (int c = 0; c < columns; c++) {
+ guiNodes[r][c].setNode(chr.getNode(r, c));
guiNodes[r][c].updateLines();
guiNodes[r][c].updateText();
}
}
for (int i = 0; i < guiOutputs.length; i++) {
+ guiOutputs[i].setOutput(chr.getOutput(i));
guiOutputs[i].updateLines();
}
if (isEvaluating()) {
- evaluate(0);
+ setInputs(testInputs);
}
-
}
public void unlockOutputs() {
@@ -144,29 +147,27 @@ public class ChromosomePane extends ScrollPane {
}
public void setInputs(Object[] values) {
+ testInputs = values;
for (int i = 0; i < guiInputs.length; i++) {
guiInputs[i].setValue(values[i]);
- guiInputs[i].updateText();
}
- evaluate(0);
+ updateValues();
}
- public void evaluate(int start) {
- if (start >= 0 || start < columns) {
- for (int c = start; c < columns; c++) {
- for (int r = 0; r < rows; r++) {
- guiNodes[r][c].calculate();
- guiNodes[r][c].updateText();
- }
- }
- for (int o = 0; o < guiOutputs.length; o++) {
- guiOutputs[o].calculate();
- guiOutputs[o].updateText();
- }
- }
- }
+// public void evaluate(int start) {
+// if (start >= 0 || start < columns) {
+// for (int c = 0; c < columns; c++) {
+// for (int r = 0; r < rows; r++) {
+// guiNodes[r][c].updateText();
+// }
+// }
+// for (int o = 0; o < guiOutputs.length; o++) {
+// guiOutputs[o].updateText();
+// }
+// }
+// }
- public void hideValues() {
+ public void updateValues() {
for (int i = 0; i < guiInputs.length; i++) {
guiInputs[i].updateText();
}
diff --git a/src/jcgp/gui/population/GUIGene.java b/src/jcgp/gui/population/GUIGene.java
index 3ace150..0eea045 100644
--- a/src/jcgp/gui/population/GUIGene.java
+++ b/src/jcgp/gui/population/GUIGene.java
@@ -39,8 +39,6 @@ public abstract class GUIGene extends Group {
protected ChromosomePane parent;
protected int locked = 0;
-
- protected Object value;
public GUIGene() {
text.setFont(Font.font("Arial", 12));
@@ -92,9 +90,5 @@ public abstract class GUIGene extends Group {
public abstract void setConnectionLine(GUIGene gene);
- public Object getValue() {
- return value;
- }
-
public abstract void updateText();
}
diff --git a/src/jcgp/gui/population/GUIInput.java b/src/jcgp/gui/population/GUIInput.java
index 05372c4..fd66ab4 100644
--- a/src/jcgp/gui/population/GUIInput.java
+++ b/src/jcgp/gui/population/GUIInput.java
@@ -219,14 +219,13 @@ public class GUIInput extends GUIGene {
}
public void setValue(Object newValue) {
- value = newValue;
input.setValue(newValue);
}
@Override
public void updateText() {
if (parent.isEvaluating()) {
- text.setText("I: " + input.getIndex() + "\n" + value.toString());
+ text.setText("I: " + input.getIndex() + "\n" + input.getValue().toString());
} else {
text.setText("I: " + input.getIndex());
}
diff --git a/src/jcgp/gui/population/GUINode.java b/src/jcgp/gui/population/GUINode.java
index 6dfeaa4..d3ae27f 100644
--- a/src/jcgp/gui/population/GUINode.java
+++ b/src/jcgp/gui/population/GUINode.java
@@ -398,7 +398,8 @@ public class GUINode extends GUIGene {
public void setChangingConnection(Connection newConnection) {
node.setConnection(connectionIndex, newConnection);
if (parent.isEvaluating()) {
- parent.evaluate(node.getColumn());
+ parent.updateValues();
+// parent.evaluate(node.getColumn());
}
}
@@ -452,24 +453,23 @@ public class GUINode extends GUIGene {
public void updateText() {
if (parent.isEvaluating()) {
- text.setText(node.getFunction() + "\n" + value.toString());
+ text.setText(node.getFunction() + "\n" + node.getValue().toString());
} else {
text.setText(node.getFunction().toString());
}
}
-
- public void calculate() {
- value = node.getValue();
- }
public void setFunction(Function function) {
node.setFunction(function);
if (parent.isEvaluating()) {
- calculate();
- parent.evaluate(node.getColumn());
+// parent.evaluate(node.getColumn());
+ parent.updateValues();
} else {
updateText();
}
-
+ }
+
+ public void setNode(Node newNode) {
+ node = newNode;
}
}
diff --git a/src/jcgp/gui/population/GUIOutput.java b/src/jcgp/gui/population/GUIOutput.java
index 29752cd..5a76298 100644
--- a/src/jcgp/gui/population/GUIOutput.java
+++ b/src/jcgp/gui/population/GUIOutput.java
@@ -267,10 +267,7 @@ public class GUIOutput extends GUIGene {
@Override
public void setChangingConnection(Connection newConnection) {
output.setConnection(0, newConnection);
- if (parent.isEvaluating()) {
- calculate();
- updateText();
- }
+ updateText();
}
@Override
@@ -308,19 +305,19 @@ public class GUIOutput extends GUIGene {
setLocked(true);
}
}
-
- public void calculate() {
- value = output.getSource().getValue();
- }
@Override
public void updateText() {
if (parent.isEvaluating()) {
- text.setText("O: " + output.getIndex() + "\n" + value.toString());
+ text.setText("O: " + output.getIndex() + "\n" + output.getSource().getValue().toString());
} else {
text.setText("O: " + output.getIndex());
}
}
+ public void setOutput(Output newOutput) {
+ output = newOutput;
+ }
+
}
diff --git a/src/jcgp/gui/population/PopulationPane.java b/src/jcgp/gui/population/PopulationPane.java
index 5fa6067..4b1b7f8 100644
--- a/src/jcgp/gui/population/PopulationPane.java
+++ b/src/jcgp/gui/population/PopulationPane.java
@@ -27,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, this);
+ cp = new ChromosomePane(jcgp.getPopulation().get(i), gui, this);
tab = new Tab("Chr " + i);
tab.setContent(cp);
getTabs().add(tab);
@@ -39,7 +39,7 @@ public class PopulationPane extends TabPane {
evaluateTestCase(currentTestCase);
}
for (int i = 0; i < getTabs().size(); i++) {
- ((ChromosomePane) getTabs().get(i).getContent()).updateGenes();
+ ((ChromosomePane) getTabs().get(i).getContent()).updateGenes(gui.getExperiment().getPopulation().get(i));
}
}
@@ -73,7 +73,7 @@ public class PopulationPane extends TabPane {
public void hideValues() {
evaluating = false;
for (int i = 0; i < getTabs().size(); i++) {
- ((ChromosomePane) getTabs().get(i).getContent()).hideValues();
+ ((ChromosomePane) getTabs().get(i).getContent()).updateValues();
}
}