Example usage for javafx.scene.layout AnchorPane getPrefHeight

List of usage examples for javafx.scene.layout AnchorPane getPrefHeight

Introduction

In this page you can find the example usage for javafx.scene.layout AnchorPane getPrefHeight.

Prototype

public final double getPrefHeight() 

Source Link

Usage

From source file:editeurpanovisu.EditeurPanovisu.java

/**
 *
 * @param i/*from   www. ja v a  2s . c  om*/
 * @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 X//from w w  w  . j av  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();

                }
            });
        }
    }
}

From source file:editeurpanovisu.EditeurPanovisu.java

/**
 *
 * @return/* w  ww .  jav  a2s  . c  o m*/
 */
private static ScrollPane spAfficheLegende() {
    double positionX;
    double positionY;
    AnchorPane apLegende = new AnchorPane();
    ScrollPane spLegende = new ScrollPane(apLegende);
    spLegende.getStyleClass().add("legendePane");

    apLegende.setMinWidth(1000);
    apLegende.setMinHeight(150);
    apLegende.setPrefWidth(1000);
    apLegende.setPrefHeight(150);
    apLegende.setMaxWidth(1000);
    apLegende.setMaxHeight(150);
    positionY = (spVuePanoramique.getPrefHeight() - apLegende.getPrefHeight() - 15);

    Circle circPoint = new Circle(30, 20, 5);
    circPoint.setFill(Color.YELLOW);
    circPoint.setStroke(Color.RED);
    circPoint.setCursor(Cursor.DEFAULT);
    Circle circPoint2 = new Circle(30, 40, 5);
    circPoint2.setFill(Color.BLUE);
    circPoint2.setStroke(Color.YELLOW);
    circPoint2.setCursor(Cursor.DEFAULT);
    Circle circPoint3 = new Circle(30, 60, 5);
    circPoint3.setFill(Color.GREEN);
    circPoint3.setStroke(Color.YELLOW);
    circPoint3.setCursor(Cursor.DEFAULT);
    Polygon polygonCroix = new Polygon();
    polygonCroix.getPoints().addAll(new Double[] { 15.0, 2.0, 2.0, 2.0, 2.0, 15.0, -2.0, 15.0, -2.0, 2.0, -15.0,
            2.0, -15.0, -2.0, -2.0, -2.0, -2.0, -15.0, 2.0, -15.0, 2.0, -2.0, 15.0, -2.0 });
    polygonCroix.setStrokeLineJoin(StrokeLineJoin.MITER);
    polygonCroix.setFill(Color.BLUEVIOLET);
    polygonCroix.setStroke(Color.YELLOW);
    polygonCroix.setId("PoV");
    polygonCroix.setLayoutX(500);
    polygonCroix.setLayoutY(20);
    Label lblHS = new Label(rbLocalisation.getString("main.legendeHS"));
    Label lblHSImage = new Label(rbLocalisation.getString("main.legendeHSImage"));
    Label lblHSHTML = new Label(rbLocalisation.getString("main.legendeHSHTML"));
    Label lblPoV = new Label(rbLocalisation.getString("main.legendePoV"));
    Label lblNord = new Label(rbLocalisation.getString("main.legendeNord"));
    Line lineNord = new Line(500, 45, 500, 65);
    lineNord.setStroke(Color.RED);
    lineNord.setStrokeWidth(3);
    lblHS.setLayoutX(50);
    lblHS.setLayoutY(15);
    lblHSImage.setLayoutX(50);
    lblHSImage.setLayoutY(35);
    lblHSHTML.setLayoutX(50);
    lblHSHTML.setLayoutY(55);
    lblPoV.setLayoutX(520);
    lblPoV.setLayoutY(15);
    lblNord.setLayoutX(520);
    lblNord.setLayoutY(55);
    apLegende.getChildren().addAll(lblHS, circPoint, lblHSImage, circPoint2, lblHSHTML, circPoint3, lblPoV,
            polygonCroix, lblNord, lineNord);
    apLegende.setId("legende");
    apLegende.setVisible(true);
    if (largeurMax - 50 < 1004) {
        spLegende.setPrefWidth(largeurMax - 50);
        spLegende.setMaxWidth(largeurMax - 50);
        positionX = 25;
    } else {
        spLegende.setPrefWidth(1004);
        spLegende.setMaxWidth(1004);
        positionX = (largeurMax - 1004) / 2.d;
    }
    spLegende.setLayoutX(positionX);
    spLegende.setLayoutY(positionY);
    spLegende.setVbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
    spLegende.setHbarPolicy(ScrollPane.ScrollBarPolicy.AS_NEEDED);

    return spLegende;
}