List of usage examples for javafx.scene.shape Circle setStroke
public final void setStroke(Paint value)
From source file:editeurpanovisu.EditeurPanovisu.java
/** * * @param i// w ww. j a va 2 s.com * @param longitude * @param latitude */ private static void afficheHS(int i, double longitude, double latitude) { double largeur = ivImagePanoramique.getFitWidth(); double X = (longitude + 180.0d) * largeur / 360.0d + ivImagePanoramique.getLayoutX(); double Y = (90.0d - latitude) * largeur / 360.0d; Circle circPoint = new Circle(X, Y, 5); circPoint.setFill(Color.YELLOW); circPoint.setStroke(Color.RED); circPoint.setId("point" + i); circPoint.setCursor(Cursor.DEFAULT); panePanoramique.getChildren().add(circPoint); Tooltip tltpHotSpot = new Tooltip("point #" + (i + 1)); tltpHotSpot.setStyle(getStrTooltipStyle()); Tooltip.install(circPoint, tltpHotSpot); circPoint.setOnDragDetected((mouseEvent1) -> { circPoint.setFill(Color.RED); circPoint.setStroke(Color.YELLOW); 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) -> { String strChPoint = circPoint.getId(); strChPoint = strChPoint.substring(5, strChPoint.length()); int iNumeroPoint = Integer.parseInt(strChPoint); double X1 = mouseEvent1.getSceneX(); double Y1 = mouseEvent1.getSceneY(); double mouseX = X1 - ivImagePanoramique.getLayoutX(); if (mouseX < 0) { mouseX = 0; } if (mouseX > ivImagePanoramique.getFitWidth()) { mouseX = ivImagePanoramique.getFitWidth(); } double mouseY = Y1 - panePanoramique.getLayoutY() - 130 - getiDecalageMac(); if (mouseY < 0) { mouseY = 0; } if (mouseY > ivImagePanoramique.getFitHeight()) { mouseY = ivImagePanoramique.getFitHeight(); } double longit, lat; double larg = ivImagePanoramique.getFitWidth(); String strLong, strLat; longit = 360.0f * mouseX / larg - 180; lat = 90.0d - 2.0f * mouseY / larg * 180.0f; getPanoramiquesProjet()[getiPanoActuel()].getHotspot(iNumeroPoint).setLatitude(lat); getPanoramiquesProjet()[getiPanoActuel()].getHotspot(iNumeroPoint).setLongitude(longit); circPoint.setFill(Color.YELLOW); circPoint.setStroke(Color.RED); mouseEvent1.consume(); }); circPoint.setOnMouseClicked((mouseEvent1) -> { String strPoint = circPoint.getId(); strPoint = strPoint.substring(5, strPoint.length()); int numeroPoint = Integer.parseInt(strPoint); Node nodePoint; nodePoint = (Node) panePanoramique.lookup("#point" + strPoint); if (mouseEvent1.isControlDown()) { setbDejaSauve(false); getStPrincipal().setTitle(getStPrincipal().getTitle().replace(" *", "") + " *"); panePanoramique.getChildren().remove(nodePoint); for (int io = numeroPoint + 1; io < getiNumPoints(); io++) { nodePoint = (Node) panePanoramique.lookup("#point" + Integer.toString(io)); nodePoint.setId("point" + Integer.toString(io - 1)); } /** * on retire les anciennes indication de HS */ dejaCharge = false; retireAffichageHotSpots(); setiNumPoints(getiNumPoints() - 1); getPanoramiquesProjet()[getiPanoActuel()].removeHotspot(numeroPoint); /** * On les cre les nouvelles */ ajouteAffichageHotspots(); mouseEvent1.consume(); valideHS(); } else { if (!bDragDrop) { if (getiNombrePanoramiques() > 1) { AnchorPane apListePanoVig = apAfficherListePanosVignettes(numeroPoint); double positX = (panePanoramique.getPrefWidth() - apListePanoVig.getPrefWidth()) / 2.d; double positY = (panePanoramique.getPrefHeight() - apListePanoVig.getPrefHeight()) / 2.d; apListePanoVig.setLayoutX(positX); apListePanoVig.setLayoutY(positY); apPanneauPrincipal.getChildren().add(apListePanoVig); } } else { bDragDrop = false; } valideHS(); mouseEvent1.consume(); } }); }
From source file:editeurpanovisu.EditeurPanovisu.java
/** * * @param i//from www . java2s. c om * @param longitude * @param latitude */ private static void afficheHSHTML(int i, double longitude, double latitude) { double largeur = ivImagePanoramique.getFitWidth(); double X = (longitude + 180.0d) * largeur / 360.0d + ivImagePanoramique.getLayoutX(); double Y = (90.0d - latitude) * largeur / 360.0d; Circle circPoint = new Circle(X, Y, 5); circPoint.setFill(Color.DARKGREEN); circPoint.setStroke(Color.YELLOWGREEN); circPoint.setId("html" + i); circPoint.setCursor(Cursor.DEFAULT); panePanoramique.getChildren().add(circPoint); Tooltip tltpHSImage = new Tooltip("HTML #" + (i + 1)); tltpHSImage.setStyle(getStrTooltipStyle()); Tooltip.install(circPoint, tltpHSImage); circPoint.setOnDragDetected((mouseEvent1) -> { circPoint.setFill(Color.YELLOWGREEN); circPoint.setStroke(Color.DARKGREEN); 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) -> { String strPoint = circPoint.getId(); strPoint = strPoint.substring(4, strPoint.length()); int iNumeroPoint = Integer.parseInt(strPoint); double X1 = mouseEvent1.getSceneX(); double Y1 = mouseEvent1.getSceneY(); double mouseX = X1 - ivImagePanoramique.getLayoutX(); if (mouseX < 0) { mouseX = 0; } if (mouseX > ivImagePanoramique.getFitWidth()) { mouseX = ivImagePanoramique.getFitWidth(); } double mouseY = Y1 - panePanoramique.getLayoutY() - 130 - getiDecalageMac(); if (mouseY < 0) { mouseY = 0; } if (mouseY > ivImagePanoramique.getFitHeight()) { mouseY = ivImagePanoramique.getFitHeight(); } double longit, lat; double larg = ivImagePanoramique.getFitWidth(); String strLong, strLat; longit = 360.0f * mouseX / larg - 180; lat = 90.0d - 2.0f * mouseY / larg * 180.0f; getPanoramiquesProjet()[getiPanoActuel()].getHotspotHTML(iNumeroPoint).setLatitude(lat); getPanoramiquesProjet()[getiPanoActuel()].getHotspotHTML(iNumeroPoint).setLongitude(longit); circPoint.setFill(Color.DARKGREEN); circPoint.setStroke(Color.YELLOWGREEN); mouseEvent1.consume(); }); circPoint.setOnMouseClicked((mouseEvent1) -> { String strPoint = circPoint.getId(); strPoint = strPoint.substring(4, strPoint.length()); int iNum = Integer.parseInt(strPoint); Node nodePointImage; nodePointImage = (Node) panePanoramique.lookup("#html" + strPoint); if (mouseEvent1.isControlDown()) { valideHS(); setbDejaSauve(false); getStPrincipal().setTitle(getStPrincipal().getTitle().replace(" *", "") + " *"); panePanoramique.getChildren().remove(nodePointImage); for (int io = iNum + 1; io < getiNumImages(); io++) { nodePointImage = (Node) panePanoramique.lookup("#html" + Integer.toString(io)); nodePointImage.setId("img" + Integer.toString(io - 1)); } /** * on retire les anciennes indication de HS */ retireAffichageHotSpots(); setiNumHTML(getiNumHTML() - 1); getPanoramiquesProjet()[getiPanoActuel()].removeHotspotHTML(iNum); /** * On les cre les nouvelles */ ajouteAffichageHotspots(); mouseEvent1.consume(); } else { if (!bDragDrop) { EditeurHTML editHTML = new EditeurHTML(); HotspotHTML HS = getPanoramiquesProjet()[getiPanoActuel()].getHotspotHTML(iNum); editHTML.setHsHTML(HS); Rectangle2D tailleEcran = Screen.getPrimary().getBounds(); int iHauteur = (int) tailleEcran.getHeight() - 100; int iLargeur = (int) tailleEcran.getWidth() - 100; editHTML.affiche(iLargeur, iHauteur); editHTML.addPropertyChangeListener("bValide", (ev) -> { if (ev.getNewValue().toString().equals("true")) { getPanoramiquesProjet()[getiPanoActuel()].setHotspotHTML(editHTML.getHsHTML(), iNum); dejaCharge = false; retireAffichageHotSpots(); Pane affHS1 = paneAffichageHS(strListePano(), getiPanoActuel()); affHS1.setId("labels"); vbVisuHotspots.getChildren().add(affHS1); } }); } else { bDragDrop = false; } mouseEvent1.consume(); } }); }
From source file:editeurpanovisu.EditeurPanovisu.java
/** * * @param iLargeur//from www . j a va 2 s .com * @param iHauteur * @param bMasqueZones * @param strIdZone * @param mouseEvent */ private static void choixZone(int iLargeur, int iHauteur, boolean bMasqueZones, String strIdZone, MouseEvent mouseEvent) { ComboBox cbTouchesBarre = new ComboBox(); cbTouchesBarre.getItems().clear(); for (int i = 0; i < strTouchesBarre.length; i++) { cbTouchesBarre.getItems().add(i, strTouchesBarre[i]); } cbTouchesBarre.setLayoutX(200); cbTouchesBarre.setLayoutX(40); final int iNumeroZone = Integer.parseInt(strIdZone.split("-")[1]); if (mouseEvent.getButton().equals(MouseButton.PRIMARY)) { if (mouseEvent.getClickCount() == 2) { for (int ij = iNumeroZone; ij < iNombreZones - 1; ij++) { zones[ij] = zones[ij + 1]; } iNombreZones--; afficheBarrePersonnalisee(iLargeur, iHauteur, bMasqueZones); } else { afficheBarrePersonnalisee(iLargeur, iHauteur, bMasqueZones); apZoneBarrePersonnalisee.getChildren().clear(); apZoneBarrePersonnalisee.getChildren().add(cbTouchesBarre); ZoneTelecommande zone = zones[iNumeroZone]; int index = -1; for (int ij = 0; ij < strCodeBarre.length; ij++) { if (strCodeBarre[ij].equals(zone.getStrIdZone())) { index = ij; } } if (index != -1) { cbTouchesBarre.getSelectionModel().select(index); } cbTouchesBarre.valueProperty().addListener((ov, ancienneValeur, nouvelleValeur) -> { if (nouvelleValeur != null) { String strId = strCodeBarre[cbTouchesBarre.getSelectionModel().getSelectedIndex()]; zones[iNumeroZone].setStrIdZone(strId); } }); Label lblTypeBarre = new Label(zone.getStrTypeZone()); lblTypeBarre.setLayoutX(20); lblTypeBarre.setLayoutY(40); Label lblCoordsBarre = new Label(zone.getStrCoordonneesZone()); lblCoordsBarre.setLayoutX(20); lblCoordsBarre.setLayoutY(70); lblCoordsBarre.setPrefWidth(260); lblCoordsBarre.setMaxWidth(260); lblCoordsBarre.setWrapText(true); apZoneBarrePersonnalisee.getChildren().addAll(lblTypeBarre, lblCoordsBarre); switch (zone.getStrTypeZone()) { case "poly": Polygon poly = (Polygon) apImgBarrePersonnalisee.lookup("#" + strIdZone); poly.setFill(Color.rgb(255, 0, 0, 0.5)); poly.setStroke(Color.YELLOW); apImgBarrePersonnalisee.getChildren() .addAll(olCreeAncresPourPolygone(iNumeroZone, poly.getPoints())); break; case "rect": Rectangle rect = (Rectangle) apImgBarrePersonnalisee.lookup("#" + strIdZone); rect.setFill(Color.rgb(255, 0, 0, 0.5)); rect.setStroke(Color.YELLOW); apImgBarrePersonnalisee.getChildren().addAll(olCreeAncresPourRectangle(iNumeroZone, rect)); break; case "circle": Circle cercle = (Circle) apImgBarrePersonnalisee.lookup("#" + strIdZone); cercle.setFill(Color.rgb(255, 0, 0, 0.5)); cercle.setStroke(Color.YELLOW); apImgBarrePersonnalisee.getChildren().addAll(olCreeAncresPourCercle(iNumeroZone, cercle)); break; } } } }
From source file:editeurpanovisu.EditeurPanovisu.java
/** * * @param i/*w w w . j a v a 2 s. c o m*/ * @param longitude * @param latitude */ private static void afficheHSDiapo(int i, double longitude, double latitude) { double largeur = ivImagePanoramique.getFitWidth(); double X = (longitude + 180.0d) * largeur / 360.0d + ivImagePanoramique.getLayoutX(); double Y = (90.0d - latitude) * largeur / 360.0d; Circle circPoint = new Circle(X, Y, 5); circPoint.setFill(Color.TURQUOISE); circPoint.setStroke(Color.ORANGE); circPoint.setId("dia" + i); circPoint.setCursor(Cursor.DEFAULT); panePanoramique.getChildren().add(circPoint); Tooltip tltpHSImage = new Tooltip("Diaporama #" + (i + 1)); tltpHSImage.setStyle(getStrTooltipStyle()); Tooltip.install(circPoint, tltpHSImage); 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) -> { String strPoint = circPoint.getId(); strPoint = strPoint.substring(3, strPoint.length()); int iNumeroPoint = Integer.parseInt(strPoint); double X1 = mouseEvent1.getSceneX(); double Y1 = mouseEvent1.getSceneY(); double mouseX = X1 - ivImagePanoramique.getLayoutX(); if (mouseX < 0) { mouseX = 0; } if (mouseX > ivImagePanoramique.getFitWidth()) { mouseX = ivImagePanoramique.getFitWidth(); } double mouseY = Y1 - panePanoramique.getLayoutY() - 130 - getiDecalageMac(); if (mouseY < 0) { mouseY = 0; } if (mouseY > ivImagePanoramique.getFitHeight()) { mouseY = ivImagePanoramique.getFitHeight(); } double longit, lat; double larg = ivImagePanoramique.getFitWidth(); String strLong, strLat; longit = 360.0f * mouseX / larg - 180; lat = 90.0d - 2.0f * mouseY / 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); Node nodePointDiapo; nodePointDiapo = (Node) panePanoramique.lookup("#dia" + strPoint); if (mouseEvent1.isControlDown()) { valideHS(); setbDejaSauve(false); getStPrincipal().setTitle(getStPrincipal().getTitle().replace(" *", "") + " *"); panePanoramique.getChildren().remove(nodePointDiapo); for (int io = iNum + 1; io < getiNumDiapo(); io++) { nodePointDiapo = (Node) panePanoramique.lookup("#dia" + Integer.toString(io)); nodePointDiapo.setId("dia" + Integer.toString(io - 1)); } /** * on retire les anciennes indication de HS */ retireAffichageHotSpots(); setiNumDiapo(getiNumDiapo() - 1); getPanoramiquesProjet()[getiPanoActuel()].removeHotspotdiapo(iNum); /** * On les cre les nouvelles */ ajouteAffichageHotspots(); mouseEvent1.consume(); } else { if (!bDragDrop) { List<String> choixDiapo1 = new ArrayList<>(); for (int ii = 0; ii < getiNombreDiapo(); ii++) { choixDiapo1.add(diaporamas[ii].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")); // Traditional way to get the response value. Optional<String> result1 = dialog1.showAndWait(); if (result1.isPresent()) { boolean bTrouve = false; int iTrouve = -1; for (int ii = 0; ii < getiNombreDiapo(); ii++) { if (diaporamas[ii].getStrNomDiaporama().equals(result1.get())) { bTrouve = true; iTrouve = ii; } } if (bTrouve) { retireAffichageHotSpots(); getPanoramiquesProjet()[getiPanoActuel()].getHotspotDiapo(iNum).setiNumDiapo(iTrouve); valideHS(); ajouteAffichageHotspots(); } } } else { bDragDrop = false; } mouseEvent1.consume(); } }); }
From source file:editeurpanovisu.EditeurPanovisu.java
/** * * @param i// w w w. jav a 2s . com * @param longitude * @param latitude */ private static void afficheHSImage(int i, double longitude, double latitude) { double largeur = ivImagePanoramique.getFitWidth(); double X = (longitude + 180.0d) * largeur / 360.0d + ivImagePanoramique.getLayoutX(); double Y = (90.0d - latitude) * largeur / 360.0d; Circle circPoint = new Circle(X, Y, 5); circPoint.setFill(Color.BLUE); circPoint.setStroke(Color.YELLOW); circPoint.setId("img" + i); circPoint.setCursor(Cursor.DEFAULT); panePanoramique.getChildren().add(circPoint); Tooltip tltpHSImage = new Tooltip("image #" + (i + 1)); tltpHSImage.setStyle(getStrTooltipStyle()); Tooltip.install(circPoint, tltpHSImage); 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) -> { String strPoint = circPoint.getId(); strPoint = strPoint.substring(3, strPoint.length()); int iNumeroPoint = Integer.parseInt(strPoint); double X1 = mouseEvent1.getSceneX(); double Y1 = mouseEvent1.getSceneY(); double mouseX = X1 - ivImagePanoramique.getLayoutX(); if (mouseX < 0) { mouseX = 0; } if (mouseX > ivImagePanoramique.getFitWidth()) { mouseX = ivImagePanoramique.getFitWidth(); } double mouseY = Y1 - panePanoramique.getLayoutY() - 130 - getiDecalageMac(); if (mouseY < 0) { mouseY = 0; } if (mouseY > ivImagePanoramique.getFitHeight()) { mouseY = ivImagePanoramique.getFitHeight(); } double longit, lat; double larg = ivImagePanoramique.getFitWidth(); String strLong, strLat; longit = 360.0f * mouseX / larg - 180; lat = 90.0d - 2.0f * mouseY / 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); Node nodePointImage; nodePointImage = (Node) panePanoramique.lookup("#img" + strPoint); if (mouseEvent1.isControlDown()) { valideHS(); setbDejaSauve(false); getStPrincipal().setTitle(getStPrincipal().getTitle().replace(" *", "") + " *"); panePanoramique.getChildren().remove(nodePointImage); for (int io = iNum + 1; io < getiNumImages(); io++) { nodePointImage = (Node) panePanoramique.lookup("#img" + Integer.toString(io)); nodePointImage.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(); mouseEvent1.consume(); } else { if (!bDragDrop) { 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()); HotspotImage HS = getPanoramiquesProjet()[getiPanoActuel()].getHotspotImage(iNum); 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()].setHotspotImage(HS, iNum); retireAffichageHotSpots(); Pane affHS1 = paneAffichageHS(strListePano(), getiPanoActuel()); affHS1.setId("labels"); vbVisuHotspots.getChildren().add(affHS1); } } else { bDragDrop = false; } mouseEvent1.consume(); } }); }
From source file:editeurpanovisu.EditeurPanovisu.java
/** * * @param X/*from www . j a v a 2 s. c om*/ * @param Y */ private static void panoMouseClic(double X, double Y) { if (getiNombrePanoramiques() > 1) { valideHS(); setbDejaSauve(false); getStPrincipal().setTitle(getStPrincipal().getTitle().replace(" *", "") + " *"); double mouseX = X; double mouseY = Y - panePanoramique.getLayoutY() - 130 - getiDecalageMac(); if (X > 0 && X < ivImagePanoramique.getFitWidth()) { double longitude, latitude; double largeur = ivImagePanoramique.getFitWidth(); String strLong, strLat; 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.YELLOW); circPoint.setStroke(Color.RED); circPoint.setId("point" + getiNumPoints()); circPoint.setCursor(Cursor.DEFAULT); panePanoramique.getChildren().add(circPoint); Tooltip tltpPoint = new Tooltip("point n" + (getiNumPoints() + 1)); tltpPoint.setStyle(getStrTooltipStyle()); Tooltip.install(circPoint, tltpPoint); HotSpot HS = new HotSpot(); HS.setLongitude(longitude); HS.setLatitude(latitude); getPanoramiquesProjet()[getiPanoActuel()].addHotspot(HS); retireAffichageHotSpots(); dejaCharge = false; Pane paneAfficheHS1 = paneAffichageHS(strListePano(), getiPanoActuel()); paneAfficheHS1.setId("labels"); vbVisuHotspots.getChildren().add(paneAfficheHS1); spPanneauOutils.setVvalue(spPanneauOutils.getVvalue() + 300); setiNumPoints(getiNumPoints() + 1); if (getiNombrePanoramiques() > 1) { AnchorPane apListePanoVig = apAfficherListePanosVignettes( getPanoramiquesProjet()[getiPanoActuel()].getNombreHotspots() - 1); double positX = (panePanoramique.getPrefWidth() - apListePanoVig.getPrefWidth()) / 2.d; double positY = (panePanoramique.getPrefHeight() - apListePanoVig.getPrefHeight()) / 2.d; apListePanoVig.setLayoutX(positX); apListePanoVig.setLayoutY(positY); apPanneauPrincipal.getChildren().add(apListePanoVig); valideHS(); } circPoint.setOnDragDetected((mouseEvent1) -> { String strPoint = circPoint.getId(); strPoint = strPoint.substring(5, strPoint.length()); int numeroPoint = Integer.parseInt(strPoint); Node nodePoint; nodePoint = (Node) panePanoramique.lookup("#point" + strPoint); circPoint.setFill(Color.RED); circPoint.setStroke(Color.YELLOW); 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(5, 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()].getHotspot(iNumeroPoint).setLatitude(lat); getPanoramiquesProjet()[getiPanoActuel()].getHotspot(iNumeroPoint).setLongitude(longit); circPoint.setFill(Color.YELLOW); circPoint.setStroke(Color.RED); mouseEvent1.consume(); }); circPoint.setOnMouseClicked((mouseEvent1) -> { if (mouseEvent1.isControlDown()) { setbDejaSauve(false); getStPrincipal().setTitle(getStPrincipal().getTitle().replace(" *", "") + " *"); String strPoint = circPoint.getId(); strPoint = strPoint.substring(5, strPoint.length()); int iNumeroPoint = Integer.parseInt(strPoint); Node nodePoint; nodePoint = (Node) panePanoramique.lookup("#point" + strPoint); panePanoramique.getChildren().remove(nodePoint); for (int io = iNumeroPoint + 1; io < getiNumPoints(); io++) { nodePoint = (Node) panePanoramique.lookup("#point" + Integer.toString(io)); nodePoint.setId("point" + Integer.toString(io - 1)); } /** * on retire les anciennes indication de HS */ retireAffichageHotSpots(); setiNumPoints(getiNumPoints() - 1); getPanoramiquesProjet()[getiPanoActuel()].removeHotspot(iNumeroPoint); /** * On les cre les nouvelles */ ajouteAffichageHotspots(); valideHS(); mouseEvent1.consume(); } else { if (!bDragDrop) { setbDejaSauve(false); getStPrincipal().setTitle(getStPrincipal().getTitle().replace(" *", "") + " *"); String strPoint = circPoint.getId(); strPoint = strPoint.substring(5, strPoint.length()); int iNumeroPoint = Integer.parseInt(strPoint); if (getiNombrePanoramiques() > 1) { AnchorPane apListePanoVig = apAfficherListePanosVignettes(iNumeroPoint); double positX = (panePanoramique.getPrefWidth() - apListePanoVig.getPrefWidth()) / 2.d; double positY = (panePanoramique.getPrefHeight() - apListePanoVig.getPrefHeight()) / 2.d; apListePanoVig.setLayoutX(positX); apListePanoVig.setLayoutY(positY); apPanneauPrincipal.getChildren().add(apListePanoVig); } } else { bDragDrop = false; } valideHS(); mouseEvent1.consume(); } }); } } }
From source file:editeurpanovisu.EditeurPanovisu.java
/** * * @param X/*from w ww . ja v a 2s .c o m*/ * @param Y */ private static void panoAjouteHTML(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.DARKGREEN); circPoint.setStroke(Color.YELLOWGREEN); circPoint.setId("html" + getiNumHTML()); circPoint.setCursor(Cursor.DEFAULT); panePanoramique.getChildren().add(circPoint); Tooltip tltpImage = new Tooltip("HTML n " + (getiNumHTML() + 1)); tltpImage.setStyle(getStrTooltipStyle()); Tooltip.install(circPoint, tltpImage); EditeurHTML editHTML = new EditeurHTML(); HotspotHTML HS = new HotspotHTML(); editHTML.setHsHTML(HS); HS.setLongitude(longitude); HS.setLatitude(latitude); Rectangle2D tailleEcran = Screen.getPrimary().getBounds(); int iHauteur = (int) tailleEcran.getHeight() - 100; int iLargeur = (int) tailleEcran.getWidth() - 100; editHTML.affiche(iLargeur, iHauteur); editHTML.addPropertyChangeListener("bValide", (e) -> { if (e.getNewValue().toString().equals("true")) { setiNumHTML(getiNumHTML() + 1); getPanoramiquesProjet()[getiPanoActuel()].addHotspotHTML(editHTML.getHsHTML()); retireAffichageHotSpots(); dejaCharge = false; Pane affHS1 = paneAffichageHS(strListePano(), getiPanoActuel()); affHS1.setId("labels"); vbVisuHotspots.getChildren().add(affHS1); spPanneauOutils.setVvalue(spPanneauOutils.getVvalue() + 145); } }); editHTML.addPropertyChangeListener("bAnnule", (e) -> { if (e.getNewValue().toString().equals("true")) { String strPoint = circPoint.getId(); strPoint = strPoint.substring(4, strPoint.length()); Node nodeImage = (Node) panePanoramique.lookup("#html" + strPoint); panePanoramique.getChildren().remove(nodeImage); } }); valideHS(); circPoint.setOnDragDetected((mouseEvent1) -> { circPoint.setFill(Color.YELLOWGREEN); circPoint.setStroke(Color.DARKGREEN); 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(4, 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()].getHotspotHTML(iNumeroPoint).setLatitude(lat); getPanoramiquesProjet()[getiPanoActuel()].getHotspotHTML(iNumeroPoint).setLongitude(longit); circPoint.setFill(Color.DARKGREEN); circPoint.setStroke(Color.YELLOWGREEN); mouseEvent1.consume(); }); circPoint.setOnMouseClicked((mouseEvent1) -> { String strPoint = circPoint.getId(); strPoint = strPoint.substring(4, strPoint.length()); int iNum = Integer.parseInt(strPoint); if (mouseEvent1.isControlDown()) { setbDejaSauve(false); getStPrincipal().setTitle(getStPrincipal().getTitle().replace(" *", "") + " *"); Node nodeImage; nodeImage = (Node) panePanoramique.lookup("#html" + strPoint); panePanoramique.getChildren().remove(nodeImage); for (int io = iNum + 1; io < getiNumHTML(); io++) { nodeImage = (Node) panePanoramique.lookup("#html" + Integer.toString(io)); nodeImage.setId("html" + Integer.toString(io - 1)); } /** * on retire les anciennes indication de HS */ retireAffichageHotSpots(); setiNumHTML(getiNumHTML() - 1); getPanoramiquesProjet()[getiPanoActuel()].removeHotspotHTML(iNum); /** * On les cre les nouvelles */ ajouteAffichageHotspots(); } else { if (!bDragDrop) { setbDejaSauve(false); getStPrincipal().setTitle(getStPrincipal().getTitle().replace(" *", "") + " *"); EditeurHTML editHTML1 = new EditeurHTML(); HotspotHTML HS1 = getPanoramiquesProjet()[getiPanoActuel()].getHotspotHTML(iNum); editHTML1.setHsHTML(HS1); Rectangle2D tailleEcran1 = Screen.getPrimary().getBounds(); int iHauteur1 = (int) tailleEcran1.getHeight() - 100; int iLargeur1 = (int) tailleEcran1.getWidth() - 100; editHTML1.affiche(iLargeur1, iHauteur1); editHTML1.addPropertyChangeListener("bValide", (ev) -> { if (ev.getNewValue().toString().equals("true")) { getPanoramiquesProjet()[getiPanoActuel()].setHotspotHTML(editHTML1.getHsHTML(), iNum); retireAffichageHotSpots(); dejaCharge = false; Pane affHS1 = paneAffichageHS(strListePano(), getiPanoActuel()); affHS1.setId("labels"); vbVisuHotspots.getChildren().add(affHS1); apVisuHS.setPrefHeight(affHS1.getPrefHeight()); } }); } else { bDragDrop = false; } mouseEvent1.consume(); } valideHS(); mouseEvent1.consume(); }); } }
From source file:editeurpanovisu.EditeurPanovisu.java
/** * * @param X//ww w. j av a2 s . c o m * @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(); }); } }
From source file:editeurpanovisu.EditeurPanovisu.java
/** * * @param X//from w w w.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 iLargeur/*from w w w. j a v a2s.c o m*/ * @param iHauteur * @param bMasqueZones */ private static void ajouterZone(int iLargeur, int iHauteur, boolean bMasqueZones) { if (iNombreZones == -1) { iNombreZones = 0; } final ZoneTelecommande zone = new ZoneTelecommande(); strTypeZone = "poly"; zone.setStrTypeZone(strTypeZone); iNombrePointsZone = 0; bRecommenceZone = false; apZoneBarrePersonnalisee.getChildren().clear(); Button btnAnnuler = new Button(rbLocalisation.getString("main.annuler"), new ImageView(new Image("file:" + getStrRepertAppli() + "/images/annule.png"))); Button btnValider = new Button(rbLocalisation.getString("main.valider"), new ImageView(new Image("file:" + getStrRepertAppli() + "/images/valide.png"))); btnValider.setLayoutX(180); btnValider.setLayoutY(170); btnAnnuler.setLayoutX(80); btnAnnuler.setLayoutY(170); ToggleGroup tgTypeZone = new ToggleGroup(); Label lblTypeZone = new Label(rbLocalisation.getString("main.typeZone")); lblTypeZone.setLayoutX(20); lblTypeZone.setLayoutY(10); RadioButton rbCercleZone = new RadioButton(rbLocalisation.getString("main.cercle")); rbCercleZone.setLayoutX(20); rbCercleZone.setLayoutY(40); rbCercleZone.setUserData("circle"); rbCercleZone.setToggleGroup(tgTypeZone); RadioButton rbRectZone = new RadioButton(rbLocalisation.getString("main.rectangle")); rbRectZone.setLayoutX(120); rbRectZone.setLayoutY(40); rbRectZone.setUserData("rect"); rbRectZone.setToggleGroup(tgTypeZone); RadioButton rbPolyZone = new RadioButton(rbLocalisation.getString("main.polygone")); rbPolyZone.setLayoutX(220); rbPolyZone.setLayoutY(40); rbPolyZone.setUserData("poly"); rbPolyZone.setToggleGroup(tgTypeZone); rbPolyZone.setSelected(true); ComboBox cbTouchesBarre = new ComboBox(); cbTouchesBarre.getItems().clear(); for (int i = 0; i < strTouchesBarre.length; i++) { cbTouchesBarre.getItems().add(i, strTouchesBarre[i]); } cbTouchesBarre.setLayoutX(50); cbTouchesBarre.setLayoutY(110); afficheBarrePersonnalisee(iLargeur, iHauteur, bMasqueZones); AnchorPane apCreeZone = new AnchorPane(); apCreeZone.setStyle("-fx-background-color : rgba(0,0,0,0.1)"); apCreeZone.setPrefWidth(imgBarrePersonnalisee.getWidth()); apCreeZone.setPrefHeight(imgBarrePersonnalisee.getHeight()); apCreeZone.setCursor(Cursor.CROSSHAIR); apImgBarrePersonnalisee.getChildren().add(apCreeZone); apZoneBarrePersonnalisee.getChildren().addAll(lblTypeZone, rbCercleZone, rbRectZone, rbPolyZone, cbTouchesBarre, btnAnnuler, btnValider); apCreeZone.setOnMouseClicked((t) -> { rbCercleZone.setDisable(true); rbRectZone.setDisable(true); rbPolyZone.setDisable(true); iNombrePointsZone++; switch (strTypeZone) { case "rect": if (iNombrePointsZone == 1) { apCreeZone.getChildren().clear(); x1Zone = t.getX(); y1Zone = t.getY(); Circle cercle = new Circle(t.getX(), t.getY(), 4); cercle.setFill(Color.rgb(255, 0, 0, 0.5)); cercle.setStroke(Color.YELLOW); apCreeZone.getChildren().add(cercle); } if (iNombrePointsZone == 2) { apCreeZone.getChildren().clear(); Rectangle rect = new Rectangle(x1Zone, y1Zone, t.getX() - x1Zone, t.getY() - y1Zone); rect.setFill(Color.rgb(255, 0, 0, 0.5)); rect.setStroke(Color.YELLOW); apCreeZone.getChildren().add(rect); String chaine = Math.round(x1Zone * 10) / 10 + "," + Math.round(y1Zone * 10) / 10 + "," + Math.round(t.getX() * 10) / 10 + "," + Math.round(t.getY() * 10) / 10; zone.setStrCoordonneesZone(chaine); iNombrePointsZone = 0; } break; case "circle": if (iNombrePointsZone == 1) { apCreeZone.getChildren().clear(); x1Zone = t.getX(); y1Zone = t.getY(); Circle cercle = new Circle(t.getX(), t.getY(), 4); cercle.setFill(Color.rgb(255, 0, 0, 0.5)); cercle.setStroke(Color.YELLOW); apCreeZone.getChildren().add(cercle); } if (iNombrePointsZone == 2) { apCreeZone.getChildren().clear(); double rayon = Math.sqrt(Math.pow(x1Zone - t.getX(), 2.d) + Math.pow(y1Zone - t.getY(), 2.d)); Circle cercle = new Circle(x1Zone, y1Zone, rayon); cercle.setFill(Color.rgb(255, 0, 0, 0.5)); cercle.setStroke(Color.YELLOW); apCreeZone.getChildren().add(cercle); String chaine = Math.round(x1Zone * 10) / 10 + "," + Math.round(y1Zone * 10) / 10 + "," + Math.round(rayon * 10) / 10; zone.setStrCoordonneesZone(chaine); iNombrePointsZone = 0; } break; case "poly": if (bRecommenceZone) { bRecommenceZone = false; iNombrePointsZone = 1; } if (iNombrePointsZone == 1) { apCreeZone.getChildren().clear(); x1Zone = t.getX(); y1Zone = t.getY(); Circle cercle = new Circle(t.getX(), t.getY(), 4); cercle.setFill(Color.rgb(255, 0, 0, 0.5)); cercle.setStroke(Color.YELLOW); apCreeZone.getChildren().add(cercle); pointsPolyZone[(iNombrePointsZone - 1) * 2] = t.getX(); pointsPolyZone[(iNombrePointsZone - 1) * 2 + 1] = t.getY(); } if (iNombrePointsZone == 2) { apCreeZone.getChildren().clear(); Line ligne = new Line(x1Zone, y1Zone, t.getX(), t.getY()); ligne.setStroke(Color.YELLOW); apCreeZone.getChildren().add(ligne); pointsPolyZone[(iNombrePointsZone - 1) * 2] = t.getX(); pointsPolyZone[(iNombrePointsZone - 1) * 2 + 1] = t.getY(); } if (iNombrePointsZone > 2) { pointsPolyZone[(iNombrePointsZone - 1) * 2] = t.getX(); pointsPolyZone[(iNombrePointsZone - 1) * 2 + 1] = t.getY(); apCreeZone.getChildren().clear(); Polygon poly = new Polygon(); for (int i = 0; i < iNombrePointsZone; i++) { poly.getPoints().addAll(pointsPolyZone[i * 2], pointsPolyZone[i * 2 + 1]); } poly.setFill(Color.rgb(255, 0, 0, 0.5)); poly.setStroke(Color.YELLOW); apCreeZone.getChildren().add(poly); } if (t.getClickCount() == 2) { String chaine = ""; for (int i = 0; i < iNombrePointsZone; i++) { if (i != 0) { chaine += ","; } chaine += Math.round(pointsPolyZone[i * 2] * 10) / 10 + "," + Math.round(pointsPolyZone[i * 2 + 1] * 10) / 10; } zone.setStrCoordonneesZone(chaine); bRecommenceZone = true; } break; } }); apCreeZone.setOnMouseMoved((t) -> { switch (strTypeZone) { case "rect": if (iNombrePointsZone == 1) { apCreeZone.getChildren().clear(); Rectangle rect = new Rectangle(x1Zone, y1Zone, t.getX() - x1Zone, t.getY() - y1Zone); rect.setFill(Color.rgb(255, 0, 0, 0.5)); rect.setStroke(Color.YELLOW); apCreeZone.getChildren().add(rect); } break; case "circle": if (iNombrePointsZone == 1) { apCreeZone.getChildren().clear(); double rayon = Math.sqrt(Math.pow(x1Zone - t.getX(), 2.d) + Math.pow(y1Zone - t.getY(), 2.d)); Circle cercle = new Circle(x1Zone, y1Zone, rayon); cercle.setFill(Color.rgb(255, 0, 0, 0.5)); cercle.setStroke(Color.YELLOW); apCreeZone.getChildren().add(cercle); } break; case "poly": if (!bRecommenceZone) { if (iNombrePointsZone == 1) { apCreeZone.getChildren().clear(); Line ligne = new Line(x1Zone, y1Zone, t.getX(), t.getY()); ligne.setStroke(Color.YELLOW); apCreeZone.getChildren().add(ligne); } if (iNombrePointsZone > 1) { apCreeZone.getChildren().clear(); Polygon poly = new Polygon(); for (int i = 0; i < iNombrePointsZone; i++) { poly.getPoints().addAll(pointsPolyZone[i * 2], pointsPolyZone[i * 2 + 1]); } poly.getPoints().addAll(t.getX(), t.getY()); poly.setFill(Color.rgb(255, 0, 0, 0.5)); poly.setStroke(Color.YELLOW); apCreeZone.getChildren().add(poly); } } break; } }); btnValider.setOnMouseClicked((t) -> { if (strTypeZone.equals("poly")) { String strChaine = ""; for (int i = 0; i < iNombrePointsZone; i++) { if (i != 0) { strChaine += ","; } strChaine += Math.round(pointsPolyZone[i * 2] * 10) / 10 + "," + Math.round(pointsPolyZone[i * 2 + 1] * 10) / 10; } zone.setStrCoordonneesZone(strChaine); } zones[iNombreZones] = zone; iNombreZones++; afficheBarrePersonnalisee(iLargeur, iHauteur, bMasqueZones); btnAjouteZone.setDisable(false); }); btnAnnuler.setOnMouseClicked((t) -> { afficheBarrePersonnalisee(iLargeur, iHauteur, bMasqueZones); btnAjouteZone.setDisable(false); }); cbTouchesBarre.valueProperty().addListener((ov, strAncienneValeur, strNouvelleValeur) -> { if (strNouvelleValeur != null) { String strId = strCodeBarre[cbTouchesBarre.getSelectionModel().getSelectedIndex()]; zone.setStrIdZone(strId); } }); tgTypeZone.selectedToggleProperty() .addListener((ObservableValue<? extends Toggle> ov, Toggle old_toggle, Toggle new_toggle) -> { if (tgTypeZone.getSelectedToggle() != null) { strTypeZone = tgTypeZone.getSelectedToggle().getUserData().toString(); zone.setStrTypeZone(strTypeZone); } }); }