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; } @Override public void setStateRecursively(GUIGeneState state) { setState(state); } @Override protected void setLinesVisible(boolean value) {} @Override public void setLockRecursively(boolean value) { setLock(value); } }