List of usage examples for javafx.application Platform runLater
public static void runLater(Runnable runnable)
From source file:herudi.controller.customerController.java
@FXML private void aksiNew(ActionEvent event) { paneTabel.setOpacity(0);// w w w . j av a2s .c om new FadeInUpTransition(paneCrud).play(); Platform.runLater(() -> { clear(); auto(); }); }
From source file:org.sleuthkit.autopsy.imageanalyzer.gui.navpanel.NavPanel.java
@Deprecated private void rebuildNavTree() { navTreeRoot = new GroupTreeItem("", null, sortByBox.getSelectionModel().selectedItemProperty().get()); ObservableList<DrawableGroup> groups = controller.getGroupManager().getAnalyzedGroups(); for (DrawableGroup g : groups) { insertIntoNavTree(g);// w w w . jav a2 s.com } Platform.runLater(() -> { navTree.setRoot(navTreeRoot); navTreeRoot.setExpanded(true); }); }
From source file:org.sleuthkit.autopsy.imagegallery.grouping.GroupManager.java
/** * remove the given file from the group with the given key. If the group * doesn't exist or doesn't already contain this file, this method is a * no-op/* w ww .j a v a 2 s .c om*/ * * @param groupKey the value of groupKey * @param fileID the value of file */ public synchronized void removeFromGroup(GroupKey<?> groupKey, final Long fileID) { //get grouping this file would be in final DrawableGroup group = getGroupForKey(groupKey); if (group != null) { group.removeFile(fileID); // If we're grouping by category, we don't want to remove empty groups. if (groupKey.getAttribute() != DrawableAttribute.CATEGORY) { if (group.fileIds().isEmpty()) { synchronized (groupMap) { groupMap.remove(groupKey, group); } Platform.runLater(() -> { analyzedGroups.remove(group); unSeenGroups.remove(group); }); } } else { } } }
From source file:photobooth.views.ExplorerPane.java
private void addNextButton() throws IOException { Button button = new Button(); button.setGraphic(/*from ww w . j a v a2 s .c om*/ new ImageView(new Image(getClass().getResource("/photobooth/images/next.png").openStream()))); button.setStyle("-fx-background-radius: 50%; "); button.setStyle("-fx-background-color: transparent;"); button.setLayoutX(740); button.setLayoutY(220); button.setMaxSize(50, 50); button.setMinSize(50, 50); this.getChildren().add(button); button.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { Global.getInstance().setSceneRoot(LoadingPane.getInstance()); Platform.runLater(() -> { new Thread(new Runnable() { @Override public void run() { ExplorerPane.getInstance().setDir(dir, offset + limit, limit, directoryLevel); Global.getInstance().setSceneRoot(ExplorerPane.getInstance()); } }).start(); }); } }); }
From source file:com.ubershy.streamsis.actors.UniversalActor.java
@Override public void start() { Platform.runLater(() -> { if (actorCheckerService.getState() == State.READY) { actorCheckerService.start(); } else {//ww w. j ava 2 s . com actorCheckerService.restart(); } }); }
From source file:com.jscriptive.moneyfx.ui.chart.ChartFrame.java
/** * This method is invoked when the monthly in/out button has been toggled * * @param actionEvent//ww w . j a va 2 s. co m */ public void monthlyInOutToggled(ActionEvent actionEvent) { final CategoryAxis xAxis = new CategoryAxis(); final NumberAxis yAxis = new NumberAxis(); xAxis.setLabel("Month of Year"); yAxis.setLabel("In/Out in Euro"); final BarChart<String, Number> barChart = new BarChart<>(xAxis, yAxis); barChart.setTitle("Monthly in/out"); chartFrame.setCenter(barChart); ToggleButton toggle = (ToggleButton) actionEvent.getTarget(); if (toggle.isSelected()) { Account account = accountCombo.getValue(); String accountLabel = getAccountLabel(account); XYChart.Series<String, Number> inSeries = new XYChart.Series<>(); inSeries.setName("In" + accountLabel); barChart.getData().add(inSeries); XYChart.Series<String, Number> outSeries = new XYChart.Series<>(); outSeries.setName("Out" + accountLabel); barChart.getData().add(outSeries); ValueRange<LocalDate> period = getTransactionOpRange(account, yearCombo.getValue()); if (period.isEmpty()) { return; } ObservableList<String> monthLabels = FXCollections.observableArrayList(); for (LocalDate date = period.from().withDayOfMonth(1); !date.isAfter(period.to()); date = date .plusMonths(1)) { monthLabels.add(getMonthLabel(date.getYear(), date.getMonthValue())); } xAxis.setCategories(monthLabels); Service<Void> service = new Service<Void>() { @Override protected Task<Void> createTask() { return new Task<Void>() { @Override protected Void call() throws Exception { List<TransactionVolume> incomingVolumes = (account == ALL_ACCOUNTS) ? transactionRepository.getMonthlyIncomingVolumes(false) : transactionRepository.getMonthlyIncomingVolumesOfAccount(account, false); if (INTEGER_ZERO.compareTo(yearCombo.getValue()) < 0) { incomingVolumes = incomingVolumes.stream() .filter(v -> v.getYear().equals(yearCombo.getValue())) .sorted((v1, v2) -> v1.getDate().compareTo(v2.getDate())).collect(toList()); } for (TransactionVolume volume : incomingVolumes) { String monthLabel = getMonthLabel(volume.getYear(), volume.getMonth()); XYChart.Data<String, Number> data = new XYChart.Data<>(monthLabel, volume.getVolume()); Platform.runLater(() -> { inSeries.getData().add(data); StackPane barNode = (StackPane) data.getNode(); // TODO make that look nicer Label labelNode = new Label( CurrencyFormat.getInstance().format(volume.getVolume())); labelNode.setPrefWidth(100); labelNode.setAlignment(CENTER_RIGHT); labelNode.setRotate(270); barNode.getChildren().add(labelNode); barNode.addEventHandler(MOUSE_CLICKED, event -> handleMonthlyInOutChartMouseClickEvent( (account == ALL_ACCOUNTS) ? null : account, of(volume.getYear(), volume.getMonth(), 1), event)); }); } List<TransactionVolume> outgoingVolumes = (account == ALL_ACCOUNTS) ? transactionRepository.getMonthlyOutgoingVolumes(false) : transactionRepository.getMonthlyOutgoingVolumesOfAccount(account, false); if (INTEGER_ZERO.compareTo(yearCombo.getValue()) < 0) { outgoingVolumes = outgoingVolumes.stream() .filter(v -> v.getYear().equals(yearCombo.getValue())) .sorted((v1, v2) -> v1.getDate().compareTo(v2.getDate())).collect(toList()); } for (TransactionVolume volume : outgoingVolumes) { String monthLabel = getMonthLabel(volume.getYear(), volume.getMonth()); XYChart.Data<String, Number> data = new XYChart.Data<>(monthLabel, volume.getVolume().abs()); Platform.runLater(() -> { outSeries.getData().add(data); StackPane node = (StackPane) data.getNode(); // TODO make that look nicer Label labelNode = new Label( CurrencyFormat.getInstance().format(volume.getVolume())); labelNode.setPrefWidth(100); labelNode.setAlignment(CENTER_RIGHT); labelNode.setRotate(270); node.getChildren().add(labelNode); node.addEventHandler(MOUSE_CLICKED, event -> handleMonthlyInOutChartMouseClickEvent( (account == ALL_ACCOUNTS ? null : account), volume.getDate(), event)); }); } return null; } }; } }; service.start(); } }
From source file:com.loyalty.controllers.DashboardController.java
private void renewPromotions() { String promotions = null;/*from w ww.j a v a 2s . c o m*/ try { promotions = getService().getPromotions().stream().map(promo -> promo.getDescription()) .collect(Collectors.joining("; ")); } catch (IOException e) { e.printStackTrace(); } String finalPromotions = promotions; Platform.runLater(() -> lbl_promotion.setText(finalPromotions)); }
From source file:org.sleuthkit.autopsy.imagegallery.datamodel.grouping.GroupManager.java
/** * remove the given file from the group with the given key. If the group * doesn't exist or doesn't already contain this file, this method is a * no-op/*from ww w . jav a 2 s . c o m*/ * * @param groupKey the value of groupKey * @param fileID the value of file */ public synchronized DrawableGroup removeFromGroup(GroupKey<?> groupKey, final Long fileID) { //get grouping this file would be in final DrawableGroup group = getGroupForKey(groupKey); if (group != null) { Platform.runLater(() -> { group.removeFile(fileID); }); // If we're grouping by category, we don't want to remove empty groups. if (groupKey.getAttribute() != DrawableAttribute.CATEGORY) { if (group.getFileIDs().isEmpty()) { Platform.runLater(() -> { if (analyzedGroups.contains(group)) { analyzedGroups.remove(group); FXCollections.sort(analyzedGroups, applySortOrder(sortOrder, sortBy)); } if (unSeenGroups.contains(group)) { unSeenGroups.remove(group); FXCollections.sort(unSeenGroups, applySortOrder(sortOrder, sortBy)); } }); } } else { //group == null // It may be that this was the last unanalyzed file in the group, so test // whether the group is now fully analyzed. popuplateIfAnalyzed(groupKey, null); } } return group; }
From source file:com.ubershy.streamsis.actors.UniversalActor.java
@Override public void stop() { Platform.runLater(() -> { actorCheckerService.cancel();/*from ww w.j av a2s .com*/ onRepeatingService.cancel(); offRepeatingService.cancel(); isSwitchOn.set(false); // reset SwitchOn }); }
From source file:io.github.mzmine.modules.plots.msspectrum.MsSpectrumPlotWindowController.java
/** * Add a new spectrum to the plot./* w w w. j a va 2 s .co m*/ * * @param spectrum */ public void addSpectrum(@Nonnull MsSpectrum spectrum, @Nonnull String name) { Preconditions.checkNotNull(spectrum); if (!Platform.isFxApplicationThread()) { throw new IllegalStateException( "Not on FX application thread; currentThread = " + Thread.currentThread().getName()); } MsSpectrumDataSet newDataSet = new MsSpectrumDataSet(spectrum, name); newDataSet.mzShiftProperty().bind(mzShift); datasets.add(newDataSet); final int datasetIndex = numberOfDataSets; numberOfDataSets++; final XYPlot plot = chartNode.getChart().getXYPlot(); final Color newColor = plotColors[datasetIndex % plotColors.length]; newDataSet.setColor(newColor); configureRenderer(newDataSet, datasetIndex); newDataSet.renderingTypeProperty().addListener(e -> { Platform.runLater(() -> 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); }