diff options
author | Eduardo Pedroni <e.pedroni91@gmail.com> | 2014-11-18 19:26:18 +0000 |
---|---|---|
committer | Eduardo Pedroni <e.pedroni91@gmail.com> | 2014-11-18 19:26:18 +0000 |
commit | 9d24ea7759c58e7b1fd4b8c37acc7d16cb7e55fa (patch) | |
tree | fa1b82a61d1ebc6edbb2f6456b6191b09bfa3e61 /src/jcgp/gui/constants | |
parent | d0718fe4762f6a50ec851085cb5d0e6d39ccc1b0 (diff) |
Refactored handlers, separated into input, node and output files. Genes are less functional now, ChromosomePane will deal with hand-wired connections.
Diffstat (limited to 'src/jcgp/gui/constants')
-rw-r--r-- | src/jcgp/gui/constants/Position.java | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/jcgp/gui/constants/Position.java b/src/jcgp/gui/constants/Position.java new file mode 100644 index 0000000..0ea1299 --- /dev/null +++ b/src/jcgp/gui/constants/Position.java @@ -0,0 +1,38 @@ +package jcgp.gui.constants; + +import javafx.scene.shape.Line; +import jcgp.gui.GUI; +import jcgp.gui.population.GUIGene; +import jcgp.gui.population.GUIInput; +import jcgp.gui.population.GUINode; +import jcgp.gui.population.GUIOutput; + +public final class Position { + + public static void place(GUIInput input) { + input.relocate(0, + input.getInput().getIndex() * (2 * Constants.NODE_RADIUS + Constants.SPACING)); + } + + public static void place(GUINode node) { + // TODO cut down method calls + double xOffset = ((node.getNode().getColumn() + 1) * (2 * Constants.NODE_RADIUS + Constants.SPACING)); + double yOffset = node.getNode().getRow() * (2 * Constants.NODE_RADIUS + Constants.SPACING); + node.relocate(xOffset, yOffset); + + for (int i = 0; i < GUI.resources.arity(); i++) { + node.getLine(i).setStartX(node.getSocket(i).getCenterX() + xOffset + Constants.NODE_RADIUS + Constants.SOCKET_RADIUS); + node.getLine(i).setStartY(node.getSocket(i).getCenterY() + yOffset + Constants.NODE_RADIUS); + } + } + + public static void place(GUIOutput output) { + output.relocate(((GUI.resources.columns() + 1) * (2 * Constants.NODE_RADIUS + Constants.SPACING)), + output.getOutput().getIndex() * (2 * Constants.NODE_RADIUS + Constants.SPACING)); + } + + public static void connect(Line line, GUIGene target) { + line.setEndX(target.getLayoutX() + Constants.NODE_RADIUS); + line.setEndY(target.getLayoutY()); + } +} |