From d0718fe4762f6a50ec851085cb5d0e6d39ccc1b0 Mon Sep 17 00:00:00 2001 From: Eduardo Pedroni Date: Sat, 15 Nov 2014 23:30:20 +0000 Subject: Added GUIConnection and GUIMutable, started reintroducing lines but positioning is not working correctly. --- src/jcgp/gui/population/GUIGene.java | 44 ++++++++++++++++++++++++++++++------ 1 file changed, 37 insertions(+), 7 deletions(-) (limited to 'src/jcgp/gui/population/GUIGene.java') 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(); - + } -- cgit v1.2.3