List of usage examples for javafx.scene.shape Circle getId
public final String getId()
From source file:editeurpanovisu.EditeurPanovisu.java
/** * * @param X/*from w ww .j a v a 2 s. c o m*/ * @param Y */ private static void panoAjouteImage(double X, double Y) { if (X > 0 && X < ivImagePanoramique.getFitWidth()) { valideHS(); setbDejaSauve(false); getStPrincipal().setTitle(getStPrincipal().getTitle().replace(" *", "") + " *"); double mouseX = X; double mouseY = Y - panePanoramique.getLayoutY() - 130 - getiDecalageMac(); double longitude, latitude; double largeur = ivImagePanoramique.getFitWidth(); longitude = 360.0f * mouseX / largeur - 180; latitude = 90.0d - 2.0f * mouseY / largeur * 180.0f; Circle circPoint = new Circle(mouseX + ivImagePanoramique.getLayoutX(), mouseY, 5); circPoint.setFill(Color.BLUE); circPoint.setStroke(Color.YELLOW); circPoint.setId("img" + getiNumImages()); circPoint.setCursor(Cursor.DEFAULT); panePanoramique.getChildren().add(circPoint); Tooltip tltpImage = new Tooltip("image n " + (getiNumImages() + 1)); tltpImage.setStyle(getStrTooltipStyle()); Tooltip.install(circPoint, tltpImage); File fileRepert; if (getStrRepertHSImages().equals("")) { fileRepert = new File(getStrCurrentDir() + File.separator); } else { fileRepert = new File(getStrRepertHSImages()); } FileChooser fileChooser = new FileChooser(); FileChooser.ExtensionFilter extFilterImages = new FileChooser.ExtensionFilter( "Fichiers Images (jpg, bmp, png)", "*.jpg", "*.bmp", "*.png"); fileChooser.setInitialDirectory(fileRepert); fileChooser.getExtensionFilters().addAll(extFilterImages); File fileFichierImage = fileChooser.showOpenDialog(null); if (fileFichierImage != null) { setStrRepertHSImages(fileFichierImage.getParent()); setiNumImages(getiNumImages() + 1); HotspotImage HS = new HotspotImage(); HS.setLongitude(longitude); HS.setLatitude(latitude); HS.setStrUrlImage(fileFichierImage.getAbsolutePath()); HS.setStrLienImg(fileFichierImage.getName()); HS.setStrInfo(fileFichierImage.getName().split("\\.")[0]); File fileRepertImage = new File(getStrRepertTemp() + File.separator + "images"); if (!fileRepertImage.exists()) { fileRepertImage.mkdirs(); } try { copieFichierRepertoire(fileFichierImage.getAbsolutePath(), fileRepertImage.getAbsolutePath()); } catch (IOException ex) { Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex); } getPanoramiquesProjet()[getiPanoActuel()].addHotspotImage(HS); retireAffichageHotSpots(); dejaCharge = false; Pane affHS1 = paneAffichageHS(strListePano(), getiPanoActuel()); affHS1.setId("labels"); vbVisuHotspots.getChildren().add(affHS1); spPanneauOutils.setVvalue(spPanneauOutils.getVvalue() + 300); } else { String strPoint = circPoint.getId(); strPoint = strPoint.substring(3, strPoint.length()); Node nodeImage = (Node) panePanoramique.lookup("#img" + strPoint); panePanoramique.getChildren().remove(nodeImage); } valideHS(); circPoint.setOnDragDetected((mouseEvent1) -> { circPoint.setFill(Color.YELLOW); circPoint.setStroke(Color.BLUE); bDragDrop = true; mouseEvent1.consume(); }); circPoint.setOnMouseDragged((mouseEvent1) -> { double XX = mouseEvent1.getX() - ivImagePanoramique.getLayoutX(); if (XX < 0) { XX = 0; } if (XX > ivImagePanoramique.getFitWidth()) { XX = ivImagePanoramique.getFitWidth(); } circPoint.setCenterX(XX + ivImagePanoramique.getLayoutX()); double YY = mouseEvent1.getY(); if (YY < 0) { YY = 0; } if (YY > ivImagePanoramique.getFitHeight()) { YY = ivImagePanoramique.getFitHeight(); } circPoint.setCenterY(YY); afficheLoupe(XX, YY); mouseEvent1.consume(); }); circPoint.setOnMouseReleased((mouseEvent1) -> { setbDejaSauve(false); getStPrincipal().setTitle(getStPrincipal().getTitle().replace(" *", "") + " *"); String strPoint = circPoint.getId(); strPoint = strPoint.substring(3, strPoint.length()); int iNumeroPoint = Integer.parseInt(strPoint); double X1 = mouseEvent1.getSceneX(); double Y1 = mouseEvent1.getSceneY(); double mouseX1 = X1 - ivImagePanoramique.getLayoutX(); if (mouseX1 < 0) { mouseX1 = 0; } if (mouseX1 > ivImagePanoramique.getFitWidth()) { mouseX1 = ivImagePanoramique.getFitWidth(); } double mouseY1 = Y1 - panePanoramique.getLayoutY() - 130 - getiDecalageMac(); if (mouseY1 < 0) { mouseY1 = 0; } if (mouseY1 > ivImagePanoramique.getFitHeight()) { mouseY1 = ivImagePanoramique.getFitHeight(); } double longit, lat; double larg = ivImagePanoramique.getFitWidth(); longit = 360.0f * mouseX1 / larg - 180; lat = 90.0d - 2.0f * mouseY1 / larg * 180.0f; getPanoramiquesProjet()[getiPanoActuel()].getHotspotImage(iNumeroPoint).setLatitude(lat); getPanoramiquesProjet()[getiPanoActuel()].getHotspotImage(iNumeroPoint).setLongitude(longit); circPoint.setFill(Color.BLUE); circPoint.setStroke(Color.YELLOW); mouseEvent1.consume(); }); circPoint.setOnMouseClicked((mouseEvent1) -> { String strPoint = circPoint.getId(); strPoint = strPoint.substring(3, strPoint.length()); int iNum = Integer.parseInt(strPoint); if (mouseEvent1.isControlDown()) { setbDejaSauve(false); getStPrincipal().setTitle(getStPrincipal().getTitle().replace(" *", "") + " *"); Node nodeImage; nodeImage = (Node) panePanoramique.lookup("#img" + strPoint); panePanoramique.getChildren().remove(nodeImage); for (int io = iNum + 1; io < getiNumImages(); io++) { nodeImage = (Node) panePanoramique.lookup("#img" + Integer.toString(io)); nodeImage.setId("img" + Integer.toString(io - 1)); } /** * on retire les anciennes indication de HS */ retireAffichageHotSpots(); setiNumImages(getiNumImages() - 1); getPanoramiquesProjet()[getiPanoActuel()].removeHotspotImage(iNum); /** * On les cre les nouvelles */ ajouteAffichageHotspots(); } else { if (!bDragDrop) { setbDejaSauve(false); getStPrincipal().setTitle(getStPrincipal().getTitle().replace(" *", "") + " *"); File fileRepert1; if (getStrRepertHSImages().equals("")) { fileRepert1 = new File(getStrCurrentDir() + File.separator); } else { fileRepert1 = new File(getStrRepertHSImages()); } FileChooser fileChooser1 = new FileChooser(); FileChooser.ExtensionFilter extFilterImages1 = new FileChooser.ExtensionFilter( "Fichiers Images (jpg, bmp, png)", "*.jpg", "*.bmp", "*.png"); fileChooser1.setInitialDirectory(fileRepert1); fileChooser1.getExtensionFilters().addAll(extFilterImages1); File fileFichierImage1 = fileChooser1.showOpenDialog(null); if (fileFichierImage1 != null) { setStrRepertHSImages(fileFichierImage1.getParent()); HotspotImage HS = getPanoramiquesProjet()[getiPanoActuel()].getHotspotImage(iNum); HS.setStrUrlImage(fileFichierImage1.getAbsolutePath()); HS.setStrLienImg(fileFichierImage1.getName()); HS.setStrInfo(fileFichierImage1.getName().split("\\.")[0]); File fileRepertImage = new File(getStrRepertTemp() + File.separator + "images"); if (!fileRepertImage.exists()) { fileRepertImage.mkdirs(); } try { copieFichierRepertoire(fileFichierImage1.getAbsolutePath(), fileRepertImage.getAbsolutePath()); } catch (IOException ex) { Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex); } getPanoramiquesProjet()[getiPanoActuel()].setHotspotImage(HS, iNum); retireAffichageHotSpots(); dejaCharge = false; Pane affHS1 = paneAffichageHS(strListePano(), getiPanoActuel()); affHS1.setId("labels"); vbVisuHotspots.getChildren().add(affHS1); } } else { bDragDrop = false; } } valideHS(); mouseEvent1.consume(); }); } }
From source file:editeurpanovisu.EditeurPanovisu.java
/** * * @param X/* ww w .java2 s . com*/ * @param Y */ private static void panoAjouteDiaporama(double X, double Y) { if (X > 0 && X < ivImagePanoramique.getFitWidth()) { valideHS(); setbDejaSauve(false); getStPrincipal().setTitle(getStPrincipal().getTitle().replace(" *", "") + " *"); double mouseX = X; double mouseY = Y - panePanoramique.getLayoutY() - 130 - getiDecalageMac(); double longitude, latitude; double largeur = ivImagePanoramique.getFitWidth(); longitude = 360.0f * mouseX / largeur - 180; latitude = 90.0d - 2.0f * mouseY / largeur * 180.0f; Circle circPoint = new Circle(mouseX + ivImagePanoramique.getLayoutX(), mouseY, 5); circPoint.setFill(Color.TURQUOISE); circPoint.setStroke(Color.ORANGE); circPoint.setId("dia" + getiNumDiapo()); circPoint.setCursor(Cursor.DEFAULT); panePanoramique.getChildren().add(circPoint); Tooltip tltpImage = new Tooltip("Diaporama n " + (getiNumDiapo() + 1)); tltpImage.setStyle(getStrTooltipStyle()); Tooltip.install(circPoint, tltpImage); HotspotDiaporama HS = new HotspotDiaporama(); HS.setLongitude(longitude); HS.setLatitude(latitude); List<String> choixDiapo = new ArrayList<>(); for (int i = 0; i < getiNombreDiapo(); i++) { choixDiapo.add(diaporamas[i].getStrNomDiaporama()); } ChoiceDialog<String> dialog = new ChoiceDialog<>(diaporamas[0].getStrNomDiaporama(), choixDiapo); dialog.setTitle(rbLocalisation.getString("main.choixDiapo")); dialog.setHeaderText(null); dialog.setContentText(rbLocalisation.getString("main.diapos")); Optional<String> result = dialog.showAndWait(); if (result.isPresent()) { boolean bTrouve = false; int iTrouve = -1; for (int i = 0; i < getiNombreDiapo(); i++) { if (diaporamas[i].getStrNomDiaporama().equals(result.get())) { bTrouve = true; iTrouve = i; } } if (bTrouve) { HS.setiNumDiapo(iTrouve); retireAffichageHotSpots(); getPanoramiquesProjet()[getiPanoActuel()].addHotspotDiapo(HS); setiNumDiapo(getiNumDiapo() + 1); valideHS(); dejaCharge = false; Pane affHS1 = paneAffichageHS(strListePano(), getiPanoActuel()); affHS1.setId("labels"); vbVisuHotspots.getChildren().add(affHS1); spPanneauOutils.setVvalue(spPanneauOutils.getVvalue() + 145); } } circPoint.setOnDragDetected((mouseEvent1) -> { circPoint.setFill(Color.ORANGE); circPoint.setStroke(Color.TURQUOISE); bDragDrop = true; mouseEvent1.consume(); }); circPoint.setOnMouseDragged((mouseEvent1) -> { double XX = mouseEvent1.getX() - ivImagePanoramique.getLayoutX(); if (XX < 0) { XX = 0; } if (XX > ivImagePanoramique.getFitWidth()) { XX = ivImagePanoramique.getFitWidth(); } circPoint.setCenterX(XX + ivImagePanoramique.getLayoutX()); double YY = mouseEvent1.getY(); if (YY < 0) { YY = 0; } if (YY > ivImagePanoramique.getFitHeight()) { YY = ivImagePanoramique.getFitHeight(); } circPoint.setCenterY(YY); afficheLoupe(XX, YY); mouseEvent1.consume(); }); circPoint.setOnMouseReleased((mouseEvent1) -> { setbDejaSauve(false); getStPrincipal().setTitle(getStPrincipal().getTitle().replace(" *", "") + " *"); String strPoint = circPoint.getId(); strPoint = strPoint.substring(3, strPoint.length()); int iNumeroPoint = Integer.parseInt(strPoint); double X1 = mouseEvent1.getSceneX(); double Y1 = mouseEvent1.getSceneY(); double mouseX1 = X1 - ivImagePanoramique.getLayoutX(); if (mouseX1 < 0) { mouseX1 = 0; } if (mouseX1 > ivImagePanoramique.getFitWidth()) { mouseX1 = ivImagePanoramique.getFitWidth(); } double mouseY1 = Y1 - panePanoramique.getLayoutY() - 130 - getiDecalageMac(); if (mouseY1 < 0) { mouseY1 = 0; } if (mouseY1 > ivImagePanoramique.getFitHeight()) { mouseY1 = ivImagePanoramique.getFitHeight(); } double longit, lat; double larg = ivImagePanoramique.getFitWidth(); longit = 360.0f * mouseX1 / larg - 180; lat = 90.0d - 2.0f * mouseY1 / larg * 180.0f; getPanoramiquesProjet()[getiPanoActuel()].getHotspotDiapo(iNumeroPoint).setLatitude(lat); getPanoramiquesProjet()[getiPanoActuel()].getHotspotDiapo(iNumeroPoint).setLongitude(longit); circPoint.setFill(Color.TURQUOISE); circPoint.setStroke(Color.ORANGE); mouseEvent1.consume(); }); circPoint.setOnMouseClicked((mouseEvent1) -> { String strPoint = circPoint.getId(); strPoint = strPoint.substring(3, strPoint.length()); int iNum = Integer.parseInt(strPoint); if (mouseEvent1.isControlDown()) { setbDejaSauve(false); getStPrincipal().setTitle(getStPrincipal().getTitle().replace(" *", "") + " *"); Node nodeImage; nodeImage = (Node) panePanoramique.lookup("#dia" + strPoint); panePanoramique.getChildren().remove(nodeImage); for (int io = iNum + 1; io < getiNumDiapo(); io++) { nodeImage = (Node) panePanoramique.lookup("#dia" + Integer.toString(io)); nodeImage.setId("dia" + Integer.toString(io - 1)); Tooltip tltpImage1 = new Tooltip("Diaporama n " + io); tltpImage1.setStyle(getStrTooltipStyle()); Tooltip.install(nodeImage, tltpImage1); } /** * on retire les anciennes indication de HS */ retireAffichageHotSpots(); setiNumDiapo(getiNumDiapo() - 1); getPanoramiquesProjet()[getiPanoActuel()].removeHotspotdiapo(iNum); /** * On les cre les nouvelles */ ajouteAffichageHotspots(); } else { if (!bDragDrop) { setbDejaSauve(false); getStPrincipal().setTitle(getStPrincipal().getTitle().replace(" *", "") + " *"); List<String> choixDiapo1 = new ArrayList<>(); for (int i = 0; i < getiNombreDiapo(); i++) { choixDiapo1.add(diaporamas[i].getStrNomDiaporama()); } ChoiceDialog<String> dialog1 = new ChoiceDialog<>( diaporamas[getPanoramiquesProjet()[getiPanoActuel()].getHotspotDiapo(iNum) .getiNumDiapo()].getStrNomDiaporama(), choixDiapo1); dialog1.setTitle(rbLocalisation.getString("main.choixDiapo")); dialog1.setHeaderText(null); dialog1.setContentText(rbLocalisation.getString("main.diapos")); Optional<String> result1 = dialog1.showAndWait(); if (result1.isPresent()) { boolean bTrouve = false; int iTrouve = -1; for (int i = 0; i < getiNombreDiapo(); i++) { if (diaporamas[i].getStrNomDiaporama().equals(result1.get())) { bTrouve = true; iTrouve = i; } } if (bTrouve) { retireAffichageHotSpots(); getPanoramiquesProjet()[getiPanoActuel()].getHotspotDiapo(iNum) .setiNumDiapo(iTrouve); valideHS(); ajouteAffichageHotspots(); } } } else { bDragDrop = false; } mouseEvent1.consume(); } valideHS(); mouseEvent1.consume(); }); } }