aboutsummaryrefslogtreecommitdiffstats
path: root/src/jcgp/gui/handlers/OutputHandlers.java
diff options
context:
space:
mode:
authorEduardo Pedroni <e.pedroni91@gmail.com>2015-05-27 13:24:23 +0200
committerEduardo Pedroni <e.pedroni91@gmail.com>2015-05-27 13:24:23 +0200
commit72f96333f0dd0bad05f3b5d10cf343cf21aa7e39 (patch)
tree1f138ac604b3d5f703301912d2c3863785a40792 /src/jcgp/gui/handlers/OutputHandlers.java
parent1e7d7a9b09ca9d24b56cf33a168953ca033d7c53 (diff)
Brought back the old GUI, refactorings are now in dev and will be merged when completeHEADmaster
Diffstat (limited to 'src/jcgp/gui/handlers/OutputHandlers.java')
-rw-r--r--src/jcgp/gui/handlers/OutputHandlers.java84
1 files changed, 0 insertions, 84 deletions
diff --git a/src/jcgp/gui/handlers/OutputHandlers.java b/src/jcgp/gui/handlers/OutputHandlers.java
deleted file mode 100644
index b89d746..0000000
--- a/src/jcgp/gui/handlers/OutputHandlers.java
+++ /dev/null
@@ -1,84 +0,0 @@
-package jcgp.gui.handlers;
-
-import javafx.event.EventHandler;
-import javafx.scene.input.MouseEvent;
-import jcgp.backend.population.Gene;
-import jcgp.gui.population.GUIConnection;
-import jcgp.gui.population.GUIGene.GUIGeneState;
-import jcgp.gui.population.GUIOutput;
-
-/**
- * Holds the handlers that define the behaviour of {@code GUIOutput}.
- * <br><br>
- * The handlers are instantiated here statically and added to {@code GUIOutput}
- * instances using {@code OutputHandlers.addHandlers(...)}. This guarantees that
- * all outputs behave the same way without instantiating a new set of handlers for
- * each output instance.
- *
- * @author Eduardo Pedroni
- *
- */
-public final class OutputHandlers {
-
- /**
- * Private constructor to prevent instantiation.
- */
- private OutputHandlers() {}
-
- /**
- * Set the output to {@code GUIGeneState.HOVER} state, and recursively set its active genes
- * to {@code GUIGeneState.ACTIVE_HOVER}.
- */
- private static EventHandler<MouseEvent> mouseEnteredHandler = new EventHandler<MouseEvent>() {
- @Override
- public void handle(MouseEvent event) {
- // 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);
- }
- };
-
- /**
- * Set the output and all of its active genes to {@code GUIGeneState.NEUTRAL} state.
- */
- private static EventHandler<MouseEvent> mouseExitedHandler = new EventHandler<MouseEvent>() {
- @Override
- public void handle(MouseEvent event) {
- // 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 the output is locked, unlock it and all of its associated genes recursively.
- * If it is unlocked, lock it and its active genes.
- */
- 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();
-
- boolean lock = !source.isLocked();
- source.setLock(lock);
- ((GUIConnection) ((Gene) source.getOutput().getSource()).getGUIObject()).setLockRecursively(lock);
- }
- };
-
- /**
- * Adds all handlers to the specified output.
- *
- * @param output the {@code GUIOutput} to which the handlers will be added.
- */
- public static void addHandlers(GUIOutput output) {
- output.addEventHandler(MouseEvent.MOUSE_ENTERED, mouseEnteredHandler);
- output.addEventHandler(MouseEvent.MOUSE_EXITED, mouseExitedHandler);
- output.addEventHandler(MouseEvent.MOUSE_CLICKED, mouseClickHandler);
- }
-
-}