Example usage for javafx.scene.control Tooltip Tooltip

List of usage examples for javafx.scene.control Tooltip Tooltip

Introduction

In this page you can find the example usage for javafx.scene.control Tooltip Tooltip.

Prototype

public Tooltip(String text) 

Source Link

Document

Creates a tooltip with the specified text.

Usage

From source file:editeurpanovisu.EditeurPanovisu.java

/**
 *
 * @param i// ww  w . j a va 2  s.c o m
 * @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 X//from w  w w  .j av a2s  . 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  w w  .  j  a  va 2s  .  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// w w w. java2  s . 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  ww w . j  a  v a  2  s  .  co 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 vbRacine panel d'installation du menu
 * @throws Exception Exceptions// ww w . ja v a2s . co m
 */
private static void creeMenu(VBox vbRacine) throws Exception {
    VBox vbMonPanneau = new VBox();

    vbMonPanneau.setPrefHeight(80);
    vbMonPanneau.setPrefWidth(3000);
    mbarPrincipal.setMinHeight(29);
    mbarPrincipal.setPrefHeight(29);
    mbarPrincipal.setMaxHeight(29);
    mbarPrincipal.setPrefWidth(3000);
    if (isMac()) {
        mbarPrincipal.setUseSystemMenuBar(true);
    }
    /* 
     Menu projets
     */
    Menu mnuProjet = new Menu(rbLocalisation.getString("projets"));

    mbarPrincipal.getMenus().add(mnuProjet);
    mniNouveauProjet = new MenuItem(rbLocalisation.getString("nouveauProjet"));
    mniNouveauProjet.setAccelerator(new KeyCodeCombination(KeyCode.N, KeyCombination.SHORTCUT_DOWN));
    mnuProjet.getItems().add(mniNouveauProjet);
    mniChargeProjet = new MenuItem(rbLocalisation.getString("ouvrirProjet"));
    mniChargeProjet.setAccelerator(new KeyCodeCombination(KeyCode.O, KeyCombination.SHORTCUT_DOWN));

    mnuProjet.getItems().add(mniChargeProjet);
    mniSauveProjet = new MenuItem(rbLocalisation.getString("sauverProjet"));
    mniSauveProjet.setDisable(true);
    mniSauveProjet.setAccelerator(new KeyCodeCombination(KeyCode.S, KeyCombination.SHORTCUT_DOWN));
    mnuProjet.getItems().add(mniSauveProjet);
    mniSauveSousProjet = new MenuItem(rbLocalisation.getString("sauverProjetSous"));
    mniSauveSousProjet.setDisable(true);
    mniSauveSousProjet.setAccelerator(
            new KeyCodeCombination(KeyCode.S, KeyCombination.SHORTCUT_DOWN, KeyCodeCombination.SHIFT_DOWN));
    mnuProjet.getItems().add(mniSauveSousProjet);
    mnuDerniersProjets = new Menu(rbLocalisation.getString("derniersProjets"));
    mnuProjet.getItems().add(mnuDerniersProjets);
    fileHistoFichiers = new File(fileRepertConfig.getAbsolutePath() + File.separator + "derniersprojets.cfg");
    nombreHistoFichiers = 0;
    if (fileHistoFichiers.exists()) {
        try (BufferedReader brHistoFichiers = new BufferedReader(
                new InputStreamReader(new FileInputStream(fileHistoFichiers), "UTF-8"))) {
            while ((strTexteHisto = brHistoFichiers.readLine()) != null) {
                MenuItem menuDerniersFichiers = new MenuItem(strTexteHisto);
                mnuDerniersProjets.getItems().add(menuDerniersFichiers);
                strHistoFichiers[nombreHistoFichiers] = strTexteHisto;
                nombreHistoFichiers++;
                menuDerniersFichiers.setOnAction((e) -> {
                    MenuItem mniSousMenu = (MenuItem) e.getSource();
                    try {
                        try {
                            projetChargeNom(mniSousMenu.getText());

                        } catch (InterruptedException ex) {
                            Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex);
                        }

                    } catch (IOException ex) {
                        Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex);
                    }
                });

            }
        }
    }

    SeparatorMenuItem sepMenu1 = new SeparatorMenuItem();
    mnuProjet.getItems().add(sepMenu1);
    mniFermerProjet = new MenuItem(rbLocalisation.getString("quitterApplication"));
    mniFermerProjet.setAccelerator(new KeyCodeCombination(KeyCode.A, KeyCombination.SHORTCUT_DOWN));
    mnuProjet.getItems().add(mniFermerProjet);
    /*
     Menu affichage
     */
    Menu mnuAffichage = new Menu(rbLocalisation.getString("affichage"));
    mbarPrincipal.getMenus().add(mnuAffichage);
    mniAffichageVisite = new MenuItem(rbLocalisation.getString("main.creationVisite"));
    mniAffichageVisite.setAccelerator(new KeyCodeCombination(KeyCode.DIGIT1, KeyCombination.SHORTCUT_DOWN));
    mnuAffichage.getItems().add(mniAffichageVisite);
    mniAffichageInterface = new MenuItem(rbLocalisation.getString("main.creationInterface"));
    mniAffichageInterface.setAccelerator(new KeyCodeCombination(KeyCode.DIGIT2, KeyCombination.SHORTCUT_DOWN));
    mnuAffichage.getItems().add(mniAffichageInterface);
    setMniAffichagePlan(new MenuItem(rbLocalisation.getString("main.tabPlan")));
    getMniAffichagePlan().setAccelerator(new KeyCodeCombination(KeyCode.DIGIT3, KeyCombination.SHORTCUT_DOWN));
    getMniAffichagePlan().setDisable(true);
    mnuAffichage.getItems().add(getMniAffichagePlan());
    mniOutilsLoupe = new MenuItem(rbLocalisation.getString("main.loupe"));
    mniOutilsLoupe.setAccelerator(new KeyCodeCombination(KeyCode.L, KeyCombination.SHORTCUT_DOWN));
    mnuAffichage.getItems().add(mniOutilsLoupe);

    SeparatorMenuItem sep3 = new SeparatorMenuItem();
    mnuAffichage.getItems().add(sep3);
    mniConfigTransformation = new MenuItem(rbLocalisation.getString("affichageConfiguration"));
    mnuAffichage.getItems().add(mniConfigTransformation);

    /*
     Menu panoramiques
     */
    mnuPanoramique = new Menu(rbLocalisation.getString("panoramiques"));
    mnuPanoramique.setDisable(true);
    mbarPrincipal.getMenus().add(mnuPanoramique);
    mniAjouterPano = new MenuItem(rbLocalisation.getString("ajouterPanoramiques"));
    mniAjouterPano.setAccelerator(new KeyCodeCombination(KeyCode.A, KeyCombination.SHORTCUT_DOWN));
    mnuPanoramique.getItems().add(mniAjouterPano);
    setMniAjouterPlan(new MenuItem(rbLocalisation.getString("ajouterPlan")));
    getMniAjouterPlan().setAccelerator(new KeyCodeCombination(KeyCode.P, KeyCombination.SHORTCUT_DOWN));
    mnuPanoramique.getItems().add(getMniAjouterPlan());
    getMniAjouterPlan().setDisable(true);
    SeparatorMenuItem sep2 = new SeparatorMenuItem();
    mnuPanoramique.getItems().add(sep2);
    mniVisiteGenere = new MenuItem(rbLocalisation.getString("genererVisite"));
    mniVisiteGenere.setDisable(true);
    mniVisiteGenere.setAccelerator(new KeyCodeCombination(KeyCode.V, KeyCombination.SHORTCUT_DOWN));
    mnuPanoramique.getItems().add(mniVisiteGenere);
    /*
     Menu Modles 
     */
    mnuModeles = new Menu(rbLocalisation.getString("menuModele"));
    mbarPrincipal.getMenus().add(mnuModeles);

    mniChargerModele = new MenuItem(rbLocalisation.getString("modeleCharger"));
    mnuModeles.getItems().add(mniChargerModele);

    mniSauverModele = new MenuItem(rbLocalisation.getString("modeleSauver"));
    mnuModeles.getItems().add(mniSauverModele);

    /*
     Menu transformations 
     */
    mnuTransformation = new Menu(rbLocalisation.getString("outils"));
    mbarPrincipal.getMenus().add(mnuTransformation);
    mniEqui2CubeTransformation = new MenuItem(rbLocalisation.getString("outilsEqui2Cube"));
    mnuTransformation.getItems().add(mniEqui2CubeTransformation);
    mniCube2EquiTransformation = new MenuItem(rbLocalisation.getString("outilsCube2Equi"));
    mnuTransformation.getItems().add(mniCube2EquiTransformation);
    SeparatorMenuItem sep6 = new SeparatorMenuItem();
    mnuTransformation.getItems().add(sep6);
    mniOutilsBarre = new MenuItem(rbLocalisation.getString("outilsBarre"));
    mniOutilsBarre.setAccelerator(new KeyCodeCombination(KeyCode.B, KeyCombination.SHORTCUT_DOWN));
    mnuTransformation.getItems().add(mniOutilsBarre);
    mniOutilsDiaporama = new MenuItem(rbLocalisation.getString("outilsDiaporama"));
    mniOutilsDiaporama.setAccelerator(new KeyCodeCombination(KeyCode.D, KeyCombination.SHORTCUT_DOWN));
    mnuTransformation.getItems().add(mniOutilsDiaporama);

    /*
     Menu Aide
     */
    Menu mnuAide = new Menu(rbLocalisation.getString("aide"));
    mbarPrincipal.getMenus().add(mnuAide);
    mniAide = new MenuItem(rbLocalisation.getString("aideAide"));
    mniAide.setAccelerator(new KeyCodeCombination(KeyCode.H, KeyCombination.SHORTCUT_DOWN));
    mnuAide.getItems().add(mniAide);
    SeparatorMenuItem sep4 = new SeparatorMenuItem();
    mnuAide.getItems().add(sep4);
    mniAPropos = new MenuItem(rbLocalisation.getString("aideAPropos"));
    mnuAide.getItems().add(mniAPropos);
    //
    //        }
    //
    /*
     barre de boutons 
     */
    hbBarreBouton = new HBox();
    hbBarreBouton.getStyleClass().add("menuBarreOutils1");

    hbBarreBouton.setPrefHeight(50);
    hbBarreBouton.setMinHeight(50);
    hbBarreBouton.setPrefWidth(3000);
    /*
     Bouton nouveau Projet
     */
    ScrollPane spBtnNouvprojet = new ScrollPane();
    spBtnNouvprojet.getStyleClass().add("menuBarreOutils");
    spBtnNouvprojet.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
    spBtnNouvprojet.setPrefHeight(35);
    spBtnNouvprojet.setMaxHeight(35);
    spBtnNouvprojet.setPadding(new Insets(2));
    spBtnNouvprojet.setPrefWidth(35);

    HBox.setMargin(spBtnNouvprojet, new Insets(5, 15, 0, 15));
    ivNouveauProjet = new ImageView(
            new Image("file:" + getStrRepertAppli() + File.separator + "images/nouveauProjet.png"));
    spBtnNouvprojet.setContent(ivNouveauProjet);
    Tooltip tltpNouveauProjet = new Tooltip(rbLocalisation.getString("nouveauProjet"));
    tltpNouveauProjet.setStyle(getStrTooltipStyle());
    spBtnNouvprojet.setTooltip(tltpNouveauProjet);
    hbBarreBouton.getChildren().add(spBtnNouvprojet);
    /*
     Bouton ouvrir Projet
     */
    ScrollPane spBtnOuvrirProjet = new ScrollPane();
    spBtnOuvrirProjet.getStyleClass().add("menuBarreOutils");
    spBtnOuvrirProjet.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
    spBtnOuvrirProjet.setPrefHeight(35);
    spBtnOuvrirProjet.setMaxHeight(35);
    spBtnOuvrirProjet.setPadding(new Insets(2));
    spBtnOuvrirProjet.setPrefWidth(35);

    HBox.setMargin(spBtnOuvrirProjet, new Insets(5, 15, 0, 0));
    ivChargeProjet = new ImageView(
            new Image("file:" + getStrRepertAppli() + File.separator + "images/ouvrirProjet.png"));
    spBtnOuvrirProjet.setContent(ivChargeProjet);
    Tooltip tltpOuvrirProjet = new Tooltip(rbLocalisation.getString("ouvrirProjet"));
    tltpOuvrirProjet.setStyle(getStrTooltipStyle());
    spBtnOuvrirProjet.setTooltip(tltpOuvrirProjet);
    hbBarreBouton.getChildren().add(spBtnOuvrirProjet);

    /*
     Bouton sauve Projet
     */
    ScrollPane spBtnSauveProjet = new ScrollPane();
    spBtnSauveProjet.getStyleClass().add("menuBarreOutils");
    spBtnSauveProjet.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
    spBtnSauveProjet.setPrefHeight(35);
    spBtnSauveProjet.setMaxHeight(35);
    spBtnSauveProjet.setPadding(new Insets(2));
    spBtnSauveProjet.setPrefWidth(35);

    HBox.setMargin(spBtnSauveProjet, new Insets(5, 15, 0, 0));
    ivSauveProjet = new ImageView(
            new Image("file:" + getStrRepertAppli() + File.separator + "images/sauveProjet.png"));
    spBtnSauveProjet.setContent(ivSauveProjet);
    Tooltip tltpSauverProjet = new Tooltip(rbLocalisation.getString("sauverProjet"));
    tltpSauverProjet.setStyle(getStrTooltipStyle());
    spBtnSauveProjet.setTooltip(tltpSauverProjet);
    hbBarreBouton.getChildren().add(spBtnSauveProjet);
    Separator sepImages = new Separator(Orientation.VERTICAL);
    sepImages.prefHeight(200);
    hbBarreBouton.getChildren().add(sepImages);
    ivSauveProjet.setDisable(true);
    ivSauveProjet.setOpacity(0.3);
    /*
     Bouton Ajoute Panoramique
     */
    ScrollPane spBtnAjoutePano = new ScrollPane();
    spBtnAjoutePano.getStyleClass().add("menuBarreOutils");
    spBtnAjoutePano.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
    spBtnAjoutePano.setPrefHeight(35);
    spBtnAjoutePano.setMaxHeight(35);
    spBtnAjoutePano.setPadding(new Insets(2));
    spBtnAjoutePano.setPrefWidth(35);

    HBox.setMargin(spBtnAjoutePano, new Insets(5, 15, 0, 15));
    ivAjouterPano = new ImageView(
            new Image("file:" + getStrRepertAppli() + File.separator + "images/ajoutePanoramique.png"));
    spBtnAjoutePano.setContent(ivAjouterPano);
    Tooltip tltpAjouterPano = new Tooltip(rbLocalisation.getString("ajouterPanoramiques"));
    tltpAjouterPano.setStyle(getStrTooltipStyle());
    spBtnAjoutePano.setTooltip(tltpAjouterPano);
    hbBarreBouton.getChildren().add(spBtnAjoutePano);
    ivAjouterPano.setDisable(true);
    ivAjouterPano.setOpacity(0.3);

    /*
     Bouton Ajoute Panoramique
     */
    ScrollPane spBtnAjoutePlan = new ScrollPane();
    spBtnAjoutePlan.getStyleClass().add("menuBarreOutils");
    spBtnAjoutePlan.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
    spBtnAjoutePlan.setPrefHeight(35);
    spBtnAjoutePlan.setMaxHeight(35);
    spBtnAjoutePlan.setPadding(new Insets(2));
    spBtnAjoutePlan.setPrefWidth(35);

    HBox.setMargin(spBtnAjoutePlan, new Insets(5, 15, 0, 15));
    setIvAjouterPlan(
            new ImageView(new Image("file:" + getStrRepertAppli() + File.separator + "images/ajoutePlan.png")));
    spBtnAjoutePlan.setContent(getIvAjouterPlan());
    Tooltip tltpAjouterPlan = new Tooltip(rbLocalisation.getString("ajouterPlan"));
    tltpAjouterPlan.setStyle(getStrTooltipStyle());
    spBtnAjoutePlan.setTooltip(tltpAjouterPlan);
    hbBarreBouton.getChildren().add(spBtnAjoutePlan);
    getIvAjouterPlan().setDisable(true);
    getIvAjouterPlan().setOpacity(0.3);

    /*
     Bouton Gnre
     */
    ScrollPane spBtnGenereVisite = new ScrollPane();
    spBtnGenereVisite.getStyleClass().add("menuBarreOutils");
    spBtnGenereVisite.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
    spBtnGenereVisite.setPrefHeight(35);
    spBtnGenereVisite.setMaxHeight(35);
    spBtnGenereVisite.setPadding(new Insets(2));
    spBtnGenereVisite.setPrefWidth(70);

    HBox.setMargin(spBtnGenereVisite, new Insets(5, 15, 0, 0));
    ivVisiteGenere = new ImageView(
            new Image("file:" + getStrRepertAppli() + File.separator + "images/genereVisite.png"));
    spBtnGenereVisite.setContent(ivVisiteGenere);
    Tooltip tltpGenererVisite = new Tooltip(rbLocalisation.getString("genererVisite"));
    tltpGenererVisite.setStyle(getStrTooltipStyle());
    spBtnGenereVisite.setTooltip(tltpGenererVisite);
    hbBarreBouton.getChildren().add(spBtnGenereVisite);
    ivVisiteGenere.setDisable(true);
    ivVisiteGenere.setOpacity(0.3);
    Separator sepImages1 = new Separator(Orientation.VERTICAL);
    sepImages1.prefHeight(200);
    hbBarreBouton.getChildren().add(sepImages1);
    /*
     Bouton equi -> faces de  Cube
     */
    ScrollPane spBtnEqui2Cube = new ScrollPane();
    spBtnEqui2Cube.getStyleClass().add("menuBarreOutils");
    spBtnEqui2Cube.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
    spBtnEqui2Cube.setPrefHeight(35);
    spBtnEqui2Cube.setMaxHeight(35);
    spBtnEqui2Cube.setPadding(new Insets(2));
    spBtnEqui2Cube.setPrefWidth(109);

    HBox.setMargin(spBtnEqui2Cube, new Insets(5, 15, 0, 250));
    ivEqui2Cube = new ImageView(
            new Image("file:" + getStrRepertAppli() + File.separator + "images/equi2cube.png"));
    spBtnEqui2Cube.setContent(ivEqui2Cube);
    Tooltip tltpEqui2Cube = new Tooltip(rbLocalisation.getString("outilsEqui2Cube"));
    tltpEqui2Cube.setStyle(getStrTooltipStyle());
    spBtnEqui2Cube.setTooltip(tltpEqui2Cube);
    hbBarreBouton.getChildren().add(spBtnEqui2Cube);

    /*
     Bouton faces de cube -> equi
     */
    ScrollPane spBtnCube2Equi = new ScrollPane();
    spBtnCube2Equi.getStyleClass().add("menuBarreOutils");
    spBtnCube2Equi.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
    spBtnCube2Equi.setPrefHeight(35);
    spBtnCube2Equi.setMaxHeight(35);
    spBtnCube2Equi.setPadding(new Insets(2));
    spBtnCube2Equi.setPrefWidth(109);

    HBox.setMargin(spBtnCube2Equi, new Insets(5, 25, 0, 0));
    ivCube2Equi = new ImageView(
            new Image("file:" + getStrRepertAppli() + File.separator + "images/cube2equi.png"));
    spBtnCube2Equi.setContent(ivCube2Equi);
    Tooltip tltpCube2Equi = new Tooltip(rbLocalisation.getString("outilsCube2Equi"));
    tltpCube2Equi.setStyle(getStrTooltipStyle());
    spBtnCube2Equi.setTooltip(tltpCube2Equi);
    hbBarreBouton.getChildren().add(spBtnCube2Equi);
    if (isMac()) {
        mbarPrincipal.setMaxHeight(0);
        hbBarreBouton.setTranslateY(-30);
    }
    vbMonPanneau.getChildren().addAll(mbarPrincipal, hbBarreBouton);
    vbRacine.getChildren().add(vbMonPanneau);
    mniNouveauProjet.setOnAction((e) -> {
        projetsNouveau();
    });
    mniChargeProjet.setOnAction((e) -> {
        try {
            try {
                projetCharge();

            } catch (InterruptedException ex) {
                Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex);
            }

        } catch (IOException ex) {
            Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex);
        }
    });
    mniSauveProjet.setOnAction((e) -> {
        try {
            projetSauve();

        } catch (IOException ex) {
            Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex);
        }
    });
    mniSauveSousProjet.setOnAction((e) -> {
        try {
            projetSauveSous();

        } catch (IOException ex) {
            Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex);
        }
    });
    mniVisiteGenere.setOnAction((e) -> {
        try {
            genereVisite();

        } catch (IOException ex) {
            Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex);
        }
    });
    mniFermerProjet.setOnAction((e) -> {
        try {
            projetsFermer();

        } catch (IOException ex) {
            Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex);
        }
    });
    mniAjouterPano.setOnAction((e) -> {
        try {
            panoramiquesAjouter();

        } catch (InterruptedException ex) {
            Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex);
        }
    });
    getMniAjouterPlan().setOnAction((e) -> {
        planAjouter();
    });
    mniAPropos.setOnAction((e) -> {
        aideapropos();
    });
    mniAide.setOnAction((e) -> {
        AideDialogController.affiche();
    });

    mniChargerModele.setOnAction((e) -> {
        try {
            modeleCharger();

        } catch (IOException ex) {
            Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex);
        }
    });

    mniSauverModele.setOnAction((e) -> {
        try {
            modeleSauver();

        } catch (IOException ex) {
            Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex);
        }
    });

    mniCube2EquiTransformation.setOnAction((e) -> {
        transformationCube2Equi();
    });

    mniEqui2CubeTransformation.setOnAction((e) -> {
        transformationEqui2Cube();
    });

    mniOutilsBarre.setOnAction((e) -> {
        creerEditerBarre("");
    });
    mniOutilsDiaporama.setOnAction((e) -> {
        creerEditerDiaporama("");
    });
    mniOutilsLoupe.setOnAction((e) -> {
        e.consume();
        setAfficheLoupe(!isAfficheLoupe());
        apLoupe.setVisible(isAfficheLoupe());
        Point p = MouseInfo.getPointerInfo().getLocation();
        if (p.x < getiTailleLoupe() + 80 && p.y < getiTailleLoupe() + 160) {
            apLoupe.setLayoutX(ivImagePanoramique.getFitWidth() - getiTailleLoupe() + 5);
            apLoupe.setLayoutY(35);
            strPositLoupe = "droite";
        } else {
            apLoupe.setLayoutX(35);
            apLoupe.setLayoutY(35);
            strPositLoupe = "gauche";
        }
    });

    mniAffichageVisite.setOnAction((e) -> {
        tpEnvironnement.getSelectionModel().select(0);
    });
    mniAffichageInterface.setOnAction((e) -> {
        tpEnvironnement.getSelectionModel().select(1);
    });
    getMniAffichagePlan().setOnAction((e) -> {
        if (!tabPlan.isDisabled()) {
            tpEnvironnement.getSelectionModel().select(2);
        }
    });

    mniConfigTransformation.setOnAction((e) -> {
        try {
            ConfigDialogController cfg = new ConfigDialogController();
            cfg.afficheFenetre();

        } catch (IOException ex) {
            Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex);
        }
    });

    spBtnNouvprojet.setOnMouseClicked((t) -> {
        projetsNouveau();
    });
    spBtnOuvrirProjet.setOnMouseClicked((t) -> {
        try {
            try {
                projetCharge();

            } catch (InterruptedException ex) {
                Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex);
            }

        } catch (IOException ex) {
            Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex);
        }
    });
    spBtnSauveProjet.setOnMouseClicked((t) -> {
        try {
            projetSauve();

        } catch (IOException ex) {
            Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex);
        }
    });
    spBtnAjoutePano.setOnMouseClicked((t) -> {
        try {
            panoramiquesAjouter();

        } catch (InterruptedException ex) {
            Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex);
        }
    });
    spBtnAjoutePlan.setOnMouseClicked((t) -> {
        planAjouter();
    });
    spBtnGenereVisite.setOnMouseClicked((t) -> {
        try {
            genereVisite();

        } catch (IOException ex) {
            Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex);
        }
    });
    spBtnEqui2Cube.setOnMouseClicked((t) -> {
        transformationEqui2Cube();
    });
    spBtnCube2Equi.setOnMouseClicked((t) -> {
        transformationCube2Equi();
    });

}

