aboutsummaryrefslogtreecommitdiffstats
path: root/src/jcgp/gui/population
diff options
context:
space:
mode:
authorEduardo Pedroni <e.pedroni91@gmail.com>2014-11-24 10:59:53 +0000
committerEduardo Pedroni <e.pedroni91@gmail.com>2014-11-24 10:59:53 +0000
commit3f17c598a374e46200f3b2a73ef4f1f82f734a2e (patch)
treef5a4f804a2dca625de1c52a149170ef189ec19b1 /src/jcgp/gui/population
parent98e02b48ea5b83fa6c3247869b841b0afd260a89 (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/population')
-rw-r--r--src/jcgp/gui/population/ChromosomePane.java2
-rw-r--r--src/jcgp/gui/population/FunctionSelector.java2
-rw-r--r--src/jcgp/gui/population/GUIConnection.java2
-rw-r--r--src/jcgp/gui/population/GUIGene.java33
-rw-r--r--src/jcgp/gui/population/GUIInput.java5
-rw-r--r--src/jcgp/gui/population/GUINode.java12
-rw-r--r--src/jcgp/gui/population/GUIOutput.java2
7 files changed, 43 insertions, 15 deletions
diff --git a/src/jcgp/gui/population/ChromosomePane.java b/src/jcgp/gui/population/ChromosomePane.java
index 7826dcc..a87a054 100644
--- a/src/jcgp/gui/population/ChromosomePane.java
+++ b/src/jcgp/gui/population/ChromosomePane.java
@@ -20,8 +20,8 @@ import jcgp.gui.GUI;
*/
public class ChromosomePane extends ScrollPane {
- private GUINode[][] guiNodes;
private GUIInput[] guiInputs;
+ private GUINode[][] guiNodes;
private GUIOutput[] guiOutputs;
private Pane content;
diff --git a/src/jcgp/gui/population/FunctionSelector.java b/src/jcgp/gui/population/FunctionSelector.java
index d96617c..14614e5 100644
--- a/src/jcgp/gui/population/FunctionSelector.java
+++ b/src/jcgp/gui/population/FunctionSelector.java
@@ -46,7 +46,7 @@ public class FunctionSelector extends VBox {
l.addEventFilter(MouseEvent.MOUSE_ENTERED, new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent event) {
- ((Label) event.getSource()).setStyle("-fx-background-color: " + Constants.SOFT_HIGHLIGHT_COLOUR + "; -fx-border-color: #B0B0B0; -fx-border-width: 0 0 1 0; -fx-padding: 2");
+ ((Label) event.getSource()).setStyle("-fx-background-color: " + Constants.SOFT_HIGHLIGHT_PAINT + "; -fx-border-color: #B0B0B0; -fx-border-width: 0 0 1 0; -fx-padding: 2");
}
});
l.addEventFilter(MouseEvent.MOUSE_EXITED, new EventHandler<MouseEvent>() {
diff --git a/src/jcgp/gui/population/GUIConnection.java b/src/jcgp/gui/population/GUIConnection.java
index c17033a..3a0ad67 100644
--- a/src/jcgp/gui/population/GUIConnection.java
+++ b/src/jcgp/gui/population/GUIConnection.java
@@ -21,4 +21,6 @@ public interface GUIConnection {
*/
public void setStateRecursively(GUIGeneState state);
+ public void setLockRecursively(boolean value);
+
}
diff --git a/src/jcgp/gui/population/GUIGene.java b/src/jcgp/gui/population/GUIGene.java
index d6f9638..02b87e7 100644
--- a/src/jcgp/gui/population/GUIGene.java
+++ b/src/jcgp/gui/population/GUIGene.java
@@ -54,6 +54,8 @@ public abstract class GUIGene extends Group {
private Text text;
private Circle mainCircle;
+
+ private int lock = 0;
/**
* Initialises the {@code Text} and {@code Circle} objects so that all genes are standardised.
@@ -66,7 +68,7 @@ public abstract class GUIGene extends Group {
text.setWrappingWidth(Constants.NODE_RADIUS * 2);
text.setX(-Constants.NODE_RADIUS);
- mainCircle = new Circle(Constants.NODE_RADIUS, Constants.NEUTRAL_COLOUR);
+ mainCircle = new Circle(Constants.NODE_RADIUS, Constants.NEUTRAL_PAINT);
mainCircle.setStroke(Paint.valueOf("black"));
getChildren().addAll(mainCircle, text);
@@ -105,24 +107,21 @@ public abstract class GUIGene extends Group {
public final void setState(GUIGeneState newState) {
switch (newState) {
case NEUTRAL:
- mainCircle.setFill(Constants.NEUTRAL_COLOUR);
- setLinesVisible(false);
+ mainCircle.setFill(isLocked() ? Constants.HARD_HIGHLIGHT_PAINT : Constants.NEUTRAL_PAINT);
+ setLinesVisible(isLocked() ? true : false);
break;
case HOVER:
- mainCircle.setFill(Constants.MEDIUM_HIGHLIGHT_COLOUR);
+ mainCircle.setFill(Constants.MEDIUM_HIGHLIGHT_PAINT);
setLinesVisible(true);
break;
case EXTENDED_HOVER:
- mainCircle.setFill(Constants.SOFT_HIGHLIGHT_COLOUR);
- setLinesVisible(false);
+ mainCircle.setFill(Constants.SOFT_HIGHLIGHT_PAINT);
+ setLinesVisible(isLocked() ? true : false);
break;
case ACTIVE_HOVER:
- mainCircle.setFill(Constants.SOFT_HIGHLIGHT_COLOUR);
+ mainCircle.setFill(Constants.SOFT_HIGHLIGHT_PAINT);
setLinesVisible(true);
break;
-
- default:
- break;
}
currentState = newState;
}
@@ -134,4 +133,18 @@ public abstract class GUIGene extends Group {
* @param value the visibility value.
*/
protected abstract void setLinesVisible(boolean value);
+
+ public boolean isLocked() {
+ return lock > 0;
+ }
+
+ public void setLock(boolean value) {
+ if (value) {
+ lock++;
+ } else if (lock > 0) {
+ lock--;
+ } else {
+ lock = 0;
+ }
+ }
}
diff --git a/src/jcgp/gui/population/GUIInput.java b/src/jcgp/gui/population/GUIInput.java
index 9b5f567..d899585 100644
--- a/src/jcgp/gui/population/GUIInput.java
+++ b/src/jcgp/gui/population/GUIInput.java
@@ -68,4 +68,9 @@ public class GUIInput extends GUIGene implements GUIConnection {
*/
@Override
protected void setLinesVisible(boolean value) {}
+
+ @Override
+ public void setLockRecursively(boolean value) {
+ setLock(value);
+ }
}
diff --git a/src/jcgp/gui/population/GUINode.java b/src/jcgp/gui/population/GUINode.java
index 230d167..ee98f22 100644
--- a/src/jcgp/gui/population/GUINode.java
+++ b/src/jcgp/gui/population/GUINode.java
@@ -37,13 +37,13 @@ public class GUINode extends GUIGene implements GUIMutable, GUIConnection {
node.setGUIObject(this);
// create the output socket
- Circle output = new Circle(Constants.NODE_RADIUS, 0, Constants.SOCKET_RADIUS, Constants.SOCKET_COLOUR);
+ Circle output = new Circle(Constants.NODE_RADIUS, 0, Constants.SOCKET_RADIUS, Constants.SOCKET_PAINT);
output.setStroke(Paint.valueOf("black"));
// create input sockets
sockets = new Circle[GUI.resources.arity()];
for (int l = 0; l < sockets.length; l++) {
- sockets[l] = new Circle(Constants.SOCKET_RADIUS, Constants.SOCKET_COLOUR);
+ sockets[l] = new Circle(Constants.SOCKET_RADIUS, Constants.SOCKET_PAINT);
sockets[l].setStroke(Paint.valueOf("black"));
sockets[l].setId(String.valueOf(l));
// relocate them
@@ -128,4 +128,12 @@ public class GUINode extends GUIGene implements GUIMutable, GUIConnection {
lines[i].setVisible(value);
}
}
+
+ @Override
+ public void setLockRecursively(boolean value) {
+ setLock(value);
+ for (int i = 0; i < GUI.resources.arity(); i++) {
+ ((GUIConnection) ((Gene) node.getConnection(i)).getGUIObject()).setLockRecursively(value);
+ }
+ }
}
diff --git a/src/jcgp/gui/population/GUIOutput.java b/src/jcgp/gui/population/GUIOutput.java
index b281833..9ffef1d 100644
--- a/src/jcgp/gui/population/GUIOutput.java
+++ b/src/jcgp/gui/population/GUIOutput.java
@@ -35,7 +35,7 @@ public class GUIOutput extends GUIGene implements GUIMutable {
output.setGUIObject(this);
// create input socket
- Circle socket = new Circle(-Constants.NODE_RADIUS, 0, Constants.SOCKET_RADIUS, Constants.SOCKET_COLOUR);
+ Circle socket = new Circle(-Constants.NODE_RADIUS, 0, Constants.SOCKET_RADIUS, Constants.SOCKET_PAINT);
socket.setStroke(Paint.valueOf("black"));
socket.setId(String.valueOf(0));
Position.connect(line, (GUIGene) ((Gene) output.getSource()).getGUIObject());