From dbae5ce2e0765f229e11b692a2aba570286980f4 Mon Sep 17 00:00:00 2001 From: Eduardo Pedroni Date: Thu, 10 Apr 2014 16:57:30 +0100 Subject: Added manual test case evaluation to GUI --- src/jcgp/gui/population/PopulationPane.java | 40 ++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 9 deletions(-) (limited to 'src/jcgp/gui/population/PopulationPane.java') diff --git a/src/jcgp/gui/population/PopulationPane.java b/src/jcgp/gui/population/PopulationPane.java index 5232eb5..64b61c4 100644 --- a/src/jcgp/gui/population/PopulationPane.java +++ b/src/jcgp/gui/population/PopulationPane.java @@ -3,26 +3,29 @@ package jcgp.gui.population; import javafx.scene.control.Tab; import javafx.scene.control.TabPane; import jcgp.JCGP; -import jcgp.backend.population.Population; -import jcgp.backend.resources.Resources; +import jcgp.backend.modules.problem.TestCaseProblem; +import jcgp.backend.modules.problem.TestCaseProblem.TestCase; +import jcgp.gui.GUI; public class PopulationPane extends TabPane { - public PopulationPane(JCGP jcgp) { + private GUI gui; + + public PopulationPane(GUI gui) { super(); - + this.gui = gui; setTabClosingPolicy(TabClosingPolicy.UNAVAILABLE); - - remakeTabs(jcgp.getPopulation(), jcgp.getResources()); + remakeTabs(); } - public void remakeTabs(Population population, Resources resources) { + public void remakeTabs() { getTabs().clear(); + JCGP jcgp = gui.getExperiment(); Tab tab; ChromosomePane cp; - for (int i = 0; i < resources.populationSize(); i++) { - cp = new ChromosomePane(population.getChromosome(i), resources); + for (int i = 0; i < jcgp.getResources().populationSize(); i++) { + cp = new ChromosomePane(jcgp.getPopulation().getChromosome(i), gui); tab = new Tab("Chr " + i); tab.setContent(cp); getTabs().add(tab); @@ -46,4 +49,23 @@ public class PopulationPane extends TabPane { ((ChromosomePane) getTabs().get(i).getContent()).relockOutputs(); } } + + public void evaluateTestCase(TestCase testCase) { + if (gui.getExperiment().getProblem() instanceof TestCaseProblem) { + if (testCase.getInputs().length == gui.getExperiment().getResources().inputs()) { + for (int i = 0; i < getTabs().size(); i++) { + ((ChromosomePane) getTabs().get(i).getContent()).setInputs(testCase.getInputs()); + } + } else { + throw new IllegalArgumentException("Test case has " + testCase.getInputs().length + + " inputs and chromosome has " + gui.getExperiment().getResources().inputs()); + } + } + } + + public void hideValues() { + for (int i = 0; i < getTabs().size(); i++) { + ((ChromosomePane) getTabs().get(i).getContent()).hideValues(); + } + } } -- cgit v1.2.3