From source file:net.sourceforge.pmd.util.fxdesigner.MainDesignerController.java

private void updateRecentFilesMenu() {
    List<MenuItem> items = new ArrayList<>();
    List<File> filesToClear = new ArrayList<>();

    for (final File f : recentFiles) {
        if (f.exists() && f.isFile()) {
            CustomMenuItem item = new CustomMenuItem(new Label(f.getName()));
            item.setOnAction(e -> loadSourceFromFile(f));
            item.setMnemonicParsing(false);
            Tooltip.install(item.getContent(), new Tooltip(f.getAbsolutePath()));
            items.add(item);/*from w w w .j  a v a  2  s  .  co  m*/
        } else {
            filesToClear.add(f);
        }
    }
    recentFiles.removeAll(filesToClear);

    if (items.isEmpty()) {
        openRecentMenu.setDisable(true);
        return;
    }

    Collections.reverse(items);

    items.add(new SeparatorMenuItem());
    MenuItem clearItem = new MenuItem();
    clearItem.setText("Clear menu");
    clearItem.setOnAction(e -> {
        recentFiles.clear();
        openRecentMenu.setDisable(true);
    });
    items.add(clearItem);

    openRecentMenu.getItems().setAll(items);
}

From source file:net.sourceforge.pmd.util.fxdesigner.util.DesignerUtil.java

