diff options
author | Eduardo Pedroni <e.pedroni91@gmail.com> | 2014-10-10 13:22:16 +0200 |
---|---|---|
committer | Eduardo Pedroni <e.pedroni91@gmail.com> | 2014-10-10 13:22:16 +0200 |
commit | e145523a2ae686dd2a2ae7996639e6e8d14d992a (patch) | |
tree | 3ffaa3c13fc48f3c58b72a53bb6a6ca41bcf96da /src/jcgp/gui/population/GUINode.java | |
parent | 952b6d502da5896b59ffecdb5fa6f9c56458a02c (diff) |
Moved constants to a separate file, added a formal README
Diffstat (limited to 'src/jcgp/gui/population/GUINode.java')
-rw-r--r-- | src/jcgp/gui/population/GUINode.java | 43 |
1 files changed, 22 insertions, 21 deletions
diff --git a/src/jcgp/gui/population/GUINode.java b/src/jcgp/gui/population/GUINode.java index 142d650..4d420ea 100644 --- a/src/jcgp/gui/population/GUINode.java +++ b/src/jcgp/gui/population/GUINode.java @@ -13,6 +13,7 @@ import jcgp.backend.population.Input; import jcgp.backend.population.Node; import jcgp.backend.resources.Resources; import jcgp.gui.GUI; +import jcgp.gui.constants.Constants; public class GUINode extends GUIGene { @@ -32,8 +33,8 @@ public class GUINode extends GUIGene { this.resources = gui.getExperiment().getResources(); // move the GUIGene to the right position - relocate(((node.getColumn() + 1) * (2 * NODE_RADIUS + SPACING)) + NODE_RADIUS, - (node.getRow() * (2 * NODE_RADIUS + SPACING)) + NODE_RADIUS); + relocate(((node.getColumn() + 1) * (2 * Constants.NODE_RADIUS + Constants.SPACING)) + Constants.NODE_RADIUS, + (node.getRow() * (2 * Constants.NODE_RADIUS + Constants.SPACING)) + Constants.NODE_RADIUS); // set the line ends correctly updateLines(); @@ -42,7 +43,7 @@ public class GUINode extends GUIGene { connectionNumber.setStyle("-fx-background-color:rgb(255, 255, 255); -fx-border-color:rgba(0, 0, 0, 0.5); "); connectionNumber.setVisible(false); - Circle output = new Circle(NODE_RADIUS, 0, SOCKET_RADIUS, Paint.valueOf("white")); + Circle output = new Circle(Constants.NODE_RADIUS, 0, Constants.SOCKET_RADIUS, Paint.valueOf("white")); output.setStroke(Paint.valueOf("black")); updateText(); @@ -50,11 +51,11 @@ public class GUINode extends GUIGene { Circle[] sockets = new Circle[resources.arity()]; double angle, xPos, yPos; for (int l = 0; l < sockets.length; l++) { - angle = (((l + 1) / ((double) (resources.arity() + 1))) * THETA) - (THETA / 2); - xPos = -Math.cos(angle) * NODE_RADIUS; - yPos = Math.sin(angle) * NODE_RADIUS; + angle = (((l + 1) / ((double) (resources.arity() + 1))) * Constants.THETA) - (Constants.THETA / 2); + xPos = -Math.cos(angle) * Constants.NODE_RADIUS; + yPos = Math.sin(angle) * Constants.NODE_RADIUS; - sockets[l] = new Circle(xPos, yPos, GUIGene.SOCKET_RADIUS, Paint.valueOf("white")); + sockets[l] = new Circle(xPos, yPos, Constants.SOCKET_RADIUS, Paint.valueOf("white")); sockets[l].setId(String.valueOf(l)); sockets[l].setStroke(Paint.valueOf("black")); @@ -253,19 +254,19 @@ public class GUINode extends GUIGene { if (locked > 0) { setState(GUIGeneState.LOCKED_HOVER); } else { - mainCircle.setFill(Paint.valueOf(GUI.SOFT_HIGHLIGHT_COLOUR)); + mainCircle.setFill(Paint.valueOf(Constants.SOFT_HIGHLIGHT_COLOUR)); showLines(true); } setConnectionStates(GUIGeneState.ACTIVE_HOVER); break; case LOCKED_HOVER: - mainCircle.setFill(Paint.valueOf(GUI.SOFT_HIGHLIGHT_COLOUR)); + mainCircle.setFill(Paint.valueOf(Constants.SOFT_HIGHLIGHT_COLOUR)); break; case INVALID_TARGET: - mainCircle.setFill(Paint.valueOf(GUI.BAD_SELECTION_COLOUR)); + mainCircle.setFill(Paint.valueOf(Constants.BAD_SELECTION_COLOUR)); break; case HOVER: - mainCircle.setFill(Paint.valueOf(GUI.MEDIUM_HIGHLIGHT_COLOUR)); + mainCircle.setFill(Paint.valueOf(Constants.MEDIUM_HIGHLIGHT_COLOUR)); showLines(true); if (locked <= 0) { setConnectionStates(GUIGeneState.INDIRECT_HOVER); @@ -274,13 +275,13 @@ public class GUINode extends GUIGene { } break; case INDIRECT_HOVER: - mainCircle.setFill(Paint.valueOf(GUI.SOFT_HIGHLIGHT_COLOUR)); + mainCircle.setFill(Paint.valueOf(Constants.SOFT_HIGHLIGHT_COLOUR)); break; case NEUTRAL: if (locked > 0) { setState(GUIGeneState.HOVER); } else { - mainCircle.setFill(Paint.valueOf(GUI.NEUTRAL_COLOUR)); + mainCircle.setFill(Paint.valueOf(Constants.NEUTRAL_COLOUR)); showLines(false); if (getState() == GUIGeneState.ACTIVE_HOVER) { setConnectionStates(GUIGeneState.NEUTRAL); @@ -289,14 +290,14 @@ public class GUINode extends GUIGene { break; case NO_CHANGE_TARGET: parent.setTarget(true); - mainCircle.setFill(Paint.valueOf(GUI.NEUTRAL_SELECTION_COLOUR)); + mainCircle.setFill(Paint.valueOf(Constants.NEUTRAL_SELECTION_COLOUR)); break; case SOURCE: - mainCircle.setFill(Paint.valueOf(GUI.HARD_HIGHLIGHT_COLOUR)); + mainCircle.setFill(Paint.valueOf(Constants.HARD_HIGHLIGHT_COLOUR)); break; case VALID_TARGET: parent.setTarget(true); - mainCircle.setFill(Paint.valueOf(GUI.GOOD_SELECTION_COLOUR)); + mainCircle.setFill(Paint.valueOf(Constants.GOOD_SELECTION_COLOUR)); break; default: break; @@ -355,12 +356,12 @@ public class GUINode extends GUIGene { if (node.getConnection(index) instanceof Node) { int row = ((Node) node.getConnection(index)).getRow(), column = ((Node) node.getConnection(index)).getColumn(); - lines[index].setEndX(((column + 1) * (2 * NODE_RADIUS + SPACING)) + 2 * NODE_RADIUS); - lines[index].setEndY((row * (2 * NODE_RADIUS + SPACING)) + NODE_RADIUS); + lines[index].setEndX(((column + 1) * (2 * Constants.NODE_RADIUS + Constants.SPACING)) + 2 * Constants.NODE_RADIUS); + lines[index].setEndY((row * (2 * Constants.NODE_RADIUS + Constants.SPACING)) + Constants.NODE_RADIUS); } else if (node.getConnection(index) instanceof Input) { int inputIndex = ((Input) node.getConnection(index)).getIndex(); - lines[index].setEndX(2 * NODE_RADIUS); - lines[index].setEndY(inputIndex * (2 * NODE_RADIUS + SPACING) + NODE_RADIUS); + lines[index].setEndX(2 * Constants.NODE_RADIUS); + lines[index].setEndY(inputIndex * (2 * Constants.NODE_RADIUS + Constants.SPACING) + Constants.NODE_RADIUS); } } @@ -444,7 +445,7 @@ public class GUINode extends GUIGene { @Override public void setConnectionLine(GUIGene gene) { - lines[connectionIndex].setEndX(gene.getLayoutX() + NODE_RADIUS); + lines[connectionIndex].setEndX(gene.getLayoutX() + Constants.NODE_RADIUS); lines[connectionIndex].setEndY(gene.getLayoutY()); } |