diff options
Diffstat (limited to 'src/jcgp/gui/population/GUINode.java')
-rw-r--r-- | src/jcgp/gui/population/GUINode.java | 48 |
1 files changed, 32 insertions, 16 deletions
diff --git a/src/jcgp/gui/population/GUINode.java b/src/jcgp/gui/population/GUINode.java index 4350e52..c5ab43a 100644 --- a/src/jcgp/gui/population/GUINode.java +++ b/src/jcgp/gui/population/GUINode.java @@ -33,7 +33,7 @@ public class GUINode extends GUIGene { private Node node; private int connectionIndex; - + public GUINode(ChromosomePane parentRef, final Node node, Resources resources, Line[] connectionLines) { // store references @@ -176,15 +176,6 @@ public class GUINode extends GUIGene { } }); - addEventFilter(MouseDragEvent.MOUSE_DRAG_OVER, new EventHandler<MouseDragEvent>() { - @Override - public void handle(MouseDragEvent event) { - // the user is dragging over this node, react appropriately - // this happens even if we are the source of the drag - - } - }); - addEventFilter(MouseDragEvent.MOUSE_DRAG_EXITED, new EventHandler<MouseDragEvent>() { @Override public void handle(MouseDragEvent event) { @@ -244,8 +235,12 @@ public class GUINode extends GUIGene { public void handle(MouseEvent event) { // cursor has left this node without dragging, or it is dragging and this is the source if (stateProperty.get() == GUIGeneState.HOVER) { - stateProperty.set(GUIGeneState.NEUTRAL); - setConnections(GUIGeneState.NEUTRAL); + if (isLocked()) { + + } else { + stateProperty.set(GUIGeneState.NEUTRAL); + setConnections(GUIGeneState.NEUTRAL); + } } } }); @@ -270,7 +265,10 @@ public class GUINode extends GUIGene { case HOVER: mainCircle.setFill(Paint.valueOf(GUI.HARD_HIGHLIGHT_COLOUR)); showLines(true); - setConnections(GUIGeneState.INDIRECT_HOVER); + if (!isLocked()) { + setConnections(GUIGeneState.INDIRECT_HOVER); + } + break; case INDIRECT_HOVER: mainCircle.setFill(Paint.valueOf(GUI.SOFT_HIGHLIGHT_COLOUR)); @@ -392,9 +390,13 @@ public class GUINode extends GUIGene { public void setConnections(GUIGeneState newState) { for (int i = 0; i < lines.length; i++) { if (node.getConnection(i) instanceof Node) { - parent.getGuiNode(((Node) node.getConnection(i)).getRow(), ((Node) node.getConnection(i)).getColumn()).setState(newState); + if (!parent.getGuiNode(((Node) node.getConnection(i)).getRow(), ((Node) node.getConnection(i)).getColumn()).isLocked()) { + parent.getGuiNode(((Node) node.getConnection(i)).getRow(), ((Node) node.getConnection(i)).getColumn()).setState(newState); + } } else if (node.getConnection(i) instanceof Input) { - parent.getGuiInput(((Input) node.getConnection(i)).getIndex()).setState(newState); + if (!parent.getGuiInput(((Input) node.getConnection(i)).getIndex()).isLocked()) { + parent.getGuiInput(((Input) node.getConnection(i)).getIndex()).setState(newState); + } } } } @@ -413,5 +415,19 @@ public class GUINode extends GUIGene { stateProperty.set(GUIGeneState.NEUTRAL); setConnections(GUIGeneState.NEUTRAL); } - + + + @Override + public void setLocked(boolean value) { + locked += value ? 1 : -1; + stateProperty.set(locked > 0 ? GUIGeneState.HOVER : GUIGeneState.ACTIVE_HOVER); + + for (int i = 0; i < lines.length; i++) { + if (node.getConnection(i) instanceof Node) { + parent.getGuiNode(((Node) node.getConnection(i)).getRow(), ((Node) node.getConnection(i)).getColumn()).setLocked(value); + } else if (node.getConnection(i) instanceof Input) { + parent.getGuiInput(((Input) node.getConnection(i)).getIndex()).setLocked(value); + } + } + } } |