From 0c288cc1952809294c8d70d86b9f41b04878ac2e Mon Sep 17 00:00:00 2001 From: Eduardo Pedroni Date: Sun, 23 Mar 2014 18:05:13 +0000 Subject: Majorly refactored, node grid is fully implemented. About to attempt active path locking. --- src/jcgp/population/Output.java | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) (limited to 'src/jcgp/population/Output.java') diff --git a/src/jcgp/population/Output.java b/src/jcgp/population/Output.java index ccecae0..b7c6128 100644 --- a/src/jcgp/population/Output.java +++ b/src/jcgp/population/Output.java @@ -2,15 +2,18 @@ package jcgp.population; import java.util.ArrayList; -public class Output implements MutableElement { +import javafx.beans.property.SimpleObjectProperty; + +public class Output extends Gene implements MutableElement { - private Connection source; + private SimpleObjectProperty source; private Chromosome chromosome; private int index; public Output(Chromosome chromosome, int index) { this.chromosome = chromosome; this.index = index; + this.source = new SimpleObjectProperty(); } public Object calculate() { @@ -19,8 +22,8 @@ public class Output implements MutableElement { } @Override - public void setConnection(Connection newConnection) { - source = newConnection; + public void setConnection(int index, Connection newConnection) { + source.set(newConnection); chromosome.recomputeActiveNodes(); } @@ -29,12 +32,16 @@ public class Output implements MutableElement { } public Connection getSource() { + return source.get(); + } + + public SimpleObjectProperty sourceProperty() { return source; } public void getActiveNodes(ArrayList activeNodes) { - if (source instanceof Node) { - ((Node) source).getActive(activeNodes); + if (source.get() instanceof Node) { + ((Node) source.get()).getActive(activeNodes); } } @@ -44,14 +51,14 @@ public class Output implements MutableElement { if (m instanceof Output) { Output o = (Output) m; if (index == o.getIndex()) { - if (source != o.getSource()) { - if (source instanceof Input && o.getSource() instanceof Input) { - if (((Input) source).getIndex() == ((Input) o.getSource()).getIndex()) { + if (source.get() != o.getSource()) { + if (source.get() instanceof Input && o.getSource() instanceof Input) { + if (((Input) source.get()).getIndex() == ((Input) o.getSource()).getIndex()) { return true; } - } else if (source instanceof Node && o.getSource() instanceof Node) { - if (((Node) source).getRow() == ((Node) o.getSource()).getRow() && - ((Node) source).getColumn() == ((Node) o.getSource()).getColumn()) { + } else if (source.get() instanceof Node && o.getSource() instanceof Node) { + if (((Node) source.get()).getRow() == ((Node) o.getSource()).getRow() && + ((Node) source.get()).getColumn() == ((Node) o.getSource()).getColumn()) { return true; } } -- cgit v1.2.3