Example usage for javafx.scene Node setId

List of usage examples for javafx.scene Node setId

Introduction

In this page you can find the example usage for javafx.scene Node setId.

Prototype

public final void setId(String value) 

Source Link

Usage

From source file:editeurpanovisu.EditeurPanovisu.java

/**
 *
 * @param X/* ww  w .j  a  va 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/*from w w  w. ja v a 2 s.co  m*/
 * @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();

                }
            });
        }
    }
}