List of usage examples for javafx.collections ObservableList iterator
Iterator<E> iterator();
From source file:ipat_fx.FXMLDocumentController.java
@FXML public void nextGeneration() { //check if num of profiles is a valid input int numOfProfiles = Integer.parseInt(noOfProfiles.getText()); if (numOfProfiles > 8) { JOptionPane.showMessageDialog(null, "Please make the number of profiles smaller than 8."); } else {/*from ww w . j ava 2s . c o m*/ HashMap<String, Object> scores = new HashMap<>(); // TODO get the scores from the user input to then get the next gen ObservableList<Tab> tabs = null; if (tabFlag.equalsIgnoreCase("byImage")) { tabs = byImageTab.getTabs(); } else if (tabFlag.equalsIgnoreCase("byProfile")) { tabs = byProfileTab.getTabs(); } else { System.out.println("Something is wrong with tabFlag in FXML DOC CONT"); } Iterator<Tab> profileTabIterator = tabs.iterator(); while (profileTabIterator.hasNext()) { Tab profileTab = profileTabIterator.next(); ScrollPane scrollPane = (ScrollPane) profileTab.getContent(); FlowPane cells = (FlowPane) scrollPane.getContent(); Iterator<Node> cellIterator = cells.getChildren().iterator(); while (cellIterator.hasNext()) { GridPane cell = (GridPane) cellIterator.next(); Iterator<Node> nodeIterator = cell.getChildren().iterator(); while (nodeIterator.hasNext()) { Node cellElement = nodeIterator.next(); if (cellElement instanceof Slider) { scores.put(cellElement.getId(), String.valueOf(((Slider) cellElement).getValue())); } if (cellElement instanceof CheckBox) { scores.put(cellElement.getId(), ((CheckBox) cellElement).isSelected()); } } } } HashMap<String, Object> display = controller.mainloop(scores, numOfProfiles); WebView previewView = (WebView) display.get("previewView"); previewPane.getChildren().add(previewView); @SuppressWarnings("unchecked") HashMap<String, ArrayList<GridPane>> map = (HashMap<String, ArrayList<GridPane>>) display .get("results"); if (tabFlag.equalsIgnoreCase("byImage")) { byImageTab = getByImage(map); byImagePane.setCenter(byImageTab); } else if (tabFlag.equalsIgnoreCase("byProfile")) { byProfileTab = getByProfile(map, numOfProfiles); byProfilePane.setCenter(byProfileTab); } tabPane.getSelectionModel().selectedIndexProperty() .addListener((ObservableValue<? extends Number> ov, Number oldValue, Number newValue) -> { if (newValue == Number.class.cast(1)) { byImageTab = getByImage(map); byImagePane.setCenter(byImageTab); } else if (newValue == Number.class.cast(0)) { byProfileTab = getByProfile(map, numOfProfiles); byProfilePane.setCenter(byProfileTab); } else { System.out.println("Error this tab has not been created."); } }); } }