aboutsummaryrefslogtreecommitdiffstats
path: root/src/jcgp/gui/population/GUIGene.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/jcgp/gui/population/GUIGene.java')
-rw-r--r--src/jcgp/gui/population/GUIGene.java24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/jcgp/gui/population/GUIGene.java b/src/jcgp/gui/population/GUIGene.java
index 02b87e7..f0fd568 100644
--- a/src/jcgp/gui/population/GUIGene.java
+++ b/src/jcgp/gui/population/GUIGene.java
@@ -14,7 +14,14 @@ import jcgp.gui.constants.Constants;
* <br><br>
* In practice, this is subclass of {@code javafx.scene.Group} containing a {@code Circle}
* object and a {@code Text} object. Subclasses may add further elements to the group, for
- * instance to display connection input and output sockets.
+ * instance to display connection input and output sockets.
+ * <br><br>
+ * Genes also contain a locked property. When locked, some gene states behave slightly
+ * differently. This is used so genes remain highlighted even in the neutral state. The
+ * gene lock is in fact recursive; a gene can be locked multiple times and only unlocking
+ * it as many times will actually revert it back to its unlocked state. This allows multiple
+ * pathways to lock the same gene independently without affecting each other; the gene remains
+ * locked until no pathways are locking it.
*
* @author Eduardo Pedroni
*
@@ -55,6 +62,10 @@ public abstract class GUIGene extends Group {
private Text text;
private Circle mainCircle;
+ /**
+ * Recursive lock; lock == 0 means unlocked, lock > 0 means locked.
+ * Accessing using {@code setLock(...)}.
+ */
private int lock = 0;
/**
@@ -134,10 +145,21 @@ public abstract class GUIGene extends Group {
*/
protected abstract void setLinesVisible(boolean value);
+ /**
+ * @return true if the gene is locked, false otherwise.
+ */
public boolean isLocked() {
return lock > 0;
}
+ /**
+ * Locks or unlocks the gene once. Locked genes
+ * behave slightly differently in some states.
+ * <br>
+ * Unlocking an already unlocked gene does nothing.
+ *
+ * @param value true to lock, false to unlock;
+ */
public void setLock(boolean value) {
if (value) {
lock++;