List of usage examples for javafx.scene.control MenuItem setOnAction
public final void setOnAction(EventHandler<ActionEvent> value)
From source file:com.bekwam.resignator.ResignatorAppMainViewController.java
void recordRecentProfile(String newProfileName) { if (activeConfiguration.getRecentProfiles().contains(newProfileName)) { return; // can assume activeConfiguration is accurate }//ww w. j av a2 s. c o m // // #18 record recent history on save // List<MenuItem> rpItems = mRecentProfiles.getItems(); MenuItem rpItem = new MenuItem(newProfileName); rpItem.setOnAction(recentProfileLoadHandler); if (CollectionUtils.isNotEmpty(rpItems)) { if (CollectionUtils.size(rpItems) == 1) { if (StringUtils.equalsIgnoreCase(rpItems.get(0).getText(), MI_NO_PROFILES.getText())) { rpItems.set(0, rpItem); } else { rpItems.add(0, rpItem); } } else { rpItems.add(0, rpItem); if (CollectionUtils.size(rpItems) > numRecentProfiles) { for (int i = (CollectionUtils.size(rpItems) - 1); i >= numRecentProfiles; i--) { rpItems.remove(i); } } } } else { // should never have no items (at least one < None >) rpItems.add(rpItem); } // reconcile with active record activeConfiguration.getRecentProfiles().clear(); if (!(CollectionUtils.size(rpItems) == 1 && StringUtils.equalsIgnoreCase(rpItems.get(0).getText(), MI_NO_PROFILES.getText()))) { // there's more than just a < None > element activeConfiguration .setRecentProfiles(rpItems.stream().map((mi) -> mi.getText()).collect(Collectors.toList())); } // end #18 }
From source file:com.panemu.tiwulfx.table.TableControl.java
/** * Add menu item to context menu. It will be displayed under search menu * item/* w w w .j a va 2s .c om*/ * * @param label the label of menu item * @param eventHandler event handler that will be executed when the menu * item is clicked * @deprecated use * {@link #addContextMenuItem(javafx.scene.control.MenuItem)} instead */ public void addContextMenuItem(String label, EventHandler<ActionEvent> eventHandler) { MenuItem mi = new MenuItem(label); mi.setOnAction(eventHandler); cm.getItems().add(mi); }
From source file:com.bekwam.resignator.ResignatorAppMainViewController.java
@FXML public void initialize() { try {//from w ww. j a v a 2s . c om miHelp.setAccelerator(KeyCombination.keyCombination("F1")); cbType.getItems().add(SigningArgumentsType.JAR); cbType.getItems().add(SigningArgumentsType.FOLDER); cbType.getSelectionModel().select(SigningArgumentsType.JAR); cbType.setConverter(new StringConverter<SigningArgumentsType>() { @Override public String toString(SigningArgumentsType type) { return StringUtils.capitalize(StringUtils.lowerCase(String.valueOf(type))); } @Override public SigningArgumentsType fromString(String type) { return Enum.valueOf(SigningArgumentsType.class, StringUtils.upperCase(type)); } }); activeConfiguration.activeProfileProperty().bindBidirectional(activeProfile.profileNameProperty()); tfSourceFile.textProperty().bindBidirectional(activeProfile.sourceFileFileNameProperty()); tfTargetFile.textProperty().bindBidirectional(activeProfile.targetFileFileNameProperty()); ckReplace.selectedProperty().bindBidirectional(activeProfile.replaceSignaturesProperty()); cbType.valueProperty().bindBidirectional(activeProfile.argsTypeProperty()); miSave.disableProperty().bind(needsSave.not()); tfSourceFile.textProperty().addListener(new WeakInvalidationListener(needsSaveListener)); tfTargetFile.textProperty().addListener(new WeakInvalidationListener(needsSaveListener)); ckReplace.selectedProperty().addListener(new WeakInvalidationListener(needsSaveListener)); cbType.valueProperty().addListener(new WeakInvalidationListener(needsSaveListener)); lblSource.setText(SOURCE_LABEL_JAR); lblTarget.setText(TARGET_LABEL_JAR); cbType.getSelectionModel().selectedItemProperty().addListener((ov, old_v, new_v) -> { if (new_v == SigningArgumentsType.FOLDER) { if (!lblSource.getText().equalsIgnoreCase(SOURCE_LABEL_FOLDER)) { lblSource.setText(SOURCE_LABEL_FOLDER); } if (!lblSource.getText().equalsIgnoreCase(TARGET_LABEL_FOLDER)) { lblTarget.setText(TARGET_LABEL_FOLDER); } } else { if (!lblSource.getText().equalsIgnoreCase(SOURCE_LABEL_JAR)) { lblSource.setText(SOURCE_LABEL_JAR); } if (!lblSource.getText().equalsIgnoreCase(TARGET_LABEL_JAR)) { lblTarget.setText(TARGET_LABEL_JAR); } } }); lvProfiles.getSelectionModel().selectedItemProperty().addListener((ov, old_v, new_v) -> { if (new_v == null) { // coming from clearSelection or sort return; } if (needsSave.getValue()) { Alert alert = new Alert(Alert.AlertType.CONFIRMATION, "Discard unsaved profile?"); alert.setHeaderText("Unsaved profile"); Optional<ButtonType> response = alert.showAndWait(); if (!response.isPresent() || response.get() != ButtonType.OK) { if (logger.isDebugEnabled()) { logger.debug("[SELECT] discard canceled"); } return; } } if (logger.isDebugEnabled()) { logger.debug("[SELECT] nv={}", new_v); } doLoadProfile(new_v); }); lvProfiles.setCellFactory(TextFieldListCell.forListView()); Task<Void> t = new Task<Void>() { @Override protected Void call() throws Exception { updateMessage("Loading configuration"); configurationDS.loadConfiguration(); if (!configurationDS.isSecured()) { if (logger.isDebugEnabled()) { logger.debug("[CALL] config not secured; getting password"); } NewPasswordController npc = newPasswordControllerProvider.get(); if (logger.isDebugEnabled()) { logger.debug("[INIT TASK] npc id={}", npc.hashCode()); } Platform.runLater(() -> { try { npc.showAndWait(); } catch (Exception exc) { logger.error("error showing npc", exc); } }); synchronized (npc) { try { npc.wait(MAX_WAIT_TIME); // 10 minutes to enter the password } catch (InterruptedException exc) { logger.error("new password operation interrupted", exc); } } if (logger.isDebugEnabled()) { logger.debug("[INIT TASK] npc={}", npc.getHashedPassword()); } if (StringUtils.isNotEmpty(npc.getHashedPassword())) { activeConfiguration.setHashedPassword(npc.getHashedPassword()); activeConfiguration.setUnhashedPassword(npc.getUnhashedPassword()); activeConfiguration.setLastUpdatedDateTime(LocalDateTime.now()); configurationDS.saveConfiguration(); configurationDS.loadConfiguration(); configurationDS.decrypt(activeConfiguration.getUnhashedPassword()); } else { Platform.runLater(() -> { Alert noPassword = new Alert(Alert.AlertType.INFORMATION, "You'll need to provide a password to save your keystore credentials."); noPassword.showAndWait(); }); return null; } } else { PasswordController pc = passwordControllerProvider.get(); Platform.runLater(() -> { try { pc.showAndWait(); } catch (Exception exc) { logger.error("error showing pc", exc); } }); synchronized (pc) { try { pc.wait(MAX_WAIT_TIME); // 10 minutes to enter the password } catch (InterruptedException exc) { logger.error("password operation interrupted", exc); } } Platform.runLater(() -> { if (pc.getStage().isShowing()) { // ended in timeout timeout pc.getStage().hide(); } if (pc.wasCancelled() || pc.wasReset() || !pc.doesPasswordMatch()) { if (logger.isDebugEnabled()) { logger.debug("[INIT TASK] was cancelled or the number of retries was exceeded"); } String msg = ""; if (pc.wasCancelled()) { msg = "You must provide a password to the datastore. Exitting..."; } else if (pc.wasReset()) { msg = "Data file removed. Exitting..."; } else { msg = "Exceeded maximum number of retries. Exitting..."; } Alert alert = new Alert(Alert.AlertType.WARNING, msg); alert.setOnCloseRequest((evt) -> { Platform.exit(); System.exit(1); }); alert.showAndWait(); } else { // // save password for later decryption ops // activeConfiguration.setUnhashedPassword(pc.getPassword()); configurationDS.decrypt(activeConfiguration.getUnhashedPassword()); // // init profileBrowser // if (logger.isDebugEnabled()) { logger.debug("[INIT TASK] loading profiles from source"); } long startTimeMillis = System.currentTimeMillis(); final List<String> profileNames = configurationDS.getProfiles().stream() .map(Profile::getProfileName).sorted((o1, o2) -> o1.compareToIgnoreCase(o2)) .collect(Collectors.toList()); final List<String> recentProfiles = configurationDS.getRecentProfileNames(); if (logger.isDebugEnabled()) { logger.debug("[INIT TASK] loading profiles into UI"); } lvProfiles.setItems(FXCollections.observableArrayList(profileNames)); if (CollectionUtils.isNotEmpty(recentProfiles)) { mRecentProfiles.getItems().clear(); mRecentProfiles.getItems().addAll( FXCollections.observableArrayList(recentProfiles.stream().map((s) -> { MenuItem mi = new MenuItem(s); mi.setOnAction(recentProfileLoadHandler); return mi; }).collect(Collectors.toList()))); } // // #31 preload the last active profile // if (StringUtils.isNotEmpty(activeConfiguration.getActiveProfile())) { if (logger.isDebugEnabled()) { logger.debug("[INIT TASK] preloading last active profile={}", activeConfiguration.getActiveProfile()); } doLoadProfile(activeConfiguration.getActiveProfile()); } long endTimeMillis = System.currentTimeMillis(); if (logger.isDebugEnabled()) { logger.debug("[INIT TASK] loading profiles took {} ms", (endTimeMillis - startTimeMillis)); } } }); } return null; } @Override protected void succeeded() { super.succeeded(); updateMessage(""); lblStatus.textProperty().unbind(); } @Override protected void cancelled() { super.cancelled(); logger.error("task cancelled", getException()); updateMessage(""); lblStatus.textProperty().unbind(); } @Override protected void failed() { super.failed(); logger.error("task failed", getException()); updateMessage(""); lblStatus.textProperty().unbind(); } }; lblStatus.textProperty().bind(t.messageProperty()); new Thread(t).start(); } catch (Exception exc) { logger.error("can't load configuration", exc); String msg = "Verify that the user has access to the directory '" + configFile + "' under " + System.getProperty("user.home") + "."; Alert alert = new Alert(Alert.AlertType.ERROR, msg); alert.setHeaderText("Can't load config file"); alert.showAndWait(); Platform.exit(); } }
From source file:qupath.lib.gui.tma.TMASummaryViewer.java
private void initialize() { model = new TMATableModel(); groupByIDProperty.addListener((v, o, n) -> refreshTableData()); MenuBar menuBar = new MenuBar(); Menu menuFile = new Menu("File"); MenuItem miOpen = new MenuItem("Open..."); miOpen.setAccelerator(new KeyCodeCombination(KeyCode.O, KeyCombination.SHORTCUT_DOWN)); miOpen.setOnAction(e -> { File file = QuPathGUI.getDialogHelper(stage).promptForFile(null, null, "TMA data files", new String[] { "qptma" }); if (file == null) return; setInputFile(file);//from w w w .java 2s. c o m }); MenuItem miSave = new MenuItem("Save As..."); miSave.setAccelerator( new KeyCodeCombination(KeyCode.S, KeyCombination.SHORTCUT_DOWN, KeyCombination.SHIFT_DOWN)); miSave.setOnAction( e -> SummaryMeasurementTableCommand.saveTableModel(model, null, Collections.emptyList())); MenuItem miImportFromImage = new MenuItem("Import from current image..."); miImportFromImage.setAccelerator( new KeyCodeCombination(KeyCode.I, KeyCombination.SHORTCUT_DOWN, KeyCombination.SHIFT_DOWN)); miImportFromImage.setOnAction(e -> setTMAEntriesFromOpenImage()); MenuItem miImportFromProject = new MenuItem("Import from current project... (experimental)"); miImportFromProject.setAccelerator( new KeyCodeCombination(KeyCode.P, KeyCombination.SHORTCUT_DOWN, KeyCombination.SHIFT_DOWN)); miImportFromProject.setOnAction(e -> setTMAEntriesFromOpenProject()); MenuItem miImportClipboard = new MenuItem("Import from clipboard..."); miImportClipboard.setOnAction(e -> { String text = Clipboard.getSystemClipboard().getString(); if (text == null) { DisplayHelpers.showErrorMessage("Import scores", "Clipboard is empty!"); return; } int n = importScores(text); if (n > 0) { setTMAEntries(new ArrayList<>(entriesBase)); } DisplayHelpers.showMessageDialog("Import scores", "Number of scores imported: " + n); }); Menu menuEdit = new Menu("Edit"); MenuItem miCopy = new MenuItem("Copy table to clipboard"); miCopy.setOnAction(e -> { SummaryMeasurementTableCommand.copyTableContentsToClipboard(model, Collections.emptyList()); }); combinedPredicate.addListener((v, o, n) -> { // We want any other changes triggered by this to have happened, // so that the data has already been updated Platform.runLater(() -> handleTableContentChange()); }); // Reset the scores for missing cores - this ensures they will be NaN and not influence subsequent results MenuItem miResetMissingScores = new MenuItem("Reset scores for missing cores"); miResetMissingScores.setOnAction(e -> { int changes = 0; for (TMAEntry entry : entriesBase) { if (!entry.isMissing()) continue; boolean changed = false; for (String m : entry.getMeasurementNames().toArray(new String[0])) { if (!TMASummaryEntry.isSurvivalColumn(m) && !Double.isNaN(entry.getMeasurementAsDouble(m))) { entry.putMeasurement(m, null); changed = true; } } if (changed) changes++; } if (changes == 0) { logger.info("No changes made when resetting scores for missing cores!"); return; } logger.info("{} change(s) made when resetting scores for missing cores!", changes); table.refresh(); updateSurvivalCurves(); if (scatterPane != null) scatterPane.updateChart(); if (histogramDisplay != null) histogramDisplay.refreshHistogram(); }); menuEdit.getItems().add(miResetMissingScores); QuPathGUI.addMenuItems(menuFile, miOpen, miSave, null, miImportClipboard, null, miImportFromImage, miImportFromProject); menuBar.getMenus().add(menuFile); menuEdit.getItems().add(miCopy); menuBar.getMenus().add(menuEdit); menuFile.setOnShowing(e -> { boolean imageDataAvailable = QuPathGUI.getInstance() != null && QuPathGUI.getInstance().getImageData() != null && QuPathGUI.getInstance().getImageData().getHierarchy().getTMAGrid() != null; miImportFromImage.setDisable(!imageDataAvailable); boolean projectAvailable = QuPathGUI.getInstance() != null && QuPathGUI.getInstance().getProject() != null && !QuPathGUI.getInstance().getProject().getImageList().isEmpty(); miImportFromProject.setDisable(!projectAvailable); }); // Double-clicking previously used for comments... but conflicts with tree table expansion // table.setOnMouseClicked(e -> { // if (!e.isPopupTrigger() && e.getClickCount() > 1) // promptForComment(); // }); table.setPlaceholder(new Text("Drag TMA data folder onto window, or choose File -> Open")); table.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE); BorderPane pane = new BorderPane(); pane.setTop(menuBar); menuBar.setUseSystemMenuBar(true); // Create options ToolBar toolbar = new ToolBar(); Label labelMeasurementMethod = new Label("Combination method"); labelMeasurementMethod.setLabelFor(comboMeasurementMethod); labelMeasurementMethod .setTooltip(new Tooltip("Method whereby measurements for multiple cores with the same " + TMACoreObject.KEY_UNIQUE_ID + " will be combined")); CheckBox cbHidePane = new CheckBox("Hide pane"); cbHidePane.setSelected(hidePaneProperty.get()); cbHidePane.selectedProperty().bindBidirectional(hidePaneProperty); CheckBox cbGroupByID = new CheckBox("Group by ID"); entriesBase.addListener((Change<? extends TMAEntry> event) -> { if (!event.getList().stream().anyMatch(e -> e.getMetadataValue(TMACoreObject.KEY_UNIQUE_ID) != null)) { cbGroupByID.setSelected(false); cbGroupByID.setDisable(true); } else { cbGroupByID.setDisable(false); } }); cbGroupByID.setSelected(groupByIDProperty.get()); cbGroupByID.selectedProperty().bindBidirectional(groupByIDProperty); CheckBox cbUseSelected = new CheckBox("Use selection only"); cbUseSelected.selectedProperty().bindBidirectional(useSelectedProperty); CheckBox cbSkipMissing = new CheckBox("Hide missing cores"); cbSkipMissing.selectedProperty().bindBidirectional(skipMissingCoresProperty); skipMissingCoresProperty.addListener((v, o, n) -> { table.refresh(); updateSurvivalCurves(); if (histogramDisplay != null) histogramDisplay.refreshHistogram(); updateSurvivalCurves(); if (scatterPane != null) scatterPane.updateChart(); }); toolbar.getItems().addAll(labelMeasurementMethod, comboMeasurementMethod, new Separator(Orientation.VERTICAL), cbHidePane, new Separator(Orientation.VERTICAL), cbGroupByID, new Separator(Orientation.VERTICAL), cbUseSelected, new Separator(Orientation.VERTICAL), cbSkipMissing); comboMeasurementMethod.getItems().addAll(MeasurementCombinationMethod.values()); comboMeasurementMethod.getSelectionModel().select(MeasurementCombinationMethod.MEDIAN); selectedMeasurementCombinationProperty.addListener((v, o, n) -> table.refresh()); ContextMenu popup = new ContextMenu(); MenuItem miSetMissing = new MenuItem("Set missing"); miSetMissing.setOnAction(e -> setSelectedMissingStatus(true)); MenuItem miSetAvailable = new MenuItem("Set available"); miSetAvailable.setOnAction(e -> setSelectedMissingStatus(false)); MenuItem miExpand = new MenuItem("Expand all"); miExpand.setOnAction(e -> { if (table.getRoot() == null) return; for (TreeItem<?> item : table.getRoot().getChildren()) { item.setExpanded(true); } }); MenuItem miCollapse = new MenuItem("Collapse all"); miCollapse.setOnAction(e -> { if (table.getRoot() == null) return; for (TreeItem<?> item : table.getRoot().getChildren()) { item.setExpanded(false); } }); popup.getItems().addAll(miSetMissing, miSetAvailable, new SeparatorMenuItem(), miExpand, miCollapse); table.setContextMenu(popup); table.setRowFactory(e -> { TreeTableRow<TMAEntry> row = new TreeTableRow<>(); // // Make rows invisible if they don't pass the predicate // row.visibleProperty().bind(Bindings.createBooleanBinding(() -> { // TMAEntry entry = row.getItem(); // if (entry == null || (entry.isMissing() && skipMissingCoresProperty.get())) // return false; // return entries.getPredicate() == null || entries.getPredicate().test(entry); // }, // skipMissingCoresProperty, // entries.predicateProperty())); // Style rows according to what they contain row.styleProperty().bind(Bindings.createStringBinding(() -> { if (row.isSelected()) return ""; TMAEntry entry = row.getItem(); if (entry == null || entry instanceof TMASummaryEntry) return ""; else if (entry.isMissing()) return "-fx-background-color:rgb(225,225,232)"; else return "-fx-background-color:rgb(240,240,245)"; }, row.itemProperty(), row.selectedProperty())); // row.itemProperty().addListener((v, o, n) -> { // if (n == null || n instanceof TMASummaryEntry || row.isSelected()) // row.setStyle(""); // else if (n.isMissing()) // row.setStyle("-fx-background-color:rgb(225,225,232)"); // else // row.setStyle("-fx-background-color:rgb(240,240,245)"); // }); return row; }); BorderPane paneTable = new BorderPane(); paneTable.setTop(toolbar); paneTable.setCenter(table); MasterDetailPane mdTablePane = new MasterDetailPane(Side.RIGHT, paneTable, createSidePane(), true); mdTablePane.showDetailNodeProperty().bind(Bindings.createBooleanBinding( () -> !hidePaneProperty.get() && !entriesBase.isEmpty(), hidePaneProperty, entriesBase)); mdTablePane.setDividerPosition(2.0 / 3.0); pane.setCenter(mdTablePane); model.getEntries().addListener(new ListChangeListener<TMAEntry>() { @Override public void onChanged(ListChangeListener.Change<? extends TMAEntry> c) { if (histogramDisplay != null) histogramDisplay.refreshHistogram(); updateSurvivalCurves(); if (scatterPane != null) scatterPane.updateChart(); } }); Label labelPredicate = new Label(); labelPredicate.setPadding(new Insets(5, 5, 5, 5)); labelPredicate.setAlignment(Pos.CENTER); // labelPredicate.setStyle("-fx-background-color: rgba(20, 120, 20, 0.15);"); labelPredicate.setStyle("-fx-background-color: rgba(120, 20, 20, 0.15);"); labelPredicate.textProperty().addListener((v, o, n) -> { if (n.trim().length() > 0) pane.setBottom(labelPredicate); else pane.setBottom(null); }); labelPredicate.setMaxWidth(Double.MAX_VALUE); labelPredicate.setMaxHeight(labelPredicate.getPrefHeight()); labelPredicate.setTextAlignment(TextAlignment.CENTER); predicateMeasurements.addListener((v, o, n) -> { if (n == null) labelPredicate.setText(""); else if (n instanceof TablePredicate) { TablePredicate tp = (TablePredicate) n; if (tp.getOriginalCommand().trim().isEmpty()) labelPredicate.setText(""); else labelPredicate.setText("Predicate: " + tp.getOriginalCommand()); } else labelPredicate.setText("Predicate: " + n.toString()); }); // predicate.set(new TablePredicate("\"Tumor\" > 100")); scene = new Scene(pane); scene.addEventHandler(KeyEvent.KEY_PRESSED, e -> { KeyCode code = e.getCode(); if ((code == KeyCode.SPACE || code == KeyCode.ENTER) && entrySelected != null) { promptForComment(); return; } }); }
From source file:com.QuarkLabs.BTCeClientJavaFX.MainController.java
@FXML void initialize() { assert clearLogButton != null : "fx:id=\"clearLogButton\" was not injected: check your FXML file 'mainlayout.fxml'."; assert fundsTable != null : "fx:id=\"fundsTable\" was not injected: check your FXML file 'mainlayout.fxml'."; assert logField != null : "fx:id=\"logField\" was not injected: check your FXML file 'mainlayout.fxml'."; assert buyButton != null : "fx:id=\"buyButton\" was not injected: check your FXML file 'mainlayout.fxml'."; assert sellButton != null : "fx:id=\"sellButton\" was not injected: check your FXML file 'mainlayout.fxml'."; assert showActiveOrdersButton != null : "fx:id=\"showActiveOrdersButton\" was not injected: check your FXML file 'mainlayout.fxml'."; assert tickersTableLastColumn != null : "fx:id=\"tickerTableLastColumn\" was not injected: check your FXML file 'mainlayout.fxml'."; assert tickersTablePairColumn != null : "fx:id=\"tickerTablePairColumn\" was not injected: check your FXML file 'mainlayout.fxml'."; assert tickersTable != null : "fx:id=\"tickersTable\" was not injected: check your FXML file 'mainlayout.fxml'."; assert tickersTableBuyColumn != null : "fx:id=\"tickersTableBuyColumn\" was not injected: check your FXML file 'mainlayout.fxml'."; assert tickersTableFeeColumn != null : "fx:id=\"tickersTableFeeColumn\" was not injected: check your FXML file 'mainlayout.fxml'."; assert tickersTableSellColumn != null : "fx:id=\"tickersTableSellColumn\" was not injected: check your FXML file 'mainlayout.fxml'."; assert tradeAmountValue != null : "fx:id=\"tradeAmountValue\" was not injected: check your FXML file 'mainlayout.fxml'."; assert tradePriceCurrencyType != null : "fx:id=\"tradeCurrencyPriceValue\" was not injected: check your FXML file 'mainlayout.fxml'."; assert tradeCurrencyType != null : "fx:id=\"tradeCurrencyType\" was not injected: check your FXML file 'mainlayout.fxml'."; assert tradePriceValue != null : "fx:id=\"tradePriceValue\" was not injected: check your FXML file 'mainlayout.fxml'."; assert updateFundsButton != null : "fx:id=\"updateFundsButton\" was not injected: check your FXML file 'mainlayout.fxml'."; assert fundsTableCurrencyColumn != null : "fx:id=\"fundsTableCurrencyColumn\" was not injected: check your FXML file 'mainlayout.fxml'."; assert fundsTableValueColumn != null : "fx:id=\"fundsTableValueColumn\" was not injected: check your FXML file 'mainlayout.fxml'."; assert activeOrdersTable != null : "fx:id=\"fundsTableValueColumn\" was not injected: check your FXML file 'mainlayout.fxml'."; assert activeOrdersAmountColumn != null : "fx:id=\"activeOrdersAmountColumn\" was not injected: check your FXML file 'mainlayout.fxml'."; assert activeOrdersPairColumn != null : "fx:id=\"activeOrdersPairColumn\" was not injected: check your FXML file 'mainlayout.fxml'."; assert activeOrdersRateColumn != null : "fx:id=\"activeOrdersRateColumn\" was not injected: check your FXML file 'mainlayout.fxml'."; assert activeOrdersTimeColumn != null : "fx:id=\"activeOrdersTimeColumn\" was not injected: check your FXML file 'mainlayout.fxml'."; assert activeOrdersTypeColumn != null : "fx:id=\"activeOrdersTypeColumn\" was not injected: check your FXML file 'mainlayout.fxml'."; assert activeOrdersCancelColumn != null : "fx:id=\"activeOrdersCancelColumn\" was not injected: check your FXML file 'mainlayout.fxml'."; //Holder for all main API methods of exchange app = new App(); //Loading configs loadExchangeConfig();/*from www.j a v a 2 s. c o m*/ //Populate choiceboxes at the trading section tradeCurrencyType.setItems(FXCollections.observableArrayList(currencies)); tradeCurrencyType.setValue(currencies.get(0)); tradePriceCurrencyType.setItems(FXCollections.observableArrayList(currencies)); tradePriceCurrencyType.setValue(currencies.get(0)); //Active Orders table activeOrdersAmountColumn.setCellValueFactory(new PropertyValueFactory<ActiveOrder, Double>("amount")); activeOrdersPairColumn.setCellValueFactory(new PropertyValueFactory<ActiveOrder, String>("pair")); activeOrdersRateColumn.setCellValueFactory(new PropertyValueFactory<ActiveOrder, Double>("rate")); activeOrdersTimeColumn.setCellValueFactory( new Callback<TableColumn.CellDataFeatures<ActiveOrder, String>, ObservableValue<String>>() { @Override public ObservableValue<String> call( TableColumn.CellDataFeatures<ActiveOrder, String> activeOrderStringCellDataFeatures) { ActiveOrder activeOrder = activeOrderStringCellDataFeatures.getValue(); DateFormat dateFormat = DateFormat.getDateTimeInstance(); Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(activeOrder.getTimestamp() * 1000); return new SimpleStringProperty(dateFormat.format(calendar.getTime())); } }); activeOrdersTypeColumn.setCellValueFactory(new PropertyValueFactory<ActiveOrder, String>("type")); activeOrdersTable.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); activeOrdersCancelColumn .setCellFactory(new Callback<TableColumn<ActiveOrder, Boolean>, TableCell<ActiveOrder, Boolean>>() { @Override public TableCell<ActiveOrder, Boolean> call( TableColumn<ActiveOrder, Boolean> activeOrderBooleanTableColumn) { return new ButtonCell<>(activeOrdersTable); } }); activeOrdersCancelColumn.setCellValueFactory( new Callback<TableColumn.CellDataFeatures<ActiveOrder, Boolean>, ObservableValue<Boolean>>() { @Override public ObservableValue<Boolean> call( TableColumn.CellDataFeatures<ActiveOrder, Boolean> activeOrderBooleanCellDataFeatures) { return new SimpleBooleanProperty(true); } }); //Tickers Table MenuItem showOrdersBook = new MenuItem("Show Orders Book"); MenuItem showPublicTrades = new MenuItem("Show Public Trades"); ContextMenu contextMenu = new ContextMenu(showOrdersBook, showPublicTrades); tickersTable.setItems(tickers); tickersTable.setContextMenu(contextMenu); tickersTableBuyColumn.setCellValueFactory(new PropertyValueFactory<Ticker, Double>("buy")); tickersTableFeeColumn.setCellValueFactory(new PropertyValueFactory<Ticker, Double>("fee")); tickersTableSellColumn.setCellValueFactory(new PropertyValueFactory<Ticker, Double>("sell")); tickersTableLastColumn.setCellValueFactory(new PropertyValueFactory<Ticker, Double>("last")); tickersTablePairColumn.setCellValueFactory(new PropertyValueFactory<Ticker, String>("pair")); tickersTable.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); tickersTable.setRowFactory(new Callback<TableView<Ticker>, TableRow<Ticker>>() { @Override public TableRow<Ticker> call(TableView<Ticker> tickerTableView) { return new TableRow<Ticker>() { @Override protected void updateItem(Ticker ticker, boolean b) { super.updateItem(ticker, b); if (!b) { if (tickersData.containsKey(ticker.getPair())) { if (ticker.getLast() < tickersData.get(ticker.getPair()).getLast()) { setStyle("-fx-control-inner-background: rgba(186, 0, 0, 0.5);"); } else if (ticker.getLast() == tickersData.get(ticker.getPair()).getLast()) { setStyle("-fx-control-inner-background: rgba(215, 193, 44, 0.5);"); } else { setStyle("-fx-control-inner-background: rgba(0, 147, 0, 0.5);"); } } } } }; } }); //Menu item to show Orders Book showOrdersBook.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent actionEvent) { Ticker selectedTicker = tickersTable.getSelectionModel().getSelectedItem(); Parent root; try { FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource(PATH_TO_ORDERS_BOOK_LAYOUT), resources); root = (Parent) fxmlLoader.load(); OrdersBookController ordersBookController = fxmlLoader.getController(); ordersBookController.injectPair(selectedTicker.getPair()); Stage stage = new Stage(); stage.setTitle("Orders Book for " + selectedTicker.getPair().replace("_", "/").toUpperCase()); stage.setScene(new Scene(root)); stage.setResizable(false); stage.show(); } catch (IOException e) { e.printStackTrace(); } } }); //Menu item to show Public Trades showPublicTrades.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent actionEvent) { Ticker selectedTicker = tickersTable.getSelectionModel().getSelectedItem(); Parent root; try { FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource(PATH_TO_TRADES_LAYOUT), resources); root = (Parent) fxmlLoader.load(); PublicTradesController publicTradesController = fxmlLoader.getController(); publicTradesController.injectPair(selectedTicker.getPair()); Stage stage = new Stage(); stage.setTitle("Public Trades for " + selectedTicker.getPair().replace("_", "/").toUpperCase()); stage.setScene(new Scene(root)); stage.setResizable(false); stage.show(); } catch (IOException e) { e.printStackTrace(); } } }); //Funds Table fundsTableCurrencyColumn.setCellValueFactory(new PropertyValueFactory<Fund, String>("currency")); fundsTableValueColumn.setCellValueFactory(new PropertyValueFactory<Fund, Double>("value")); fundsTable.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); fundsTable.setItems(fundsData); //Task to load tickers data from server final javafx.concurrent.Service loadTickersService = new javafx.concurrent.Service() { @Override protected Task createTask() { Task<JSONObject> loadTickers = new Task<JSONObject>() { @Override protected JSONObject call() throws Exception { String[] pairsArray = new String[pairs.size()]; pairsArray = pairs.toArray(pairsArray); return App.getPairInfo(pairsArray); } }; loadTickers.setOnFailed(new EventHandler<WorkerStateEvent>() { @Override public void handle(WorkerStateEvent workerStateEvent) { logField.appendText(workerStateEvent.getSource().getException().getMessage() + "\r\n"); } }); loadTickers.setOnSucceeded(new EventHandler<WorkerStateEvent>() { @Override public void handle(WorkerStateEvent workerStateEvent) { JSONObject jsonObject = (JSONObject) workerStateEvent.getSource().getValue(); //ugly hack to store old values //dump old values to tickersData //TODO think about better solution if (tickers.size() != 0) { for (Ticker x : tickers) { tickersData.put(x.getPair(), x); } } tickers.clear(); for (Iterator iterator = jsonObject.keys(); iterator.hasNext();) { String key = (String) iterator.next(); JSONObject data = jsonObject.getJSONObject(key); Ticker ticker = new Ticker(); ticker.setPair(key); ticker.setUpdated(data.optLong("updated")); ticker.setAvg(data.optDouble("avg")); ticker.setBuy(data.optDouble("buy")); ticker.setSell(data.optDouble("sell")); ticker.setHigh(data.optDouble("high")); ticker.setLast(data.optDouble("last")); ticker.setLow(data.optDouble("low")); ticker.setVol(data.optDouble("vol")); ticker.setVolCur(data.optDouble("vol_cur")); tickers.add(ticker); } } }); return loadTickers; } }; //Update tickers every 15 seconds //TODO better solution is required Timeline timeline = new Timeline(new KeyFrame(Duration.ZERO, new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent actionEvent) { loadTickersService.restart(); } }), new KeyFrame(Duration.seconds(15))); timeline.setCycleCount(Timeline.INDEFINITE); timeline.playFromStart(); }
From source file:snpviewer.SnpViewer.java
private void drawSavedRegions(String chrom) { selectionOverlayPane.getChildren().clear(); if (savedRegions.isEmpty()) { selectionOverlayPane.getChildren().add(dragSelectRectangle); return;//from w w w .j ava 2 s . c o m } for (RegionSummary r : savedRegions) { if (r.getChromosome() == null) { selectionOverlayPane.getChildren().add(dragSelectRectangle); return; } if (r.getChromosome().equalsIgnoreCase(chrom)) { drawRegionSummary(r, chrom); } } int rectCounter = 0; for (final Rectangle rect : savedRegionsDisplay) { final int counter = rectCounter; 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(rect); } }); final MenuItem scmItem2 = new MenuItem("Write 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 * write SNPs in region to file */ writeRegionToFile(rect); } }); } }); final MenuItem scmItem3 = new MenuItem("Remove this Saved Region"); scmItem3.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { /* get coordinates of selection and * write SNPs in region to file */ removeSavedRegion(counter); } }); 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) { /* get coordinates of selection and report back * write SNPs in region to file */ zoomRegion(rect); } }); 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); rect.addEventHandler(MouseEvent.MOUSE_CLICKED, new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent e) { ocm.hide(); if (scm.isShowing()) { scm.hide(); } if (e.getButton() == MouseButton.SECONDARY) { if (chromosomeSelector.getSelectionModel().isEmpty()) { for (MenuItem mi : scm.getItems()) { mi.setDisable(true); } } else { for (MenuItem mi : scm.getItems()) { mi.setDisable(false); } } scm.show(selectionOverlayPane, e.getScreenX(), e.getScreenY()); } } }); rect.setVisible(true); selectionOverlayPane.getChildren().add(rect); rectCounter++; } selectionOverlayPane.getChildren().add(dragSelectRectangle); }
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);/* www .j a v a 2s. 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:editeurpanovisu.EditeurPanovisu.java
private void ajouteFichierHisto(String nomFich) { if (nombreHistoFichiers > 10) { nombreHistoFichiers = 10;/* ww w .j av a 2s . c om*/ } int trouve = -1; for (int i = 0; i < nombreHistoFichiers; i++) { if (histoFichiers[i].equals(nomFich)) { trouve = i; } } if (trouve == -1) { for (int i = nombreHistoFichiers; i >= 0; i--) { if (i < 9) { histoFichiers[i + 1] = histoFichiers[i]; } } histoFichiers[0] = nomFich; if (nombreHistoFichiers < 10) { nombreHistoFichiers++; } } else { for (int i = trouve - 1; i >= 0; i--) { if (i < 9) { histoFichiers[i + 1] = histoFichiers[i]; } } histoFichiers[0] = nomFich; } derniersProjets.getItems().clear(); for (int i = 0; i < nombreHistoFichiers; i++) { if (histoFichiers[i] != null) { MenuItem menuDerniersFichiers = new MenuItem(histoFichiers[i]); derniersProjets.getItems().add(menuDerniersFichiers); menuDerniersFichiers.setOnAction((ActionEvent e) -> { MenuItem mnu = (MenuItem) e.getSource(); try { try { projetChargeNom(mnu.getText()); } catch (InterruptedException ex) { Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex); } } catch (IOException ex) { Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex); } }); } } }
From source file:editeurpanovisu.EditeurPanovisu.java
/** * * @param primaryStage/* w w w . j av a 2s. com*/ * @param racine * @param taille * @throws Exception */ private void creeMenu(VBox racine, int taille) throws Exception { //Pane myPane = (Pane) FXMLLoader.load(getClass().getResource("menuPrincipal.fxml")); VBox myPane = new VBox(); myPane.setPrefHeight(80); myPane.setPrefWidth(3000); MenuBar menuPrincipal = new MenuBar(); menuPrincipal.setMinHeight(25); menuPrincipal.setPrefHeight(29); menuPrincipal.setPrefWidth(3000); /* Menu projets */ Menu menuProjet = new Menu(rb.getString("projets")); menuPrincipal.getMenus().add(menuProjet); nouveauProjet = new MenuItem(rb.getString("nouveauProjet")); nouveauProjet.setAccelerator(KeyCombination.keyCombination("Ctrl+N")); menuProjet.getItems().add(nouveauProjet); chargeProjet = new MenuItem(rb.getString("ouvrirProjet")); chargeProjet.setAccelerator(KeyCombination.keyCombination("Ctrl+O")); menuProjet.getItems().add(chargeProjet); sauveProjet = new MenuItem(rb.getString("sauverProjet")); sauveProjet.setDisable(true); sauveProjet.setAccelerator(KeyCombination.keyCombination("Ctrl+S")); menuProjet.getItems().add(sauveProjet); sauveSousProjet = new MenuItem(rb.getString("sauverProjetSous")); sauveSousProjet.setDisable(true); sauveSousProjet.setAccelerator(KeyCombination.keyCombination("Shift+Ctrl+S")); menuProjet.getItems().add(sauveSousProjet); derniersProjets = new Menu(rb.getString("derniersProjets")); // derniersProjets.setDisable(true); menuProjet.getItems().add(derniersProjets); fichHistoFichiers = new File(repertConfig.getAbsolutePath() + File.separator + "derniersprojets.cfg"); nombreHistoFichiers = 0; if (fichHistoFichiers.exists()) { FileReader fr; fr = new FileReader(fichHistoFichiers); try (BufferedReader br = new BufferedReader(fr)) { while ((texteHisto = br.readLine()) != null) { MenuItem menuDerniersFichiers = new MenuItem(texteHisto); derniersProjets.getItems().add(menuDerniersFichiers); histoFichiers[nombreHistoFichiers] = texteHisto; nombreHistoFichiers++; menuDerniersFichiers.setOnAction((ActionEvent e) -> { MenuItem mnu = (MenuItem) e.getSource(); try { try { projetChargeNom(mnu.getText()); } catch (InterruptedException ex) { Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex); } } catch (IOException ex) { Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex); } }); } } } SeparatorMenuItem sep1 = new SeparatorMenuItem(); menuProjet.getItems().add(sep1); fermerProjet = new MenuItem(rb.getString("quitterApplication")); fermerProjet.setAccelerator(KeyCombination.keyCombination("Ctrl+Q")); menuProjet.getItems().add(fermerProjet); /* Menu affichage */ Menu menuAffichage = new Menu(rb.getString("affichage")); menuPrincipal.getMenus().add(menuAffichage); affichageVisite = new MenuItem(rb.getString("main.creationVisite")); affichageVisite.setAccelerator(KeyCombination.keyCombination("Ctrl+1")); menuAffichage.getItems().add(affichageVisite); affichageInterface = new MenuItem(rb.getString("main.creationInterface")); affichageInterface.setAccelerator(KeyCombination.keyCombination("Ctrl+2")); menuAffichage.getItems().add(affichageInterface); affichagePlan = new MenuItem(rb.getString("main.tabPlan")); affichagePlan.setAccelerator(KeyCombination.keyCombination("Ctrl+3")); affichagePlan.setDisable(true); menuAffichage.getItems().add(affichagePlan); SeparatorMenuItem sep3 = new SeparatorMenuItem(); menuAffichage.getItems().add(sep3); configTransformation = new MenuItem(rb.getString("affichageConfiguration")); menuAffichage.getItems().add(configTransformation); /* Menu panoramiques */ menuPanoramique = new Menu(rb.getString("panoramiques")); menuPanoramique.setDisable(true); menuPrincipal.getMenus().add(menuPanoramique); ajouterPano = new MenuItem(rb.getString("ajouterPanoramiques")); ajouterPano.setAccelerator(KeyCombination.keyCombination("Ctrl+A")); menuPanoramique.getItems().add(ajouterPano); ajouterPlan = new MenuItem(rb.getString("ajouterPlan")); ajouterPlan.setAccelerator(KeyCombination.keyCombination("Ctrl+P")); menuPanoramique.getItems().add(ajouterPlan); ajouterPlan.setDisable(true); SeparatorMenuItem sep2 = new SeparatorMenuItem(); menuPanoramique.getItems().add(sep2); visiteGenere = new MenuItem(rb.getString("genererVisite")); visiteGenere.setDisable(true); visiteGenere.setAccelerator(KeyCombination.keyCombination("Ctrl+V")); menuPanoramique.getItems().add(visiteGenere); /* Menu Modles */ menuModeles = new Menu(rb.getString("menuModele")); menuPrincipal.getMenus().add(menuModeles); chargerModele = new MenuItem(rb.getString("modeleCharger")); menuModeles.getItems().add(chargerModele); sauverModele = new MenuItem(rb.getString("modeleSauver")); menuModeles.getItems().add(sauverModele); /* Menu transformations */ menuTransformation = new Menu(rb.getString("outils")); menuPrincipal.getMenus().add(menuTransformation); equi2CubeTransformation = new MenuItem(rb.getString("outilsEqui2Cube")); menuTransformation.getItems().add(equi2CubeTransformation); cube2EquiTransformation = new MenuItem(rb.getString("outilsCube2Equi")); menuTransformation.getItems().add(cube2EquiTransformation); /* Menu Aide */ Menu menuAide = new Menu(rb.getString("aide")); menuPrincipal.getMenus().add(menuAide); aide = new MenuItem(rb.getString("aideAide")); aide.setAccelerator(KeyCombination.keyCombination("Ctrl+H")); menuAide.getItems().add(aide); SeparatorMenuItem sep4 = new SeparatorMenuItem(); menuAide.getItems().add(sep4); aPropos = new MenuItem(rb.getString("aideAPropos")); menuAide.getItems().add(aPropos); /* barre de boutons */ HBox barreBouton = new HBox(); barreBouton.getStyleClass().add("menuBarreOutils1"); barreBouton.setPrefHeight(50); barreBouton.setMinHeight(50); barreBouton.setPrefWidth(3000); /* Bouton nouveau Projet */ ScrollPane spBtnNouvprojet = new ScrollPane(); spBtnNouvprojet.getStyleClass().add("menuBarreOutils"); spBtnNouvprojet.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER); spBtnNouvprojet.setPrefHeight(35); spBtnNouvprojet.setMaxHeight(35); spBtnNouvprojet.setPadding(new Insets(2)); spBtnNouvprojet.setPrefWidth(35); HBox.setMargin(spBtnNouvprojet, new Insets(5, 15, 0, 15)); imgNouveauProjet = new ImageView( new Image("file:" + repertAppli + File.separator + "images/nouveauProjet.png")); spBtnNouvprojet.setContent(imgNouveauProjet); Tooltip t0 = new Tooltip(rb.getString("nouveauProjet")); t0.setStyle(tooltipStyle); spBtnNouvprojet.setTooltip(t0); barreBouton.getChildren().add(spBtnNouvprojet); /* Bouton ouvrir Projet */ ScrollPane spBtnOuvrirProjet = new ScrollPane(); spBtnOuvrirProjet.getStyleClass().add("menuBarreOutils"); spBtnOuvrirProjet.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER); spBtnOuvrirProjet.setPrefHeight(35); spBtnOuvrirProjet.setMaxHeight(35); spBtnOuvrirProjet.setPadding(new Insets(2)); spBtnOuvrirProjet.setPrefWidth(35); HBox.setMargin(spBtnOuvrirProjet, new Insets(5, 15, 0, 0)); imgChargeProjet = new ImageView( new Image("file:" + repertAppli + File.separator + "images/ouvrirProjet.png")); spBtnOuvrirProjet.setContent(imgChargeProjet); Tooltip t1 = new Tooltip(rb.getString("ouvrirProjet")); t1.setStyle(tooltipStyle); spBtnOuvrirProjet.setTooltip(t1); barreBouton.getChildren().add(spBtnOuvrirProjet); /* Bouton sauve Projet */ ScrollPane spBtnSauveProjet = new ScrollPane(); spBtnSauveProjet.getStyleClass().add("menuBarreOutils"); spBtnSauveProjet.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER); spBtnSauveProjet.setPrefHeight(35); spBtnSauveProjet.setMaxHeight(35); spBtnSauveProjet.setPadding(new Insets(2)); spBtnSauveProjet.setPrefWidth(35); HBox.setMargin(spBtnSauveProjet, new Insets(5, 15, 0, 0)); imgSauveProjet = new ImageView( new Image("file:" + repertAppli + File.separator + "images/sauveProjet.png")); spBtnSauveProjet.setContent(imgSauveProjet); Tooltip t2 = new Tooltip(rb.getString("sauverProjet")); t2.setStyle(tooltipStyle); spBtnSauveProjet.setTooltip(t2); barreBouton.getChildren().add(spBtnSauveProjet); Separator sepImages = new Separator(Orientation.VERTICAL); sepImages.prefHeight(200); barreBouton.getChildren().add(sepImages); imgSauveProjet.setDisable(true); imgSauveProjet.setOpacity(0.3); /* Bouton Ajoute Panoramique */ ScrollPane spBtnAjoutePano = new ScrollPane(); spBtnAjoutePano.getStyleClass().add("menuBarreOutils"); spBtnAjoutePano.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER); spBtnAjoutePano.setPrefHeight(35); spBtnAjoutePano.setMaxHeight(35); spBtnAjoutePano.setPadding(new Insets(2)); spBtnAjoutePano.setPrefWidth(35); HBox.setMargin(spBtnAjoutePano, new Insets(5, 15, 0, 15)); imgAjouterPano = new ImageView( new Image("file:" + repertAppli + File.separator + "images/ajoutePanoramique.png")); spBtnAjoutePano.setContent(imgAjouterPano); Tooltip t3 = new Tooltip(rb.getString("ajouterPanoramiques")); t3.setStyle(tooltipStyle); spBtnAjoutePano.setTooltip(t3); barreBouton.getChildren().add(spBtnAjoutePano); imgAjouterPano.setDisable(true); imgAjouterPano.setOpacity(0.3); /* Bouton Ajoute Panoramique */ ScrollPane spBtnAjoutePlan = new ScrollPane(); spBtnAjoutePlan.getStyleClass().add("menuBarreOutils"); spBtnAjoutePlan.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER); spBtnAjoutePlan.setPrefHeight(35); spBtnAjoutePlan.setMaxHeight(35); spBtnAjoutePlan.setPadding(new Insets(2)); spBtnAjoutePlan.setPrefWidth(35); HBox.setMargin(spBtnAjoutePlan, new Insets(5, 15, 0, 15)); imgAjouterPlan = new ImageView(new Image("file:" + repertAppli + File.separator + "images/ajoutePlan.png")); spBtnAjoutePlan.setContent(imgAjouterPlan); Tooltip t31 = new Tooltip(rb.getString("ajouterPlan")); t31.setStyle(tooltipStyle); spBtnAjoutePlan.setTooltip(t31); barreBouton.getChildren().add(spBtnAjoutePlan); imgAjouterPlan.setDisable(true); imgAjouterPlan.setOpacity(0.3); /* Bouton Gnre */ ScrollPane spBtnGenereVisite = new ScrollPane(); spBtnGenereVisite.getStyleClass().add("menuBarreOutils"); spBtnGenereVisite.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER); spBtnGenereVisite.setPrefHeight(35); spBtnGenereVisite.setMaxHeight(35); spBtnGenereVisite.setPadding(new Insets(2)); spBtnGenereVisite.setPrefWidth(70); HBox.setMargin(spBtnGenereVisite, new Insets(5, 15, 0, 0)); imgVisiteGenere = new ImageView( new Image("file:" + repertAppli + File.separator + "images/genereVisite.png")); spBtnGenereVisite.setContent(imgVisiteGenere); Tooltip t4 = new Tooltip(rb.getString("genererVisite")); t4.setStyle(tooltipStyle); spBtnGenereVisite.setTooltip(t4); barreBouton.getChildren().add(spBtnGenereVisite); imgVisiteGenere.setDisable(true); imgVisiteGenere.setOpacity(0.3); Separator sepImages1 = new Separator(Orientation.VERTICAL); sepImages1.prefHeight(200); barreBouton.getChildren().add(sepImages1); /* Bouton equi -> faces de Cube */ ScrollPane spBtnEqui2Cube = new ScrollPane(); spBtnEqui2Cube.getStyleClass().add("menuBarreOutils"); spBtnEqui2Cube.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER); spBtnEqui2Cube.setPrefHeight(35); spBtnEqui2Cube.setMaxHeight(35); spBtnEqui2Cube.setPadding(new Insets(2)); spBtnEqui2Cube.setPrefWidth(109); HBox.setMargin(spBtnEqui2Cube, new Insets(5, 15, 0, 250)); imgEqui2Cube = new ImageView(new Image("file:" + repertAppli + File.separator + "images/equi2cube.png")); spBtnEqui2Cube.setContent(imgEqui2Cube); Tooltip t6 = new Tooltip(rb.getString("outilsEqui2Cube")); t6.setStyle(tooltipStyle); spBtnEqui2Cube.setTooltip(t6); barreBouton.getChildren().add(spBtnEqui2Cube); /* Bouton faces de cube -> equi */ ScrollPane spBtnCube2Equi = new ScrollPane(); spBtnCube2Equi.getStyleClass().add("menuBarreOutils"); spBtnCube2Equi.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER); spBtnCube2Equi.setPrefHeight(35); spBtnCube2Equi.setMaxHeight(35); spBtnCube2Equi.setPadding(new Insets(2)); spBtnCube2Equi.setPrefWidth(109); HBox.setMargin(spBtnCube2Equi, new Insets(5, 25, 0, 0)); imgCube2Equi = new ImageView(new Image("file:" + repertAppli + File.separator + "images/cube2equi.png")); spBtnCube2Equi.setContent(imgCube2Equi); Tooltip t5 = new Tooltip(rb.getString("outilsCube2Equi")); t5.setStyle(tooltipStyle); spBtnCube2Equi.setTooltip(t5); barreBouton.getChildren().add(spBtnCube2Equi); myPane.getChildren().addAll(menuPrincipal, barreBouton); racine.getChildren().add(myPane); nouveauProjet.setOnAction((ActionEvent e) -> { projetsNouveau(); }); chargeProjet.setOnAction((ActionEvent e) -> { try { try { projetCharge(); } catch (InterruptedException ex) { Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex); } } catch (IOException ex) { Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex); } }); sauveProjet.setOnAction((ActionEvent e) -> { try { projetSauve(); } catch (IOException ex) { Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex); } }); sauveSousProjet.setOnAction((ActionEvent e) -> { try { projetSauveSous(); } catch (IOException ex) { Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex); } }); visiteGenere.setOnAction((ActionEvent e) -> { try { genereVisite(); } catch (IOException ex) { Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex); } }); fermerProjet.setOnAction((ActionEvent e) -> { try { projetsFermer(); } catch (IOException ex) { Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex); } }); ajouterPano.setOnAction((ActionEvent e) -> { try { panoramiquesAjouter(); } catch (InterruptedException ex) { Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex); } }); ajouterPlan.setOnAction((ActionEvent e) -> { planAjouter(); }); aPropos.setOnAction((ActionEvent e) -> { aideapropos(); }); aide.setOnAction((ActionEvent e) -> { AideDialogController.affiche(); }); chargerModele.setOnAction((ActionEvent e) -> { try { modeleCharger(); } catch (IOException ex) { Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex); } }); sauverModele.setOnAction((ActionEvent e) -> { try { modeleSauver(); } catch (IOException ex) { Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex); } }); cube2EquiTransformation.setOnAction((ActionEvent e) -> { transformationCube2Equi(); }); equi2CubeTransformation.setOnAction((ActionEvent e) -> { transformationEqui2Cube(); }); affichageVisite.setOnAction((ActionEvent e) -> { tabPaneEnvironnement.getSelectionModel().select(0); }); affichageInterface.setOnAction((ActionEvent e) -> { tabPaneEnvironnement.getSelectionModel().select(1); }); affichagePlan.setOnAction((ActionEvent e) -> { if (!tabPlan.isDisabled()) { tabPaneEnvironnement.getSelectionModel().select(2); } }); configTransformation.setOnAction((ActionEvent e) -> { try { ConfigDialogController cfg = new ConfigDialogController(); cfg.afficheFenetre(); } catch (IOException ex) { Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex); } }); spBtnNouvprojet.setOnMouseClicked((MouseEvent t) -> { projetsNouveau(); }); spBtnOuvrirProjet.setOnMouseClicked((MouseEvent t) -> { try { try { projetCharge(); } catch (InterruptedException ex) { Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex); } } catch (IOException ex) { Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex); } }); spBtnSauveProjet.setOnMouseClicked((MouseEvent t) -> { try { projetSauve(); } catch (IOException ex) { Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex); } }); spBtnAjoutePano.setOnMouseClicked((MouseEvent t) -> { try { panoramiquesAjouter(); } catch (InterruptedException ex) { Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex); } }); spBtnAjoutePlan.setOnMouseClicked((MouseEvent t) -> { planAjouter(); }); spBtnGenereVisite.setOnMouseClicked((MouseEvent t) -> { try { genereVisite(); } catch (IOException ex) { Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex); } }); spBtnEqui2Cube.setOnMouseClicked((MouseEvent t) -> { transformationEqui2Cube(); }); spBtnCube2Equi.setOnMouseClicked((MouseEvent t) -> { transformationCube2Equi(); }); }
From source file:fr.amap.lidar.amapvox.gui.MainFrameController.java
private void addMenuItemPadValue(MenuItem menuItem, final float value) { menuItem.setOnAction(new EventHandler<ActionEvent>() { @Override/*from w ww . j a va 2 s . c o m*/ public void handle(ActionEvent event) { textFieldPADMax.setText(String.valueOf(value)); } }); }