aboutsummaryrefslogtreecommitdiffstats
path: root/src/jcgp/gui/handlers/Target.java
blob: b05066328e8658047239621c5bd70b2aa308da5e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
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;
	}
}