diff options
Diffstat (limited to 'src/jcgp/gui/population/GUIInput.java')
-rw-r--r-- | src/jcgp/gui/population/GUIInput.java | 45 |
1 files changed, 35 insertions, 10 deletions
diff --git a/src/jcgp/gui/population/GUIInput.java b/src/jcgp/gui/population/GUIInput.java index 68952f6..9b5f567 100644 --- a/src/jcgp/gui/population/GUIInput.java +++ b/src/jcgp/gui/population/GUIInput.java @@ -4,43 +4,68 @@ 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; /** - * @param 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.setId(String.valueOf(0)); outputSocket.setStroke(Paint.valueOf("black")); - - getChildren().addAll(outputSocket); + 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) { - // blank - } + protected void setLinesVisible(boolean value) {} } |