List of usage examples for javafx.application Platform isFxApplicationThread
public static boolean isFxApplicationThread()
From source file:net.rptools.gui.listeners.fxml.ScriptController.java
@Override public void assetListChanged(final Collection<String> removed, final Collection<String> added) { LOGGER.info("removed={}; added={}", removed, added); if (!Platform.isFxApplicationThread()) { Platform.runLater(new Runnable() { @Override/* w w w .j a v a 2 s . c o m*/ public void run() { assetListChanged(removed, added); } }); return; } // Now we are in the right thread final int selectedIndex = scriptList.getSelectionModel().getSelectedIndex(); if (added != null && added.size() != 0) { final List<AssetTableRow> addRows = new ArrayList<>(); createRows(added, addRows); scriptList.getItems().addAll(addRows); } if (removed != null && removed.size() != 0) { final List<AssetTableRow> removeRows = new ArrayList<>(); createRows(removed, removeRows); scriptList.getItems().removeAll(removeRows); } if (scriptList.getItems().size() > selectedIndex) { scriptList.getSelectionModel().select(selectedIndex); } }
From source file:net.rptools.layercontrol.LayerStackLayer.java
/** * Add a layer./*w ww .j a v a 2 s. co m*/ * @param i index to add at * @param layer layer to add */ @ThreadPolicy(ThreadPolicy.ThreadId.ANY) public synchronized void addLayer(final int i, final Layer layer) { if (!Platform.isFxApplicationThread()) { Platform.runLater(new Runnable() { @Override public void run() { addLayer(i, layer); } }); } // Now on JFX thread Pane pane = new Pane(); final String resource = "layer" + layer.getName() + ".fxml"; try { pane = component.getFramework().getFXMLLoader(layer.getClass().getResource(resource)).load(); } catch (final Exception e) { LOGGER.warn("no layer pane found resource={}", resource); } pane.getStyleClass().add(layer.getName().toLowerCase()); pane.setId(StringUtils.uncapitalize(layer.getName())); pane.minWidthProperty().bind(getDrawable().widthProperty()); pane.minHeightProperty().bind(getDrawable().heightProperty()); final int size = getDrawable().getChildren().size(); getDrawable().getChildren().add(size - i, pane); layer.setDrawable(pane); }
From source file:com.esri.geoevent.clusterSimulator.ui.CertificateCheckerDialog.java
@Override public boolean allowConnection(final X509Certificate[] chain) { if (trustedCerts.contains(chain[0])) { return true; }//from w ww . j av a 2 s . c o m final ArrayBlockingQueue<Boolean> responseQueue = new ArrayBlockingQueue<Boolean>(1); Runnable runnable = new Runnable() { @Override public void run() { try { final Stage dialog = new Stage(); dialog.initModality(Modality.APPLICATION_MODAL); dialog.initOwner(MainApplication.primaryStage); dialog.setTitle("Certificate Check"); FXMLLoader loader = new FXMLLoader(getClass().getResource("CertificateCheckerDialog.fxml")); Parent parent = (Parent) loader.load(); CertCheckController controller = (CertCheckController) loader.getController(); controller.certText.setText(chain[0].toString()); Scene scene = new Scene(parent); dialog.setScene(scene); dialog.showAndWait(); responseQueue.put(Boolean.valueOf(controller.allowConnection)); } catch (Exception e) { e.printStackTrace(); } } }; if (Platform.isFxApplicationThread()) { runnable.run(); } else { Platform.runLater(runnable); } try { boolean retVal = responseQueue.take(); if (retVal) { trustedCerts.add(chain[0]); } return retVal; } catch (Exception e) { e.printStackTrace(); } return false; }
From source file:net.rptools.image.listeners.TransformHandler.java
/** * Resize the selection. When scaling, the drag point difference to before * determines the new scale. When snapping, * @param phase one of "start", "continue", "end" * @param fix fixed point/*from w ww. j a v a 2 s. c o m*/ * @param transformType one of "rotate", "scalex", "scaley", or "scalexy" * @param constraints one of "iso", or "free" * @param drag drag point */ @ThreadPolicy(ThreadPolicy.ThreadId.ANY) public void transform(final String phase, final Point2D fix, final String transformType, final String constraints, final Point2D drag) { if (!Platform.isFxApplicationThread()) { Platform.runLater(new Runnable() { @Override public void run() { resizeIntern(phase, fix, transformType, constraints, drag); } }); } else { resizeIntern(phase, fix, transformType, constraints, drag); } }
From source file:net.rptools.layercontrol.LayerStackLayer.java
/** * Remove a layer.//from w ww .ja v a 2 s . c o m * @param layer layer to remove */ @ThreadPolicy(ThreadPolicy.ThreadId.ANY) public synchronized void removeLayer(final Layer layer) { if (!Platform.isFxApplicationThread()) { Platform.runLater(new Runnable() { @Override public void run() { removeLayer(layer); } }); } // Now on JFX thread getDrawable().getChildren().remove(layer.getDrawable()); }
From source file:ijfx.core.uicontext.UiContextService.java
@Override public UiContextManager update() { if (Platform.isFxApplicationThread()) { ImageJFX.getThreadQueue().execute(this::update); return this; }/*from w w w .j ava 2s . com*/ if (!hasChanged()) { return this; } logger.info("Updating..."); logger.info("Actual context : " + getActualContextListAsString()); lastContextList.clear(); lastContextList.addAll(currentContextList); //logger.info(linkSet.toString()); // for each controller, update the controller by telling it which widget it should show // and which widget it should hide viewMap.values().stream().forEach(controller -> updateController(controller)); eventService.publishLater(new UiContextUpdatedEvent().setObject(currentContextList)); return this; }
From source file:edu.wustl.lookingglass.issue.ExceptionPane.java
private BugReport generateReport() { assert Platform.isFxApplicationThread(); BugReport report = new BugReport(); report.subject = getThrowable().toString(); report.environment = edu.cmu.cs.dennisc.issue.IssueUtilities.getEnvironmentShortDescription(); report.version = LookingGlassIDE.APPLICATION_VERSION.toString(); report.ideUUID = LookingGlassIDE.getActiveInstance().getApplicationId().toString(); report.stacktrace = getStackTrace(); report.description = this.description.getText(); report.email = this.email.getText(); return report; }
From source file:gov.va.isaac.sync.view.SyncView.java
private void addLine(String line) { Runnable work = new Runnable() { @Override/*from w ww. ja va 2 s . c om*/ public void run() { summary_.setText(summary_.getText() + line + "\n"); } }; if (Platform.isFxApplicationThread()) { work.run(); } else { Platform.runLater(work); } }
From source file:io.github.mzmine.modules.plots.chromatogram.ChromatogramPlotWindowController.java
void addChromatogram(Chromatogram chromatogram, String title) { if (!Platform.isFxApplicationThread()) { throw new IllegalStateException( "Not on FX application thread; currentThread = " + Thread.currentThread().getName()); }//from w w w.j av a 2s . c om final int datasetIndex = numberOfDataSets; numberOfDataSets++; ChromatogramDataSet newDataSet = new ChromatogramDataSet(chromatogram, title); datasets.add(newDataSet); final XYPlot plot = chartNode.getChart().getXYPlot(); final Color newColor = plotColors[datasetIndex % plotColors.length]; newDataSet.setColor(newColor); configureRenderer(newDataSet, datasetIndex); newDataSet.colorProperty().addListener(e -> { Platform.runLater(() -> configureRenderer(newDataSet, datasetIndex)); }); newDataSet.lineThicknessProperty().addListener(e -> { Platform.runLater(() -> configureRenderer(newDataSet, datasetIndex)); }); newDataSet.showDataPointsProperty().addListener(e -> { Platform.runLater(() -> configureRenderer(newDataSet, datasetIndex)); }); // Once everything is configured, add the dataset to the plot plot.setDataset(datasetIndex, newDataSet); }
From source file:edu.wustl.lookingglass.issue.ExceptionPane.java
private void attachProject(BugReport report) { assert Platform.isFxApplicationThread(); if (attach.isSelected()) { edu.cmu.cs.dennisc.issue.Attachment attachment = null; if (org.alice.ide.IDE.getActiveInstance().getProject() != null) { attachment = new CurrentProjectAttachment(); }/*from w w w . j a va2 s .c o m*/ if (attachment != null) { report.addAttachment(attachment); } } }