List of usage examples for javafx.scene.input MouseEvent consume
public void consume()
From source file:com.rockhoppertech.symchords.fx.SymChordsController.java
protected void setupDragonDrop() { Image image = new Image(getClass().getResourceAsStream("/images/rocky-32-trans.png")); dragImageView = new ImageView(image); dragImageView.setFitHeight(32);/* w w w. jav a2 s. co m*/ dragImageView.setFitWidth(32); grandStaff.setOnDragDetected(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent me) { if (!root.getChildren().contains(dragImageView)) { root.getChildren().add(dragImageView); } // dragImageView.setOpacity(0.5); dragImageView.toFront(); dragImageView.setMouseTransparent(true); dragImageView.setVisible(true); dragImageView.relocate((int) (me.getSceneX() - dragImageView.getBoundsInLocal().getWidth() / 2), (int) (me.getSceneY() - dragImageView.getBoundsInLocal().getHeight() / 2)); Dragboard db = grandStaff.startDragAndDrop(TransferMode.ANY); // TODO remove the custom image nonsense in javafx 8 // javafx 8 // db.setDragView(dragImageView); ClipboardContent content = new ClipboardContent(); // MIDITrack track = grandStaff.getMIDITrack(); MIDITrack track = model.getMIDITrack(); content.put(midiTrackDataFormat, track); db.setContent(content); me.consume(); } }); grandStaff.setOnDragDone(new EventHandler<DragEvent>() { public void handle(DragEvent e) { dragImageView.setVisible(false); e.consume(); } }); // Parent root = grandStaff.getScene().getRoot(); // stage.getScene().getRoot(); if (root != null) { root.setOnDragOver(new EventHandler<DragEvent>() { public void handle(DragEvent e) { Point2D localPoint = grandStaff.getScene().getRoot() .sceneToLocal(new Point2D(e.getSceneX(), e.getSceneY())); dragImageView.relocate( (int) (localPoint.getX() - dragImageView.getBoundsInLocal().getWidth() / 2), (int) (localPoint.getY() - dragImageView.getBoundsInLocal().getHeight() / 2)); e.consume(); } }); } trackList.setOnDragOver(new EventHandler<DragEvent>() { public void handle(DragEvent event) { /* * data is dragged over the target; accept it only if it is not * dragged from the same node and if it has MIDITrack data */ if (event.getGestureSource() != trackList && event.getDragboard().hasContent(midiTrackDataFormat)) { logger.debug("drag over"); /* allow for both copying and moving, whatever user chooses */ event.acceptTransferModes(TransferMode.COPY_OR_MOVE); } // Don't consume the event. Let the layers below process the // DragOver event as well so that the // translucent container image will follow the cursor. // event.consume(); } }); trackList.setOnDragEntered(new EventHandler<DragEvent>() { public void handle(DragEvent event) { /* the drag-and-drop gesture entered the target */ /* show to the user that it is an actual gesture target */ logger.debug("drag entered"); if (event.getGestureSource() != trackList && event.getDragboard().hasContent(midiTrackDataFormat)) { DropShadow dropShadow = new DropShadow(); dropShadow.setRadius(5.0); dropShadow.setOffsetX(3.0); dropShadow.setOffsetY(3.0); dropShadow.setColor(Color.color(0.4, 0.5, 0.5)); trackList.setEffect(dropShadow); } event.consume(); } }); trackList.setOnDragExited(new EventHandler<DragEvent>() { public void handle(DragEvent event) { /* mouse moved away, remove the graphical cues */ trackList.setEffect(null); event.consume(); } }); trackList.setOnDragDropped(new EventHandler<DragEvent>() { public void handle(DragEvent event) { Dragboard db = event.getDragboard(); boolean success = false; if (db.hasContent(midiTrackDataFormat)) { MIDITrack track = (MIDITrack) db.getContent(midiTrackDataFormat); trackList.getItems().add(track); success = true; } /* * let the source know whether the data was successfully * transferred and used */ event.setDropCompleted(success); event.consume(); } }); logger.debug("jvm mime {}", DataFlavor.javaJVMLocalObjectMimeType); }
From source file:editeurpanovisu.EditeurPanovisu.java
private void afficheNord(double longitude) { double largeur = imagePanoramique.getFitWidth(); double X = (longitude + 180.0d) * largeur / 360.0d + imagePanoramique.getLayoutX(); Node ancPoV = (Node) pano.lookup("#Nord"); if (ancPoV != null) { pano.getChildren().remove(ancPoV); }// w w w . j a v a 2 s. c o m Line ligne = new Line(0, 0, 0, imagePanoramique.getFitHeight()); ligne.setCursor(Cursor.DEFAULT); ligne.setLayoutX(X); ligne.setStroke(Color.RED); ligne.setStrokeWidth(4); ligne.setId("Nord"); ligne.setOnDragDetected((MouseEvent me1) -> { ligne.setStroke(Color.BLUEVIOLET); dragDrop = true; me1.consume(); }); ligne.setOnMouseDragged((MouseEvent me1) -> { double XX = me1.getSceneX() - imagePanoramique.getLayoutX(); if (XX < 0) { XX = 0; } if (XX > imagePanoramique.getFitWidth()) { XX = imagePanoramique.getFitWidth(); } ligne.setLayoutX(XX + imagePanoramique.getLayoutX()); me1.consume(); }); ligne.setOnMouseReleased((MouseEvent me1) -> { double X1 = me1.getSceneX(); double mouseX1 = X1 - imagePanoramique.getLayoutX(); if (mouseX1 < 0) { mouseX1 = 0; } if (mouseX1 > imagePanoramique.getFitWidth()) { mouseX1 = imagePanoramique.getFitWidth(); } double regardX = 360.0f * mouseX1 / largeur - 180; panoramiquesProjet[panoActuel].setZeroNord(regardX); ligne.setStroke(Color.RED); me1.consume(); }); pano.getChildren().add(ligne); }
From source file:editeurpanovisu.EditeurPanovisu.java
private void affichePoV(double longitude, double latitude) { double largeur = imagePanoramique.getFitWidth(); double X = (longitude + 180.0d) * largeur / 360.0d + imagePanoramique.getLayoutX(); double Y = (90.0d - latitude) * largeur / 360.0d; Node ancPoV = (Node) pano.lookup("#PoV"); if (ancPoV != null) { pano.getChildren().remove(ancPoV); }//w ww . jav a 2 s . c om Polygon polygon = new Polygon(); polygon.getPoints().addAll(new Double[] { 20.0, 2.0, 2.0, 2.0, 2.0, 20.0, -2.0, 20.0, -2.0, 2.0, -20.0, 2.0, -20.0, -2.0, -2.0, -2.0, -2.0, -20.0, 2.0, -20.0, 2.0, -2.0, 20.0, -2.0 }); polygon.setStrokeLineJoin(StrokeLineJoin.MITER); polygon.setFill(Color.BLUEVIOLET); polygon.setStroke(Color.YELLOW); polygon.setId("PoV"); polygon.setLayoutX(X); polygon.setLayoutY(Y); polygon.setCursor(Cursor.DEFAULT); polygon.setOnDragDetected((MouseEvent me1) -> { polygon.setFill(Color.YELLOW); polygon.setStroke(Color.BLUEVIOLET); dragDrop = true; me1.consume(); }); polygon.setOnMouseDragged((MouseEvent me1) -> { double XX = me1.getSceneX() - imagePanoramique.getLayoutX(); if (XX < 0) { XX = 0; } if (XX > imagePanoramique.getFitWidth()) { XX = imagePanoramique.getFitWidth(); } polygon.setLayoutX(XX + imagePanoramique.getLayoutX()); double YY = me1.getSceneY() - pano.getLayoutY() - 109; if (YY < 0) { YY = 0; } if (YY > imagePanoramique.getFitHeight()) { YY = imagePanoramique.getFitHeight(); } polygon.setLayoutY(YY); me1.consume(); }); polygon.setOnMouseReleased((MouseEvent me1) -> { double X1 = me1.getSceneX(); double Y1 = me1.getSceneY(); double mouseX1 = X1 - imagePanoramique.getLayoutX(); if (mouseX1 < 0) { mouseX1 = 0; } if (mouseX1 > imagePanoramique.getFitWidth()) { mouseX1 = imagePanoramique.getFitWidth(); } double mouseY1 = Y1 - pano.getLayoutY() - 109; if (mouseY1 < 0) { mouseY1 = 0; } if (mouseY1 > imagePanoramique.getFitHeight()) { mouseY1 = imagePanoramique.getFitHeight(); } double regardX = 360.0f * mouseX1 / largeur - 180; double regardY = 90.0d - 2.0f * mouseY1 / largeur * 180.0f; panoramiquesProjet[panoActuel].setLookAtX(regardX); panoramiquesProjet[panoActuel].setLookAtY(regardY); polygon.setFill(Color.BLUEVIOLET); polygon.setStroke(Color.YELLOW); me1.consume(); }); pano.getChildren().add(polygon); }
From source file:editeurpanovisu.EditeurPanovisu.java
private void gereSourisPanoramique(MouseEvent me) { if (me.getButton() == MouseButton.SECONDARY) { if (me.isShiftDown()) { panoChoixNord(me.getSceneX() - imagePanoramique.getLayoutX()); me.consume(); } else if (me.isControlDown()) { } else {/* ww w. j av a2 s.c om*/ panoChoixRegard(me.getSceneX() - imagePanoramique.getLayoutX(), me.getSceneY()); me.consume(); } } if (me.getButton() == MouseButton.PRIMARY) { if (me.isShiftDown()) { if (!me.isControlDown()) { if (!dragDrop) { panoAjouteImage(me.getSceneX() - imagePanoramique.getLayoutX(), me.getSceneY()); } else { dragDrop = false; } } else { } } else if (!(me.isControlDown()) && estCharge) { if (!dragDrop) { panoMouseClic(me.getSceneX() - imagePanoramique.getLayoutX(), me.getSceneY()); } else { dragDrop = false; } } } }
From source file:editeurpanovisu.EditeurPanovisu.java
/** * * @param i//w w w. j ava 2s .com * @param longitude * @param latitude */ private void afficheHSImage(int i, double longitude, double latitude) { double largeur = imagePanoramique.getFitWidth(); double X = (longitude + 180.0d) * largeur / 360.0d + imagePanoramique.getLayoutX(); double Y = (90.0d - latitude) * largeur / 360.0d; Circle point = new Circle(X, Y, 5); point.setFill(Color.BLUE); point.setStroke(Color.YELLOW); point.setId("img" + i); point.setCursor(Cursor.DEFAULT); pano.getChildren().add(point); Tooltip t = new Tooltip("image n " + (i + 1)); t.setStyle(tooltipStyle); Tooltip.install(point, t); point.setOnDragDetected((MouseEvent me1) -> { point.setFill(Color.YELLOW); point.setStroke(Color.BLUE); dragDrop = true; me1.consume(); }); point.setOnMouseDragged((MouseEvent me1) -> { double XX = me1.getX() - imagePanoramique.getLayoutX(); if (XX < 0) { XX = 0; } if (XX > imagePanoramique.getFitWidth()) { XX = imagePanoramique.getFitWidth(); } point.setCenterX(XX + imagePanoramique.getLayoutX()); double YY = me1.getY(); if (YY < 0) { YY = 0; } if (YY > imagePanoramique.getFitHeight()) { YY = imagePanoramique.getFitHeight(); } point.setCenterY(YY); me1.consume(); }); point.setOnMouseReleased((MouseEvent me1) -> { String chPoint = point.getId(); chPoint = chPoint.substring(3, chPoint.length()); int numeroPoint = Integer.parseInt(chPoint); double X1 = me1.getSceneX(); double Y1 = me1.getSceneY(); double mouseX = X1 - imagePanoramique.getLayoutX(); if (mouseX < 0) { mouseX = 0; } if (mouseX > imagePanoramique.getFitWidth()) { mouseX = imagePanoramique.getFitWidth(); } double mouseY = Y1 - pano.getLayoutY() - 109; if (mouseY < 0) { mouseY = 0; } if (mouseY > imagePanoramique.getFitHeight()) { mouseY = imagePanoramique.getFitHeight(); } double longit, lat; double larg = imagePanoramique.getFitWidth(); String chLong, chLat; longit = 360.0f * mouseX / larg - 180; lat = 90.0d - 2.0f * mouseY / larg * 180.0f; panoramiquesProjet[panoActuel].getHotspotImage(numeroPoint).setLatitude(lat); panoramiquesProjet[panoActuel].getHotspotImage(numeroPoint).setLongitude(longit); point.setFill(Color.BLUE); point.setStroke(Color.YELLOW); me1.consume(); }); point.setOnMouseClicked((MouseEvent me1) -> { String chPoint = point.getId(); chPoint = chPoint.substring(3, chPoint.length()); int numeroPoint = Integer.parseInt(chPoint); Node pt; pt = (Node) pano.lookup("#img" + chPoint); if (me1.isControlDown()) { valideHS(); dejaSauve = false; stPrincipal.setTitle(stPrincipal.getTitle().replace(" *", "") + " *"); pano.getChildren().remove(pt); for (int o = numeroPoint + 1; o < numImages; o++) { pt = (Node) pano.lookup("#img" + Integer.toString(o)); pt.setId("img" + Integer.toString(o - 1)); } /** * on retire les anciennes indication de HS */ retireAffichageHotSpots(); numImages--; panoramiquesProjet[panoActuel].removeHotspotImage(numeroPoint); /** * On les cre les nouvelles */ ajouteAffichageHotspots(); me1.consume(); } else { me1.consume(); } }); }
From source file:editeurpanovisu.EditeurPanovisu.java
/** * * @param i/*from ww w. j a v a2 s.c o m*/ * @param longitude * @param latitude */ private void afficheHS(int i, double longitude, double latitude) { double largeur = imagePanoramique.getFitWidth(); double X = (longitude + 180.0d) * largeur / 360.0d + imagePanoramique.getLayoutX(); double Y = (90.0d - latitude) * largeur / 360.0d; Circle point = new Circle(X, Y, 5); point.setFill(Color.YELLOW); point.setStroke(Color.RED); point.setId("point" + i); point.setCursor(Cursor.DEFAULT); pano.getChildren().add(point); Tooltip t = new Tooltip("point n " + (i + 1)); t.setStyle(tooltipStyle); Tooltip.install(point, t); point.setOnDragDetected((MouseEvent me1) -> { point.setFill(Color.RED); point.setStroke(Color.YELLOW); dragDrop = true; me1.consume(); }); point.setOnMouseDragged((MouseEvent me1) -> { double XX = me1.getX() - imagePanoramique.getLayoutX(); if (XX < 0) { XX = 0; } if (XX > imagePanoramique.getFitWidth()) { XX = imagePanoramique.getFitWidth(); } point.setCenterX(XX + imagePanoramique.getLayoutX()); double YY = me1.getY(); if (YY < 0) { YY = 0; } if (YY > imagePanoramique.getFitHeight()) { YY = imagePanoramique.getFitHeight(); } point.setCenterY(YY); me1.consume(); }); point.setOnMouseReleased((MouseEvent me1) -> { String chPoint = point.getId(); chPoint = chPoint.substring(5, chPoint.length()); int numeroPoint = Integer.parseInt(chPoint); double X1 = me1.getSceneX(); double Y1 = me1.getSceneY(); double mouseX = X1 - imagePanoramique.getLayoutX(); if (mouseX < 0) { mouseX = 0; } if (mouseX > imagePanoramique.getFitWidth()) { mouseX = imagePanoramique.getFitWidth(); } double mouseY = Y1 - pano.getLayoutY() - 109; if (mouseY < 0) { mouseY = 0; } if (mouseY > imagePanoramique.getFitHeight()) { mouseY = imagePanoramique.getFitHeight(); } double longit, lat; double larg = imagePanoramique.getFitWidth(); String chLong, chLat; longit = 360.0f * mouseX / larg - 180; lat = 90.0d - 2.0f * mouseY / larg * 180.0f; panoramiquesProjet[panoActuel].getHotspot(numeroPoint).setLatitude(lat); panoramiquesProjet[panoActuel].getHotspot(numeroPoint).setLongitude(longit); point.setFill(Color.YELLOW); point.setStroke(Color.RED); me1.consume(); }); point.setOnMouseClicked((MouseEvent me1) -> { double mouseX = me1.getSceneX() - imagePanoramique.getLayoutX(); if (mouseX < 0) { mouseX = 0; } if (mouseX > imagePanoramique.getFitWidth()) { mouseX = imagePanoramique.getFitWidth(); } double mouseY = me1.getSceneY() - pano.getLayoutY() - 115; if (mouseY < 0) { mouseY = 0; } if (mouseY > imagePanoramique.getFitHeight()) { mouseY = imagePanoramique.getFitHeight(); } String chPoint = point.getId(); chPoint = chPoint.substring(5, chPoint.length()); int numeroPoint = Integer.parseInt(chPoint); Node pt; pt = (Node) pano.lookup("#point" + chPoint); if (me1.isControlDown()) { dejaSauve = false; stPrincipal.setTitle(stPrincipal.getTitle().replace(" *", "") + " *"); pano.getChildren().remove(pt); for (int o = numeroPoint + 1; o < numPoints; o++) { pt = (Node) pano.lookup("#point" + Integer.toString(o)); pt.setId("point" + Integer.toString(o - 1)); } /** * on retire les anciennes indication de HS */ retireAffichageHotSpots(); numPoints--; panoramiquesProjet[panoActuel].removeHotspot(numeroPoint); /** * On les cre les nouvelles */ ajouteAffichageHotspots(); me1.consume(); valideHS(); } else { if (!dragDrop) { if (nombrePanoramiques > 1) { AnchorPane listePanoVig = afficherListePanosVignettes(numeroPoint); int largeurVignettes = 4; if (nombrePanoramiques < 4) { largeurVignettes = nombrePanoramiques; } if (mouseX + largeurVignettes * 130 > pano.getWidth()) { listePanoVig.setLayoutX(pano.getWidth() - largeurVignettes * 130); } else { listePanoVig.setLayoutX(mouseX); } listePanoVig.setLayoutY(mouseY); pano.getChildren().add(listePanoVig); } } else { dragDrop = false; } valideHS(); me1.consume(); } }); }
From source file:editeurpanovisu.EditeurPanovisu.java
private void panoAjouteImage(double X, double Y) { if (X > 0 && X < imagePanoramique.getFitWidth()) { valideHS();/*from www. ja v a2 s . com*/ dejaSauve = false; stPrincipal.setTitle(stPrincipal.getTitle().replace(" *", "") + " *"); double mouseX = X; double mouseY = Y - pano.getLayoutY() - 115; double longitude, latitude; double largeur = imagePanoramique.getFitWidth(); String chLong, chLat; longitude = 360.0f * mouseX / largeur - 180; latitude = 90.0d - 2.0f * mouseY / largeur * 180.0f; Circle point = new Circle(mouseX, mouseY, 5); point.setFill(Color.BLUE); point.setStroke(Color.YELLOW); point.setId("img" + numImages); point.setCursor(Cursor.DEFAULT); pano.getChildren().add(point); Tooltip t = new Tooltip("image n " + (numImages + 1)); t.setStyle(tooltipStyle); Tooltip.install(point, t); // File repert; if (repertHSImages.equals("")) { repert = new File(currentDir + File.separator); } else { repert = new File(repertHSImages); } FileChooser fileChooser = new FileChooser(); FileChooser.ExtensionFilter extFilterImages = new FileChooser.ExtensionFilter( "Fichiers Images (jpg, bmp, png)", "*.jpg", "*.bmp", "*.png"); fileChooser.setInitialDirectory(repert); fileChooser.getExtensionFilters().addAll(extFilterImages); File fichierImage = fileChooser.showOpenDialog(null); if (fichierImage != null) { repertHSImages = fichierImage.getParent(); numImages++; HotspotImage HS = new HotspotImage(); HS.setLongitude(longitude); HS.setLatitude(latitude); HS.setUrlImage(fichierImage.getAbsolutePath()); HS.setLienImg(fichierImage.getName()); HS.setInfo(fichierImage.getName().split("\\.")[0]); File repertImage = new File(repertTemp + File.separator + "images"); if (!repertImage.exists()) { repertImage.mkdirs(); } try { copieFichierRepertoire(fichierImage.getAbsolutePath(), repertImage.getAbsolutePath()); } catch (IOException ex) { Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex); } panoramiquesProjet[panoActuel].addHotspotImage(HS); retireAffichageHotSpots(); Pane affHS1 = affichageHS(listePano(panoActuel), panoActuel); affHS1.setId("labels"); outils.getChildren().add(affHS1); } else { String chPoint = point.getId(); chPoint = chPoint.substring(3, chPoint.length()); Node pt = (Node) pano.lookup("#img" + chPoint); pano.getChildren().remove(pt); } valideHS(); point.setOnDragDetected((MouseEvent me1) -> { point.setFill(Color.YELLOW); point.setStroke(Color.BLUE); dragDrop = true; me1.consume(); }); point.setOnMouseDragged((MouseEvent me1) -> { double XX = me1.getX() - imagePanoramique.getLayoutX(); if (XX < 0) { XX = 0; } if (XX > imagePanoramique.getFitWidth()) { XX = imagePanoramique.getFitWidth(); } point.setCenterX(XX + imagePanoramique.getLayoutX()); double YY = me1.getY(); if (YY < 0) { YY = 0; } if (YY > imagePanoramique.getFitHeight()) { YY = imagePanoramique.getFitHeight(); } point.setCenterY(YY); me1.consume(); }); point.setOnMouseReleased((MouseEvent me1) -> { String chPoint = point.getId(); chPoint = chPoint.substring(3, chPoint.length()); int numeroPoint = Integer.parseInt(chPoint); double X1 = me1.getSceneX(); double Y1 = me1.getSceneY(); double mouseX1 = X1 - imagePanoramique.getLayoutX(); if (mouseX1 < 0) { mouseX1 = 0; } if (mouseX1 > imagePanoramique.getFitWidth()) { mouseX1 = imagePanoramique.getFitWidth(); } double mouseY1 = Y1 - pano.getLayoutY() - 109; if (mouseY1 < 0) { mouseY1 = 0; } if (mouseY1 > imagePanoramique.getFitHeight()) { mouseY1 = imagePanoramique.getFitHeight(); } double longit, lat; double larg = imagePanoramique.getFitWidth(); longit = 360.0f * mouseX1 / larg - 180; lat = 90.0d - 2.0f * mouseY1 / larg * 180.0f; panoramiquesProjet[panoActuel].getHotspotImage(numeroPoint).setLatitude(lat); panoramiquesProjet[panoActuel].getHotspotImage(numeroPoint).setLongitude(longit); point.setFill(Color.BLUE); point.setStroke(Color.YELLOW); me1.consume(); }); point.setOnMouseClicked((MouseEvent me1) -> { if (me1.isControlDown()) { dejaSauve = false; stPrincipal.setTitle(stPrincipal.getTitle().replace(" *", "") + " *"); String chPoint = point.getId(); chPoint = chPoint.substring(3, chPoint.length()); int numeroPoint = Integer.parseInt(chPoint); Node pt; pt = (Node) pano.lookup("#img" + chPoint); pano.getChildren().remove(pt); for (int o = numeroPoint + 1; o < numImages; o++) { pt = (Node) pano.lookup("#img" + Integer.toString(o)); pt.setId("img" + Integer.toString(o - 1)); } /** * on retire les anciennes indication de HS */ retireAffichageHotSpots(); numImages--; panoramiquesProjet[panoActuel].removeHotspotImage(numeroPoint); /** * On les cre les nouvelles */ ajouteAffichageHotspots(); } valideHS(); me1.consume(); }); } }
From source file:editeurpanovisu.EditeurPanovisu.java
private void panoMouseClic(double X, double Y) { if (nombrePanoramiques > 1) { valideHS();/*from w ww. j ava 2 s .co m*/ dejaSauve = false; stPrincipal.setTitle(stPrincipal.getTitle().replace(" *", "") + " *"); double mouseX = X; double mouseY = Y - pano.getLayoutY() - 109; if (X > 0 && X < imagePanoramique.getFitWidth()) { double longitude, latitude; double largeur = imagePanoramique.getFitWidth(); String chLong, chLat; longitude = 360.0f * mouseX / largeur - 180; latitude = 90.0d - 2.0f * mouseY / largeur * 180.0f; Circle point = new Circle(mouseX + imagePanoramique.getLayoutX(), mouseY, 5); point.setFill(Color.YELLOW); point.setStroke(Color.RED); point.setId("point" + numPoints); point.setCursor(Cursor.DEFAULT); pano.getChildren().add(point); Tooltip t = new Tooltip("point n" + (numPoints + 1)); t.setStyle(tooltipStyle); Tooltip.install(point, t); HotSpot HS = new HotSpot(); HS.setLongitude(longitude); HS.setLatitude(latitude); panoramiquesProjet[panoActuel].addHotspot(HS); retireAffichageHotSpots(); Pane affHS1 = affichageHS(listePano(panoActuel), panoActuel); affHS1.setId("labels"); outils.getChildren().add(affHS1); numPoints++; if (nombrePanoramiques > 1) { AnchorPane listePanoVig = afficherListePanosVignettes( panoramiquesProjet[panoActuel].getNombreHotspots() - 1); int largeurVignettes = 4; if (nombrePanoramiques < 4) { largeurVignettes = nombrePanoramiques; } if (mouseX + largeurVignettes * 130 > pano.getWidth()) { listePanoVig.setLayoutX(pano.getWidth() - largeurVignettes * 130); } else { listePanoVig.setLayoutX(mouseX); } listePanoVig.setLayoutY(mouseY); pano.getChildren().add(listePanoVig); valideHS(); } point.setOnDragDetected((MouseEvent me1) -> { String chPoint = point.getId(); chPoint = chPoint.substring(5, chPoint.length()); int numeroPoint = Integer.parseInt(chPoint); Node pt; pt = (Node) pano.lookup("#point" + chPoint); point.setFill(Color.RED); point.setStroke(Color.YELLOW); dragDrop = true; me1.consume(); }); point.setOnMouseDragged((MouseEvent me1) -> { double XX = me1.getX() - imagePanoramique.getLayoutX(); if (XX < 0) { XX = 0; } if (XX > imagePanoramique.getFitWidth()) { XX = imagePanoramique.getFitWidth(); } point.setCenterX(XX + imagePanoramique.getLayoutX()); double YY = me1.getY(); if (YY < 0) { YY = 0; } if (YY > imagePanoramique.getFitHeight()) { YY = imagePanoramique.getFitHeight(); } point.setCenterY(YY); me1.consume(); }); point.setOnMouseReleased((MouseEvent me1) -> { String chPoint = point.getId(); chPoint = chPoint.substring(5, chPoint.length()); int numeroPoint = Integer.parseInt(chPoint); double X1 = me1.getSceneX(); double Y1 = me1.getSceneY(); double mouseX1 = X1 - imagePanoramique.getLayoutX(); if (mouseX1 < 0) { mouseX1 = 0; } if (mouseX1 > imagePanoramique.getFitWidth()) { mouseX1 = imagePanoramique.getFitWidth(); } double mouseY1 = Y1 - pano.getLayoutY() - 109; if (mouseY1 < 0) { mouseY1 = 0; } if (mouseY1 > imagePanoramique.getFitHeight()) { mouseY1 = imagePanoramique.getFitHeight(); } double longit, lat; double larg = imagePanoramique.getFitWidth(); longit = 360.0f * mouseX1 / larg - 180; lat = 90.0d - 2.0f * mouseY1 / larg * 180.0f; panoramiquesProjet[panoActuel].getHotspot(numeroPoint).setLatitude(lat); panoramiquesProjet[panoActuel].getHotspot(numeroPoint).setLongitude(longit); point.setFill(Color.YELLOW); point.setStroke(Color.RED); me1.consume(); }); point.setOnMouseClicked((MouseEvent me1) -> { if (me1.isControlDown()) { dejaSauve = false; stPrincipal.setTitle(stPrincipal.getTitle().replace(" *", "") + " *"); String chPoint = point.getId(); chPoint = chPoint.substring(5, chPoint.length()); int numeroPoint = Integer.parseInt(chPoint); Node pt; pt = (Node) pano.lookup("#point" + chPoint); pano.getChildren().remove(pt); for (int o = numeroPoint + 1; o < numPoints; o++) { pt = (Node) pano.lookup("#point" + Integer.toString(o)); pt.setId("point" + Integer.toString(o - 1)); } /** * on retire les anciennes indication de HS */ retireAffichageHotSpots(); numPoints--; panoramiquesProjet[panoActuel].removeHotspot(numeroPoint); /** * On les cre les nouvelles */ ajouteAffichageHotspots(); valideHS(); me1.consume(); } else { if (!dragDrop) { String chPoint = point.getId(); chPoint = chPoint.substring(5, chPoint.length()); int numeroPoint = Integer.parseInt(chPoint); if (nombrePanoramiques > 1) { AnchorPane listePanoVig = afficherListePanosVignettes(numeroPoint); int largeurVignettes = 4; if (nombrePanoramiques < 4) { largeurVignettes = nombrePanoramiques; } if (mouseX + largeurVignettes * 130 > pano.getWidth()) { listePanoVig.setLayoutX(pano.getWidth() - largeurVignettes * 130); } else { listePanoVig.setLayoutX(mouseX); } listePanoVig.setLayoutY(mouseY); pano.getChildren().add(listePanoVig); } } else { dragDrop = false; } valideHS(); me1.consume(); } }); } } }
From source file:editeurpanovisu.EditeurPanovisu.java
private AnchorPane afficherListePanosVignettes(int numHS) { AnchorPane aplistePano = new AnchorPane(); aplistePano.setOpacity(1);/*from w ww .j av a 2s.c o m*/ Pane fond = new Pane(); fond.setStyle("-fx-background-color : #bbb;"); fond.setPrefWidth(540); fond.setPrefHeight(((nombrePanoramiques - 2) / 4 + 1) * 65 + 10); fond.setMinWidth(540); fond.setMinHeight(70); aplistePano.getChildren().add(fond); aplistePano.setStyle("-fx-backgroung-color : #bbb;"); int j = 0; ImageView[] IVPano; IVPano = new ImageView[nombrePanoramiques]; double xPos; double yPos; int row = 0; for (int i = 0; i < nombrePanoramiques; i++) { int numeroPano = i; IVPano[j] = new ImageView(panoramiquesProjet[i].getVignettePanoramique()); IVPano[j].setFitWidth(120); IVPano[j].setFitHeight(60); IVPano[j].setSmooth(true); String nomPano = panoramiquesProjet[i].getNomFichier(); int col = j % 4; row = j / 4; xPos = col * 130 + 25; yPos = row * 65 + 5; IVPano[j].setLayoutX(xPos); IVPano[j].setLayoutY(yPos); IVPano[j].setCursor(Cursor.HAND); IVPano[j].setStyle("-fx-background-color : #ccc;"); Tooltip t = new Tooltip( nomPano.substring(nomPano.lastIndexOf(File.separator) + 1, nomPano.lastIndexOf("."))); t.setStyle(tooltipStyle); Tooltip.install(IVPano[j], t); IVPano[j].setOnMouseClicked((MouseEvent me) -> { pano.setCursor(Cursor.CROSSHAIR); pano.setOnMouseClicked((MouseEvent me1) -> { gereSourisPanoramique(me1); }); panoListeVignette = nomPano; if (panoramiquesProjet[numeroPano].getTitrePanoramique() != null) { String texteHS = panoramiquesProjet[numeroPano].getTitrePanoramique(); TextArea txtHS = (TextArea) outils.lookup("#txtHS" + numHS); txtHS.setText(texteHS); } panoramiquesProjet[panoActuel].getHotspot(numHS).setNumeroPano(numeroPano); ComboBox cbx = (ComboBox) outils.lookup("#cbpano" + numHS); cbx.setValue(nomPano.substring(nomPano.lastIndexOf(File.separator) + 1, nomPano.lastIndexOf("."))); aplistePano.setVisible(false); me.consume(); }); aplistePano.getChildren().add(IVPano[j]); j++; } int taille = (row + 1) * 65 + 5; aplistePano.setPrefWidth(540); aplistePano.setPrefHeight(taille); aplistePano.setMinWidth(540); aplistePano.setMinHeight(taille); ImageView IVClose = new ImageView( new Image("file:" + repertAppli + File.separator + "images/ferme.png", 20, 20, true, true)); IVClose.setLayoutX(2); IVClose.setLayoutY(5); IVClose.setCursor(Cursor.HAND); aplistePano.getChildren().add(IVClose); IVClose.setOnMouseClicked((MouseEvent me) -> { pano.setCursor(Cursor.CROSSHAIR); pano.setOnMouseClicked((MouseEvent me1) -> { gereSourisPanoramique(me1); }); panoListeVignette = ""; aplistePano.setVisible(false); me.consume(); }); aplistePano.setTranslateZ(2); return aplistePano; }
From source file:editeurpanovisu.EditeurPanovisu.java
/** * * @param mouseEvent/* w ww. ja v a 2 s. com*/ */ private static void gereSourisPanoramique(MouseEvent mouseEvent) { if (mouseEvent.getButton() == MouseButton.SECONDARY) { if (mouseEvent.isShiftDown()) { panoChoixNord(mouseEvent.getSceneX() - ivImagePanoramique.getLayoutX()); mouseEvent.consume(); } else if (mouseEvent.isControlDown()) { } else { panoChoixRegard(mouseEvent.getSceneX() - ivImagePanoramique.getLayoutX(), mouseEvent.getSceneY() - getiDecalageMac()); mouseEvent.consume(); } } if (mouseEvent.getButton() == MouseButton.PRIMARY) { if (!(mouseEvent.isControlDown()) && bEstCharge) { if (!bDragDrop) { panePanoramique.setCursor(Cursor.DEFAULT); panePanoramique.setOnMouseClicked((me) -> { }); Circle c1 = new Circle(mouseEvent.getSceneX(), mouseEvent.getSceneY() - panePanoramique.getLayoutY() - 130 - getiDecalageMac(), 3); panePanoramique.getChildren().add(c1); ListView<String> lvMenuChoixTypeHotspot = new ListView<>(); double tailleFenetre = 70; if (getiNombrePanoramiques() > 1) { lvMenuChoixTypeHotspot.getItems().add("Panoramique"); tailleFenetre += 20; } lvMenuChoixTypeHotspot.getItems().add("Image"); if (getiNombreDiapo() > 0) { lvMenuChoixTypeHotspot.getItems().add("Diaporama"); tailleFenetre += 20; } lvMenuChoixTypeHotspot.getItems().add("HTML"); lvMenuChoixTypeHotspot.getItems().add("Annuler"); lvMenuChoixTypeHotspot.setMaxHeight(tailleFenetre); lvMenuChoixTypeHotspot.setPrefHeight(tailleFenetre); lvMenuChoixTypeHotspot.setMinHeight(tailleFenetre); lvMenuChoixTypeHotspot.setPrefWidth(120); lvMenuChoixTypeHotspot.setCursor(Cursor.DEFAULT); lvMenuChoixTypeHotspot.setLayoutX(mouseEvent.getSceneX()); lvMenuChoixTypeHotspot.setLayoutY( mouseEvent.getSceneY() - panePanoramique.getLayoutY() - 104 - getiDecalageMac()); panePanoramique.getChildren().add(lvMenuChoixTypeHotspot); lvMenuChoixTypeHotspot.getSelectionModel().selectedItemProperty() .addListener((ov, ancValeur, nouvValeur) -> { panePanoramique.getChildren().remove(lvMenuChoixTypeHotspot); panePanoramique.getChildren().remove(c1); switch (nouvValeur) { case "Panoramique": panoMouseClic(mouseEvent.getSceneX() - ivImagePanoramique.getLayoutX(), mouseEvent.getSceneY()); break; case "Image": panoAjouteImage(mouseEvent.getSceneX() - ivImagePanoramique.getLayoutX(), mouseEvent.getSceneY()); break; case "HTML": panoAjouteHTML(mouseEvent.getSceneX() - ivImagePanoramique.getLayoutX(), mouseEvent.getSceneY()); break; case "Diaporama": panoAjouteDiaporama(mouseEvent.getSceneX() - ivImagePanoramique.getLayoutX(), mouseEvent.getSceneY()); break; case "Annuler": break; } panePanoramique.setCursor(Cursor.CROSSHAIR); panePanoramique.setOnMouseClicked((me) -> { gereSourisPanoramique(me); }); }); } else { bDragDrop = false; } } } }