Java Code Examples for javafx.collections.ObservableList#forEach()
The following examples show how to use
javafx.collections.ObservableList#forEach() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: VirtualResourceTree.java From jmonkeybuilder with Apache License 2.0 | 6 votes |
/** * Fill the tree item. * * @param item the tree item. */ @FxThread private void fill(@NotNull final TreeItem<VirtualResourceElement<?>> item) { final VirtualResourceElement<?> element = item.getValue(); if(!element.hasChildren()) { return; } final ObservableList<TreeItem<VirtualResourceElement<?>>> items = item.getChildren(); final Array<VirtualResourceElement<?>> children = element.getChildren(); children.sort(NAME_COMPARATOR); children.forEach(child -> items.add(new TreeItem<>(child))); items.forEach(this::fill); }
Example 2
Source File: UpdateAxisLabels.java From chart-fx with Apache License 2.0 | 6 votes |
private void setupDataSetListeners(Renderer renderer, ObservableList<DataSet> dataSets) { Map<DataSet, EventListener> dataSetListeners; if (renderer == null) { dataSetListeners = chartDataSetsListeners; } else if (rendererDataSetsListeners.containsKey(renderer)) { dataSetListeners = rendererDataSetsListeners.get(renderer); } else { dataSetListeners = new HashMap<>(); rendererDataSetsListeners.put(renderer, dataSetListeners); } ListChangeListener<DataSet> rendererListener = (ListChangeListener.Change<? extends DataSet> change) -> dataSetsChanged(change, renderer); dataSets.addListener(rendererListener); renderersListeners.put(renderer, rendererListener); dataSets.forEach((DataSet dataSet) -> { EventListener dataSetListener = update -> FXUtils.runFX(() -> dataSetChange(update, renderer)); EventRateLimiter rateLimitedDataSetListener = new EventRateLimiter(dataSetListener, UPDATE_RATE_LIMIT); dataSet.addListener(rateLimitedDataSetListener); dataSetListeners.put(dataSet, rateLimitedDataSetListener); dataSetChange(new AxisChangeEvent(dataSet, -1), renderer); }); }
Example 3
Source File: UpdateAxisLabels.java From chart-fx with Apache License 2.0 | 6 votes |
private void teardownDataSetListeners(Renderer renderer, ObservableList<DataSet> dataSets) { Map<DataSet, EventListener> dataSetListeners; if (renderer == null) { dataSetListeners = chartDataSetsListeners; } else if (rendererDataSetsListeners.containsKey(renderer)) { dataSetListeners = rendererDataSetsListeners.get(renderer); } else { dataSetListeners = new HashMap<>(); rendererDataSetsListeners.put(renderer, dataSetListeners); } dataSets.removeListener(renderersListeners.get(renderer)); renderersListeners.remove(renderer); dataSets.forEach((DataSet dataSet) -> { dataSet.removeListener(dataSetListeners.get(dataSet)); dataSetListeners.remove(dataSet); }); }
Example 4
Source File: UiUtils.java From jmonkeybuilder with Apache License 2.0 | 6 votes |
/** * Fill a list of components. * * @param container the container * @param node the node */ @FxThread public static void fillComponents(@NotNull final Array<ScreenComponent> container, @NotNull final Node node) { if (node instanceof ScreenComponent) { container.add((ScreenComponent) node); } if (node instanceof SplitPane) { final ObservableList<Node> items = ((SplitPane) node).getItems(); items.forEach(child -> fillComponents(container, child)); } else if (node instanceof TabPane) { final ObservableList<Tab> tabs = ((TabPane) node).getTabs(); tabs.forEach(tab -> fillComponents(container, tab.getContent())); } if (!(node instanceof Parent)) { return; } final ObservableList<Node> nodes = ((Parent) node).getChildrenUnmodifiable(); nodes.forEach(child -> fillComponents(container, child)); }
Example 5
Source File: ExportController.java From mapper-generator-javafx with Apache License 2.0 | 6 votes |
@FXML public void useTkMybatis() { final boolean selected = useTkMybatis.isSelected(); final ObservableList<Toggle> toggles = targetName.getToggles(); if (selected) { toggles.forEach(toggle -> { if ("MyBatis3Simple".equals(((RadioButton) toggle).getText())) { toggle.setSelected(true); } ((RadioButton) toggle).setDisable(true); }); } else { toggles.forEach(toggle -> { if ("Mybatis3".equals(((RadioButton) toggle).getText())) { toggle.setSelected(true); } ((RadioButton) toggle).setDisable(false); }); } }
Example 6
Source File: LabAssistantController.java From HealthPlus with Apache License 2.0 | 5 votes |
@FXML public void fillPieChart() { ArrayList<ArrayList<String>> data = lab.lastMonthsReports(12); String[] test = { "Blood Grouping & Rh","Lipid Profile Test","LFT","RFT", "HIV","CPK","Pathalogy Test", "Complete Blood Count" }; int tmpSize = test.length; ObservableList<PieChart.Data> pieChartData = FXCollections.observableArrayList(); for(int i = 0; i < tmpSize; i++) { pieChartData.add(new PieChart.Data(test[i], Integer.parseInt(data.get(1).get(i)))); } pieChartData.forEach(data1 -> data1.nameProperty().bind( Bindings.concat( data1.getName(), " (", data1.pieValueProperty(), ")" ) ) ); piechart.setLegendSide(Side.BOTTOM); piechart.setLegendVisible(true); piechart.setData(pieChartData); }
Example 7
Source File: PharmacistController.java From HealthPlus with Apache License 2.0 | 5 votes |
@FXML public void fillPieChart() { HashMap<String,String> supplierNames = pharmacist.getSupplierNames(); ArrayList<ArrayList<String>> suppliers = pharmacist.getSupplierSummary(); int noOfSuppliers = suppliers.get(0).size(); ObservableList<PieChart.Data> pieChartData = FXCollections.observableArrayList(); for (int i = 0; i < noOfSuppliers; i++) { String supplierID = suppliers.get(0).get(i); int stocks = Integer.parseInt(suppliers.get(1).get(i)); pieChartData.add(new PieChart.Data(supplierNames.get(supplierID), stocks)); } pieChartData.forEach(data1 -> data1.nameProperty().bind( Bindings.concat( data1.getName(), " (", data1.pieValueProperty().intValue(), ")" ) ) ); //piechart.setLabelLineLength(20); piechart.setLegendSide(Side.BOTTOM); piechart.setLabelsVisible(true); piechart.setData(pieChartData); }
Example 8
Source File: UiUtils.java From jmonkeybuilder with Apache License 2.0 | 5 votes |
/** * Get all elements of a menu. * * @param menuBar the menu bar * @return the all items */ @FxThread public static @NotNull Array<MenuItem> getAllItems(@NotNull final MenuBar menuBar) { final Array<MenuItem> container = ArrayFactory.newArray(MenuItem.class); final ObservableList<Menu> menus = menuBar.getMenus(); menus.forEach(menu -> getAllItems(container, menu)); return container; }
Example 9
Source File: ActivityDashboard.java From medusademo with Apache License 2.0 | 5 votes |
private static void calcNoOfNodes(Node node) { if (node instanceof Parent) { if (((Parent) node).getChildrenUnmodifiable().size() != 0) { ObservableList<Node> tempChildren = ((Parent) node).getChildrenUnmodifiable(); noOfNodes += tempChildren.size(); tempChildren.forEach(n -> calcNoOfNodes(n)); } } }
Example 10
Source File: UiUtils.java From jmonkeybuilder with Apache License 2.0 | 5 votes |
/** * Clear children of a pane. * * @param pane the pane. */ @FxThread public static void clear(@NotNull final Pane pane) { final ObservableList<Node> children = pane.getChildren(); children.forEach(UiUtils::unbind); children.clear(); }
Example 11
Source File: ColoredClock.java From medusademo with Apache License 2.0 | 5 votes |
private static void calcNoOfNodes(Node node) { if (node instanceof Parent) { if (((Parent) node).getChildrenUnmodifiable().size() != 0) { ObservableList<Node> tempChildren = ((Parent) node).getChildrenUnmodifiable(); noOfNodes += tempChildren.size(); tempChildren.forEach(n -> calcNoOfNodes(n)); } } }
Example 12
Source File: CombinedGauges.java From medusademo with Apache License 2.0 | 5 votes |
private static void calcNoOfNodes(Node node) { if (node instanceof Parent) { if (((Parent) node).getChildrenUnmodifiable().size() != 0) { ObservableList<Node> tempChildren = ((Parent) node).getChildrenUnmodifiable(); noOfNodes += tempChildren.size(); tempChildren.forEach(n -> calcNoOfNodes(n)); } } }
Example 13
Source File: MainController.java From qiniu with MIT License | 5 votes |
/** * 设置文件生存时间 */ public void setLife() { ObservableList<FileBean> selectedItems = resTV.getSelectionModel().getSelectedItems(); if (Checker.isNotEmpty(selectedItems)) { // 弹出输入框 String fileLife = DialogUtils.showInputDialog(null, QiniuValueConsts.FILE_LIFE, QiniuValueConsts.DEFAULT_FILE_LIFE); if (Checker.isNumber(fileLife)) { int life = Formatter.stringToInt(fileLife); selectedItems.forEach(bean -> service.setFileLife(bucketCB.getValue(), bean.getName(), life)); } } }
Example 14
Source File: MainController.java From qiniu with MIT License | 5 votes |
/** * 更新镜像源 */ public void updateFile() { ObservableList<FileBean> selectedItems = resTV.getSelectionModel().getSelectedItems(); if (Checker.isNotEmpty(selectedItems)) { selectedItems.forEach(bean -> service.updateFile(bucketCB.getValue(), bean.getName())); } }
Example 15
Source File: MainController.java From qiniu with MIT License | 5 votes |
/** * 下载文件 */ private void download(DownloadWay way) { ObservableList<FileBean> selectedItems = resTV.getSelectionModel().getSelectedItems(); if (Checker.isNotEmpty(selectedItems)) { if (way == DownloadWay.PUBLIC) { selectedItems.forEach(bean -> service.publicDownload(bean.getName(), domainTF.getText())); } else { selectedItems.forEach(bean -> service.privateDownload(bean.getName(), domainTF.getText())); } } }
Example 16
Source File: ClockControl.java From medusademo with Apache License 2.0 | 5 votes |
private static void calcNoOfNodes(Node node) { if (node instanceof Parent) { if (((Parent) node).getChildrenUnmodifiable().size() != 0) { ObservableList<Node> tempChildren = ((Parent) node).getChildrenUnmodifiable(); noOfNodes += tempChildren.size(); tempChildren.forEach(n -> calcNoOfNodes(n)); } } }
Example 17
Source File: KpiDashboard.java From medusademo with Apache License 2.0 | 5 votes |
private static void calcNoOfNodes(Node node) { if (node instanceof Parent) { if (((Parent) node).getChildrenUnmodifiable().size() != 0) { ObservableList<Node> tempChildren = ((Parent) node).getChildrenUnmodifiable(); noOfNodes += tempChildren.size(); tempChildren.forEach(n -> calcNoOfNodes(n)); } } }
Example 18
Source File: TransactionAwareTrade.java From bisq with GNU Affero General Public License v3.0 | 5 votes |
private boolean isRefundPayoutTx(String txId) { String tradeId = trade.getId(); ObservableList<Dispute> disputes = refundManager.getDisputesAsObservableList(); AtomicBoolean isRefundTx = new AtomicBoolean(false); AtomicBoolean isDisputeRelatedToThis = new AtomicBoolean(false); disputes.forEach(dispute -> { String disputeTradeId = dispute.getTradeId(); isDisputeRelatedToThis.set(tradeId.equals(disputeTradeId)); if (isDisputeRelatedToThis.get()) { Transaction tx = btcWalletService.getTransaction(txId); if (tx != null) { tx.getOutputs().forEach(txo -> { if (btcWalletService.isTransactionOutputMine(txo)) { try { Address receiverAddress = txo.getAddressFromP2PKHScript(btcWalletService.getParams()); Contract contract = checkNotNull(trade.getContract()); String myPayoutAddressString = contract.isMyRoleBuyer(pubKeyRing) ? contract.getBuyerPayoutAddressString() : contract.getSellerPayoutAddressString(); if (receiverAddress != null && myPayoutAddressString.equals(receiverAddress.toString())) { isRefundTx.set(true); } } catch (Throwable ignore) { } } }); } } }); return isRefundTx.get() && isDisputeRelatedToThis.get(); }
Example 19
Source File: ServiceDataMatch.java From Corendon-LostLuggage with MIT License | 4 votes |
/** * Here are two different observable lists actually being compared * * @param foundList list of found luggage that will be compared * @param lostList list of lost luggage that will be compared * @param minPercentage percentage that is required to be a match * @return ObservableList of the type: matched luggage ! */ private ObservableList<MatchLuggage> checkData( ObservableList<LostLuggage> lostList, ObservableList<FoundLuggage> foundList, int minPercentage){ //clear the previous lists potentialMatchesList.clear(); this.potentialMatchesList.clear(); //loop trough all the items in the lost list lostList.forEach((lost)-> { //and compare them to all the items of the found list foundList.forEach((found) -> { //set match id and percentage on zero. int matchedId = 0; int matchingPercentage = 0; //Contorle of different match possibilities: if (lost.getLuggageType() == found.getLuggageType() && lost.getLuggageType() != 0 && found.getLuggageType() != 0){ matchingPercentage += 10; } //check if they are equal and both not null if (checkField(lost.getBrand(), found.getBrand()) ){ matchingPercentage += 10; } if (checkField(lost.getMainColor(), found.getMainColor()) ) { matchingPercentage += 10; } if (checkField(lost.getSecondColor(), found.getSecondColor()) ) { matchingPercentage += 10; } if (checkField(lost.getFlight(), found.getFlight()) ) { matchingPercentage += 10; } if (checkField(lost.getWeight(), found.getWeight()) ){ matchingPercentage += 10; } if (checkField(lost.getSize(), found.getSize()) ) { matchingPercentage += 10; } if (checkField(lost.getLuggageTag(), found.getLuggageTag()) ) { matchingPercentage += 50; if (matchingPercentage >= 100){ matchingPercentage=100; System.out.println("Same: luggage tag"); } } //check if the match percentage is higher than the minimum if (matchingPercentage>=minPercentage){ this.potentialMatchesList.add(new MatchLuggage( found.getRegistrationNr(), lost.getRegistrationNr(), lost.getLuggageTag()+" | "+found.getLuggageTag(), matchingPercentage, lost.getLuggageType()+" | "+found.getLuggageType(), lost.getBrand()+" | "+found.getBrand(), lost.getMainColor()+" | "+found.getMainColor(), lost.getSecondColor()+" | "+found.getSecondColor(), lost.getSize()+" | "+found.getSize(), lost.getWeight()+" | "+found.getWeight(), lost.getOtherCharaccteristics()+" | "+found.getOtherCharaccteristics(), matchedId++)); } }); }); return potentialMatchesList; }
Example 20
Source File: UiUtils.java From jmonkeybuilder with Apache License 2.0 | 2 votes |
/** * Collect all items. * * @param container the container * @param menuButton the menu button */ @FxThread public static void getAllItems(@NotNull final Array<MenuItem> container, @NotNull final MenuButton menuButton) { final ObservableList<MenuItem> items = menuButton.getItems(); items.forEach(subMenuItem -> getAllItems(container, subMenuItem)); }