aboutsummaryrefslogtreecommitdiffstats
path: root/src/jcgp/gui/population/GUIOutput.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/jcgp/gui/population/GUIOutput.java')
-rw-r--r--src/jcgp/gui/population/GUIOutput.java26
1 files changed, 21 insertions, 5 deletions
diff --git a/src/jcgp/gui/population/GUIOutput.java b/src/jcgp/gui/population/GUIOutput.java
index c5b889e..89c12b3 100644
--- a/src/jcgp/gui/population/GUIOutput.java
+++ b/src/jcgp/gui/population/GUIOutput.java
@@ -16,23 +16,21 @@ import jcgp.gui.GUI;
public class GUIOutput extends GUIGene {
private Line sourceLine;
-
private Output output;
- public GUIOutput(ChromosomePane parentRef, final Output output, Line line) {
+ public GUIOutput(ChromosomePane parentRef, final Output output, Line line, GUI gui) {
super();
this.parent = parentRef;
this.output = output;
this.sourceLine = line;
- relocate(((GUI.resources.columns() + 1) * (2 * NODE_RADIUS + SPACING)) + NODE_RADIUS,
+ relocate(((gui.getExperiment().getResources().columns() + 1) * (2 * NODE_RADIUS + SPACING)) + NODE_RADIUS,
(output.getIndex() * (2 * NODE_RADIUS + SPACING)) + NODE_RADIUS);
// set the line ends correctly
updateLines();
-
- text.setText("O: " + output.getIndex());
+ updateText();
Circle socket = new Circle(-NODE_RADIUS, 0, SOCKET_RADIUS, Paint.valueOf("white"));
socket.setId(String.valueOf(0));
@@ -274,6 +272,10 @@ public class GUIOutput extends GUIGene {
@Override
public void setChangingConnection(Connection newConnection) {
output.setConnection(0, newConnection);
+ if (parent.isEvaluating()) {
+ calculate();
+ updateText();
+ }
}
@Override
@@ -311,5 +313,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() + "\nValue: " + value.toString());
+ } else {
+ text.setText("O: " + output.getIndex());
+ }
+
+ }
}