From d69fa8746728367646494fd8c2c18944f306c6a2 Mon Sep 17 00:00:00 2001 From: Eduardo Pedroni Date: Mon, 9 Mar 2015 17:03:48 -0300 Subject: Added existing source code --- src/jcgp/gui/handlers/Target.java | 70 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 src/jcgp/gui/handlers/Target.java (limited to 'src/jcgp/gui/handlers/Target.java') diff --git a/src/jcgp/gui/handlers/Target.java b/src/jcgp/gui/handlers/Target.java new file mode 100644 index 0000000..b050663 --- /dev/null +++ b/src/jcgp/gui/handlers/Target.java @@ -0,0 +1,70 @@ +package jcgp.gui.handlers; + +import javafx.scene.shape.Circle; +import javafx.scene.shape.Line; +import jcgp.gui.population.GUIConnection; +import jcgp.gui.population.GUIMutable; + +/** + * @author Eduardo Pedroni + * + */ +public final class Target { + + /** + * Private constructor to prevent instantiation. + */ + private Target() {} + + private static GUIConnection targetConnection; + private static GUIMutable sourceMutable; + private static int connectionIndex; + private static Line connectionLine; + private static Circle sourceSocket; + private static boolean prospecting = false; + + public static void start(Circle newSocket) { + // store new socket + sourceSocket = newSocket; + // derive the rest of the information from it + connectionIndex = Integer.valueOf(newSocket.getId()); + sourceMutable = (GUIMutable) newSocket.getParent(); + connectionLine = sourceMutable.getLines()[connectionIndex]; + } + + public static GUIMutable getSourceMutable() { + return sourceMutable; + } + + public static int getConnectionIndex() { + return connectionIndex; + } + + public static Line getConnectionLine() { + return connectionLine; + } + + public static Circle getSourceSocket() { + return sourceSocket; + } + + public static GUIConnection getTarget() { + return targetConnection; + } + + public static GUIConnection getCurrentConnection() { + return sourceMutable.getConnections()[connectionIndex]; + } + + public static void setProspecting(boolean value) { + prospecting = value; + } + + public static boolean isProspecting() { + return prospecting; + } + + public static void setTarget(GUIConnection newTarget) { + targetConnection = newTarget; + } +} -- cgit v1.2.3