private PopulationPane parent;
public ChromosomePane(Chromosome chromosome, GUI gui, PopulationPane parent) {
super();
final Resources resources = gui.getExperiment().getResources();
this.parent = parent;
rows = resources.rows();
columns = resources.columns();
connectionLines = new ArrayList<Line>();
content = new Pane();
content.setId("content pane for genes");
// generate the GUIGenes
// inputs
guiInputs = new GUIInput[resources.inputs()];
for (int i = 0; i < guiInputs.length; i++) {
// make the GUI elements
guiInputs[i] = new GUIInput(this, chromosome.getInput(i));
content.getChildren().addAll(guiInputs[i]);
}
// nodes
guiNodes = new GUINode[rows][columns];
double angle, xPos, yPos;
for (int r = 0; r < rows; r++) {
for (int c = 0; c < columns; c++) {
// make the connection lines
Line lines[] = new Line[resources.arity()];
for (int l = 0; l < lines.length; l++) {
angle = ((((double) (l + 1)) / ((double) (lines.length + 1))) * Constants.THETA) - (Constants.THETA / 2);
xPos = (-Math.cos(angle) * Constants.NODE_RADIUS) + (((c + 1) * (2 * Constants.NODE_RADIUS + Constants.SPACING)) + Constants.NODE_RADIUS);
yPos = (Math.sin(angle) * Constants.NODE_RADIUS) + ((r * (2 * Constants.NODE_RADIUS + Constants.SPACING)) + Constants.NODE_RADIUS);
lines[l] = new Line(xPos, yPos, xPos, yPos);
lines[l].setMouseTransparent(true);
lines[l].setVisible(false);
connectionLines.add(lines[l]);
}
// make the GUI elements
guiNodes[r][c] = new GUINode(this, chromosome.getNode(r, c), lines, gui);
}
content.getChildren().addAll(guiNodes[r]);
}
// outputs
guiOutputs = new GUIOutput[resources.outputs()];
for (int i = 0; i < guiOutputs.length; i++) {
xPos = ((resources.columns() + 1) * (2 * Constants.NODE_RADIUS + Constants.SPACING));
yPos = (chromosome.getOutput(i).getIndex() * (2 * Constants.NODE_RADIUS + Constants.SPACING)) + Constants.NODE_RADIUS;
// make the line
Line line = new Line(xPos, yPos, xPos, yPos);
line.setMouseTransparent(true);
line.setVisible(false);