From ff5248437491f1829c0168b271e85cb358516577 Mon Sep 17 00:00:00 2001 From: Eduardo Pedroni Date: Mon, 9 Mar 2015 16:40:17 -0300 Subject: Moved GUI to its own repository --- src/jcgp/gui/population/GUINode.java | 134 ----------------------------------- 1 file changed, 134 deletions(-) delete mode 100644 src/jcgp/gui/population/GUINode.java (limited to 'src/jcgp/gui/population/GUINode.java') diff --git a/src/jcgp/gui/population/GUINode.java b/src/jcgp/gui/population/GUINode.java deleted file mode 100644 index 1a32426..0000000 --- a/src/jcgp/gui/population/GUINode.java +++ /dev/null @@ -1,134 +0,0 @@ -package jcgp.gui.population; - -import javafx.scene.paint.Paint; -import javafx.scene.shape.Circle; -import javafx.scene.shape.Line; -import jcgp.backend.population.Gene; -import jcgp.backend.population.Node; -import jcgp.gui.GUI; -import jcgp.gui.constants.Constants; -import jcgp.gui.constants.Position; -import jcgp.gui.handlers.NodeHandlers; - -/** - * The GUI counterpart of {@link jcgp.backend.population.Node}. This is a - * subclass of {@code GUIGene} which represents a chromosome node. - * - * @author Eduardo Pedroni - */ -public class GUINode extends GUIGene implements GUIMutable, GUIConnection { - - private Node node; - private Line[] lines; - private Circle[] sockets; - - /** - * Instantiate {@code GUINode} given a {@code Node} and the lines needed - * to show its connections. - * - * @param node the associated backend node. - * @param lines the lines used to display connections. - */ - public GUINode(Node node, Line[] lines) { - super(); - // store references, associate with node - this.node = node; - this.lines = lines; - node.setGUIObject(this); - - // create the output socket - Circle output = new Circle(Constants.NODE_RADIUS, 0, Constants.SOCKET_RADIUS, Constants.SOCKET_PAINT); - output.setStroke(Paint.valueOf("black")); - - // create input sockets - sockets = new Circle[GUI.resources.arity()]; - for (int l = 0; l < sockets.length; l++) { - sockets[l] = new Circle(Constants.SOCKET_RADIUS, Constants.SOCKET_PAINT); - sockets[l].setStroke(Paint.valueOf("black")); - sockets[l].setId(String.valueOf(l)); - // relocate them - Position.placeSocket(l, sockets[l]); - Position.connect(lines[l], (GUIGene) ((Gene) node.getConnection(l)).getGUIObject()); - } - - // add elements - getChildren().addAll(sockets); - getChildren().add(output); - - // relocate node, add handlers - Position.place(this); - NodeHandlers.addHandlers(this); - } - - /** - * @return the {@code Node} instance associated with this object. - */ - public Node getNode() { - return node; - } - - /** - * Associates this instance with a new node. - * - * @param node the new node. - */ - void setNode(Node node) { - this.node = node; - } - - @Override - public Line[] getLines() { - return lines; - } - - /** - * Returns one of this object's connection sockets. They are - * indexed in the same order as lines and the connections - * they represent. - * - * @param index the socket to return. - * @return the indexed socket object. - */ - public Circle getSocket(int index) { - return sockets[index]; - } - - /** - * @return the entire {@code Socket} array. - */ - public Circle[] getSockets() { - return sockets; - } - - @Override - public void setStateRecursively(GUIGeneState state) { - setState(state); - for (int i = 0; i < GUI.resources.arity(); i++) { - ((GUIConnection) ((Gene) node.getConnection(i)).getGUIObject()).setStateRecursively(state); - } - } - - @Override - protected void setLinesVisible(boolean value) { - for (int i = 0; i < lines.length; i++) { - lines[i].setVisible(value); - } - } - - @Override - public void setLockRecursively(boolean value) { - setLock(value); - for (int i = 0; i < GUI.resources.arity(); i++) { - ((GUIConnection) ((Gene) node.getConnection(i)).getGUIObject()).setLockRecursively(value); - } - } - - @Override - public GUIConnection[] getConnections() { - GUIConnection[] connections = new GUIConnection[GUI.resources.arity()]; - for (int c = 0; c < connections.length; c++) { - connections[c] = (GUIConnection) ((Gene) node.getConnection(c)).getGUIObject(); - } - return connections; - } -} -- cgit v1.2.3