List of usage examples for javafx.application Platform runLater
public static void runLater(Runnable runnable)
From source file:edu.kit.trufflehog.view.jung.visualization.FXVisualizationViewer.java
synchronized public void refreshLayout() { // logger.debug("refresh"); final FRLayout2<INode, IConnection> l = new FRLayout2<>(this.layout.getObservableGraph()); l.setMaxIterations(layout.getGraph().getEdgeCount() * (int) (this.getWidth() / canvas.getScale())); // l.setMaxIterations(700); this.layout = new ObservableLayout<>(l); //TODO make the dimension changeable from settings menu? // logger.debug(canvas.getScale() + " " + this.getWidth() + " " + this.getHeight()); layout.setSize(new Dimension((int) (this.getWidth() / (2 * canvas.getScale())), (int) (this.getHeight() / (2 * canvas.getScale())))); //layout.set/*from w ww . j a va 2 s . com*/ final Executor layouter = Executors.newSingleThreadExecutor(); layouter.execute(() -> { while (!layout.done()) { layout.step(); Platform.runLater(this::repaint); } }); }
From source file:se.trixon.mapollage.ui.MainApp.java
private void setRunningState(RunState runState) { ArrayList<Action> actions = new ArrayList<>(); switch (runState) { case STARTABLE: actions.addAll(Arrays.asList(mLogAction, ActionUtils.ACTION_SPAN, mAddAction)); mOptionsAction.setDisabled(false); break;/* w ww . j a v a 2 s. c o m*/ case CANCELABLE: actions.addAll(Arrays.asList(mHomeAction, ActionUtils.ACTION_SPAN, mCancelAction)); mHomeAction.setDisabled(true); mOptionsAction.setDisabled(true); break; case CLOSEABLE: actions.addAll(Arrays.asList(mHomeAction, ActionUtils.ACTION_SPAN, mRunAction)); mHomeAction.setDisabled(false); mOptionsAction.setDisabled(false); break; default: throw new AssertionError(); } actions.addAll(Arrays.asList(mOptionsAction, new ActionGroup(Dict.HELP.toString(), mFontAwesome.create(FontAwesome.Glyph.QUESTION).size(ICON_SIZE_TOOLBAR).color(mIconColor), mHelpAction, mAboutDateFormatAction, ActionUtils.ACTION_SEPARATOR, mAboutAction))); Platform.runLater(() -> { if (mToolBar == null) { mToolBar = ActionUtils.createToolBar(actions, ActionUtils.ActionTextBehavior.HIDE); mToolBar.setStyle("-fx-spacing: 0px;"); mRoot.setTop(mToolBar); } else { mToolBar = ActionUtils.updateToolBar(mToolBar, actions, ActionUtils.ActionTextBehavior.HIDE); mToolBar.getItems().add(1, mIndicator); mIndicator.setVisible(runState != RunState.STARTABLE); } adjustButtonWidth(mToolBar.getItems().stream(), ICON_SIZE_TOOLBAR * 1.5); mToolBar.getItems().stream().filter((item) -> (item instanceof ButtonBase)) .map((item) -> (ButtonBase) item).forEachOrdered((buttonBase) -> { FxHelper.undecorateButton(buttonBase); }); }); }
From source file:snpviewer.SnpViewer.java
@Override public void initialize(URL url, ResourceBundle rb) { labelSplitPane.setDividerPositions(); chromSplitPane.setDividerPositions(); Pane lpane = (Pane) horizontalSplit.getItems().get(0); SplitPane.setResizableWithParent(lpane, false); //mnemonics/shortcuts for menus mainMenu.useSystemMenuBarProperty().set(true); fileMenu.setMnemonicParsing(true);// ww w .j a v a2 s .c om sampleMenu.setMnemonicParsing(true); goMenu.setMnemonicParsing(true); helpMenu.setMnemonicParsing(true); newProjectMenu.setAccelerator(new KeyCodeCombination(KeyCode.N, KeyCombination.SHORTCUT_DOWN)); loadProjectMenu.setAccelerator(new KeyCodeCombination(KeyCode.L, KeyCombination.SHORTCUT_DOWN)); addAffSampleMenu.setAccelerator( new KeyCodeCombination(KeyCode.A, KeyCombination.SHORTCUT_DOWN, KeyCombination.SHIFT_DOWN)); addUnSampleMenu.setAccelerator( new KeyCodeCombination(KeyCode.U, KeyCombination.SHORTCUT_DOWN, KeyCombination.SHIFT_DOWN)); nextChromMenu.setAccelerator(new KeyCodeCombination(KeyCode.EQUALS, KeyCombination.SHORTCUT_DOWN)); prevChromMenu.setAccelerator(new KeyCodeCombination(KeyCode.MINUS, KeyCombination.SHORTCUT_DOWN)); firstChromMenu.setAccelerator(new KeyCodeCombination(KeyCode.DIGIT1, KeyCombination.SHORTCUT_DOWN)); lastChromMenu.setAccelerator(new KeyCodeCombination(KeyCode.DIGIT0, KeyCombination.SHORTCUT_DOWN)); redrawMenu.setAccelerator(new KeyCodeCombination(KeyCode.R, KeyCombination.SHORTCUT_DOWN)); cacheChromsMenu.setAccelerator( new KeyCodeCombination(KeyCode.C, KeyCombination.SHORTCUT_DOWN, KeyCombination.SHIFT_DOWN)); saveToPngMenu.setAccelerator( new KeyCodeCombination(KeyCode.S, KeyCombination.SHORTCUT_DOWN, KeyCombination.SHIFT_DOWN)); autoFindRegions.setAccelerator(new KeyCodeCombination(KeyCode.F, KeyCombination.SHORTCUT_DOWN)); //need to disable hideSavedRegionsMenu accelerator for linux - doesn't work for check menus hideSavedRegionsMenu.setAccelerator( new KeyCodeCombination(KeyCode.H, KeyCombination.SHORTCUT_DOWN, KeyCombination.SHIFT_DOWN)); clearSavedRegionsMenu.setAccelerator( new KeyCodeCombination(KeyCode.X, KeyCombination.SHORTCUT_DOWN, KeyCombination.SHIFT_DOWN)); displaySavedsRegionsMenu.setAccelerator(new KeyCodeCombination(KeyCode.T, KeyCombination.SHORTCUT_DOWN)); outputSavedRegionsMenu.setAccelerator(new KeyCodeCombination(KeyCode.O, KeyCombination.SHORTCUT_DOWN)); removeSampleMenu.setAccelerator( new KeyCodeCombination(KeyCode.R, KeyCombination.SHORTCUT_DOWN, KeyCombination.SHIFT_DOWN)); //set radio menu item toggle group ArrayList<RadioMenuItem> callQualityRadios = new ArrayList<>( Arrays.asList(noFilteringRadio, filter99, filter95, filter90, filter85)); ToggleGroup callQualityToggle = new ToggleGroup(); for (RadioMenuItem r : callQualityRadios) { r.setToggleGroup(callQualityToggle); } noFilteringRadio.setOnAction(new EventHandler() { @Override public void handle(Event ev) { setQualityFilter(null); } }); filter99.setOnAction(new EventHandler() { @Override public void handle(Event ev) { setQualityFilter(0.01); } }); filter95.setOnAction(new EventHandler() { @Override public void handle(Event ev) { setQualityFilter(0.05); } }); filter90.setOnAction(new EventHandler() { @Override public void handle(Event ev) { setQualityFilter(0.10); } }); filter85.setOnAction(new EventHandler() { @Override public void handle(Event ev) { setQualityFilter(0.15); } }); nextChromMenu.setOnAction(new EventHandler() { @Override public void handle(Event ev) { selectNextChromosome(true); } }); prevChromMenu.setOnAction(new EventHandler() { @Override public void handle(Event ev) { selectNextChromosome(false); } }); firstChromMenu.setOnAction(new EventHandler() { @Override public void handle(Event ev) { if (!cancelButton.isDisabled()) { cancelButton.fire(); } if (!chromosomeSelector.isDisabled()) { chromosomeSelector.getSelectionModel().selectFirst(); } } }); lastChromMenu.setOnAction(new EventHandler() { @Override public void handle(Event ev) { if (!cancelButton.isDisabled()) { cancelButton.fire(); } if (!chromosomeSelector.isDisabled()) { chromosomeSelector.getSelectionModel().selectLast(); } } }); hideSavedRegionsMenu.setOnAction(new EventHandler() { @Override public void handle(Event ev) { showHideSavedRegions(); } }); colorComp.addAll(Arrays.asList(colorComponants)); //selection context menu final ContextMenu scm = new ContextMenu(); final MenuItem scmItem1 = new MenuItem("Display Flanking SNP IDs"); scmItem1.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { /* get coordinates of selection and report back * flanking snp ids and coordinates */ displayFlankingSnpIDs(dragSelectRectangle); } }); final MenuItem scmItem2 = new MenuItem("Write Selected Region to File"); scmItem2.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { Platform.runLater(new Runnable() { @Override public void run() { /* get coordinates of selection and report back * write SNPs in region to file */ writeRegionToFile(dragSelectRectangle); } }); } }); final MenuItem scmItem3 = new MenuItem("Add To Saved Regions"); scmItem3.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { /* get coordinates of selection and report back * write SNPs in region to file */ saveSelection(); } }); final MenuItem scmItem4 = new MenuItem("Show/Hide Saved Regions"); scmItem4.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { /* get coordinates of selection and report back * write SNPs in region to file */ hideSavedRegionsMenu.selectedProperty().setValue(!hideSavedRegionsMenu.isSelected()); hideSavedRegionsMenu.fire(); } }); final MenuItem scmItem5 = new MenuItem("Zoom Region"); scmItem5.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { Platform.runLater(new Runnable() { @Override public void run() { /* get coordinates of selection and report back * write SNPs in region to file */ zoomRegion(dragSelectRectangle); } }); } }); final MenuItem scmItem6 = new MenuItem("Write Saved Regions to File"); scmItem6.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { Platform.runLater(new Runnable() { @Override public void run() { /* get coordinates of selection and report back * write SNPs in region to file */ writeSavedRegionsToFile(); } }); } }); scm.getItems().add(scmItem1); scm.getItems().add(scmItem2); scm.getItems().add(scmItem3); scm.getItems().add(scmItem4); scm.getItems().add(scmItem5); scm.getItems().add(scmItem6); //overlayPane context menu ocm = new ContextMenu(); final MenuItem ocmItem1 = new MenuItem("Save Image to File"); ocmItem1.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { Platform.runLater(new Runnable() { @Override public void run() { drawPaneToPng(); } }); } }); ocm.getItems().add(ocmItem1); ocm.getItems().add(scmItem4); ocm.getItems().add(scmItem6); //color selections colorComponantSelector.getItems().clear(); colorComponantSelector.getItems().add("AA"); colorComponantSelector.getItems().add("BB"); colorComponantSelector.getItems().add("AB"); colorComponantSelector.getItems().add("Selection Outline"); colorComponantSelector.getItems().add("Selection Fill"); colorComponantSelector.getItems().add("Saved Region Outline"); colorComponantSelector.getItems().add("Saved Region Fill"); colorComponantSelector.getSelectionModel().selectFirst(); colorPicker.setValue(colorComponants[0]); colorComponantSelector.getSelectionModel().selectedIndexProperty() .addListener(new ChangeListener<Number>() { @Override public void changed(ObservableValue ov, Number value, Number new_value) { colorPicker.setValue(colorComp.get(new_value.intValue())); colorPicker.fireEvent(new ActionEvent()); } }); colorPicker.setOnAction(new EventHandler() { @Override public void handle(Event t) { if (!colorComp.get(colorComponantSelector.getSelectionModel().getSelectedIndex()) .equals(colorPicker.getValue())) { colorComp.set(colorComponantSelector.getSelectionModel().getSelectedIndex(), colorPicker.getValue()); saveProject(); //colorComponants[colorComponantSelector.getSelectionModel().getSelectedIndex()] = colorPicker.getValue(); if (colorComponantSelector.getSelectionModel().getSelectedIndex() == Colors.fill.value) { dragSelectRectangle.setFill(colorPicker.getValue()); } else if (colorComponantSelector.getSelectionModel().getSelectedIndex() == Colors.line.value) { dragSelectRectangle.setStroke(colorPicker.getValue()); } else if (colorComponantSelector.getSelectionModel() .getSelectedIndex() == Colors.saveLine.value) { for (Rectangle r : savedRegionsDisplay) { r.setStroke(colorPicker.getValue()); } } else if (colorComponantSelector.getSelectionModel() .getSelectedIndex() == Colors.saveFill.value) { for (Rectangle r : savedRegionsDisplay) { r.setFill(colorPicker.getValue()); } } else { removeSavedChromosomeImages(); if (redrawCheckBox.isSelected()) { refreshView(null, true); } } } } }); /*perform appropriate action when user selects a chromosome * from the chromosome choice box */ chromosomeSelector.getSelectionModel().selectedIndexProperty().addListener(new ChangeListener<Number>() { @Override public void changed(ObservableValue ov, Number value, Number new_value) { chromosomeBoxList = chromosomeSelector.getItems().toArray(); if (new_value.intValue() > -1) { chromosomeSelected((String) chromosomeBoxList[new_value.intValue()]); } } }); chromosomeSelector.addEventFilter(KeyEvent.ANY, new EventHandler<KeyEvent>() { @Override public void handle(KeyEvent ke) { if (ke.getCode() == KeyCode.UP) { ke.consume(); chromosomeSelector.show(); } } }); selectionOverlayPane.heightProperty().addListener(new ChangeListener<Number>() { @Override public void changed(ObservableValue<? extends Number> observableValue, Number oldSceneWidth, Number newSceneWidth) { windowResized(new ActionEvent()); } }); selectionOverlayPane.widthProperty().addListener(new ChangeListener<Number>() { @Override public void changed(ObservableValue<? extends Number> observableValue, Number oldSceneWidth, Number newSceneWidth) { windowResized(new ActionEvent()); } }); /*upon addition of a new affected file adjust components accordingly * i.e. ensure appropriate chromosomes are in the choice box * adjust the split panes to fit all files and redisplay */ affObserve.addListener(new ListChangeListener() { @Override public void onChanged(ListChangeListener.Change change) { change.next();/*from the javadoc * 'Go to the next change. In initial state is invalid a require * a call to next() before calling other methods. The first * next() call will make this object represent the first change. */ if (change.getRemovedSize() > 0) { List<SnpFile> both = new ArrayList<>(unFiles); both.addAll(affFiles); recheckChromosomeSelector(both);//need to check all files again, not just affFiles } else if (change.getAddedSize() > 0) { addToChromosomeSelector(affFiles); } } }); /*as above * but for unaffected files */ unObserve.addListener(new ListChangeListener() { @Override public void onChanged(ListChangeListener.Change change) { change.next(); if (change.getRemovedSize() > 0) { List<SnpFile> both = new ArrayList<>(unFiles); both.addAll(affFiles); recheckChromosomeSelector(both);//need to check all files again, not just unFiles } else if (change.getAddedSize() > 0) { addToChromosomeSelector(unFiles); } } }); selectionOverlayPane.addEventHandler(MouseEvent.MOUSE_MOVED, new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent e) { if (!genomeVersion.equals("") && chromosomeSelector.getSelectionModel().getSelectedIndex() > -1) { try { ChromosomeLength chromLength = new ChromosomeLength(genomeVersion); String currentChrom = (String) chromosomeBoxList[chromosomeSelector.getSelectionModel() .getSelectedIndex()]; double coordinate = chromLength.getLength(currentChrom) / chromSplitPane.getWidth() * e.getX(); positionIndicator.setText(nf.format(coordinate)); } catch (Exception ex) { positionIndicator.setText("Build Error!"); } } } }); /*handle mouse dragging and effect on dragSelectRectangle * */ dragSelectRectangle.widthProperty().bind(dragSelectRectX.subtract(dragSelectRectInitX)); dragSelectRectangle.heightProperty().bind(selectionOverlayPane.heightProperty()); //dragSelectRectangle.strokeProperty().set(colorComponants[Colors.line.value]); dragSelectRectangle.setStrokeWidth(4.0); //dragSelectRectangle.setBlendMode(BlendMode.SCREEN); dragSelectRectangle.setOpacity(0.45); dragSelectRectangle.setVisible(false); selectionOverlayPane.getChildren().add(dragSelectRectangle); selectionOverlayPane.addEventHandler(MouseEvent.MOUSE_PRESSED, new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent e) { if (scm.isShowing()) { scm.hide(); } if (!e.isPrimaryButtonDown()) { if (e.isSecondaryButtonDown()) { //check we're not overlapping selection if (e.getX() >= dragSelectRectangle.getX() && e.getX() <= (dragSelectRectangle.getX() + dragSelectRectangle.getWidth())) { return; } //check we're not overlapping saved regions for (Rectangle r : savedRegionsDisplay) { if (r.isVisible() && e.getX() >= r.getX() && e.getX() <= r.getX() + r.getWidth()) { return; } } if (chromosomeSelector.getSelectionModel().isEmpty()) { ocmItem1.setDisable(true); } else { ocmItem1.setDisable(false); } ocm.show(selectionOverlayPane, e.getScreenX(), e.getScreenY()); return; } } if (ocm.isShowing()) { ocm.hide(); } dragSelectRectangle.strokeProperty().set(colorComp.get(Colors.line.value)); dragSelectRectangle.fillProperty().set(colorComp.get(Colors.fill.value)); dragSelectRectX.set(0); dragSelectRectangle.setVisible(true); dragSelectRectangle.setX(e.getX()); dragSelectRectangle.setY(0); dragSelectRectInitX.set(e.getX()); anchorInitX.set(e.getX()); } }); selectionOverlayPane.addEventHandler(MouseEvent.MOUSE_DRAGGED, new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent e) { if (!e.isPrimaryButtonDown()) { return; } dragSelectRectangle.setVisible(true); if (e.getX() > anchorInitX.doubleValue()) {//dragging to the right if (e.getX() <= selectionOverlayPane.getLayoutX() + selectionOverlayPane.getWidth()) { //mouse is before the edge of the pane dragSelectRectInitX.set(anchorInitX.doubleValue()); dragSelectRectX.set(e.getX()); } else { //mouse is over the edge dragSelectRectX.set(selectionOverlayPane.getWidth()); } } else { if (e.getX() > selectionOverlayPane.getLayoutX()) { dragSelectRectInitX.set(e.getX()); dragSelectRectangle.setX(e.getX()); dragSelectRectX.set(anchorInitX.doubleValue()); } else { dragSelectRectInitX.set(0); dragSelectRectangle.setX(0); /* the two lines below are just to trigger * dragSelectRectangle.widthProperty listener * so that start coordinate changes to 1 */ dragSelectRectX.set(anchorInitX.doubleValue() + 1); dragSelectRectX.set(anchorInitX.doubleValue() + 1); } } } }); selectionOverlayPane.addEventHandler(MouseEvent.MOUSE_RELEASED, new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent e) { //dragSelectRectX.set(e.getX()); if (!e.isPrimaryButtonDown()) { return; } dragSelectRectangle.setVisible(true); if (dragSelectRectangle.getWidth() == 0) { clearDragSelectRectangle(); } } }); dragSelectRectangle.widthProperty().addListener(new ChangeListener() { @Override public void changed(ObservableValue observableValue, Object oldValue, Object newRectWidth) { if (!genomeVersion.equals("") && chromosomeSelector.getSelectionModel().getSelectedIndex() > -1 && dragSelectRectangle.getWidth() > 0) { try { ChromosomeLength chromLength = new ChromosomeLength(genomeVersion); String currentChrom = (String) chromosomeBoxList[chromosomeSelector.getSelectionModel() .getSelectedIndex()]; double startCoordinate = chromLength.getLength(currentChrom) / selectionOverlayPane.getWidth() * dragSelectRectangle.getX(); double selectionWidth = chromLength.getLength(currentChrom) / selectionOverlayPane.getWidth() * dragSelectRectangle.getWidth(); if (dragSelectRectangle.getX() == 0) { startCoordinate = 1; } selectionIndicator.setText("chr" + currentChrom + ":" + nf.format(startCoordinate) + "-" + nf.format(startCoordinate + selectionWidth)); } catch (Exception ex) { selectionIndicator.setText("Build Error!"); } } else { selectionIndicator.setText(""); } } }); dragSelectRectangle.addEventHandler(MouseEvent.MOUSE_CLICKED, new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent e) { if (e.getButton() == MouseButton.SECONDARY) { if (chromosomeSelector.getSelectionModel().isEmpty()) { scmItem1.setDisable(true); scmItem2.setDisable(true); } else { scmItem1.setDisable(false); scmItem2.setDisable(false); } if (ocm.isShowing()) { ocm.hide(); } scm.show(selectionOverlayPane, e.getScreenX(), e.getScreenY()); } } }); }
From source file:org.sleuthkit.autopsy.imagegallery.grouping.GroupManager.java
/** * regroup all files in the database using given {@link DrawableAttribute} * see {@link ReGroupTask} for more details. * * @param groupBy// w w w. j av a 2 s . co m * @param sortBy * @param sortOrder * @param force true to force a full db query regroup */ public <A extends Comparable<A>> void regroup(final DrawableAttribute<A> groupBy, final GroupSortBy sortBy, final SortOrder sortOrder, Boolean force) { if (!Case.isCaseOpen()) { return; } //only re-query the db if the group by attribute changed or it is forced if (groupBy != getGroupBy() || force == true) { setGroupBy(groupBy); setSortBy(sortBy); setSortOrder(sortOrder); if (groupByTask != null) { groupByTask.cancel(true); } Platform.runLater(() -> { FXCollections.sort(unSeenGroups, sortBy.getGrpComparator(sortOrder)); }); groupByTask = new ReGroupTask<A>(groupBy, sortBy, sortOrder); Platform.runLater(() -> { regroupProgress.bind(groupByTask.progressProperty()); }); regroupExecutor.submit(groupByTask); } else { // just resort the list of groups setSortBy(sortBy); setSortOrder(sortOrder); Platform.runLater(() -> { FXCollections.sort(unSeenGroups, sortBy.getGrpComparator(sortOrder)); FXCollections.sort(analyzedGroups, sortBy.getGrpComparator(sortOrder)); }); } }
From source file:org.sleuthkit.autopsy.imageanalyzer.grouping.GroupManager.java
/** * regroup all files in the database using given {@link DrawableAttribute} * see {@link ReGroupTask} for more details. * * @param groupBy/*from w w w.ja v a 2s . co m*/ * @param sortBy * @param sortOrder * @param force true to force a full db query regroup */ public <A extends Comparable<A>> void regroup(final DrawableAttribute<A> groupBy, final GroupSortBy sortBy, final SortOrder sortOrder, Boolean force) { //only re-query the db if the group by attribute changed or it is forced if (groupBy != getGroupBy() || force == true) { setGroupBy(groupBy); setSortBy(sortBy); setSortOrder(sortOrder); if (groupByTask != null) { groupByTask.cancel(true); } Platform.runLater(() -> { FXCollections.sort(unSeenGroups, sortBy.getGrpComparator(sortOrder)); }); groupByTask = new ReGroupTask<A>(groupBy, sortBy, sortOrder); Platform.runLater(() -> { regroupProgress.bind(groupByTask.progressProperty()); }); regroupExecutor.submit(groupByTask); } else { // just resort the list of groups setSortBy(sortBy); setSortOrder(sortOrder); Platform.runLater(() -> { FXCollections.sort(unSeenGroups, sortBy.getGrpComparator(sortOrder)); }); } }
From source file:com.github.vatbub.tictactoe.view.Main.java
@FXML // This method is called by the FXMLLoader when initialization is complete void initialize() { // modify the default exception handler to show a good error message on every uncaught exception final Thread.UncaughtExceptionHandler currentUncaughtExceptionHandler = Thread .getDefaultUncaughtExceptionHandler(); Thread.setDefaultUncaughtExceptionHandler((thread, exception) -> { if (currentUncaughtExceptionHandler != null) { // execute current handler as we only want to append it currentUncaughtExceptionHandler.uncaughtException(thread, exception); }//w ww. ja v a2s .c o m Platform.runLater(() -> new ExceptionAlert(exception).showAndWait()); }); opponentsTurnHBox.heightProperty() .addListener((observable, oldValue, newValue) -> updateOpponentsTurnHBox(false)); aiLevelLabelClipRectangle = new Rectangle(0, 0, 0, 0); aiLevelLabelClipRectangle.setEffect(new MotionBlur(0, 10)); aiLevelLabelPane.setClip(aiLevelLabelClipRectangle); aiLevelLabelClipRectangle.heightProperty().bind(aiLevelLabelPane.heightProperty()); aiLevelLabelPane.widthProperty().addListener((observable, oldValue, newValue) -> updateAILevelLabel(true)); Rectangle menuSubBoxClipRectangle = new Rectangle(0, 0, 0, 0); menuSubBox.setClip(menuSubBoxClipRectangle); menuSubBoxClipRectangle.heightProperty().bind(menuSubBox.heightProperty()); menuSubBoxClipRectangle.widthProperty().bind(menuSubBox.widthProperty()); Rectangle playOnlineClipRectangle = new Rectangle(0, 0, 0, 0); playOnlineClipAnchorPane.setClip(playOnlineClipRectangle); playOnlineClipRectangle.heightProperty().bind(playOnlineClipAnchorPane.heightProperty()); playOnlineClipRectangle.widthProperty().bind(playOnlineClipAnchorPane.widthProperty()); player1SetSampleName(); player2SetSampleName(); gameTable.heightProperty() .addListener((observable, oldValue, newValue) -> refreshedNodes.refreshAll(gameTable.getWidth(), oldValue.doubleValue(), gameTable.getWidth(), newValue.doubleValue())); gameTable.widthProperty() .addListener((observable, oldValue, newValue) -> refreshedNodes.refreshAll(oldValue.doubleValue(), gameTable.getHeight(), newValue.doubleValue(), gameTable.getHeight())); player1AIToggle.selectedProperty().addListener((observable, oldValue, newValue) -> { showHideAILevelSlider(newValue, player2AIToggle.isSelected()); player1SetSampleName(); }); player2AIToggle.selectedProperty().addListener((observable, oldValue, newValue) -> { showHideAILevelSlider(player1AIToggle.isSelected(), newValue); player2SetSampleName(); }); gameTable.setSelectionModel(null); gameTable.heightProperty().addListener((observable, oldValue, newValue) -> { Pane header = (Pane) gameTable.lookup("TableHeaderRow"); if (header.isVisible()) { header.setMaxHeight(0); header.setMinHeight(0); header.setPrefHeight(0); header.setVisible(false); } renderRows(); }); gameTable.setRowFactory(param -> { TableRow<Row> row = new TableRow<>(); row.styleProperty().bind(style); if (rowFont == null) { rowFont = new SimpleObjectProperty<>(); rowFont.bind(row.fontProperty()); } return row; }); looseImage.fitHeightProperty().bind(looserPane.heightProperty()); looseImage.fitWidthProperty().bind(looserPane.widthProperty()); looseImage.fitHeightProperty().addListener((observable, oldValue, newValue) -> reloadImage(looseImage, getClass().getResource("loose.png").toString(), looseImage.getFitWidth(), newValue.doubleValue())); looseImage.fitWidthProperty().addListener((observable, oldValue, newValue) -> reloadImage(looseImage, getClass().getResource("loose.png").toString(), newValue.doubleValue(), looseImage.getFitWidth())); confetti.fitHeightProperty().bind(winPane.heightProperty()); confetti.fitWidthProperty().bind(winPane.widthProperty()); confetti.fitHeightProperty().addListener((observable, oldValue, newValue) -> reloadImage(confetti, getClass().getResource("confetti.png").toString(), confetti.getFitWidth(), newValue.doubleValue())); confetti.fitWidthProperty().addListener((observable, oldValue, newValue) -> reloadImage(confetti, getClass().getResource("confetti.png").toString(), newValue.doubleValue(), confetti.getFitWidth())); aiLevelSlider.valueProperty().addListener((observable, oldValue, newValue) -> updateAILevelLabel()); playOnlineHyperlink.widthProperty().addListener((observable, oldValue, newValue) -> { if (playOnlineAnchorPane.isVisible()) { setLowerRightAnchorPaneDimensions(playOnlineHyperlink, currentPlayerLabel, true); } }); playOnlineHyperlink.heightProperty().addListener((observable, oldValue, newValue) -> { if (playOnlineAnchorPane.isVisible()) { setLowerRightAnchorPaneDimensions(playOnlineHyperlink, currentPlayerLabel, true); } }); playOnlineHyperlink.textProperty().addListener((observable, oldValue, newValue) -> { if (!newValue.equals(oldValue)) { if (newValue.contains("ff")) { setLowerRightAnchorPaneDimensions(playOnlineHyperlink, currentPlayerLabel, true, 1); } else { setLowerRightAnchorPaneDimensions(playOnlineHyperlink, currentPlayerLabel, true, -1); } } }); // Kunami code root.setOnKeyPressed(event -> { if (KunamiCode.isCompleted(event.getCode())) { if (root.getEffect() != null && root.getEffect() instanceof Blend) { BlendMode currentMode = ((Blend) root.getEffect()).getMode(); BlendMode nextMode; if (currentMode == BlendMode.values()[BlendMode.values().length - 1]) { nextMode = BlendMode.values()[0]; } else { nextMode = BlendMode.values()[Arrays.asList(BlendMode.values()).indexOf(currentMode) + 1]; } ((Blend) root.getEffect()).setMode(nextMode); } else { root.setEffect(new Blend(BlendMode.EXCLUSION)); } } }); // prompt text of the my username field in the online multiplayer menu onlineMyUsername.promptTextProperty().bind(player1Name.promptTextProperty()); onlineMyUsername.textProperty().bindBidirectional(player1Name.textProperty()); setAccessibleTextsForNodesThatDoNotChange(); updateAccessibleTexts(); initBoard(); initNewGame(); }
From source file:com.github.drbookings.ui.controller.MainController.java
private void initTableViewContextMenus() { final ContextMenu menu = new ContextMenu(); final MenuItem mi1 = new MenuItem("Delete"); final MenuItem mi2 = new MenuItem("Add"); final MenuItem mi3 = new MenuItem("Modify"); mi1.setOnAction(event -> {//from w w w .j ava2 s . co m Platform.runLater(() -> deleteSelected()); }); mi2.setOnAction(event -> { Platform.runLater(() -> addBooking()); }); mi3.setOnAction(event -> { Platform.runLater(() -> showModifyBookingDialog()); }); menu.getItems().addAll(mi2, mi1, mi3); tableView.setContextMenu(menu); tableView.addEventHandler(MouseEvent.MOUSE_CLICKED, t -> { if (t.getButton() == MouseButton.SECONDARY) { menu.show(tableView, t.getScreenX(), t.getScreenY()); } }); }
From source file:genrsa.GenRSAController.java
/** * Comprueba la primalidad de P y Q por el metodo de Miller Rabin * @param event //from www. j av a 2s.co m */ public void primalityMiller(ActionEvent event) { Task CAstart = new Task() { @Override protected Object call() throws Exception { progress.setVisible(true); Platform.runLater(() -> { mainWindow.clearPrimality(); disableOnProgress(true); }); boolean isMiller = true; checkPrimes.check(primo_P.getText(), primo_Q.getText(), iteraciones_primalidad.getText(), isMiller); Platform.runLater(() -> { disableOnProgress(false); disableButtons(); }); progress.setVisible(false); return null; } }; new Thread(CAstart).start(); }
From source file:org.sleuthkit.autopsy.imagegallery.datamodel.grouping.GroupManager.java
@SuppressWarnings("AssignmentToMethodParameter") private void addFileToGroup(DrawableGroup g, final GroupKey<?> groupKey, final long fileID) { if (g == null) { //if there wasn't already a group check if there should be one now g = popuplateIfAnalyzed(groupKey, null); }/*from www . j a va 2 s .com*/ DrawableGroup group = g; if (group != null) { //if there is aleady a group that was previously deemed fully analyzed, then add this newly analyzed file to it. Platform.runLater(() -> { group.addFile(fileID); }); } }
From source file:com.neuronrobotics.bowlerstudio.MainController.java
@FXML public void onMobileBaseFromFile() { new Thread() { public void run() { setName("Load Mobile Base Thread"); openFile = FileSelectionFactory.GetFile(ScriptingEngine.getLastFile(), new ExtensionFilter("MobileBase XML", "*.xml", "*.XML")); if (openFile == null) { return; }// w w w . j a va2s. co m Platform.runLater(() -> { try { MobileBase mb = new MobileBase(new FileInputStream(openFile)); ConnectionManager.addConnection(mb, mb.getScriptingName()); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } }); } }.start(); }