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.java44
1 files changed, 37 insertions, 7 deletions
diff --git a/src/jcgp/gui/population/GUIGene.java b/src/jcgp/gui/population/GUIGene.java
index eb7070c..6e61875 100644
--- a/src/jcgp/gui/population/GUIGene.java
+++ b/src/jcgp/gui/population/GUIGene.java
@@ -21,9 +21,17 @@ import jcgp.gui.constants.Constants;
*/
public abstract class GUIGene extends Group {
+ public enum GUIGeneState {
+ NEUTRAL,
+ HOVER,
+ EXTENDED_HOVER
+ }
+
+ private GUIGeneState currentState = GUIGeneState.NEUTRAL;
+
private Text text = new Text();
- protected final Circle mainCircle = new Circle(Constants.NODE_RADIUS, Paint.valueOf(Constants.NEUTRAL_COLOUR));
-
+ private Circle mainCircle = new Circle(Constants.NODE_RADIUS, Paint.valueOf(Constants.NEUTRAL_COLOUR));
+
/**
* Initialises the {@code Text} and {@code Circle} objects so that all genes are standardised.
*/
@@ -34,12 +42,12 @@ public abstract class GUIGene extends Group {
text.setWrappingWidth(Constants.NODE_RADIUS * 2);
text.setX(-Constants.NODE_RADIUS);
text.setVisible(true);
-
+
mainCircle.setStroke(Paint.valueOf("black"));
-
+
getChildren().addAll(mainCircle, text);
}
-
+
/**
* Sets the gene's text field.
*
@@ -48,8 +56,30 @@ public abstract class GUIGene extends Group {
public void setText(String newText) {
text.setText(newText);
}
-
+
+ public GUIGeneState getState() {
+ return currentState;
+ }
+
+ void setState(GUIGeneState newState) {
+ switch (newState) {
+ case NEUTRAL:
+ mainCircle.setFill(Paint.valueOf(Constants.NEUTRAL_COLOUR));
+ break;
+ case HOVER:
+ mainCircle.setFill(Paint.valueOf(Constants.MEDIUM_HIGHLIGHT_COLOUR));
+ break;
+ case EXTENDED_HOVER:
+ mainCircle.setFill(Paint.valueOf(Constants.SOFT_HIGHLIGHT_COLOUR));
+ break;
+
+ default:
+ break;
+ }
+ currentState = newState;
+ }
+
public abstract void mouseEnter();
public abstract void mouseExit();
-
+
}