diff options
author | Eduardo Pedroni <e.pedroni91@gmail.com> | 2014-11-24 10:59:53 +0000 |
---|---|---|
committer | Eduardo Pedroni <e.pedroni91@gmail.com> | 2014-11-24 10:59:53 +0000 |
commit | 3f17c598a374e46200f3b2a73ef4f1f82f734a2e (patch) | |
tree | f5a4f804a2dca625de1c52a149170ef189ec19b1 /src/jcgp/gui/handlers | |
parent | 98e02b48ea5b83fa6c3247869b841b0afd260a89 (diff) |
Visualisation features complete, seems to be quite stable. Behaves slightly differently to before, but the source is cleaner and more maintainable. Now moving on to connection manipulation.
Diffstat (limited to 'src/jcgp/gui/handlers')
-rw-r--r-- | src/jcgp/gui/handlers/InputHandlers.java | 8 | ||||
-rw-r--r-- | src/jcgp/gui/handlers/NodeHandlers.java | 10 | ||||
-rw-r--r-- | src/jcgp/gui/handlers/OutputHandlers.java | 34 |
3 files changed, 36 insertions, 16 deletions
diff --git a/src/jcgp/gui/handlers/InputHandlers.java b/src/jcgp/gui/handlers/InputHandlers.java index d0a8812..6be4e7e 100644 --- a/src/jcgp/gui/handlers/InputHandlers.java +++ b/src/jcgp/gui/handlers/InputHandlers.java @@ -5,12 +5,17 @@ import javafx.scene.input.MouseEvent; import jcgp.gui.population.GUIGene.GUIGeneState; import jcgp.gui.population.GUIInput; +/** + * + * + * @author Eduardo Pedroni + * + */ public final class InputHandlers { private static EventHandler<MouseEvent> mouseEnteredHandler = new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent event) { - //((GUIGene) event.getSource()).mouseEnter(); ((GUIInput) event.getSource()).setState(GUIGeneState.HOVER); } }; @@ -18,7 +23,6 @@ public final class InputHandlers { private static EventHandler<MouseEvent> mouseExitedHandler = new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent event) { - //((GUIGene) event.getSource()).mouseExit(); ((GUIInput) event.getSource()).setState(GUIGeneState.NEUTRAL); } }; diff --git a/src/jcgp/gui/handlers/NodeHandlers.java b/src/jcgp/gui/handlers/NodeHandlers.java index 9d1f6a8..8c9c465 100644 --- a/src/jcgp/gui/handlers/NodeHandlers.java +++ b/src/jcgp/gui/handlers/NodeHandlers.java @@ -15,14 +15,8 @@ public final class NodeHandlers { public void handle(MouseEvent event) { // acquire the source, we can safely cast it to GUINode GUINode source = (GUINode) event.getSource(); - source.setState(GUIGeneState.HOVER); - /* - * What have I done? Have I gone too far? - * Have I unleashed an evil beyond control? - * Will the gods of type casting ever forgive me? - */ for (int i = 0; i < GUI.resources.arity(); i++) { ((GUIGene) ((Gene) source.getNode().getConnection(i)).getGUIObject()).setState(GUIGeneState.EXTENDED_HOVER); } @@ -37,10 +31,6 @@ public final class NodeHandlers { source.setState(GUIGeneState.NEUTRAL); - /* - * Is this the end? Is there any hope for salvation? - * Am I damned beyond redemption? - */ for (int i = 0; i < GUI.resources.arity(); i++) { ((GUIGene) ((Gene) source.getNode().getConnection(i)).getGUIObject()).setState(GUIGeneState.NEUTRAL); } diff --git a/src/jcgp/gui/handlers/OutputHandlers.java b/src/jcgp/gui/handlers/OutputHandlers.java index 31d6380..7399e50 100644 --- a/src/jcgp/gui/handlers/OutputHandlers.java +++ b/src/jcgp/gui/handlers/OutputHandlers.java @@ -15,8 +15,10 @@ public final class OutputHandlers { // acquire the source, we can safely cast it to GUIOutput GUIOutput source = (GUIOutput) event.getSource(); - source.setState(GUIGeneState.HOVER); - ((GUIConnection) ((Gene) source.getOutput().getSource()).getGUIObject()).setStateRecursively(GUIGeneState.ACTIVE_HOVER); + //if (!source.isLocked()) { + source.setState(GUIGeneState.HOVER); + ((GUIConnection) ((Gene) source.getOutput().getSource()).getGUIObject()).setStateRecursively(GUIGeneState.ACTIVE_HOVER); + //} } }; @@ -26,14 +28,38 @@ public final class OutputHandlers { // acquire the source, we can safely cast it to GUIOutput GUIOutput source = (GUIOutput) event.getSource(); - source.setState(GUIGeneState.NEUTRAL); - ((GUIConnection) ((Gene) source.getOutput().getSource()).getGUIObject()).setStateRecursively(GUIGeneState.NEUTRAL); + //if (!source.isLocked()) { + source.setState(GUIGeneState.NEUTRAL); + ((GUIConnection) ((Gene) source.getOutput().getSource()).getGUIObject()).setStateRecursively(GUIGeneState.NEUTRAL); + //} + + } + }; + + private static EventHandler<MouseEvent> mouseClickHandler = new EventHandler<MouseEvent>() { + @Override + public void handle(MouseEvent event) { + // acquire the source, we can safely cast it to GUIOutput + GUIOutput source = (GUIOutput) event.getSource(); + + if (source.isLocked()) { + source.setLock(false); + ((GUIConnection) ((Gene) source.getOutput().getSource()).getGUIObject()).setLockRecursively(false); + } else { + source.setLock(true); + ((GUIConnection) ((Gene) source.getOutput().getSource()).getGUIObject()).setLockRecursively(true); + } + +// source.setState(GUIGeneState.HOVER); +// ((GUIConnection) ((Gene) source.getOutput().getSource()).getGUIObject()).setStateRecursively(GUIGeneState.ACTIVE_HOVER); + } }; public static void addHandlers(GUIOutput output) { output.addEventHandler(MouseEvent.MOUSE_ENTERED, mouseEnteredHandler); output.addEventHandler(MouseEvent.MOUSE_EXITED, mouseExitedHandler); + output.addEventHandler(MouseEvent.MOUSE_CLICKED, mouseClickHandler); } } |