List of usage examples for javafx.scene.input MouseEvent getScreenX
public final double getScreenX()
From source file:de.pixida.logtest.designer.automaton.Graph.java
public void onMouseClicked(final BaseObject baseObject, final MouseEvent event) { Validate.notNull(baseObject);//w w w .j a v a2 s.c o m this.contextMenu.hide(); if (event.getButton() == MouseButton.PRIMARY) { if (this.connectorSourceNode != null) { Validate.notNull(this.connector); if (baseObject == this.currentConnectorTargetNode) { this.connector.attach(this.connectorSourceNode, this.currentConnectorTargetNode); this.connector = null; this.connectorSourceNode = null; this.currentConnectorTargetNode = null; this.handleChange(); } } event.consume(); } else if (event.getButton() == MouseButton.SECONDARY) { final ContextMenu objectContextMenu = baseObject.createContextMenu(); if (objectContextMenu != null) { Node contextMenuOwner = baseObject.getActionHandler(); if (contextMenuOwner == null) { contextMenuOwner = this.pane; } objectContextMenu.show(contextMenuOwner, event.getScreenX(), event.getScreenY()); event.consume(); } } }
From source file:com.virus.removal.javafxapplication.FXMLDocumentController.java
/** * @param event//from ww w. j a va 2 s . c o m */ @FXML private void mouseDrag(final MouseEvent event) { JavaFXApplication.primaryStage.setX(event.getScreenX() + xOffset); JavaFXApplication.primaryStage.setY(event.getScreenY() + yOffset); }
From source file:com.virus.removal.javafxapplication.FXMLDocumentController.java
/** * @param event/*from w w w .j a v a2 s . c om*/ */ @FXML private void mousePress(final MouseEvent event) { xOffset = (int) (JavaFXApplication.primaryStage.getX() - event.getScreenX()); yOffset = (int) (JavaFXApplication.primaryStage.getY() - event.getScreenY()); }
From source file:view.EditorView.java
@FXML void scrollPaneOnMouseEntered(MouseEvent event) { isMouseOverDrawing = true;//ww w .j a va 2 s . com currentMouseX = event.getScreenX(); currentMouseY = event.getScreenY(); if (this.getCurrentEditMode() == EditMode.INSERT_ROOM) { initInsertRoomEditMode(); } }
From source file:view.EditorView.java
@FXML void scrollPaneOnMouseMoved(MouseEvent event) { currentMouseX = event.getScreenX(); currentMouseY = event.getScreenY();/*from w w w. j a v a 2s . c om*/ if (currentEditMode == EditMode.INSERT_ROOM) { insertRoomUpdateTempRoomPosition(); } // Fade compassIcon if (event.getX() >= compassImage.getLayoutX() && event.getX() <= (compassImage.getLayoutX() + compassImage.getFitWidth()) && event.getY() >= compassImage.getLayoutY() && event.getY() <= (compassImage.getLayoutY() + compassImage.getFitHeight()) && !compassIconFaded) { // fade out compassIconFaded = true; compassImageFadeOut(); } if ((event.getX() < compassImage.getLayoutX() || event.getX() > (compassImage.getLayoutX() + compassImage.getFitWidth()) || event.getY() < compassImage.getLayoutY() || event.getY() > (compassImage.getLayoutY() + compassImage.getFitHeight())) && compassIconFaded) { // fade in compassIconFaded = false; compassImageFadeIn(); } }
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 ww w.j ava2s. com 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:View.Visualize.java
private void addColorChangeOnIndividual(ObservableList<XYChart.Data> data) { final ContextMenu contextMenu = new ContextMenu(); MenuItem changeColor = new MenuItem("Change Color"); MenuItem delete = new MenuItem("Standard color"); ColorPicker cp = new ColorPicker(); changeColor.setGraphic(cp);// w w w . j a va 2 s. com contextMenu.getItems().addAll(changeColor, delete); for (XYChart.Data d : data) { 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: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);// w w w . jav a 2s . 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()); } } }); }