public static <T> Callback<ListView<T>, ListCell<T>> simpleListCellFactory(Function<T, String> converter,
        Function<T, String> toolTipMaker) {
    return collection -> new ListCell<T>() {
        @Override//  ww w . j a va2 s  . c om
        protected void updateItem(T item, boolean empty) {
            super.updateItem(item, empty);

            if (empty || item == null) {
                setText(null);
                setGraphic(null);
                Tooltip.uninstall(this, getTooltip());
            } else {
                setText(converter.apply(item));
                Tooltip.install(this, new Tooltip(toolTipMaker.apply(item)));
            }
        }
    };
}

From source file:nl.rivm.cib.episim.model.disease.infection.MSEIRSPlot.java

@Override
public void start(final Stage stage) {
    final SIRConfig conf = ConfigFactory.create(SIRConfig.class);
    final double[] t = conf.t();
    final long[] pop = conf.population();
    final double n0 = Arrays.stream(pop).sum();
    final String[] colors = conf.colors(), colors2 = conf.colors2();

    final Pane plot = new Pane();
    plot.setPrefSize(400, 300);/*from  w  ww  .j av  a2  s  .c  o m*/
    plot.setMinSize(50, 50);

    final NumberAxis xAxis = new NumberAxis(t[0], t[1], (t[1] - t[0]) / 10);
    final NumberAxis yAxis = new NumberAxis(0, n0, n0 / 10);
    final Pane axes = new Pane();
    axes.prefHeightProperty().bind(plot.heightProperty());
    axes.prefWidthProperty().bind(plot.widthProperty());

    xAxis.setSide(Side.BOTTOM);
    xAxis.setMinorTickVisible(false);
    xAxis.setPrefWidth(axes.getPrefWidth());
    xAxis.prefWidthProperty().bind(axes.widthProperty());
    xAxis.layoutYProperty().bind(axes.heightProperty());

    yAxis.setSide(Side.LEFT);
    yAxis.setMinorTickVisible(false);
    yAxis.setPrefHeight(axes.getPrefHeight());
    yAxis.prefHeightProperty().bind(axes.heightProperty());
    yAxis.layoutXProperty().bind(Bindings.subtract(1, yAxis.widthProperty()));
    axes.getChildren().setAll(xAxis, yAxis);

    final Label lbl = new Label(String.format("R0=%.1f, recovery=%.1ft\nSIR(0)=%s", conf.reproduction(),
            conf.recovery(), Arrays.toString(pop)));
    lbl.setTextAlignment(TextAlignment.CENTER);
    lbl.setTextFill(Color.WHITE);

    final Path[] deterministic = { new Path(), new Path(), new Path() };
    IntStream.range(0, pop.length).forEach(i -> {
        final Color color = Color.valueOf(colors[i]);
        final Path path = deterministic[i];
        path.setStroke(color.deriveColor(0, 1, 1, 0.6));
        path.setStrokeWidth(2);
        path.setClip(new Rectangle(0, 0, plot.getPrefWidth(), plot.getPrefHeight()));
    });

    plot.getChildren().setAll(axes);

    // fill paths with integration estimates
    final double xl = xAxis.getLowerBound(), sx = plot.getPrefWidth() / (xAxis.getUpperBound() - xl),
            yh = plot.getPrefHeight(), sy = yh / (yAxis.getUpperBound() - yAxis.getLowerBound());
    final TreeMap<Double, Integer> iDeterministic = new TreeMap<>();

    MSEIRSTest.deterministic(conf, () -> new DormandPrince853Integrator(1.0E-8, 10, 1.0E-20, 1.0E-20))
            .subscribe(yt -> {
                iDeterministic.put(yt.getKey(), deterministic[0].getElements().size());
                final double[] y = yt.getValue();
                final double x = (yt.getKey() - xl) * sx;
                for (int i = 0; i < y.length; i++) {
                    final double yi = yh - y[i] * sy;
                    final PathElement di = deterministic[i].getElements().isEmpty() ? new MoveTo(x, yi)
                            : new LineTo(x, yi);
                    deterministic[i].getElements().add(di);
                }
            }, e -> LOG.error("Problem", e), () -> plot.getChildren().addAll(deterministic));

    final Path[] stochasticTau = { new Path(), new Path(), new Path() };
    IntStream.range(0, pop.length).forEach(i -> {
        final Color color = Color.valueOf(colors[i]);
        final Path path = stochasticTau[i];
        path.setStroke(color);
        path.setStrokeWidth(1);
        path.setClip(new Rectangle(0, 0, plot.getPrefWidth(), plot.getPrefHeight()));
    });

    final TreeMap<Double, Integer> iStochasticTau = new TreeMap<>();
    MSEIRSTest.stochasticGillespie(conf).subscribe(yt -> {
        final double x = (yt.getKey() - xl) * sx;
        iStochasticTau.put(yt.getKey(), stochasticTau[0].getElements().size());
        final long[] y = yt.getValue();
        for (int i = 0; i < y.length; i++) {
            final double yi = yh - y[i] * sy;
            final ObservableList<PathElement> path = stochasticTau[i].getElements();
            if (path.isEmpty()) {
                path.add(new MoveTo(x, yi)); // first
            } else {
                final PathElement last = path.get(path.size() - 1);
                final double y_prev = last instanceof MoveTo ? ((MoveTo) last).getY() : ((LineTo) last).getY();
                path.add(new LineTo(x, y_prev));
                path.add(new LineTo(x, yi));
            }
        }
    }, e -> LOG.error("Problem", e), () -> plot.getChildren().addAll(stochasticTau));

    final Path[] stochasticRes = { new Path(), new Path(), new Path() };
    IntStream.range(0, pop.length).forEach(i -> {
        final Color color = Color.valueOf(colors2[i]);
        final Path path = stochasticRes[i];
        path.setStroke(color);
        path.setStrokeWidth(1);
        path.setClip(new Rectangle(0, 0, plot.getPrefWidth(), plot.getPrefHeight()));
    });

    final TreeMap<Double, Integer> iStochasticRes = new TreeMap<>();
    MSEIRSTest.stochasticSellke(conf).subscribe(yt -> {
        final double x = (yt.getKey() - xl) * sx;
        iStochasticRes.put(yt.getKey(), stochasticRes[0].getElements().size());
        final long[] y = yt.getValue();
        for (int i = 0; i < y.length; i++) {
            final double yi = yh - y[i] * sy;
            final ObservableList<PathElement> path = stochasticRes[i].getElements();
            if (path.isEmpty()) {
                path.add(new MoveTo(x, yi)); // first
            } else {
                final PathElement last = path.get(path.size() - 1);
                final double y_prev = last instanceof MoveTo ? ((MoveTo) last).getY() : ((LineTo) last).getY();
                path.add(new LineTo(x, y_prev));
                path.add(new LineTo(x, yi));
            }
        }
    }, e -> LOG.error("Problem", e), () -> plot.getChildren().addAll(stochasticRes));

    // auto-scale on stage/plot resize 
    // FIXME scaling around wrong origin, use ScatterChart?
    //         xAxis.widthProperty()
    //               .addListener( (ChangeListener<Number>) ( observable,
    //                  oldValue, newValue ) ->
    //               {
    //                  final double scale = ((Double) newValue)
    //                        / plot.getPrefWidth();
    //                  plot.getChildren().filtered( n -> n instanceof Path )
    //                        .forEach( n ->
    //                        {
    //                           final Path path = (Path) n;
    //                           path.setScaleX( scale );
    //                           path.setTranslateX( (path
    //                                 .getBoundsInParent().getWidth()
    //                                 - path.getLayoutBounds().getWidth())
    //                                 / 2 );
    //                        } );
    //               } );
    //         plot.heightProperty()
    //               .addListener( (ChangeListener<Number>) ( observable,
    //                  oldValue, newValue ) ->
    //               {
    //                  final double scale = ((Double) newValue)
    //                        / plot.getPrefHeight();
    //                  plot.getChildren().filtered( n -> n instanceof Path )
    //                        .forEach( n ->
    //                        {
    //                           final Path path = (Path) n;
    //                           path.setScaleY( scale );
    //                           path.setTranslateY(
    //                                 (path.getBoundsInParent()
    //                                       .getHeight() * (scale - 1))
    //                                       / 2 );
    //                        } );
    //               } );

    final StackPane layout = new StackPane(lbl, plot);
    layout.setAlignment(Pos.TOP_CENTER);
    layout.setPadding(new Insets(50));
    layout.setStyle("-fx-background-color: rgb(35, 39, 50);");

    final Line vertiCross = new Line();
    vertiCross.setStroke(Color.SILVER);
    vertiCross.setStrokeWidth(1);
    vertiCross.setVisible(false);
    axes.getChildren().add(vertiCross);

    final Tooltip tip = new Tooltip("");
    tip.setAutoHide(false);
    tip.hide();
    axes.setOnMouseExited(ev -> tip.hide());
    axes.setOnMouseMoved(ev -> {
        final Double x = (Double) xAxis.getValueForDisplay(ev.getX());
        if (x > xAxis.getUpperBound() || x < xAxis.getLowerBound()) {
            tip.hide();
            vertiCross.setVisible(false);
            return;
        }
        final Double y = (Double) yAxis.getValueForDisplay(ev.getY());
        if (y > yAxis.getUpperBound() || y < yAxis.getLowerBound()) {
            tip.hide();
            vertiCross.setVisible(false);
            return;
        }
        final double xs = xAxis.getDisplayPosition(x);
        vertiCross.setStartX(xs);
        vertiCross.setStartY(yAxis.getDisplayPosition(0));
        vertiCross.setEndX(xs);
        vertiCross.setEndY(yAxis.getDisplayPosition(yAxis.getUpperBound()));
        vertiCross.setVisible(true);
        final int i = (iDeterministic.firstKey() > x ? iDeterministic.firstEntry()
                : iDeterministic.floorEntry(x)).getValue();
        final Object[] yi = Arrays.stream(deterministic).mapToDouble(p -> getY(p, i))
                .mapToObj(yAxis::getValueForDisplay).map(n -> DecimalUtil.toScale(n, 1)).toArray();
        final int j = (iStochasticTau.firstKey() > x ? iStochasticTau.firstEntry()
                : iStochasticTau.floorEntry(x)).getValue();
        final Object[] yj = Arrays.stream(stochasticTau).mapToDouble(p -> getY(p, j))
                .mapToObj(yAxis::getValueForDisplay).map(n -> DecimalUtil.toScale(n, 0)).toArray();
        final int k = (iStochasticRes.firstKey() > x ? iStochasticRes.firstEntry()
                : iStochasticRes.floorEntry(x)).getValue();
        final Object[] yk = Arrays.stream(stochasticRes).mapToDouble(p -> getY(p, k))
                .mapToObj(yAxis::getValueForDisplay).map(n -> DecimalUtil.toScale(n, 0)).toArray();
        final String txt = String.format("SIR(t=%.1f)\n" + "~det%s\n" + "~tau%s\n" + "~res%s", x,
                Arrays.toString(yi), Arrays.toString(yj), Arrays.toString(yk));

        tip.setText(txt);
        tip.show(axes, ev.getScreenX() - ev.getSceneX() + xs, ev.getScreenY() + 15);
    });

    try {
        stage.getIcons().add(new Image(FileUtil.toInputStream("icon.jpg")));
    } catch (final IOException e) {
        LOG.error("Problem", e);
    }
    stage.setTitle("Deterministic vs. Stochastic");
    stage.setScene(new Scene(layout, Color.rgb(35, 39, 50)));
    //         stage.setOnHidden( ev -> tip.hide() );
    stage.show();
}

