diff options
Diffstat (limited to 'src/jcgp/gui/GUI.java')
-rw-r--r-- | src/jcgp/gui/GUI.java | 79 |
1 files changed, 78 insertions, 1 deletions
diff --git a/src/jcgp/gui/GUI.java b/src/jcgp/gui/GUI.java index 2f09dea..8735ccd 100644 --- a/src/jcgp/gui/GUI.java +++ b/src/jcgp/gui/GUI.java @@ -352,9 +352,14 @@ public class GUI extends Application { } /** - * + * Run/pause method. + * Run the experiment if it is paused, or pause it if it is running. + * <br> + * This method is the callback used by the run/pause button. It + * controls the jcgp service. */ public void runPause() { + // do nothing if experiment is finished or parameters aren't valid if (!jcgp.isFinished() && settingsPane.areParametersValid()) { if (!running) { runningMode(true); @@ -366,7 +371,15 @@ public class GUI extends Application { } } + /** + * Perform a single generation using {@code nextGeneration()}. + * <br> + * On top of that, this method performs all of the housekeeping + * that is normally done before and after running, such as + * refreshing the chromosome panes. + */ public void step() { + // do nothing if experiment is finished, running or parameters aren't valid if (!running && !jcgp.isFinished() && settingsPane.areParametersValid()) { if (settingsPane.isResetRequired()) { reset(); @@ -382,6 +395,11 @@ public class GUI extends Application { } } + /** + * Reset button callback. If the parameters are valid, + * this resets the entire experiment by calling {@code reset()} + * on jcgp. + */ public void reset() { if (!running && settingsPane.areParametersValid()) { setEvaluating(false); @@ -391,6 +409,10 @@ public class GUI extends Application { } } + /** + * Does a complete GUI refresh. + * This is potentially lengthy, so use with care. + */ public void reDraw() { populationPane.remakeTabs(); settingsPane.revalidateParameters(); @@ -398,6 +420,17 @@ public class GUI extends Application { console.flush(); } + /** + * Toggles the entire GUI between run and pause + * mode. + * <br><br> + * A lot of the GUI must be enabled or disabled + * depending on what the experiment is doing. This + * method provides a one-line way to make + * all required adjustments. + * + * @param value true if experiment is running, false otherwise. + */ private void runningMode(boolean value) { if (value) { populationPane.unlockOutputs(); @@ -415,42 +448,86 @@ public class GUI extends Application { running = value; } + /** + * Refresh the function selector, used when functions are enabled or disabled. + */ public void updateFunctionSelector() { functionSelector.remakeFunctions(jcgp.getResources().getFunctionSet()); } + /** + * @return true if jcgp is evolving. + */ public boolean isWorking() { return running; } + /** + * Relocate the function selector to the right position + * relative to the specified node and set it visible. + * + * @param event the mouse event containing cursor coordinates. + * @param node the node whose function should be changed. + */ public void bringFunctionSelector(MouseEvent event, GUINode node) { functionSelector.relocateAndShow(event, node); } + /** + * @return a reference to the {@code JCGP} experiment. + */ public JCGP getExperiment() { return jcgp; } + /** + * Starts the evaluation process with the given test case. + * It does so by calling {@code evaluateTestCase()} on + * the population pane. + * + * @param testCase the test case to evaluate. + */ public void evaluateTestCase(TestCase<Object> testCase) { populationPane.evaluateTestCase(testCase); } + /** + * Hide all evaluated values. This should be called when + * evaluations are no longer being performed. + */ public void hideGeneValues() { populationPane.hideValues(); } + /** + * Set the system into evaluation mode. + * When in evaluation mode, the population pane + * refreshes the node values whenever connection + * changes happen. + * + * @param value true if evaluations are happening, false otherwise. + */ public void setEvaluating(boolean value) { populationPane.setEvaluating(value); } + /** + * @return a reference to the GUI stage. + */ public Stage getStage() { return stage; } + /** + * Writes all buffered content out to the GUI console. + */ public void flushConsole() { console.flush(); } + /** + * @return the index of the chromosome currently being looked at. + */ public int getChromosomeIndex() { return populationPane.getSelectionModel().getSelectedIndex(); } |