List of usage examples for javafx.application Platform runLater
public static void runLater(Runnable runnable)
From source file:at.ac.tuwien.qse.sepm.gui.controller.impl.SlideshowViewImpl.java
private void handleDeletedPhotos(List<Path> paths) { Platform.runLater(() -> { loadAllSlideshows(); refreshGrid(); }); }
From source file:api.wiki.WikiNameApi2.java
private void processSpecific(String s, PeopleNameOption option, final ProgressCallback callback) { final TreeMap<String, String> values = getGenderNames(s); final float[] progressValues = ProgressUtil.getProgressValues(values.size()); int counter = 1; for (final String peopleName : values.values()) { final int c = counter++; callback.onProgressUpdate(progressValues[c]); Task<Void> task = new Task<Void>() { @Override/*from w w w. j a va2 s . c om*/ protected Void call() throws Exception { final File file = processName(peopleName, option); Platform.runLater(new Runnable() { @Override public void run() { callback.onProgress(processFile(peopleName, file)); } }); return null; } }; Thread thread = new Thread(task); thread.setPriority(Thread.MAX_PRIORITY); thread.start(); } }
From source file:org.sleuthkit.autopsy.imageanalyzer.gui.MetaDataPane.java
public void updateUI() { final Image icon = getFile().getThumbnail(); final ObservableList<Pair<DrawableAttribute<?>, ? extends Object>> attributesList = getFile() .getAttributesList();//w w w . ja v a 2 s. com Platform.runLater(() -> { imageView.setImage(icon); tableView.getItems().setAll(attributesList); }); updateCategoryBorder(); }
From source file:com.adobe.ags.curly.test.ErrorBehaviorTest.java
private void sync() { Semaphore test = new Semaphore(1); test.acquireUninterruptibly();/* w w w. j a v a 2s . c o m*/ Platform.runLater(test::release); try { test.acquire(); } catch (InterruptedException ex) { Logger.getLogger(ErrorBehaviorTest.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:cz.lbenda.dataman.db.sql.SQLEditorController.java
public void addQueryResult(SQLQueryResult result) { StringBuilder msg = new StringBuilder(); if (result.getSqlQueryRows() == null) { msg.append("<sql>").append(result.getSql()).append("</sql>\n"); if (StringUtils.isNotBlank(result.getErrorMsg())) { msg.append("<error>").append(result.getErrorMsg()).append("</error>\n"); }//from ww w.ja v a 2s . c o m if (result.getAffectedRow() != null) { msg.append("Affected rows: ").append(result.getAffectedRow()).append("<br />\n"); } consoleMessages.append("<div class=\"msg\">\n").append(msg).append("</div>\n"); Platform.runLater( () -> webView.getEngine().loadContent(String.format(HTML, consoleMessages.toString()))); } else { DataTableFrmController dataTableController = new DataTableFrmController(result); String title = result.getSql() == null ? "" : (result.getSql().length() > 50 ? result.getSql().substring(1, 45) + "..." : result.getSql()); Platform.runLater(() -> nodeShower.addNode(dataTableController.getTabView(), title, true)); } }
From source file:com.heliosdecompiler.helios.gui.view.editors.DisassemblerView.java
@Override protected Node createView0(OpenedFile file, String path) { CodeArea codeArea = new CodeArea(); if (controller instanceof KrakatauDisassemblerController) { ContextMenu contextMenu = new ContextMenu(); MenuItem save = new MenuItem("Assemble"); save.setOnAction(e -> {/*from w w w .j ava 2s .c o m*/ save(codeArea).whenComplete((res, err) -> { if (err != null) { if (err instanceof KrakatauException) { StringBuilder message = new StringBuilder(); message.append("stdout:\r\n").append(((KrakatauException) err).getStdout()) .append("\r\n\r\nstderr:\r\n").append(((KrakatauException) err).getStderr()); messageHandler.handleLongMessage(Message.ERROR_FAILED_TO_ASSEMBLE_KRAKATAU, message.toString()); } else { messageHandler.handleException(Message.ERROR_UNKNOWN_ERROR.format(), err); } } else { file.putContent(path, res); messageHandler.handleMessage(Message.GENERIC_ASSEMBLED.format()); } }); }); contextMenu.getItems().add(save); codeArea.setContextMenu(contextMenu); } codeArea.setStyle("-fx-font-size: 1em"); codeArea.getProperties().put("fontSize", 1); codeArea.setParagraphGraphicFactory(line -> { Node label = LineNumberFactory.get(codeArea, (digits) -> "%1$" + digits + "d").apply(line); label.styleProperty().bind(codeArea.styleProperty()); return label; }); codeArea.replaceText("Disassembling... this may take a while"); codeArea.getUndoManager().forgetHistory(); codeArea.richChanges().filter(ch -> !ch.getInserted().equals(ch.getRemoved())) // XXX .successionEnds(Duration.ofMillis(500)).supplyTask(() -> computeHighlightingAsync(codeArea)) .awaitLatest(codeArea.richChanges()).filterMap(t -> { if (t.isSuccess()) { return Optional.of(t.get()); } else { t.getFailure().printStackTrace(); return Optional.empty(); } }).subscribe(f -> applyHighlighting(codeArea, f)); codeArea.getStylesheets().add(getClass().getResource("/java-keywords.css").toExternalForm()); codeArea.addEventFilter(ScrollEvent.SCROLL, e -> { if (e.isShortcutDown()) { if (e.getDeltaY() > 0) { int size = (int) codeArea.getProperties().get("fontSize") + 1; codeArea.setStyle("-fx-font-size: " + size + "em"); codeArea.getProperties().put("fontSize", size); } else { int size = (int) codeArea.getProperties().get("fontSize") - 1; if (size > 0) { codeArea.setStyle("-fx-font-size: " + size + "em"); codeArea.getProperties().put("fontSize", size); } } e.consume(); } }); controller.disassemble(file, path, (success, text) -> { Platform.runLater(() -> { codeArea.replaceText(text); codeArea.getUndoManager().forgetHistory(); }); }); return new VirtualizedScrollPane<>(codeArea); }
From source file:SampleTableModel.java
private BarChart createBarChart() { CategoryAxis xAxis = new CategoryAxis(); xAxis.setCategories(FXCollections.<String>observableArrayList(tableModel.getColumnNames())); xAxis.setLabel("Year"); double tickUnit = tableModel.getTickUnit(); NumberAxis yAxis = new NumberAxis(); yAxis.setTickUnit(tickUnit);// w w w. j a va 2 s. c o m yAxis.setLabel("Units Sold"); final BarChart chart = new BarChart(xAxis, yAxis, tableModel.getBarChartData()); tableModel.addTableModelListener(new TableModelListener() { public void tableChanged(TableModelEvent e) { if (e.getType() == TableModelEvent.UPDATE) { final int row = e.getFirstRow(); final int column = e.getColumn(); final Object value = ((SampleTableModel) e.getSource()).getValueAt(row, column); Platform.runLater(new Runnable() { public void run() { XYChart.Series<String, Number> s = (XYChart.Series<String, Number>) chart.getData() .get(row); BarChart.Data data = s.getData().get(column); data.setYValue(value); } }); } } }); return chart; }
From source file:edu.kit.trufflehog.view.jung.visualization.FXVisualizationViewer.java
public FXVisualizationViewer(INetworkViewPort port) { this.port = port; // create canvas this.setStyle("-fx-background-color: #213245"); for (double divide = .25; divide < 1; divide += .25) { final Line line = new Line(0, 200, this.getWidth(), this.getHeight()); line.setFill(null);// w w w.j a v a2 s . co m line.setStroke(Color.web("0x385172")); line.setStrokeWidth(1.3); line.getStrokeDashArray().addAll(5d, 10d); line.startYProperty().bind(this.heightProperty().multiply(divide)); line.endXProperty().bind(this.widthProperty()); line.endYProperty().bind(this.heightProperty().multiply(divide)); this.getChildren().add(line); } for (double divide = .25; divide < 1; divide += .25) { final Line line = new Line(0, 0, this.getWidth(), this.getHeight()); line.setFill(null); line.setStroke(Color.web("0x385172")); line.setStrokeWidth(1.3); line.getStrokeDashArray().addAll(5d, 10d); line.startXProperty().bind(this.widthProperty().multiply(divide)); line.endXProperty().bind(this.widthProperty().multiply(divide)); line.endYProperty().bind(this.heightProperty()); this.getChildren().add(line); } //StackPane spane = new StackPane(); //spane.setBackground(new Background(new BackgroundFill(Color.BEIGE, null, null))); Pane ghost = new Pane(); canvas = new PannableCanvas(ghost); Pane parent = new Pane(); parent.getChildren().add(ghost); parent.getChildren().add(canvas); SceneGestures sceneGestures = new SceneGestures(parent, canvas); addEventFilter(MouseEvent.MOUSE_PRESSED, sceneGestures.getOnMousePressedEventHandler()); addEventFilter(MouseEvent.MOUSE_DRAGGED, sceneGestures.getOnMouseDraggedEventHandler()); addEventFilter(ScrollEvent.ANY, sceneGestures.getOnScrollEventHandler()); new RubberBandSelection(this); // TODO make canvas transparent //canvas.setStyle("-fx-background-color: #1d1d1d"); // we don't want the canvas on the top/left in this example => just // translate it a bit //canvas.setTranslateX(100); //canvas.setTranslateY(100); // create sample nodes which can be dragged nodeGestures = new NodeGestures(); //this.getChildren().add(spane); this.getChildren().add(parent); this.layout = port.getDelegate(); //this.layout.getGraph().getVertices().forEach(v -> Platform.runLater(() -> this.initVertex(v))); //this.layout.getGraph().getEdges().forEach(e -> Platform.runLater(() -> this.initEdge(e))); this.layout.getObservableGraph().addGraphEventListener(e -> { //Platform.runLater(() -> { switch (e.getType()) { case VERTEX_ADDED: final INode node = ((GraphEvent.Vertex<INode, IConnection>) e).getVertex(); Platform.runLater(() -> initVertex(node)); break; case EDGE_ADDED: final IConnection edge = ((GraphEvent.Edge<INode, IConnection>) e).getEdge(); Platform.runLater(() -> initEdge(edge)); break; case VERTEX_CHANGED: break; case EDGE_CHANGED: final IConnection changedEdge = ((GraphEvent.Edge<INode, IConnection>) e).getEdge(); Platform.runLater(() -> changedEdge.getComponent(ViewComponent.class).getRenderer().animate()); break; } //}); }); }
From source file:application.Main.java
private void hide(final Stage stage) { Platform.runLater(new Runnable() { @Override//ww w.j av a2s. c o m public void run() { // if the operating system // supports the system tray if (SystemTray.isSupported()) { stage.hide(); showProgramIsMinimizedMsg(); } else { System.exit(0); } } }); }
From source file:org.noroomattheinn.visibletesla.MainController.java
private void fetchInitialCarState() { issueCommand(new Callable<Result>() { @Override/*www . jav a 2s.c o m*/ public Result call() { Result r = cacheBasics(); if (!r.success) { if (r.explanation.equals("mobile_access_disabled")) exitWithMobileAccessError(); else exitWithCachingError(); return Result.Failed; } Platform.runLater(finishAppStartup); return Result.Succeeded; } }, "Cache Basics"); }