Java Code Examples for javafx.collections.ObservableList#size()
The following examples show how to use
javafx.collections.ObservableList#size() .
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: GridPaneDetailPaneInfo.java From scenic-view with GNU General Public License v3.0 | 6 votes |
private void updateColumnConstraints() { final GridPane gridpane = (GridPane) getTarget(); final ObservableList<ColumnConstraints> columns = gridpane != null ? gridpane.getColumnConstraints() : null; columnConstraintsDetail.setConstraints(columns); if (columns != null) { for (int rowIndex = 1; rowIndex <= columns.size(); rowIndex++) { final ColumnConstraints cc = columns.get(rowIndex - 1); int colIndex = 0; columnConstraintsDetail.add(Integer.toString(rowIndex - 1), colIndex++, rowIndex); columnConstraintsDetail.addSize(cc.getMinWidth(), rowIndex, colIndex++); columnConstraintsDetail.addSize(cc.getPrefWidth(), rowIndex, colIndex++); columnConstraintsDetail.addSize(cc.getMaxWidth(), rowIndex, colIndex++); columnConstraintsDetail.add(cc.getPercentWidth() != -1 ? f.format(cc.getPercentWidth()) : "-", colIndex++, rowIndex); columnConstraintsDetail.addObject(cc.getHgrow(), rowIndex, colIndex++); columnConstraintsDetail.addObject(cc.getHalignment(), rowIndex, colIndex++); columnConstraintsDetail.add(Boolean.toString(cc.isFillWidth()), colIndex, rowIndex); } } }
Example 2
Source File: RightListViewController.java From mapper-generator-javafx with Apache License 2.0 | 6 votes |
/** * 刷新 table 的字段信息 */ @FXML public void refreshTableColumn() { ObservableList<VBox> selectedItemVBoxs = vBoxListView.getSelectionModel().getSelectedItems(); Assert.isTrue(selectedItemVBoxs.size() == 1, "请选择一个表进行操作", StageConstants.primaryStage); VBox selectedItemVBox = selectedItemVBoxs.get(0); String tableName = ((Label) ((HBox) selectedItemVBox.getChildren().get(0)).getChildren().get(0)).getText(); columnService.reloadColumns(tableName); // 如果 size == 2 说明是,闭合状态下点击,如果 > 2 说明是展开状态下点击,这时需要删除 ObservableList<Node> children = selectedItemVBox.getChildren(); if (children.size() > 2) { selectedItemVBox.getChildren().remove(2); } rightListViewInit.expandTableViewColumns(selectedItemVBox); }
Example 3
Source File: EditableTreeTable.java From Open-Lowcode with Eclipse Public License 2.0 | 6 votes |
/** * @return the elements corresponding to the active cell */ public List<E> getSelectedElements() { ObservableList<TreeTablePosition<EditableTreeTableLineItem<Wrapper<E>>, ?>> selectedcells = treetableview .getSelectionModel().getSelectedCells(); if (selectedcells.size() == 1) { TreeTablePosition<EditableTreeTableLineItem<Wrapper<E>>, ?> selectedposition = selectedcells.get(0); TreeTableColumn<EditableTreeTableLineItem<Wrapper<E>>, ?> tablecolumn = selectedposition.getTableColumn(); if (tablecolumn instanceof EditableTreeTableValueColumn) { @SuppressWarnings({ "unchecked", "rawtypes" }) EditableTreeTableValueColumn<E, ?, ?> tablecolumnparsed = (EditableTreeTableValueColumn) tablecolumn; TreeItem<EditableTreeTableLineItem<Wrapper<E>>> treeitem = selectedposition.getTreeItem(); EditableTreeTableLineItem<Wrapper<E>> rowdata = treeitem.getValue(); ArrayList<Wrapper<E>> filteredvalues = tablecolumnparsed.columngrouping.filterItems(rowdata, tablecolumnparsed.titlekey); ArrayList<E> returnedvalues = new ArrayList<E>(); for (int i = 0; i < filteredvalues.size(); i++) { returnedvalues.add(filteredvalues.get(i).getPayload()); } return returnedvalues; } } return new ArrayList<E>(); }
Example 4
Source File: GridPaneDetailPaneInfo.java From scenic-view with GNU General Public License v3.0 | 6 votes |
private void updateRowConstraints() { final GridPane gridpane = (GridPane) getTarget(); final ObservableList<RowConstraints> rows = gridpane != null ? gridpane.getRowConstraints() : null; rowConstraintsDetail.setConstraints(rows); if (rows != null) { for (int rowIndex = 1; rowIndex <= rows.size(); rowIndex++) { final RowConstraints rc = rows.get(rowIndex - 1); int colIndex = 0; rowConstraintsDetail.add(Integer.toString(rowIndex - 1), colIndex++, rowIndex); rowConstraintsDetail.addSize(rc.getMinHeight(), rowIndex, colIndex++); rowConstraintsDetail.addSize(rc.getPrefHeight(), rowIndex, colIndex++); rowConstraintsDetail.addSize(rc.getMaxHeight(), rowIndex, colIndex++); rowConstraintsDetail.add(rc.getPercentHeight() != -1 ? f.format(rc.getPercentHeight()) : "-", colIndex++, rowIndex); rowConstraintsDetail.addObject(rc.getVgrow(), rowIndex, colIndex++); rowConstraintsDetail.addObject(rc.getValignment(), rowIndex, colIndex++); rowConstraintsDetail.add(Boolean.toString(rc.isFillHeight()), colIndex, rowIndex); } } }
Example 5
Source File: QiniuService.java From qiniu with MIT License | 6 votes |
/** * 刷新文件 */ public void refreshFile(ObservableList<FileBean> fileBeans, String domain) { if (Checker.isNotEmpty(fileBeans)) { String[] files = new String[fileBeans.size()]; int i = 0; // 获取公有链接 for (FileBean fileBean : fileBeans) { files[i++] = QiniuUtils.buildUrl(fileBean.getName(), domain); } try { // 刷新文件 sdkManager.refreshFile(files); } catch (QiniuException e) { LOGGER.error("refresh files error, message -> " + e.getMessage()); DialogUtils.showException(e); } } }
Example 6
Source File: ProjectorArenaPane.java From ShootOFF with GNU General Public License v3.0 | 5 votes |
private Optional<Screen> getStageHomeScreen(Stage stage) { final double dpiScaleFactor = ShootOFFController.getDpiScaleFactorForScreen(); final ObservableList<Screen> stageHomeScreens = Screen.getScreensForRectangle(stage.getX() / dpiScaleFactor, stage.getY() / dpiScaleFactor, 1, 1); if (stageHomeScreens.isEmpty()) { final StringBuilder message = new StringBuilder( String.format("Didn't find screen for stage with title %s at (%f, %f)." + " Existing screens:%n", stage.getTitle(), stage.getX() / dpiScaleFactor, stage.getY() / dpiScaleFactor)); final Iterator<Screen> it = Screen.getScreens().iterator(); while (it.hasNext()) { final Screen s = it.next(); message.append(String.format("(w = %f, h = %f, x = %f, y = %f, dpi = %f)", s.getBounds().getWidth(), s.getBounds().getHeight(), s.getBounds().getMinX(), s.getBounds().getMinY(), s.getDpi())); if (it.hasNext()) { message.append("\n"); } } logger.error(message.toString()); return Optional.empty(); } else if (stageHomeScreens.size() > 1) { logger.warn("Found multiple screens as the possible arena home screen, this is unexpected: {}", stageHomeScreens.size()); } return Optional.of(stageHomeScreens.get(0)); }
Example 7
Source File: SetTableController.java From CPUSim with GNU General Public License v3.0 | 5 votes |
/** * Set the clones to the new array passed as a parameter. * Does not check for validity. * * @param newClones Object array containing new set of clones */ public void setClones(ObservableList newClones) { CpusimSet[] sets = new CpusimSet[newClones.size()]; for (int i = 0; i < newClones.size(); i++) { sets[i] = (CpusimSet) newClones.get(i); } clones = sets; }
Example 8
Source File: TabDockingContainer.java From marathonv5 with Apache License 2.0 | 5 votes |
@Override public void tab(Dockable base, Dockable dockable, int order, boolean select) { dockables.add(base); dockables.add(dockable); base.setContainer(this); dockable.setContainer(this); ObservableList<Tab> tabs = getTabs(); if (order > tabs.size()) { order = tabs.size(); } getTabs().add(order, newTab(dockable)); if (select) { getSelectionModel().select(order); } }
Example 9
Source File: IncrementTableController.java From CPUSim with GNU General Public License v3.0 | 5 votes |
/** * Set the clones to the new array passed as a parameter. * Does not check for validity. * * @param newClones Object array containing new set of clones */ public void setClones(ObservableList newClones) { Increment[] increments = new Increment[newClones.size()]; for (int i = 0; i < newClones.size(); i++) { increments[i] = (Increment) newClones.get(i); } clones = increments; }
Example 10
Source File: jfxtiles.java From jbang with MIT License | 5 votes |
private void calcNoOfNodes(Node node) { if (node instanceof Parent) { if (((Parent) node).getChildrenUnmodifiable().size() != 0) { ObservableList<Node> tempChildren = ((Parent) node).getChildrenUnmodifiable(); noOfNodes += tempChildren.size(); for (Node n : tempChildren) { calcNoOfNodes(n); } } } }
Example 11
Source File: SetTableController.java From CPUSim with GNU General Public License v3.0 | 5 votes |
/** * Check validity of array of Objects' properties. * @param micros an array of Objects to check. * @return boolean denoting whether array has objects with * valid properties or not */ public void checkValidity(ObservableList micros) { // convert the array to an array of Branches CpusimSet[] sets = new CpusimSet[micros.size()]; for (int i = 0; i < micros.size(); i++) { sets[i] = (CpusimSet) micros.get(i); } // check that all names are unique and nonempty Validate.rangeInBound(sets); Validate.valueFitsInNumBitsForSetMicros(sets); }
Example 12
Source File: Demo.java From Medusa 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(); for (Node n : tempChildren) { calcNoOfNodes(n); } } } }
Example 13
Source File: ParticipantDAO.java From pikatimer with GNU General Public License v3.0 | 5 votes |
public void addParticipant(ObservableList newParticipantList) { int max = newParticipantList.size(); int i=1; Session s=HibernateUtil.getSessionFactory().getCurrentSession(); s.beginTransaction(); int count = 0; Iterator<Participant> addIterator = newParticipantList.iterator(); while (addIterator.hasNext()) { Participant p = addIterator.next(); s.save(p); if ( ++count % 20 == 0 ) { //flush a batch of updates and release memory: s.flush(); s.clear(); } //updateProgress(i++, max); Participant2BibMap.put(p, p.getBib()); Bib2ParticipantMap.put(p.getBib(),p); ID2ParticipantMap.put(p.getID(),p); resultsDAO.getResultsQueue().add(p.getBib()); } s.getTransaction().commit(); Platform.runLater(() -> { //refreshParticipantsList(); participantsList.addAll(newParticipantList); }); }
Example 14
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 15
Source File: ConvolutionKernelManagerController.java From MyBox with Apache License 2.0 | 5 votes |
private void checkTableSelected() { ObservableList<ConvolutionKernel> selected = tableView.getSelectionModel().getSelectedItems(); if (selected != null && selected.size() > 0) { editButton.setDisable(false); deleteButton.setDisable(false); copyButton.setDisable(false); } else { editButton.setDisable(true); deleteButton.setDisable(true); copyButton.setDisable(true); } }
Example 16
Source File: TilesFXTest.java From tilesfx 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(); for (Node n : tempChildren) { calcNoOfNodes(n); } } } }
Example 17
Source File: Helper.java From tilesfx with Apache License 2.0 | 5 votes |
public static final Path smoothPath(final ObservableList<PathElement> ELEMENTS, final boolean FILLED) { if (ELEMENTS.isEmpty()) { return new Path(); } final Point[] dataPoints = new Point[ELEMENTS.size()]; for (int i = 0; i < ELEMENTS.size(); i++) { final PathElement element = ELEMENTS.get(i); if (element instanceof MoveTo) { MoveTo move = (MoveTo) element; dataPoints[i] = new Point(move.getX(), move.getY()); } else if (element instanceof LineTo) { LineTo line = (LineTo) element; dataPoints[i] = new Point(line.getX(), line.getY()); } } double zeroY = ((MoveTo) ELEMENTS.get(0)).getY(); List<PathElement> smoothedElements = new ArrayList<>(); Pair<Point[], Point[]> result = calcCurveControlPoints(dataPoints); Point[] firstControlPoints = result.getKey(); Point[] secondControlPoints = result.getValue(); // Start path dependent on filled or not if (FILLED) { smoothedElements.add(new MoveTo(dataPoints[0].getX(), zeroY)); smoothedElements.add(new LineTo(dataPoints[0].getX(), dataPoints[0].getY())); } else { smoothedElements.add(new MoveTo(dataPoints[0].getX(), dataPoints[0].getY())); } // Add curves for (int i = 2; i < dataPoints.length; i++) { final int ci = i - 1; smoothedElements.add(new CubicCurveTo( firstControlPoints[ci].getX(), firstControlPoints[ci].getY(), secondControlPoints[ci].getX(), secondControlPoints[ci].getY(), dataPoints[i].getX(), dataPoints[i].getY())); } // Close the path if filled if (FILLED) { smoothedElements.add(new LineTo(dataPoints[dataPoints.length - 1].getX(), zeroY)); smoothedElements.add(new ClosePath()); } return new Path(smoothedElements); }
Example 18
Source File: PharmacistController.java From HealthPlus with Apache License 2.0 | 4 votes |
@FXML public void fillBarChart() { try{ ArrayList<ArrayList<String>> drugs = pharmacist.getStockSummary(); int noOfSlots = (drugs.size()-1); //System.out.println(noOfSlots); //System.out.println(currentTimeTableData0); HashMap<String,String> drugInfo = pharmacist.getDrugGenericInfo(); final ObservableList<Drug> data = FXCollections.observableArrayList(); for (int i = 1; i <= noOfSlots; i++) { String name = drugs.get(i).get(1); String amount = drugs.get(i).get(3); data.add(new Drug(name,"0","0","0",amount,"0")); } Collections.sort(data, new Comparator<Drug>() { @Override public int compare(Drug drug1, Drug drug2) { if ( drug1.getAmount() < drug2.getAmount() ) return drug2.getAmount(); else return drug1.getAmount(); } }); ArrayList<String> names = new ArrayList<>(); names.add("All"); XYChart.Series<String, Number> series1 = new XYChart.Series(); int noOfDrugs = 0; if (data.size() > 5) noOfDrugs = 5; else noOfDrugs = data.size(); for (int i = 0; i < noOfDrugs; i++) { series1.getData().add(new XYChart.Data(data.get(i).getName() , data.get(i).getAmount())); names.add(data.get(i).getName()); } series1.setName("Availability"); barchart.getData().clear(); barchart.getData().add(series1); Platform.runLater(() -> genericNameSelectCombo.getItems().clear()); Platform.runLater(() -> genericNameSelectCombo.getItems().addAll(names)); }catch(Exception e){} }
Example 19
Source File: StateCell.java From phoebus with Eclipse Public License 1.0 | 4 votes |
@Override protected void updateItem(final ScanState state, final boolean empty) { super.updateItem(state, empty); if (empty) setGraphic(null); else { text.setText(state.toString()); text.setTextFill(getStateColor(state)); // Remove all but the label int i = graphics.getChildren().size(); while (i > 1) graphics.getChildren().remove(--i); // Add suitable buttons switch (state) { case Idle: final ObservableList<ScanInfoProxy> items = getTableView().getItems(); final int index = getIndex(); // Allow moving all but top row 'up' getMoveUp(); move_up.setDisable(index <= 0); show(move_up); // Only enable if there is another idle item below getMoveDown(); boolean enable = false; for (int r=index + 1; r<items.size(); ++r) if (items.get(r).state.get() == ScanState.Idle) { enable = true; break; } move_down.setDisable(! enable); show(move_down); show(getAbort()); break; case Running: show(getPause()); show(getNext()); show(getAbort()); break; case Paused: show(getResume()); show(getAbort()); break; case Aborted: case Failed: case Finished: case Logged: show(getRemove()); break; } setGraphic(graphics); } }
Example 20
Source File: ArtistsMainController.java From MusicPlayer with MIT License | 4 votes |
private void showAllSongs(Artist artist, boolean fromMainController) { ObservableList<Album> albums = FXCollections.observableArrayList(); ObservableList<Song> songs = FXCollections.observableArrayList(); for (Album album : artist.getAlbums()) { albums.add(album); songs.addAll(album.getSongs()); } Collections.sort(songs, (first, second) -> { Album firstAlbum = albums.stream().filter(x -> x.getTitle().equals(first.getAlbum())).findFirst().get(); Album secondAlbum = albums.stream().filter(x -> x.getTitle().equals(second.getAlbum())).findFirst().get(); if (firstAlbum.compareTo(secondAlbum) != 0) { return firstAlbum.compareTo(secondAlbum); } else { return first.compareTo(second); } }); Collections.sort(albums); if (selectedSong != null) { selectedSong.setSelected(false); } selectedSong = null; selectedAlbum = null; albumList.getSelectionModel().clearSelection(); albumList.setItems(albums); songTable.setItems(songs); songTable.getSelectionModel().clearSelection(); scrollPane.setVvalue(0); albumLabel.setText("All Songs"); songTable.setMinHeight(0); songTable.setPrefHeight(0); songTable.setVisible(true); double height = (songs.size() + 1) * 50 + 2; Animation songTableLoadAnimation = new Transition() { { setCycleDuration(Duration.millis(250)); setInterpolator(Interpolator.EASE_BOTH); } protected void interpolate(double frac) { songTable.setMinHeight(frac * height); songTable.setPrefHeight(frac * height); } }; songTableLoadAnimation.setOnFinished(x -> loadedLatch.countDown()); new Thread(() -> { try { if (fromMainController) { MusicPlayer.getMainController().getLatch().await(); MusicPlayer.getMainController().resetLatch(); } else { loadedLatch.await(); loadedLatch = new CountDownLatch(1); } } catch (Exception e) { e.printStackTrace(); } songTableLoadAnimation.play(); }).start(); }