aboutsummaryrefslogtreecommitdiffstats
path: root/src/jcgp/gui/handlers
diff options
context:
space:
mode:
Diffstat (limited to 'src/jcgp/gui/handlers')
-rw-r--r--src/jcgp/gui/handlers/InputHandlers.java8
-rw-r--r--src/jcgp/gui/handlers/NodeHandlers.java10
-rw-r--r--src/jcgp/gui/handlers/OutputHandlers.java34
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);
}
}