Java Code Examples for javafx.collections.ObservableList#get()
The following examples show how to use
javafx.collections.ObservableList#get() .
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: 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 2
Source File: FilesController.java From AudioBookConverter with GNU General Public License v2.0 | 6 votes |
public void moveUp(ActionEvent event) { if (chaptersMode.get()) { ObservableList<TreeTablePosition<Organisable, ?>> selectedCells = bookStructure.getSelectionModel().getSelectedCells(); if (selectedCells.size() == 1) { Organisable organisable = selectedCells.get(0).getTreeItem().getValue(); organisable.moveUp(); Platform.runLater(() -> updateBookStructure(ConverterApplication.getContext().getBook(), bookStructure.getRoot())); } } else { ObservableList<Integer> selectedIndices = fileList.getSelectionModel().getSelectedIndices(); if (selectedIndices.size() == 1) { ObservableList<MediaInfo> items = fileList.getItems(); int selected = selectedIndices.get(0); if (selected > 0) { MediaInfo upper = items.get(selected - 1); MediaInfo lower = items.get(selected); items.set(selected - 1, lower); items.set(selected, upper); fileList.getSelectionModel().clearAndSelect(selected - 1); } } } }
Example 3
Source File: TransferRtoATableController.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 TransferRtoAs TransferRtoA[] transferRtoAs = new TransferRtoA[micros.size()]; for (int i = 0; i < micros.size(); i++) { transferRtoAs[i] = (TransferRtoA) micros.get(i); } // check that all names are unique and nonempty Validate.rangesAreInBound(transferRtoAs); }
Example 4
Source File: FxDockTabPane.java From FxDock with Apache License 2.0 | 5 votes |
public int indexOfTab(Node n) { ObservableList<Tab> ts = getTabs(); for(int i=ts.size()-1; i>=0; --i) { Tab t = ts.get(i); if(t.getContent() == n) { return i; } } return -1; }
Example 5
Source File: TransferRtoATableController.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) { TransferRtoA[] transferRtoAs = new TransferRtoA[newClones.size()]; for (int i = 0; i < newClones.size(); i++) { transferRtoAs[i] = (TransferRtoA) newClones.get(i); } clones = transferRtoAs; }
Example 6
Source File: UndecoratorController.java From DevToolBox with GNU Lesser General Public License v2.1 | 5 votes |
/** * Under Windows, the undecorator Stage could be been dragged below the Task * bar and then no way to grab it again... On Mac, do not drag above the * menu bar * * @param y */ void setStageY(Stage stage, double y) { try { ObservableList<Screen> screensForRectangle = Screen.getScreensForRectangle(stage.getX(), stage.getY(), stage.getWidth(), stage.getHeight()); if (screensForRectangle.size() > 0) { Screen screen = screensForRectangle.get(0); Rectangle2D visualBounds = screen.getVisualBounds(); if (y < visualBounds.getHeight() - 30 && y + SHADOW_WIDTH >= visualBounds.getMinY()) { stage.setY(y); } } } catch (Exception e) { Undecorator.LOGGER.log(Level.SEVERE, "setStageY issue", e); } }
Example 7
Source File: SmoothedChart.java From tilesfx with Apache License 2.0 | 5 votes |
private void smooth(ObservableList<PathElement> strokeElements, ObservableList<PathElement> fillElements, final double HEIGHT) { if (fillElements.isEmpty()) return; // as we do not have direct access to the data, first recreate the list of all the data points we have final Point[] dataPoints = new Point[strokeElements.size()]; for (int i = 0; i < strokeElements.size(); i++) { final PathElement element = strokeElements.get(i); if (element instanceof MoveTo) { final MoveTo move = (MoveTo) element; dataPoints[i] = new Point(move.getX(), move.getY()); } else if (element instanceof LineTo) { final LineTo line = (LineTo) element; final double x = line.getX(), y = line.getY(); dataPoints[i] = new Point(x, y); } } double firstX = dataPoints[0].getX(); double lastX = dataPoints[dataPoints.length - 1].getX(); Point[] points = Helper.subdividePoints(dataPoints, getSubDivisions()); fillElements.clear(); fillElements.add(new MoveTo(firstX, HEIGHT)); strokeElements.clear(); strokeElements.add(new MoveTo(points[0].getX(), points[0].getY())); for (Point p : points) { if (Double.compare(p.getX(), firstX) >= 0) { fillElements.add(new LineTo(p.getX(), p.getY())); strokeElements.add(new LineTo(p.getX(), p.getY())); } } fillElements.add(new LineTo(lastX, HEIGHT)); fillElements.add(new LineTo(0, HEIGHT)); fillElements.add(new ClosePath()); }
Example 8
Source File: SmoothedChart.java From OEE-Designer with MIT License | 5 votes |
private void smooth(ObservableList<PathElement> strokeElements, ObservableList<PathElement> fillElements, final double HEIGHT) { if (fillElements.isEmpty()) return; // as we do not have direct access to the data, first recreate the list of all the data points we have final Point[] dataPoints = new Point[strokeElements.size()]; for (int i = 0; i < strokeElements.size(); i++) { final PathElement element = strokeElements.get(i); if (element instanceof MoveTo) { final MoveTo move = (MoveTo) element; dataPoints[i] = new Point(move.getX(), move.getY()); } else if (element instanceof LineTo) { final LineTo line = (LineTo) element; final double x = line.getX(), y = line.getY(); dataPoints[i] = new Point(x, y); } } double firstX = dataPoints[0].getX(); double lastX = dataPoints[dataPoints.length - 1].getX(); Point[] points = Helper.subdividePoints(dataPoints, getSubDivisions()); fillElements.clear(); fillElements.add(new MoveTo(firstX, HEIGHT)); strokeElements.clear(); strokeElements.add(new MoveTo(points[0].getX(), points[0].getY())); for (Point p : points) { if (Double.compare(p.getX(), firstX) >= 0) { fillElements.add(new LineTo(p.getX(), p.getY())); strokeElements.add(new LineTo(p.getX(), p.getY())); } } fillElements.add(new LineTo(lastX, HEIGHT)); fillElements.add(new LineTo(0, HEIGHT)); fillElements.add(new ClosePath()); }
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: DisputeManager.java From bisq-core with GNU Affero General Public License v3.0 | 5 votes |
private void onPeerOpenedDisputeMessage(PeerOpenedDisputeMessage peerOpenedDisputeMessage) { String errorMessage; Dispute dispute = peerOpenedDisputeMessage.getDispute(); if (!isArbitrator(dispute)) { if (!disputes.contains(dispute)) { final Optional<Dispute> storedDisputeOptional = findDispute(dispute.getTradeId(), dispute.getTraderId()); if (!storedDisputeOptional.isPresent()) { dispute.setStorage(disputeStorage); disputes.add(dispute); Optional<Trade> tradeOptional = tradeManager.getTradeById(dispute.getTradeId()); tradeOptional.ifPresent(trade -> trade.setDisputeState(Trade.DisputeState.DISPUTE_STARTED_BY_PEER)); errorMessage = null; } else { errorMessage = "We got a dispute already open for that trade and trading peer.\n" + "TradeId = " + dispute.getTradeId(); log.warn(errorMessage); } } else { errorMessage = "We got a dispute msg what we have already stored. TradeId = " + dispute.getTradeId(); log.warn(errorMessage); } } else { errorMessage = "Arbitrator received peerOpenedDisputeMessage. That must never happen."; log.error(errorMessage); } // We use the DisputeCommunicationMessage not the peerOpenedDisputeMessage for the ACK ObservableList<DisputeCommunicationMessage> messages = peerOpenedDisputeMessage.getDispute().getDisputeCommunicationMessages(); if (!messages.isEmpty()) { DisputeCommunicationMessage msg = messages.get(0); sendAckMessage(msg, dispute.getArbitratorPubKeyRing(), errorMessage == null, errorMessage); } sendAckMessage(peerOpenedDisputeMessage, dispute.getArbitratorPubKeyRing(), errorMessage == null, errorMessage); }
Example 11
Source File: MemoryAccessTableController.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) { MemoryAccess[] memoryAccesses = new MemoryAccess[newClones.size()]; for (int i = 0; i < newClones.size(); i++) { memoryAccesses[i] = (MemoryAccess) newClones.get(i); } clones = memoryAccesses; }
Example 12
Source File: BatchController.java From MyBox with Apache License 2.0 | 5 votes |
public boolean makeMoreParameters() { if (tableData == null || tableData.isEmpty()) { actualParameters = null; return false; } for (int i = 0; i < tableData.size(); ++i) { FileInformation d = tableController.fileInformation(i); if (d == null) { continue; } d.setHandled(""); if (!isPreview && !sourceFiles.contains(d.getFile())) { sourceFiles.add(d.getFile()); } } if (isPreview) { int index = 0; ObservableList<Integer> selected = tableView.getSelectionModel().getSelectedIndices(); if (selected != null && !selected.isEmpty()) { index = selected.get(0); } sourceFiles.add(tableController.file(index)); } initLogs(); totalFilesHandled = totalItemsHandled = 0; processStartTime = new Date(); fileStartTime = new Date(); return true; }
Example 13
Source File: FxSchema.java From FxDock with Apache License 2.0 | 5 votes |
private static void restoreTableView(String prefix, TableView t) { ObservableList<TableColumn<?,?>> cs = t.getColumns(); // columns SStream s = GlobalSettings.getStream(prefix + SFX_COLUMNS); int sz = s.nextInt(); if(sz == cs.size()) { for(int i=0; i<sz; i++) { TableColumn<?,?> c = cs.get(i); String id = s.nextString(); double w = s.nextDouble(); int sortOrder = s.nextInt(); // TODO } } // selection int ix = GlobalSettings.getInt(prefix + SFX_SELECTION, -1); if(ix >= 0) { // if done immediately it screws up the selection model for some reason // FIX does not select for some reason. /* TODO FX.later(() -> { if(ix < t.getItems().size()) { t.getSelectionModel().select(ix); } }); */ } }
Example 14
Source File: DecodeTableController.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) { Decode[] decodes = new Decode[newClones.size()]; for (int i = 0; i < newClones.size(); i++) decodes[i] = (Decode) newClones.get(i); clones = decodes; }
Example 15
Source File: JavaFXElementPropertyAccessor.java From marathonv5 with Apache License 2.0 | 4 votes |
protected String getTreeTableColumnName(TreeTableView<?> treeTableView, int columnIndex) { ObservableList<?> columns = treeTableView.getColumns(); TreeTableColumn<?, ?> tableColumn = (TreeTableColumn<?, ?>) columns.get(columnIndex); return tableColumn.getText(); }
Example 16
Source File: CustomPlainAmpSkin.java From medusademo with Apache License 2.0 | 4 votes |
private void drawSections(final GraphicsContext CTX) { final double x = -width * 0.03; final double y = height * 0.345; final double w = width * 1.06; final double h = height * 2.085; final double MIN_VALUE = gauge.getMinValue(); final double MAX_VALUE = gauge.getMaxValue(); final double OFFSET = 90 - START_ANGLE; final ObservableList<Section> sections = gauge.getSections(); final boolean highlightSections = gauge.isHighlightSections(); double value = gauge.getCurrentValue(); int listSize = sections.size(); for (int i = 0 ; i < listSize ; i++) { final Section SECTION = sections.get(i); final double SECTION_START_ANGLE; if (Double.compare(SECTION.getStart(), MAX_VALUE) <= 0 && Double.compare(SECTION.getStop(), MIN_VALUE) >= 0) { if (SECTION.getStart() < MIN_VALUE && SECTION.getStop() < MAX_VALUE) { SECTION_START_ANGLE = 0; } else { SECTION_START_ANGLE = (SECTION.getStart() - MIN_VALUE) * angleStep; } final double SECTION_ANGLE_EXTEND; if (SECTION.getStop() > MAX_VALUE) { SECTION_ANGLE_EXTEND = (MAX_VALUE - SECTION.getStart()) * angleStep; } else { SECTION_ANGLE_EXTEND = (SECTION.getStop() - SECTION.getStart()) * angleStep; } CTX.save(); if (highlightSections) { CTX.setStroke(SECTION.contains(value) ? SECTION.getHighlightColor() : SECTION.getColor()); } else { CTX.setStroke(SECTION.getColor()); } CTX.setLineWidth(height * 0.0415); CTX.setLineCap(StrokeLineCap.BUTT); CTX.strokeArc(x, y, w, h, -(OFFSET + SECTION_START_ANGLE), -SECTION_ANGLE_EXTEND, ArcType.OPEN); CTX.restore(); } } }
Example 17
Source File: FxTreeTable.java From FxDock with Apache License 2.0 | 4 votes |
public TreeTableColumn<T,?> lastColumn() { ObservableList<TreeTableColumn<T,?>> cs = tree.getColumns(); return cs.get(cs.size() - 1); }
Example 18
Source File: Shape2Geometry.java From gef with Eclipse Public License 2.0 | 4 votes |
/** * Converts the given JavaFX {@link Path} to a * {@link org.eclipse.gef.geometry.planar.Path}. * * @param path * The JavaFX {@link Path} to convert. * @return The newly created {@link org.eclipse.gef.geometry.planar.Path} * that describes the given {@link Path}. */ public static final org.eclipse.gef.geometry.planar.Path toPath( Path path) { ObservableList<PathElement> elements = path.getElements(); org.eclipse.gef.geometry.planar.Path.Segment[] segments = new org.eclipse.gef.geometry.planar.Path.Segment[elements .size()]; for (int i = 0; i < segments.length; i++) { PathElement element = elements.get(i); if (element instanceof MoveTo) { MoveTo moveTo = (MoveTo) element; segments[i] = new Segment(Segment.MOVE_TO, new Point(moveTo.getX(), moveTo.getY())); } else if (element instanceof LineTo) { LineTo lineTo = (LineTo) element; segments[i] = new Segment(Segment.LINE_TO, new Point(lineTo.getX(), lineTo.getY())); } else if (element instanceof QuadCurveTo) { QuadCurveTo quadTo = (QuadCurveTo) element; segments[i] = new Segment(Segment.QUAD_TO, new Point(quadTo.getControlX(), quadTo.getControlY()), new Point(quadTo.getX(), quadTo.getY())); } else if (element instanceof CubicCurveTo) { CubicCurveTo cubicTo = (CubicCurveTo) element; segments[i] = new Segment(Segment.CUBIC_TO, new Point(cubicTo.getControlX1(), cubicTo.getControlY1()), new Point(cubicTo.getControlX2(), cubicTo.getControlY2()), new Point(cubicTo.getX(), cubicTo.getY())); } else if (element instanceof ClosePath) { segments[i] = new Segment(Segment.CLOSE); } } int windingRule = path.getFillRule() == FillRule.EVEN_ODD ? org.eclipse.gef.geometry.planar.Path.WIND_EVEN_ODD : org.eclipse.gef.geometry.planar.Path.WIND_NON_ZERO; return new org.eclipse.gef.geometry.planar.Path(windingRule, segments); }
Example 19
Source File: CGrid.java From Open-Lowcode with Eclipse Public License 2.0 | 4 votes |
/** * change the update state of the grid following user interaction * * @param event action event * @param mouseevent mouse event */ public void launchupdate(ActionEvent event, MouseEvent mouseevent) { logger.fine(" --- ** --- display commit update with updatenote on cgrid is " + updatenote); boolean update = true; if (updatenote) { updatenotecomment = actionmanager.getClientDisplay().showModalTextEntry("Enter update note", 200); if (updatenotecomment == null) update = false; } if (update) { if (!this.reversetree) { tableview.setEditable(false); tableview.getSelectionModel().setCellSelectionEnabled(true); startupdate.setDisable(false); commitupdate.setDisable(true); tableview.getSelectionModel().setSelectionMode(SelectionMode.SINGLE); ObservableList<CObjectGridLine<String>> tabledata = tableview.getItems(); boolean isupdated = false; for (int i = 0; i < tabledata.size(); i++) { CObjectGridLine<String> thisrow = tabledata.get(i); if (thisrow.isRowUpdate()) isupdated = true; } if (isupdated) { if (event != null) actionmanager.handle(event); if (mouseevent != null) actionmanager.getMouseHandler().handle(mouseevent); } else { actionmanager.getClientSession().getActiveClientDisplay() .updateStatusBar("No modification performed on grid table in edit mode"); } updatemodeactive = false; } else { // ------------------------- treetable.setEditable(false); startupdate.setDisable(false); commitupdate.setDisable(true); int updatedrows = treetable.getUpdatedItems().size(); if (updatedrows > 0) { if (event != null) actionmanager.handle(event); if (mouseevent != null) actionmanager.getMouseHandler().handle(mouseevent); } else { actionmanager.getClientSession().getActiveClientDisplay() .updateStatusBar("No modification performed on grid table in edit mode"); } } } }
Example 20
Source File: Listeners.java From SynchronizeFX with GNU Lesser General Public License v3.0 | 4 votes |
@Override public void onChanged(final ListChangeListener.Change<? extends Object> event) { final ObservableList<? extends Object> list = event.getList(); if (disabledFor.containsKey(list)) { return; } event.reset(); try { final UUID listId = objectRegistry.getIdOrFail(list); while (event.next()) { List<Command> commands = null; if (event.wasPermutated()) { LOG.warn("Got an ListChangeListener.Change event that permutates the list." + " This case is not implemented and is not synchronized."); // for (int i = event.getFrom(); i < event.getTo(); ++i) { // //TODO // } } else if (event.wasUpdated()) { LOG.warn("Got an ListChangeListener.Change event that indicates that some elements in a list" + " have been updated. This case is not implemented and is not synchronized."); // TODO } else if (event.wasAdded()) { commands = new LinkedList<>(); for (int i = event.getFrom(); i < event.getTo(); i++) { final Object elem = list.get(i); final Optional<UUID> id = objectRegistry.getId(elem); if (event.wasRemoved()) { // this is a replaced event (see ListChangeListener.Change documentation) commands.addAll(creator.replaceInList(listId, i, elem)); } else { commands.addAll(creator.addToList(listId, i, elem, list.size())); } // if getId() was null, then newValue is unknown to the meta model and therefore // listeners need to be registered on it. if (elem != null && !id.isPresent()) { registerListenersOnEverything(elem); } } } else if (event.wasRemoved()) { commands = creator.removeFromList(listId, event.getTo(), event.getRemovedSize()); // TODO don't let distributeCommands() happen } if (commands != null) { distributeCommands(commands); } } } catch (final SynchronizeFXException e) { topology.onError(e); } finally { event.reset(); } }