From db2bc6e935ff1632d78ea8a03606b396944ef21e Mon Sep 17 00:00:00 2001 From: Eduardo Pedroni Date: Mon, 24 Nov 2014 16:29:06 +0000 Subject: Added partial support for connection manipulation, now using a static storage class for targetting. --- src/jcgp/gui/population/GUIGene.java | 21 ++++++++++++++++++--- src/jcgp/gui/population/GUIMutable.java | 10 +++++++++- src/jcgp/gui/population/GUINode.java | 25 ++++++++++--------------- src/jcgp/gui/population/GUIOutput.java | 13 ++++++++----- 4 files changed, 45 insertions(+), 24 deletions(-) (limited to 'src/jcgp/gui/population') diff --git a/src/jcgp/gui/population/GUIGene.java b/src/jcgp/gui/population/GUIGene.java index f0fd568..5e6107f 100644 --- a/src/jcgp/gui/population/GUIGene.java +++ b/src/jcgp/gui/population/GUIGene.java @@ -54,7 +54,13 @@ public abstract class GUIGene extends Group { /** * User is hovering over an output connected to this gene. */ - ACTIVE_HOVER + ACTIVE_HOVER, + + GOOD_TARGET, + + NEUTRAL_TARGET, + + BAD_TARGET } private GUIGeneState currentState = GUIGeneState.NEUTRAL; @@ -119,7 +125,7 @@ public abstract class GUIGene extends Group { switch (newState) { case NEUTRAL: mainCircle.setFill(isLocked() ? Constants.HARD_HIGHLIGHT_PAINT : Constants.NEUTRAL_PAINT); - setLinesVisible(isLocked() ? true : false); + setLinesVisible(isLocked()); break; case HOVER: mainCircle.setFill(Constants.MEDIUM_HIGHLIGHT_PAINT); @@ -127,12 +133,21 @@ public abstract class GUIGene extends Group { break; case EXTENDED_HOVER: mainCircle.setFill(Constants.SOFT_HIGHLIGHT_PAINT); - setLinesVisible(isLocked() ? true : false); + setLinesVisible(isLocked()); break; case ACTIVE_HOVER: mainCircle.setFill(Constants.SOFT_HIGHLIGHT_PAINT); setLinesVisible(true); break; + case GOOD_TARGET: + mainCircle.setFill(Constants.GOOD_SELECTION_PAINT); + break; + case NEUTRAL_TARGET: + mainCircle.setFill(Constants.NEUTRAL_SELECTION_PAINT); + break; + case BAD_TARGET: + mainCircle.setFill(Constants.BAD_SELECTION_PAINT); + break; } currentState = newState; } diff --git a/src/jcgp/gui/population/GUIMutable.java b/src/jcgp/gui/population/GUIMutable.java index b210672..fa996e2 100644 --- a/src/jcgp/gui/population/GUIMutable.java +++ b/src/jcgp/gui/population/GUIMutable.java @@ -1,5 +1,7 @@ package jcgp.gui.population; +import javafx.scene.shape.Line; + /** * A loose equivalent to {@link jcgp.backend.population.Mutable}. *
@@ -9,4 +11,10 @@ package jcgp.gui.population; * @author Eduardo Pedroni * */ -public interface GUIMutable {} +public interface GUIMutable { + + public Line[] getLines(); + + public GUIConnection[] getConnections(); + +} diff --git a/src/jcgp/gui/population/GUINode.java b/src/jcgp/gui/population/GUINode.java index ee98f22..1a32426 100644 --- a/src/jcgp/gui/population/GUINode.java +++ b/src/jcgp/gui/population/GUINode.java @@ -76,21 +76,7 @@ public class GUINode extends GUIGene implements GUIMutable, GUIConnection { this.node = node; } - /** - * Returns one of this object's connection lines. Lines are - * indexed in the same order as sockets and the connections - * they represent. - * - * @param index the line to return. - * @return the indexed line object. - */ - public Line getLine(int index) { - return lines[index]; - } - - /** - * @return the entire {@code Line} array. - */ + @Override public Line[] getLines() { return lines; } @@ -136,4 +122,13 @@ public class GUINode extends GUIGene implements GUIMutable, GUIConnection { ((GUIConnection) ((Gene) node.getConnection(i)).getGUIObject()).setLockRecursively(value); } } + + @Override + public GUIConnection[] getConnections() { + GUIConnection[] connections = new GUIConnection[GUI.resources.arity()]; + for (int c = 0; c < connections.length; c++) { + connections[c] = (GUIConnection) ((Gene) node.getConnection(c)).getGUIObject(); + } + return connections; + } } diff --git a/src/jcgp/gui/population/GUIOutput.java b/src/jcgp/gui/population/GUIOutput.java index 3bc81d9..f023d00 100644 --- a/src/jcgp/gui/population/GUIOutput.java +++ b/src/jcgp/gui/population/GUIOutput.java @@ -62,15 +62,18 @@ public class GUIOutput extends GUIGene implements GUIMutable { this.output = output; } - /** - * @return this output's single connection line. - */ - public Line getLine() { - return line; + @Override + public Line[] getLines() { + return new Line[] {line}; } @Override protected void setLinesVisible(boolean value) { line.setVisible(value); } + + @Override + public GUIConnection[] getConnections() { + return new GUIConnection[] {(GUIConnection) output.getGUIObject()}; + } } -- cgit v1.2.3