From 12ebe6f6375e7db31ba1bb2eba5e3b28b51c7a19 Mon Sep 17 00:00:00 2001 From: Eduardo Pedroni Date: Sat, 15 Nov 2014 19:16:25 +0000 Subject: Added GUIHandlers file for extracted handlers, started removing parent class references from genes --- src/jcgp/gui/population/GUIGene.java | 81 ++++++++++++------------------------ 1 file changed, 27 insertions(+), 54 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 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. + *

+ * 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(); } -- cgit v1.2.3