package jcgp.backend.population; import java.util.ArrayList; public class Output extends Gene implements MutableElement { private Connection 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() { Object result = source.getValue(); return result; } @Override public void setConnection(int index, Connection newConnection) { source = newConnection; chromosome.recomputeActiveNodes(); } public int getIndex() { return index; } public Connection getSource() { return source; } // public SimpleObjectProperty sourceProperty() { // return source; // } public void getActiveNodes(ArrayList activeNodes) { if (source instanceof Node) { ((Node) source).getActive(activeNodes); } } @Override public boolean copyOf(MutableElement m) { if (this != m) { 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()) { 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()) { return true; } } } } } } return false; } }