diff options
author | Eduardo Pedroni <ep625@york.ac.uk> | 2014-05-06 14:29:37 +0100 |
---|---|---|
committer | Eduardo Pedroni <ep625@york.ac.uk> | 2014-05-06 14:29:37 +0100 |
commit | 8189116ea4b5db4675e31dfd04a5687d55e29262 (patch) | |
tree | c1815021452a888f8838f1628d8fb4689777e73e /src/jcgp/gui/settings | |
parent | aa9e74e7f67789f6353fc26e02ee8e68e40609a2 (diff) |
Added javadocs, made minor changes to the comments
Diffstat (limited to 'src/jcgp/gui/settings')
-rw-r--r-- | src/jcgp/gui/settings/SettingsPane.java | 9 | ||||
-rw-r--r-- | src/jcgp/gui/settings/parameters/GUIParameter.java | 2 | ||||
-rw-r--r-- | src/jcgp/gui/settings/testcase/TestCaseTable.java | 33 |
3 files changed, 36 insertions, 8 deletions
diff --git a/src/jcgp/gui/settings/SettingsPane.java b/src/jcgp/gui/settings/SettingsPane.java index 802c1f1..2898dc3 100644 --- a/src/jcgp/gui/settings/SettingsPane.java +++ b/src/jcgp/gui/settings/SettingsPane.java @@ -255,7 +255,7 @@ public class SettingsPane extends AnchorPane { } private Button makeTestCaseButton() { - Button b = new Button("Show data1"); + Button b = new Button("Show data"); b.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { @@ -331,7 +331,7 @@ public class SettingsPane extends AnchorPane { fc.getExtensionFilters().add(new ExtensionFilter("All files", "*.*")); File chrFile = fc.showOpenDialog(gui.getStage()); if (chrFile != null) { - gui.getExperiment().loadChromosome(chrFile, 0); + gui.getExperiment().loadChromosome(chrFile, gui.getChromosomeIndex()); gui.reDraw(); } gui.flushConsole(); @@ -346,7 +346,7 @@ public class SettingsPane extends AnchorPane { fc.getExtensionFilters().add(new ExtensionFilter("All files", "*.*")); File chrFile = fc.showSaveDialog(gui.getStage()); if (chrFile != null) { - gui.getExperiment().saveChromosome(chrFile, 0); + gui.getExperiment().saveChromosome(chrFile, gui.getChromosomeIndex()); } gui.flushConsole(); } @@ -474,6 +474,9 @@ public class SettingsPane extends AnchorPane { parameter.applyValue(); } updateArity(); + if (testCaseTable != null) { + testCaseTable.close(); + } } /** diff --git a/src/jcgp/gui/settings/parameters/GUIParameter.java b/src/jcgp/gui/settings/parameters/GUIParameter.java index 3009340..f896fa3 100644 --- a/src/jcgp/gui/settings/parameters/GUIParameter.java +++ b/src/jcgp/gui/settings/parameters/GUIParameter.java @@ -23,7 +23,7 @@ import jcgp.gui.settings.SettingsPane; * This is the base class for all @code{GUIParameter}s. Using the factory method @code{GUIParameter.create()} * generates an appropriate instance of this class for the specified parameter. * <br><br> - * @code{GUIParameter} is an @code{HBox} containing a @code{Text} for the parameter name + * A @code{GUIParameter} is an @code{HBox} containing a @code{Text} for the parameter name * and a @code{Control} for interaction. * It stores an instance of its associated @code{Parameter} object and also contains a @code{Tooltip} for * displaying status information. diff --git a/src/jcgp/gui/settings/testcase/TestCaseTable.java b/src/jcgp/gui/settings/testcase/TestCaseTable.java index d4c1ff9..d4f789c 100644 --- a/src/jcgp/gui/settings/testcase/TestCaseTable.java +++ b/src/jcgp/gui/settings/testcase/TestCaseTable.java @@ -20,7 +20,10 @@ import jcgp.backend.resources.Resources; import jcgp.gui.GUI; /** - * + * This is a test case table. For problems that have test cases, + * this table shows the test case inputs and outputs. Clicking on + * a test case (one is shown per row) applies the values to all + * chromosome inputs shows the calculated values throughout the chromosome. * * @author Eduardo Pedroni * @@ -29,17 +32,27 @@ public class TestCaseTable extends Stage { private TableView<TestCase<Object>> table; + /** + * Make a new instance of {@code TestCaseTable}. + * + * @param testCaseProblem the {@code TestCaseProblem} whose data must be displayed. + * @param gui a reference to the GUI. + */ public TestCaseTable(final TestCaseProblem<Object> testCaseProblem, final GUI gui) { super(); Resources resources = gui.getExperiment().getResources(); + // create the actual table view table = new TableView<TestCase<Object>>(); + // get test cases from problem ObservableList<TestCase<Object>> testCaseList = testCaseProblem.getTestCases(); + // prepare input and output columns ArrayList<TableColumn<TestCase<Object>, String>> inputs = new ArrayList<TableColumn<TestCase<Object>, String>>(resources.inputs()); ArrayList<TableColumn<TestCase<Object>, String>> outputs = new ArrayList<TableColumn<TestCase<Object>, String>>(resources.outputs()); + // create input columns TableColumn<TestCase<Object>, String> tc; for (int i = 0; i < resources.inputs(); i++) { tc = new TableColumn<TestCase<Object>, String>("I: " + i); @@ -48,13 +61,16 @@ public class TestCaseTable extends Stage { tc.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<TestCase<Object>,String>, ObservableValue<String>>() { @Override public ObservableValue<String> call(CellDataFeatures<TestCase<Object>, String> param) { + // create a new string property and give it the test case value, no need for dynamic binding - this wont change often return new SimpleStringProperty(param.getValue().getInput(index).toString()); } }); tc.setSortable(false); + // set column width so all columns are distributed across the width of the stage tc.prefWidthProperty().bind(table.widthProperty().divide(resources.inputs() + resources.outputs())); } + // create output columns for (int o = 0; o < resources.outputs(); o++) { tc = new TableColumn<TestCase<Object>, String>("O: " + o); outputs.add(tc); @@ -62,37 +78,46 @@ public class TestCaseTable extends Stage { tc.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<TestCase<Object>,String>, ObservableValue<String>>() { @Override public ObservableValue<String> call(CellDataFeatures<TestCase<Object>, String> param) { + // create a new string property and give it the test case value, no need for dynamic binding - this wont change often return new SimpleStringProperty(param.getValue().getOutput(index).toString()); } }); tc.setSortable(false); + // set column width so all columns are distributed across the width of the stage tc.prefWidthProperty().bind(table.widthProperty().divide(resources.inputs() + resources.outputs())); } + // add created columns table.getColumns().addAll(inputs); table.getColumns().addAll(outputs); + // populate table with actual data table.setItems(testCaseList); + // apply test case values when a new test case is selected table.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<TestCase<Object>>() { @Override - public void changed( - ObservableValue<? extends TestCase<Object>> observable, TestCase<Object> oldValue, TestCase<Object> newValue) { + public void changed(ObservableValue<? extends TestCase<Object>> observable, TestCase<Object> oldValue, TestCase<Object> newValue) { gui.evaluateTestCase(newValue); } }); + // when the stage is closed, clear the selection + // this doesn't work if the stage is closed by the program for some reason... setOnCloseRequest(new EventHandler<WindowEvent>() { @Override public void handle(WindowEvent event) { gui.hideGeneValues(); - table.getSelectionModel().select(null); + table.getSelectionModel().clearSelection(); } }); setScene(new Scene(table)); } + /** + * @return a reference to the actual table of test cases. + */ public TableView<TestCase<Object>> getTable() { return table; } |