List of usage examples for javafx.scene.input MouseEvent getButton
public final MouseButton getButton()
From source file:View.Visualize.java
private void addColorChangeOnSeries(XYChart.Series series) { final ContextMenu contextMenu = new ContextMenu(); MenuItem changeColor = new MenuItem("Change color"); MenuItem delete = new MenuItem("Standard color"); ColorPicker cp = new ColorPicker(); changeColor.setGraphic(cp);//from ww w .j av a 2 s.c o m contextMenu.getItems().addAll(changeColor, delete); Node d = series.getNode(); d.setOnMouseClicked(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent t) { if (t.getButton() == MouseButton.SECONDARY) { delete.setOnAction(new EventHandler() { public void handle(Event t) { if (series.getChart() instanceof StackedAreaChart) { series.getChart().lookup(".default-color" + series.getNode().getUserData() + ".chart-series-area-fill").setStyle(""); } if (series.getChart() instanceof LineChart) { series.getChart().lookup( ".default-color" + series.getNode().getUserData() + ".chart-series-line") .setStyle(""); } } }); cp.setValue(null); cp.setOnAction(new EventHandler() { public void handle(Event t) { String hex1 = "#" + Integer.toHexString(cp.getValue().hashCode()); if (series.getChart() instanceof StackedAreaChart) { series.getChart().lookup(".default-color" + series.getNode().getUserData() + ".chart-series-area-fill").setStyle("-fx-fill:" + hex1 + ";"); } if (series.getChart() instanceof LineChart) { series.getChart().lookup( ".default-color" + series.getNode().getUserData() + ".chart-series-line") .setStyle("-fx-stroke:" + hex1 + ";"); } } }); contextMenu.show(d, t.getScreenX(), t.getScreenY()); } } }); }
From source file:mesclasses.view.RootLayoutController.java
@Override public void initialize(URL location, ResourceBundle resources) { name = "Root Layout Ctrl"; super.initialize(location, resources); notificationPane.setManaged(false);/* ww w .j a v a 2s.c om*/ notificationPane.setVisible(false); notificationPane.setOnMouseClicked((MouseEvent mouseEvent) -> { if (mouseEvent.getButton().equals(MouseButton.PRIMARY)) { closeNotif(); } }); screenMap = new HashMap<>(); loadData(null); }
From source file:View.Visualize.java
public void getPieChartData(Integer nameColumn, Integer valueColumn, Table table, PieChart pieChart, Label lbl, Boolean newSeries, Boolean rowCounter) { data.clear();/*from w ww .j a v a 2 s . co m*/ if (!newSeries) { pieChart.getData().clear(); } addDataFromTable(table, nameColumn, valueColumn, rowCounter); data.entrySet().stream().map(entry -> new PieChart.Data(entry.getKey(), entry.getValue())) .forEach(pieChart.getData()::add); for (PieChart.Data d : pieChart.getData()) { //deretter legger vi animasjon p piecharten.. d.getNode().setOnMouseClicked(new mouseHooverAnimationPieChart.MouseHoverAnimation(d, pieChart)); final Node n = d.getNode(); Tooltip tooltip = new Tooltip(); String toolTipText = "Value : " + d.getPieValue(); tooltip.setText(toolTipText); Tooltip.install(n, tooltip); n.setOnMouseEntered(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent e) { n.setEffect(glow); } }); n.setOnMouseExited(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent e) { n.setEffect(null); } }); final ContextMenu contextMenu = new ContextMenu(); MenuItem changeColor = new MenuItem("Change Color"); MenuItem delete = new MenuItem("Standard color"); ColorPicker cp = new ColorPicker(); changeColor.setGraphic(cp); contextMenu.getItems().addAll(changeColor, delete); d.getNode().setOnMouseClicked(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent t) { if (t.getButton() == MouseButton.SECONDARY) { delete.setOnAction(new EventHandler() { public void handle(Event t) { d.getNode().setStyle(""); } }); cp.setValue(null); cp.setOnAction(new EventHandler() { public void handle(Event t) { String hex1 = "#" + Integer.toHexString(cp.getValue().hashCode()); d.getNode().setStyle("-fx-background-color: " + hex1 + ";"); } }); contextMenu.show(d.getNode(), t.getScreenX(), t.getScreenY()); } } }); } }
From source file:fr.amap.commons.javafx.chart.ChartViewer.java
public ChartViewer(String title, int width, int height, int maxChartNumberInARow) { stage = new Stage(); stage.setTitle(title);/*w w w .j a va 2 s .c o m*/ stage.setWidth(width); stage.setHeight(height); this.maxChartNumberInARow = maxChartNumberInARow; this.setContextMenu(createContextMenu()); vBoxPane = new VBox(); scrollPane = new ScrollPane(); scrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER); scrollPane.setVbarPolicy(ScrollPane.ScrollBarPolicy.NEVER); scrollPane.setFitToHeight(true); scrollPane.setFitToWidth(true); scrollPane.setPannable(true); scrollPane.setOnMouseClicked(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent event) { MouseButton button = event.getButton(); if (button == MouseButton.SECONDARY) { menu.show(stage, event.getScreenX(), event.getScreenY()); } } }); scrollPane.widthProperty().addListener(new ChangeListener<Number>() { @Override public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) { refreshChartPositionAndSize(); } }); scrollPane.heightProperty().addListener(new ChangeListener<Number>() { @Override public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) { refreshChartPositionAndSize(); } }); vBoxPane.getChildren().add(new HBox()); scrollPane.setContent(vBoxPane); chartCanvasList = new ArrayList<>(); stage.setScene(new Scene(scrollPane)); }
From source file:com.joliciel.talismane.terminology.viewer.TerminologyViewerController.java
@FXML protected void tblTerms_OnMouseClicked(MouseEvent mouseEvent) { if (mouseEvent.getButton().equals(MouseButton.PRIMARY)) { this.refreshContexts(); }//from ww w . ja v a 2 s .c om }
From source file:net.rptools.tokentool.controller.ManageOverlays_Controller.java
private void loadImages(File dir) { // Clear Details panel clearDetails();/*from w w w. j av a 2 s. com*/ currentDirectory = dir; File[] files = dir.listFiles(ImageUtil.SUPPORTED_FILENAME_FILTER); Task<Void> task = new Task<Void>() { @Override public Void call() { for (File file : files) { Path filePath = file.toPath(); if (loadOverlaysThread.isInterrupted()) { Platform.runLater(() -> overlayViewFlowPane.getChildren().clear()); break; } try { ToggleButton overlayButton = new ToggleButton(); ImageView imageViewNode = ImageUtil.getOverlayThumb(new ImageView(), filePath); overlayButton.getStyleClass().add("overlay-toggle-button"); overlayButton.setGraphic(imageViewNode); overlayButton.setUserData(file); overlayButton.setToggleGroup(overlayToggleGroup); overlayButton.addEventHandler(ActionEvent.ACTION, event -> { // No modifier keys used so add toggle group back to all buttons resetToggleGroup(); // Also set button to selected due to resetting toggle groups & no unselecting needed, makes for better interface IMO overlayButton.setSelected(true); // Update the Details panel with the last selected overlay File overlayFile = (File) overlayButton.getUserData(); updateDetails(overlayFile, (ImageView) overlayButton.getGraphic(), overlayButton.isSelected()); // Consume the event, no more logic needed event.consume(); }); overlayButton.setOnMouseClicked(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent event) { // Allow multiple selections if shortcutKey+left_mouse is pressed if (event.getButton().equals(MouseButton.PRIMARY) && event.isShortcutDown()) { // Update the Details panel with the last selected overlay File overlayFile = (File) overlayButton.getUserData(); updateDetails(overlayFile, (ImageView) overlayButton.getGraphic(), true); // Remove the toggle group to allow multiple toggle button selection overlayButton.setToggleGroup(null); // Select the button overlayButton.setSelected(true); // Consume the event, no more logic needed event.consume(); } } }); Platform.runLater(() -> overlayViewFlowPane.getChildren().add(overlayButton)); } catch (IOException e) { log.error("Loading image: " + filePath.getFileName(), e); } } return null; } }; loadOverlaysThread.interrupt(); executorService.execute(task); }
From source file:com.github.technosf.posterer.controllers.impl.RequestController.java
/** * {@inheritDoc}/*from w ww . j a v a2s. c o m*/ * * @see com.github.technosf.posterer.controllers.Controller#initialize() */ @Override public void initialize() { logger.debug("Initialization starts"); statusController = StatusController.loadController(statusWindow.textProperty()); certificateFileChooser.setRoot(getRoot()); certificateFileChooser.getChosenFileProperty().addListener(new ChangeListener<File>() { @Override public void changed(ObservableValue<? extends File> arg0, File oldValue, File newValue) { setCertificateFile(newValue); } }); propertiesTable.addEventFilter(MouseEvent.MOUSE_CLICKED, new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent event) { if (event.getClickCount() > 1 && event.getButton().ordinal() == 1) { loadRequest(propertiesTable.getSelectionModel().getSelectedItem()); } } }); propertiesTable.setItems(properties); endpointColumn.setCellValueFactory(new PropertyValueFactory<RequestData, String>("endpoint")); payloadColumn.setCellValueFactory(new PropertyValueFactory<RequestData, String>("payload")); methodColumn.setCellValueFactory(new PropertyValueFactory<RequestData, String>("method")); contentTypeColumn.setCellValueFactory(new PropertyValueFactory<RequestData, String>("contentType")); base64Column.setCellValueFactory(new PropertyValueFactory<RequestData, Boolean>("base64")); httpUserColumn.setCellValueFactory(new PropertyValueFactory<RequestData, String>("httpUser")); httpPasswordColumn.setCellValueFactory(new PropertyValueFactory<RequestData, String>("httpPassword")); processProperties(); /* * Bindings */ timeoutText.textProperty().bind(timeout.asString("%d")); timeout.bind(timeoutSlider.valueProperty()); useProxy.bindBidirectional(proxyToggle1.selectedProperty()); useProxy.bindBidirectional(proxyToggle2.selectedProperty()); useProxy.bindBidirectional(proxyToggle3.selectedProperty()); useProxy.bindBidirectional(proxyToggle4.selectedProperty()); useProxy.bindBidirectional(proxyToggle5.selectedProperty()); proxyToggle1.textProperty().bind(useProxyText); proxyToggle2.textProperty().bind(useProxyText); proxyToggle3.textProperty().bind(useProxyText); proxyToggle4.textProperty().bind(useProxyText); proxyToggle5.textProperty().bind(useProxyText); proxyportlabel.textFillProperty().bind(proxyhostlabel.textFillProperty()); proxyuserlabel.textFillProperty().bind(proxyhostlabel.textFillProperty()); proxypasswordlabel.textFillProperty().bind(proxyhostlabel.textFillProperty()); proxyhost.disableProperty().bind(useProxy.not()); proxyport.disableProperty().bind(useProxy.not()); proxyuser.disableProperty().bind(useProxy.not()); proxypassword.disableProperty().bind(useProxy.not()); /* * Preferences */ proxyhost.textProperty().set(requestModel.getProxyHost()); proxyport.textProperty().set(requestModel.getProxyPort()); proxyuser.textProperty().set(requestModel.getProxyUser()); proxypassword.textProperty().set(requestModel.getProxyPass()); try { homedir.textProperty().set(propertiesModel.getPropertiesDir()); } catch (IOException e) { store.setDisable(true); statusController.setStatus(INFO_PROPERTIES, e.getMessage()); } logger.debug("Initialization complete"); }
From source file:com.joliciel.talismane.terminology.viewer.TerminologyViewerController.java
@FXML protected void tblContexts_OnMouseClicked(MouseEvent mouseEvent) throws Exception { if (mouseEvent.getButton().equals(MouseButton.PRIMARY)) { if (mouseEvent.getClickCount() == 2) { if (editor != null && arguments != null) { Context context = tblContexts.getSelectionModel().getSelectedItem(); if (context != null) { String argumentString = arguments; argumentString = argumentString.replace("%file", context.getFileName()); argumentString = argumentString.replace("%line", "" + context.getLineNumber()); argumentString = argumentString.replace("%column", "" + context.getColumnNumber()); String command = "\"" + editor + "\"" + argumentString; LOG.debug(command);//from ww w.ja v a2 s.c o m Runtime.getRuntime().exec(command); } } } } }
From source file:be.makercafe.apps.makerbench.Main.java
/** * Creates the viewer control//from w ww .j a v a2 s . c om * * @return */ private TreeView<String> createViewer() { TreeView<String> viewer = new TreeView<String>(setRootFolder(new File(this.pathMakerbenchHome))); viewer.setMinWidth(200.0); viewer.getSelectionModel().setSelectionMode(SelectionMode.SINGLE); viewer.setOnMouseClicked(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent mouseEvent) { if (mouseEvent.getClickCount() == 2) { ResourceTreeItem<String> item = (ResourceTreeItem<String>) viewer.getSelectionModel() .getSelectedItem(); // System.out.println("Selected Text : " + item.getValue()); createEditor(item.getValue(), item.getPath(), null); } else if (mouseEvent.getButton() == MouseButton.SECONDARY) { ResourceTreeItem<String> item = (ResourceTreeItem<String>) viewer.getSelectionModel() .getSelectedItem(); if (item.getPath().toFile().isFile()) { viewer.getContextMenu().getItems().get(0).setDisable(true); viewer.getContextMenu().getItems().get(1).setDisable(true); viewer.getContextMenu().getItems().get(2).setDisable(true); } else { viewer.getContextMenu().getItems().get(0).setDisable(false); viewer.getContextMenu().getItems().get(1).setDisable(false); viewer.getContextMenu().getItems().get(2).setDisable(false); } } } }); viewer.setContextMenu(rootContextMenu); viewer.setEditable(false); viewer.setShowRoot(false); return viewer; }
From source file:com.exalttech.trex.ui.views.PacketTableView.java
/** * Handle table row click event/* w ww . j a va 2s. co m*/ * * @param event */ public void handleTableRowClick(MouseEvent event) { streamPacketTableView.setContextMenu(null); if (event.getClickCount() == 2 && streamPacketTableView.getSelectionModel().getSelectedItem() != null) { openStreamDialog(StreamBuilderType.EDIT_STREAM); } else if (event.getButton() == MouseButton.SECONDARY && streamPacketTableView.getSelectionModel().getSelectedItem() != null) { streamPacketTableView.setContextMenu(rightClickMenu); } }