aboutsummaryrefslogtreecommitdiffstats
path: root/src/jcgp/gui/population/GUIGene.java
diff options
context:
space:
mode:
authorEduardo Pedroni <e.pedroni91@gmail.com>2014-11-15 19:16:25 +0000
committerEduardo Pedroni <e.pedroni91@gmail.com>2014-11-15 19:16:25 +0000
commit12ebe6f6375e7db31ba1bb2eba5e3b28b51c7a19 (patch)
treee4ed8c2617550db031d8cf94cdc52d71ac972cab /src/jcgp/gui/population/GUIGene.java
parentd0aca8c4035a59bdb562650a4a8d6efbcf55f2ca (diff)
Added GUIHandlers file for extracted handlers, started removing parent class references from genes
Diffstat (limited to 'src/jcgp/gui/population/GUIGene.java')
-rw-r--r--src/jcgp/gui/population/GUIGene.java81
1 files changed, 27 insertions, 54 deletions
diff --git a/src/jcgp/gui/population/GUIGene.java b/src/jcgp/gui/population/GUIGene.java
index bae7647..eb7070c 100644
--- a/src/jcgp/gui/population/GUIGene.java
+++ b/src/jcgp/gui/population/GUIGene.java
@@ -7,33 +7,27 @@ import javafx.scene.shape.Circle;
import javafx.scene.text.Font;
import javafx.scene.text.Text;
import javafx.scene.text.TextAlignment;
-import jcgp.backend.population.Connection;
import jcgp.gui.constants.Constants;
+/**
+ * Defines the general behaviour of the visual representation of each chromosome gene.
+ * <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.
+ *
+ * @author Eduardo Pedroni
+ *
+ */
public abstract class GUIGene extends Group {
- public enum GUIGeneState {
- NEUTRAL,
- HOVER,
- INDIRECT_HOVER,
- ACTIVE_HOVER,
- LOCKED_HOVER,
- SOURCE,
- VALID_TARGET,
- NO_CHANGE_TARGET,
- INVALID_TARGET
- }
-
- protected Text text = new Text();
- protected Circle mainCircle = new Circle(Constants.NODE_RADIUS, Paint.valueOf("white"));
+ private Text text = new Text();
+ protected final Circle mainCircle = new Circle(Constants.NODE_RADIUS, Paint.valueOf(Constants.NEUTRAL_COLOUR));
- private GUIGeneState state = GUIGeneState.NEUTRAL;
-
- protected ChromosomePane parent;
-
- protected int locked = 0;
-
- public GUIGene() {
+ /**
+ * Initialises the {@code Text} and {@code Circle} objects so that all genes are standardised.
+ */
+ protected GUIGene() {
text.setFont(Font.font("Arial", 12));
text.setTextOrigin(VPos.CENTER);
text.setTextAlignment(TextAlignment.CENTER);
@@ -42,41 +36,20 @@ public abstract class GUIGene extends Group {
text.setVisible(true);
mainCircle.setStroke(Paint.valueOf("black"));
+
+ getChildren().addAll(mainCircle, text);
}
- public void setState(GUIGeneState newState) {
- state = newState;
- }
-
- public GUIGeneState getState() {
- return state;
- }
-
- public boolean isLocked() {
- return locked > 0;
- }
-
- public int getLocks() {
- return locked;
+ /**
+ * Sets the gene's text field.
+ *
+ * @param newText the text string to be displayed.
+ */
+ public void setText(String newText) {
+ text.setText(newText);
}
- protected abstract void setLocked(boolean value);
-
- public abstract void addLocks(int value);
-
- public abstract void removeLocks(int value);
-
- public abstract void updateLines();
-
- public abstract void setChangingConnection(Connection newConnection);
-
- public abstract Connection getChangingConnection();
-
- public abstract void setConnectionStates(GUIGeneState newState);
-
- public abstract void resetState();
-
- public abstract void setConnectionLine(GUIGene gene);
+ public abstract void mouseEnter();
+ public abstract void mouseExit();
- public abstract void updateText();
}