aboutsummaryrefslogtreecommitdiffstats
path: root/src/jcgp/gui/constants
diff options
context:
space:
mode:
Diffstat (limited to 'src/jcgp/gui/constants')
-rw-r--r--src/jcgp/gui/constants/Position.java38
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());
+ }
+}