aboutsummaryrefslogtreecommitdiffstats
path: root/src/jcgp/gui/population/GUIInput.java
blob: 9b5f567a2f8b7b17c192e7633f2a374d9c83c687 (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
71
package jcgp.gui.population;

import javafx.scene.paint.Paint;
import javafx.scene.shape.Circle;
import jcgp.backend.population.Input;
import jcgp.gui.constants.Constants;
import jcgp.gui.constants.Position;
import jcgp.gui.handlers.InputHandlers;

/**
 * The GUI counterpart of {@link jcgp.backend.population.Input}. This is a 
 * subclass of {@code GUIGene} which represents a chromosome input.
 * 
 * @author Eduardo Pedroni
 */
public class GUIInput extends GUIGene implements GUIConnection {

	private Input input;
	
	/**
	 * Instantiate {@code GUIInput} given an {@code Input}.
	 * 
	 * @param input the associated backend input.
	 */
	public GUIInput(final Input input) {
		super();
		// store the input, associate itself with it
		this.input = input;
		input.setGUIObject(this);
		
		// inputs only have a single output socket
		Circle outputSocket = new Circle(Constants.NODE_RADIUS, 0, Constants.SOCKET_RADIUS, Paint.valueOf("white"));
		outputSocket.setStroke(Paint.valueOf("black"));
		outputSocket.setId(String.valueOf(0));
		getChildren().add(outputSocket);
		
		// relocate to the right position, add mouse handlers
		Position.place(this);
		InputHandlers.addHandlers(this);
	}

	/**
	 * @return the {@code Input} instance associated with this object.
	 */
	public Input getInput() {
		return input;
	}
	
	/**
	 * Associates this instance with a new input.
	 * 
	 * @param input the new input.
	 */
	void setInput(Input input) {
		this.input = input;
	}

	/* (non-Javadoc)
	 * @see jcgp.gui.population.GUIConnection#setStateRecursively(jcgp.gui.population.GUIGene.GUIGeneState)
	 */
	@Override
	public void setStateRecursively(GUIGeneState state) {
		setState(state);
	}

	/* (non-Javadoc)
	 * @see jcgp.gui.population.GUIGene#setLinesVisible(boolean)
	 */
	@Override
	protected void setLinesVisible(boolean value) {}
}