From source file:open.dolphin.client.MainWindowController.java

/**
 * align Image of the cell to center in the specified column
 *
 * @param col table column to be aligned to center
 *//*from   w w  w. j a v a  2 s .c  o  m*/
private void tableCellImageAlignCenter(TableColumn col) {
    col.setCellFactory(new Callback<TableColumn, TableCell>() {
        @Override
        public TableCell call(TableColumn param) {
            TableCell cell = new TableCell() {
                @Override
                public void updateItem(Object item, boolean empty) {
                    String imagesPath = "/resources/images/";

                    super.updateItem(item, empty);
                    if (!empty) {
                        switch (item.toString()) {
                        case "0":
                            setTooltip(new Tooltip(""));
                            folderIcon = new Image(imagesPath + "os_folder_vertical_document_16.png");
                            break;
                        case "1":
                            setTooltip(new Tooltip("/??"));
                            folderIcon = new Image(imagesPath + "os_network_wireless_16.png");
                            break;
                        case "2":
                            setTooltip(new Tooltip("/??"));
                            folderIcon = new Image(imagesPath + "os_server_information_16.png");
                            break;
                        case "3":
                            setTooltip(new Tooltip("/"));
                            folderIcon = new Image(imagesPath + "os_cog_16.png");
                            break;
                        case "4":
                            setTooltip(new Tooltip(""));
                            folderIcon = new Image(imagesPath + "os_hot_16.png");
                            break;
                        case "5":
                            setTooltip(new Tooltip(""));
                            folderIcon = new Image(imagesPath + "os_cart_16.png");
                            break;
                        case "6":
                            setTooltip(new Tooltip(""));
                            folderIcon = new Image(imagesPath + "os_cancel_16.png");
                            break;
                        case "8":
                            setTooltip(new Tooltip(""));
                            folderIcon = new Image(imagesPath + "os_flag_yellow_16.png");
                            break;
                        }
                        setGraphic(new ImageView(folderIcon));
                    }
                }
            };
            cell.setAlignment(Pos.BOTTOM_CENTER);
            return cell;
        }
    });
}