Example usage for javafx.scene Cursor DEFAULT

List of usage examples for javafx.scene Cursor DEFAULT

Introduction

In this page you can find the example usage for javafx.scene Cursor DEFAULT.

Prototype

Cursor DEFAULT

To view the source code for javafx.scene Cursor DEFAULT.

Click Source Link

Document

The default cursor type (gets set if no cursor is defined).

Usage

From source file:ui.main.MainViewController.java

private synchronized void paintReceivedPhotoOnTransmit(Chat chat, File recievedFile, String time) {
    //this method paints the recieved picture message
    Task<HBox> recievedMessages = new Task<HBox>() {
        @Override//from   w w  w . jav a 2s.c  o m
        protected HBox call() throws Exception {
            VBox vbox = new VBox(); //to add text
            Thread.sleep(2000);
            ImageView imageRec = new ImageView(chatterAvatar.getImage()); //image
            imageRec.setFitHeight(60);
            imageRec.setFitWidth(50);

            String strChatterName = chat.getParticipant(); //add name of the chatter with light color
            strChatterName = Character.toUpperCase(strChatterName.charAt(0))
                    + strChatterName.substring(1, strChatterName.indexOf("@"));
            Label chatterName = new Label(strChatterName);
            chatterName.setDisable(true);

            Label timeL = new Label(time);
            timeL.setDisable(true);
            timeL.setFont(new Font("Arial", 10));

            try {
                Image recievedImage = SwingFXUtils.toFXImage(ImageIO.read(recievedFile), null);
                ImageView receivedImageView = new ImageView(recievedImage);
                receivedImageView.setFitHeight(300);
                receivedImageView.setFitWidth(300);
                receivedImageView.setPreserveRatio(true);

                receivedImageView.setOnMouseClicked(new EventHandler<MouseEvent>() {
                    @Override
                    public void handle(MouseEvent event) {
                        if (event.getButton() == MouseButton.PRIMARY) {
                            Desktop dt = Desktop.getDesktop();
                            try {
                                dt.open(recievedFile);
                            } catch (IOException ex) {
                                Logger.getLogger(MainViewController.class.getName()).log(Level.SEVERE, null,
                                        ex);
                            }
                        }
                    }
                });

                receivedImageView.setOnMouseEntered(new EventHandler<MouseEvent>() {
                    @Override
                    public void handle(MouseEvent event) {
                        chatList.getScene().setCursor(Cursor.HAND);
                    }
                });

                receivedImageView.setOnMouseExited(new EventHandler<MouseEvent>() {
                    @Override
                    public void handle(MouseEvent event) {
                        chatList.getScene().setCursor(Cursor.DEFAULT);
                    }
                });

                vbox.getChildren().addAll(chatterName, receivedImageView, timeL);
            } catch (IOException e) {
                e.printStackTrace();
            }
            vbox.setAlignment(Pos.CENTER_RIGHT);
            HBox hbox = new HBox();
            hbox.getChildren().addAll(imageRec, vbox);
            return hbox;
        }
    };

    recievedMessages.setOnSucceeded(event -> {
        chatList.getChildren().add(recievedMessages.getValue());
    });
    //set the received chat message appear on the screen
    if (chat.getParticipant().contains(currentChat.getParticipant())) {
        Thread t = new Thread(recievedMessages);
        t.start();
    }
    Task t = new Task() {
        @Override
        protected Object call() throws Exception {
            Thread.sleep(2500);
            return new Object();
        }
    };

    t.setOnSucceeded(value -> scrollPane.setVvalue(scrollPane.getHmax()));

    Thread thread1 = new Thread(t);
    thread1.start();
}

From source file:ui.main.MainViewController.java

private synchronized void paintSentPhoto(Chat chat, File file, String time) {
    //this method paints the recieved picture message
    Task<HBox> recievedMessages = new Task<HBox>() {
        @Override//from  ww  w.j  a va2 s.c  o m
        protected HBox call() throws Exception {
            //                Thread.sleep(100);
            VBox vbox = new VBox(); //to add text

            ImageView imageRec = new ImageView(myAvatar.getImage()); //image
            imageRec.setFitHeight(60);
            imageRec.setFitWidth(50);

            Label chatterName = new Label(name.getText());
            chatterName.setDisable(true);

            Label timeL = new Label(time);
            timeL.setDisable(true);
            timeL.setFont(new Font("Arial", 10));

            try {
                Image recievedImage = SwingFXUtils.toFXImage(ImageIO.read(file), null);
                ImageView receivedImageView = new ImageView(recievedImage);
                receivedImageView.setFitHeight(300);
                receivedImageView.setFitWidth(300);
                receivedImageView.setPreserveRatio(true);

                receivedImageView.setOnMouseClicked(new EventHandler<MouseEvent>() {
                    @Override
                    public void handle(MouseEvent event) {
                        if (event.getButton() == MouseButton.PRIMARY) {
                            Desktop dt = Desktop.getDesktop();
                            try {
                                dt.open(file);
                            } catch (IOException ex) {
                                Logger.getLogger(MainViewController.class.getName()).log(Level.SEVERE, null,
                                        ex);
                            }
                        }
                    }
                });

                receivedImageView.setOnMouseEntered(new EventHandler<MouseEvent>() {
                    @Override
                    public void handle(MouseEvent event) {
                        chatList.getScene().setCursor(Cursor.HAND);
                    }
                });

                receivedImageView.setOnMouseExited(new EventHandler<MouseEvent>() {
                    @Override
                    public void handle(MouseEvent event) {
                        chatList.getScene().setCursor(Cursor.DEFAULT);
                    }
                });

                vbox.getChildren().addAll(chatterName, receivedImageView, timeL);
            } catch (IOException e) {
                e.printStackTrace();
            }
            vbox.setAlignment(Pos.CENTER_LEFT);
            HBox hbox = new HBox();
            hbox.setAlignment(Pos.CENTER_RIGHT);
            //bbl.setBubbleSpec(BubbleSpec.FACE_LEFT_CENTER);
            hbox.getChildren().addAll(vbox, imageRec);
            return hbox;
        }
    };

    recievedMessages.setOnSucceeded(event -> {
        chatList.getChildren().add(recievedMessages.getValue());
    });

    if (chat.getParticipant().contains(currentChat.getParticipant())) {
        Thread t = new Thread(recievedMessages);
        t.start();
        try {
            t.join();
        } catch (InterruptedException ex) {
            Logger.getLogger(MainViewController.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}

From source file:editeurpanovisu.EditeurPanovisu.java

private ScrollPane afficheLegende() {
    double positionX = 0;
    double positionY = 0;
    AnchorPane apLegende = new AnchorPane();
    ScrollPane spLegende = new ScrollPane(apLegende);
    spLegende.getStyleClass().add("legendePane");

    apLegende.setMinWidth(1000);//from ww w. j  a v a 2 s .c o m
    apLegende.setMinHeight(150);
    apLegende.setPrefWidth(1000);
    apLegende.setPrefHeight(150);
    apLegende.setMaxWidth(1000);
    apLegende.setMaxHeight(150);
    positionY = (pano.getLayoutY() + pano.getPrefHeight() + 10);

    Circle point = new Circle(30, 20, 5);
    point.setFill(Color.YELLOW);
    point.setStroke(Color.RED);
    point.setCursor(Cursor.DEFAULT);
    Circle point2 = new Circle(30, 60, 5);
    point2.setFill(Color.BLUE);
    point2.setStroke(Color.YELLOW);
    point2.setCursor(Cursor.DEFAULT);
    Circle point3 = new Circle(30, 100, 5);
    point3.setFill(Color.GREEN);
    point3.setStroke(Color.YELLOW);
    point3.setCursor(Cursor.DEFAULT);
    Polygon polygon = new Polygon();
    polygon.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 });
    polygon.setStrokeLineJoin(StrokeLineJoin.MITER);
    polygon.setFill(Color.BLUEVIOLET);
    polygon.setStroke(Color.YELLOW);
    polygon.setId("PoV");
    polygon.setLayoutX(500);
    polygon.setLayoutY(20);
    Label lblHS = new Label(rb.getString("main.legendeHS"));
    Label lblHSImage = new Label(rb.getString("main.legendeHSImage"));
    //Label lblHSHTML = new Label(rb.getString("main.legendeHSHTML"));
    Label lblPoV = new Label(rb.getString("main.legendePoV"));
    Label lblNord = new Label(rb.getString("main.legendeNord"));
    Line ligneNord = new Line(500, 45, 500, 65);
    ligneNord.setStroke(Color.RED);
    ligneNord.setStrokeWidth(3);
    lblHS.setLayoutX(50);
    lblHS.setLayoutY(10);
    lblHSImage.setLayoutX(50);
    lblHSImage.setLayoutY(50);
    //lblHSHTML.setLayoutX(50);
    //lblHSHTML.setLayoutY(90);
    lblPoV.setLayoutX(520);
    lblPoV.setLayoutY(10);
    lblNord.setLayoutX(520);
    lblNord.setLayoutY(50);
    //        apLegende.getChildren().addAll(lblHS, point, lblHSImage, point2, lblHSHTML, point3, lblPoV, polygon, lblNord, ligneNord);
    apLegende.getChildren().addAll(lblHS, point, lblHSImage, point2, lblPoV, polygon, lblNord, ligneNord);
    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;
}

From source file:editeurpanovisu.EditeurPanovisu.java

/**
 *
 * @param i/* w  w  w.ja va  2 s.com*/
 * @param longitude
 * @param latitude
 */
private void afficheHS(int i, double longitude, double latitude) {
    double largeur = imagePanoramique.getFitWidth();
    double X = (longitude + 180.0d) * largeur / 360.0d + imagePanoramique.getLayoutX();
    double Y = (90.0d - latitude) * largeur / 360.0d;
    Circle point = new Circle(X, Y, 5);
    point.setFill(Color.YELLOW);
    point.setStroke(Color.RED);
    point.setId("point" + i);
    point.setCursor(Cursor.DEFAULT);
    pano.getChildren().add(point);

    Tooltip t = new Tooltip("point n " + (i + 1));
    t.setStyle(tooltipStyle);
    Tooltip.install(point, t);
    point.setOnDragDetected((MouseEvent me1) -> {
        point.setFill(Color.RED);
        point.setStroke(Color.YELLOW);
        dragDrop = true;
        me1.consume();

    });
    point.setOnMouseDragged((MouseEvent me1) -> {
        double XX = me1.getX() - imagePanoramique.getLayoutX();
        if (XX < 0) {
            XX = 0;
        }
        if (XX > imagePanoramique.getFitWidth()) {
            XX = imagePanoramique.getFitWidth();
        }
        point.setCenterX(XX + imagePanoramique.getLayoutX());
        double YY = me1.getY();
        if (YY < 0) {
            YY = 0;
        }
        if (YY > imagePanoramique.getFitHeight()) {
            YY = imagePanoramique.getFitHeight();
        }
        point.setCenterY(YY);
        me1.consume();

    });
    point.setOnMouseReleased((MouseEvent me1) -> {
        String chPoint = point.getId();
        chPoint = chPoint.substring(5, chPoint.length());
        int numeroPoint = Integer.parseInt(chPoint);
        double X1 = me1.getSceneX();
        double Y1 = me1.getSceneY();
        double mouseX = X1 - imagePanoramique.getLayoutX();
        if (mouseX < 0) {
            mouseX = 0;
        }
        if (mouseX > imagePanoramique.getFitWidth()) {
            mouseX = imagePanoramique.getFitWidth();
        }

        double mouseY = Y1 - pano.getLayoutY() - 109;
        if (mouseY < 0) {
            mouseY = 0;
        }
        if (mouseY > imagePanoramique.getFitHeight()) {
            mouseY = imagePanoramique.getFitHeight();
        }

        double longit, lat;
        double larg = imagePanoramique.getFitWidth();
        String chLong, chLat;
        longit = 360.0f * mouseX / larg - 180;
        lat = 90.0d - 2.0f * mouseY / larg * 180.0f;
        panoramiquesProjet[panoActuel].getHotspot(numeroPoint).setLatitude(lat);
        panoramiquesProjet[panoActuel].getHotspot(numeroPoint).setLongitude(longit);
        point.setFill(Color.YELLOW);
        point.setStroke(Color.RED);
        me1.consume();

    });

    point.setOnMouseClicked((MouseEvent me1) -> {
        double mouseX = me1.getSceneX() - imagePanoramique.getLayoutX();
        if (mouseX < 0) {
            mouseX = 0;
        }
        if (mouseX > imagePanoramique.getFitWidth()) {
            mouseX = imagePanoramique.getFitWidth();
        }

        double mouseY = me1.getSceneY() - pano.getLayoutY() - 115;
        if (mouseY < 0) {
            mouseY = 0;
        }
        if (mouseY > imagePanoramique.getFitHeight()) {
            mouseY = imagePanoramique.getFitHeight();
        }

        String chPoint = point.getId();
        chPoint = chPoint.substring(5, chPoint.length());
        int numeroPoint = Integer.parseInt(chPoint);
        Node pt;
        pt = (Node) pano.lookup("#point" + chPoint);

        if (me1.isControlDown()) {
            dejaSauve = false;
            stPrincipal.setTitle(stPrincipal.getTitle().replace(" *", "") + " *");
            pano.getChildren().remove(pt);

            for (int o = numeroPoint + 1; o < numPoints; o++) {
                pt = (Node) pano.lookup("#point" + Integer.toString(o));
                pt.setId("point" + Integer.toString(o - 1));
            }
            /**
             * on retire les anciennes indication de HS
             */
            retireAffichageHotSpots();
            numPoints--;
            panoramiquesProjet[panoActuel].removeHotspot(numeroPoint);
            /**
             * On les cre les nouvelles
             */
            ajouteAffichageHotspots();
            me1.consume();
            valideHS();
        } else {
            if (!dragDrop) {
                if (nombrePanoramiques > 1) {
                    AnchorPane listePanoVig = afficherListePanosVignettes(numeroPoint);
                    int largeurVignettes = 4;
                    if (nombrePanoramiques < 4) {
                        largeurVignettes = nombrePanoramiques;
                    }
                    if (mouseX + largeurVignettes * 130 > pano.getWidth()) {
                        listePanoVig.setLayoutX(pano.getWidth() - largeurVignettes * 130);
                    } else {
                        listePanoVig.setLayoutX(mouseX);
                    }
                    listePanoVig.setLayoutY(mouseY);
                    pano.getChildren().add(listePanoVig);
                }
            } else {
                dragDrop = false;
            }
            valideHS();
            me1.consume();

        }

    });
}

From source file:editeurpanovisu.EditeurPanovisu.java

/**
 *
 * @param i// ww w.  ja  v  a2  s.c  o  m
 * @param longitude
 * @param latitude
 */
private void afficheHSImage(int i, double longitude, double latitude) {
    double largeur = imagePanoramique.getFitWidth();
    double X = (longitude + 180.0d) * largeur / 360.0d + imagePanoramique.getLayoutX();
    double Y = (90.0d - latitude) * largeur / 360.0d;
    Circle point = new Circle(X, Y, 5);
    point.setFill(Color.BLUE);
    point.setStroke(Color.YELLOW);
    point.setId("img" + i);
    point.setCursor(Cursor.DEFAULT);
    pano.getChildren().add(point);
    Tooltip t = new Tooltip("image n " + (i + 1));
    t.setStyle(tooltipStyle);
    Tooltip.install(point, t);
    point.setOnDragDetected((MouseEvent me1) -> {
        point.setFill(Color.YELLOW);
        point.setStroke(Color.BLUE);
        dragDrop = true;
        me1.consume();

    });
    point.setOnMouseDragged((MouseEvent me1) -> {
        double XX = me1.getX() - imagePanoramique.getLayoutX();
        if (XX < 0) {
            XX = 0;
        }
        if (XX > imagePanoramique.getFitWidth()) {
            XX = imagePanoramique.getFitWidth();
        }
        point.setCenterX(XX + imagePanoramique.getLayoutX());
        double YY = me1.getY();
        if (YY < 0) {
            YY = 0;
        }
        if (YY > imagePanoramique.getFitHeight()) {
            YY = imagePanoramique.getFitHeight();
        }
        point.setCenterY(YY);

        me1.consume();

    });
    point.setOnMouseReleased((MouseEvent me1) -> {
        String chPoint = point.getId();
        chPoint = chPoint.substring(3, chPoint.length());
        int numeroPoint = Integer.parseInt(chPoint);
        double X1 = me1.getSceneX();
        double Y1 = me1.getSceneY();
        double mouseX = X1 - imagePanoramique.getLayoutX();
        if (mouseX < 0) {
            mouseX = 0;
        }
        if (mouseX > imagePanoramique.getFitWidth()) {
            mouseX = imagePanoramique.getFitWidth();
        }
        double mouseY = Y1 - pano.getLayoutY() - 109;
        if (mouseY < 0) {
            mouseY = 0;
        }
        if (mouseY > imagePanoramique.getFitHeight()) {
            mouseY = imagePanoramique.getFitHeight();
        }

        double longit, lat;
        double larg = imagePanoramique.getFitWidth();
        String chLong, chLat;
        longit = 360.0f * mouseX / larg - 180;
        lat = 90.0d - 2.0f * mouseY / larg * 180.0f;
        panoramiquesProjet[panoActuel].getHotspotImage(numeroPoint).setLatitude(lat);
        panoramiquesProjet[panoActuel].getHotspotImage(numeroPoint).setLongitude(longit);
        point.setFill(Color.BLUE);
        point.setStroke(Color.YELLOW);
        me1.consume();

    });

    point.setOnMouseClicked((MouseEvent me1) -> {
        String chPoint = point.getId();
        chPoint = chPoint.substring(3, chPoint.length());
        int numeroPoint = Integer.parseInt(chPoint);
        Node pt;
        pt = (Node) pano.lookup("#img" + chPoint);

        if (me1.isControlDown()) {
            valideHS();
            dejaSauve = false;
            stPrincipal.setTitle(stPrincipal.getTitle().replace(" *", "") + " *");
            pano.getChildren().remove(pt);

            for (int o = numeroPoint + 1; o < numImages; o++) {
                pt = (Node) pano.lookup("#img" + Integer.toString(o));
                pt.setId("img" + Integer.toString(o - 1));
            }
            /**
             * on retire les anciennes indication de HS
             */
            retireAffichageHotSpots();
            numImages--;
            panoramiquesProjet[panoActuel].removeHotspotImage(numeroPoint);
            /**
             * On les cre les nouvelles
             */
            ajouteAffichageHotspots();
            me1.consume();
        } else {
            me1.consume();
        }

    });
}

From source file:editeurpanovisu.EditeurPanovisu.java

private void afficheNord(double longitude) {
    double largeur = imagePanoramique.getFitWidth();
    double X = (longitude + 180.0d) * largeur / 360.0d + imagePanoramique.getLayoutX();
    Node ancPoV = (Node) pano.lookup("#Nord");
    if (ancPoV != null) {
        pano.getChildren().remove(ancPoV);
    }//from w  ww. j  ava 2  s . c o  m
    Line ligne = new Line(0, 0, 0, imagePanoramique.getFitHeight());
    ligne.setCursor(Cursor.DEFAULT);

    ligne.setLayoutX(X);
    ligne.setStroke(Color.RED);
    ligne.setStrokeWidth(4);
    ligne.setId("Nord");
    ligne.setOnDragDetected((MouseEvent me1) -> {
        ligne.setStroke(Color.BLUEVIOLET);
        dragDrop = true;
        me1.consume();
    });
    ligne.setOnMouseDragged((MouseEvent me1) -> {

        double XX = me1.getSceneX() - imagePanoramique.getLayoutX();
        if (XX < 0) {
            XX = 0;
        }
        if (XX > imagePanoramique.getFitWidth()) {
            XX = imagePanoramique.getFitWidth();
        }
        ligne.setLayoutX(XX + imagePanoramique.getLayoutX());
        me1.consume();

    });
    ligne.setOnMouseReleased((MouseEvent me1) -> {
        double X1 = me1.getSceneX();
        double mouseX1 = X1 - imagePanoramique.getLayoutX();
        if (mouseX1 < 0) {
            mouseX1 = 0;
        }
        if (mouseX1 > imagePanoramique.getFitWidth()) {
            mouseX1 = imagePanoramique.getFitWidth();
        }
        double regardX = 360.0f * mouseX1 / largeur - 180;
        panoramiquesProjet[panoActuel].setZeroNord(regardX);
        ligne.setStroke(Color.RED);
        me1.consume();

    });

    pano.getChildren().add(ligne);
}

From source file:editeurpanovisu.EditeurPanovisu.java

private void affichePoV(double longitude, double latitude) {
    double largeur = imagePanoramique.getFitWidth();
    double X = (longitude + 180.0d) * largeur / 360.0d + imagePanoramique.getLayoutX();
    double Y = (90.0d - latitude) * largeur / 360.0d;
    Node ancPoV = (Node) pano.lookup("#PoV");
    if (ancPoV != null) {
        pano.getChildren().remove(ancPoV);
    }//  w w w . j  a v a 2  s .  c  o  m
    Polygon polygon = new Polygon();
    polygon.getPoints().addAll(new Double[] { 20.0, 2.0, 2.0, 2.0, 2.0, 20.0, -2.0, 20.0, -2.0, 2.0, -20.0, 2.0,
            -20.0, -2.0, -2.0, -2.0, -2.0, -20.0, 2.0, -20.0, 2.0, -2.0, 20.0, -2.0 });
    polygon.setStrokeLineJoin(StrokeLineJoin.MITER);
    polygon.setFill(Color.BLUEVIOLET);
    polygon.setStroke(Color.YELLOW);
    polygon.setId("PoV");
    polygon.setLayoutX(X);
    polygon.setLayoutY(Y);
    polygon.setCursor(Cursor.DEFAULT);
    polygon.setOnDragDetected((MouseEvent me1) -> {
        polygon.setFill(Color.YELLOW);
        polygon.setStroke(Color.BLUEVIOLET);
        dragDrop = true;
        me1.consume();

    });
    polygon.setOnMouseDragged((MouseEvent me1) -> {

        double XX = me1.getSceneX() - imagePanoramique.getLayoutX();
        if (XX < 0) {
            XX = 0;
        }
        if (XX > imagePanoramique.getFitWidth()) {
            XX = imagePanoramique.getFitWidth();
        }
        polygon.setLayoutX(XX + imagePanoramique.getLayoutX());
        double YY = me1.getSceneY() - pano.getLayoutY() - 109;
        if (YY < 0) {
            YY = 0;
        }
        if (YY > imagePanoramique.getFitHeight()) {
            YY = imagePanoramique.getFitHeight();
        }
        polygon.setLayoutY(YY);

        me1.consume();

    });
    polygon.setOnMouseReleased((MouseEvent me1) -> {
        double X1 = me1.getSceneX();
        double Y1 = me1.getSceneY();
        double mouseX1 = X1 - imagePanoramique.getLayoutX();
        if (mouseX1 < 0) {
            mouseX1 = 0;
        }
        if (mouseX1 > imagePanoramique.getFitWidth()) {
            mouseX1 = imagePanoramique.getFitWidth();
        }
        double mouseY1 = Y1 - pano.getLayoutY() - 109;
        if (mouseY1 < 0) {
            mouseY1 = 0;
        }
        if (mouseY1 > imagePanoramique.getFitHeight()) {
            mouseY1 = imagePanoramique.getFitHeight();
        }
        double regardX = 360.0f * mouseX1 / largeur - 180;
        double regardY = 90.0d - 2.0f * mouseY1 / largeur * 180.0f;
        panoramiquesProjet[panoActuel].setLookAtX(regardX);
        panoramiquesProjet[panoActuel].setLookAtY(regardY);
        polygon.setFill(Color.BLUEVIOLET);
        polygon.setStroke(Color.YELLOW);
        me1.consume();

    });

    pano.getChildren().add(polygon);
}

From source file:editeurpanovisu.EditeurPanovisu.java

private void panoMouseClic(double X, double Y) {

    if (nombrePanoramiques > 1) {
        valideHS();/*from  www  . j a  v a2s .co  m*/
        dejaSauve = false;
        stPrincipal.setTitle(stPrincipal.getTitle().replace(" *", "") + " *");
        double mouseX = X;
        double mouseY = Y - pano.getLayoutY() - 109;
        if (X > 0 && X < imagePanoramique.getFitWidth()) {
            double longitude, latitude;
            double largeur = imagePanoramique.getFitWidth();
            String chLong, chLat;
            longitude = 360.0f * mouseX / largeur - 180;
            latitude = 90.0d - 2.0f * mouseY / largeur * 180.0f;
            Circle point = new Circle(mouseX + imagePanoramique.getLayoutX(), mouseY, 5);
            point.setFill(Color.YELLOW);
            point.setStroke(Color.RED);
            point.setId("point" + numPoints);
            point.setCursor(Cursor.DEFAULT);
            pano.getChildren().add(point);
            Tooltip t = new Tooltip("point n" + (numPoints + 1));
            t.setStyle(tooltipStyle);
            Tooltip.install(point, t);
            HotSpot HS = new HotSpot();
            HS.setLongitude(longitude);
            HS.setLatitude(latitude);
            panoramiquesProjet[panoActuel].addHotspot(HS);
            retireAffichageHotSpots();
            Pane affHS1 = affichageHS(listePano(panoActuel), panoActuel);
            affHS1.setId("labels");
            outils.getChildren().add(affHS1);

            numPoints++;
            if (nombrePanoramiques > 1) {

                AnchorPane listePanoVig = afficherListePanosVignettes(
                        panoramiquesProjet[panoActuel].getNombreHotspots() - 1);
                int largeurVignettes = 4;
                if (nombrePanoramiques < 4) {
                    largeurVignettes = nombrePanoramiques;
                }
                if (mouseX + largeurVignettes * 130 > pano.getWidth()) {
                    listePanoVig.setLayoutX(pano.getWidth() - largeurVignettes * 130);
                } else {
                    listePanoVig.setLayoutX(mouseX);
                }
                listePanoVig.setLayoutY(mouseY);
                pano.getChildren().add(listePanoVig);
                valideHS();
            }
            point.setOnDragDetected((MouseEvent me1) -> {
                String chPoint = point.getId();
                chPoint = chPoint.substring(5, chPoint.length());
                int numeroPoint = Integer.parseInt(chPoint);
                Node pt;
                pt = (Node) pano.lookup("#point" + chPoint);
                point.setFill(Color.RED);
                point.setStroke(Color.YELLOW);
                dragDrop = true;
                me1.consume();

            });
            point.setOnMouseDragged((MouseEvent me1) -> {
                double XX = me1.getX() - imagePanoramique.getLayoutX();
                if (XX < 0) {
                    XX = 0;
                }
                if (XX > imagePanoramique.getFitWidth()) {
                    XX = imagePanoramique.getFitWidth();
                }
                point.setCenterX(XX + imagePanoramique.getLayoutX());
                double YY = me1.getY();
                if (YY < 0) {
                    YY = 0;
                }
                if (YY > imagePanoramique.getFitHeight()) {
                    YY = imagePanoramique.getFitHeight();
                }
                point.setCenterY(YY);

                me1.consume();

            });
            point.setOnMouseReleased((MouseEvent me1) -> {
                String chPoint = point.getId();
                chPoint = chPoint.substring(5, chPoint.length());
                int numeroPoint = Integer.parseInt(chPoint);
                double X1 = me1.getSceneX();
                double Y1 = me1.getSceneY();
                double mouseX1 = X1 - imagePanoramique.getLayoutX();
                if (mouseX1 < 0) {
                    mouseX1 = 0;
                }
                if (mouseX1 > imagePanoramique.getFitWidth()) {
                    mouseX1 = imagePanoramique.getFitWidth();
                }
                double mouseY1 = Y1 - pano.getLayoutY() - 109;
                if (mouseY1 < 0) {
                    mouseY1 = 0;
                }
                if (mouseY1 > imagePanoramique.getFitHeight()) {
                    mouseY1 = imagePanoramique.getFitHeight();
                }
                double longit, lat;
                double larg = imagePanoramique.getFitWidth();
                longit = 360.0f * mouseX1 / larg - 180;
                lat = 90.0d - 2.0f * mouseY1 / larg * 180.0f;
                panoramiquesProjet[panoActuel].getHotspot(numeroPoint).setLatitude(lat);
                panoramiquesProjet[panoActuel].getHotspot(numeroPoint).setLongitude(longit);
                point.setFill(Color.YELLOW);
                point.setStroke(Color.RED);
                me1.consume();

            });

            point.setOnMouseClicked((MouseEvent me1) -> {
                if (me1.isControlDown()) {
                    dejaSauve = false;
                    stPrincipal.setTitle(stPrincipal.getTitle().replace(" *", "") + " *");
                    String chPoint = point.getId();
                    chPoint = chPoint.substring(5, chPoint.length());
                    int numeroPoint = Integer.parseInt(chPoint);
                    Node pt;
                    pt = (Node) pano.lookup("#point" + chPoint);
                    pano.getChildren().remove(pt);

                    for (int o = numeroPoint + 1; o < numPoints; o++) {
                        pt = (Node) pano.lookup("#point" + Integer.toString(o));
                        pt.setId("point" + Integer.toString(o - 1));
                    }
                    /**
                     * on retire les anciennes indication de HS
                     */
                    retireAffichageHotSpots();
                    numPoints--;
                    panoramiquesProjet[panoActuel].removeHotspot(numeroPoint);
                    /**
                     * On les cre les nouvelles
                     */
                    ajouteAffichageHotspots();
                    valideHS();
                    me1.consume();
                } else {
                    if (!dragDrop) {
                        String chPoint = point.getId();
                        chPoint = chPoint.substring(5, chPoint.length());
                        int numeroPoint = Integer.parseInt(chPoint);
                        if (nombrePanoramiques > 1) {
                            AnchorPane listePanoVig = afficherListePanosVignettes(numeroPoint);
                            int largeurVignettes = 4;
                            if (nombrePanoramiques < 4) {
                                largeurVignettes = nombrePanoramiques;
                            }
                            if (mouseX + largeurVignettes * 130 > pano.getWidth()) {
                                listePanoVig.setLayoutX(pano.getWidth() - largeurVignettes * 130);
                            } else {
                                listePanoVig.setLayoutX(mouseX);
                            }
                            listePanoVig.setLayoutY(mouseY);
                            pano.getChildren().add(listePanoVig);
                        }
                    } else {
                        dragDrop = false;
                    }
                    valideHS();
                    me1.consume();

                }
            });
        }
    }
}

From source file:editeurpanovisu.EditeurPanovisu.java

private void panoAjouteImage(double X, double Y) {
    if (X > 0 && X < imagePanoramique.getFitWidth()) {

        valideHS();/* ww  w .j  av a  2  s . c o  m*/
        dejaSauve = false;
        stPrincipal.setTitle(stPrincipal.getTitle().replace(" *", "") + " *");
        double mouseX = X;
        double mouseY = Y - pano.getLayoutY() - 115;
        double longitude, latitude;
        double largeur = imagePanoramique.getFitWidth();
        String chLong, chLat;
        longitude = 360.0f * mouseX / largeur - 180;
        latitude = 90.0d - 2.0f * mouseY / largeur * 180.0f;
        Circle point = new Circle(mouseX, mouseY, 5);
        point.setFill(Color.BLUE);
        point.setStroke(Color.YELLOW);
        point.setId("img" + numImages);
        point.setCursor(Cursor.DEFAULT);
        pano.getChildren().add(point);
        Tooltip t = new Tooltip("image n " + (numImages + 1));
        t.setStyle(tooltipStyle);
        Tooltip.install(point, t);

        //
        File repert;
        if (repertHSImages.equals("")) {
            repert = new File(currentDir + File.separator);
        } else {
            repert = new File(repertHSImages);
        }
        FileChooser fileChooser = new FileChooser();
        FileChooser.ExtensionFilter extFilterImages = new FileChooser.ExtensionFilter(
                "Fichiers Images (jpg, bmp, png)", "*.jpg", "*.bmp", "*.png");

        fileChooser.setInitialDirectory(repert);
        fileChooser.getExtensionFilters().addAll(extFilterImages);

        File fichierImage = fileChooser.showOpenDialog(null);
        if (fichierImage != null) {
            repertHSImages = fichierImage.getParent();
            numImages++;
            HotspotImage HS = new HotspotImage();
            HS.setLongitude(longitude);
            HS.setLatitude(latitude);
            HS.setUrlImage(fichierImage.getAbsolutePath());
            HS.setLienImg(fichierImage.getName());
            HS.setInfo(fichierImage.getName().split("\\.")[0]);
            File repertImage = new File(repertTemp + File.separator + "images");
            if (!repertImage.exists()) {
                repertImage.mkdirs();
            }
            try {
                copieFichierRepertoire(fichierImage.getAbsolutePath(), repertImage.getAbsolutePath());
            } catch (IOException ex) {
                Logger.getLogger(EditeurPanovisu.class.getName()).log(Level.SEVERE, null, ex);
            }
            panoramiquesProjet[panoActuel].addHotspotImage(HS);
            retireAffichageHotSpots();
            Pane affHS1 = affichageHS(listePano(panoActuel), panoActuel);
            affHS1.setId("labels");
            outils.getChildren().add(affHS1);

        } else {
            String chPoint = point.getId();
            chPoint = chPoint.substring(3, chPoint.length());
            Node pt = (Node) pano.lookup("#img" + chPoint);
            pano.getChildren().remove(pt);
        }
        valideHS();
        point.setOnDragDetected((MouseEvent me1) -> {
            point.setFill(Color.YELLOW);
            point.setStroke(Color.BLUE);
            dragDrop = true;
            me1.consume();

        });
        point.setOnMouseDragged((MouseEvent me1) -> {
            double XX = me1.getX() - imagePanoramique.getLayoutX();
            if (XX < 0) {
                XX = 0;
            }
            if (XX > imagePanoramique.getFitWidth()) {
                XX = imagePanoramique.getFitWidth();
            }
            point.setCenterX(XX + imagePanoramique.getLayoutX());
            double YY = me1.getY();
            if (YY < 0) {
                YY = 0;
            }
            if (YY > imagePanoramique.getFitHeight()) {
                YY = imagePanoramique.getFitHeight();
            }
            point.setCenterY(YY);

            me1.consume();

        });
        point.setOnMouseReleased((MouseEvent me1) -> {
            String chPoint = point.getId();
            chPoint = chPoint.substring(3, chPoint.length());
            int numeroPoint = Integer.parseInt(chPoint);
            double X1 = me1.getSceneX();
            double Y1 = me1.getSceneY();
            double mouseX1 = X1 - imagePanoramique.getLayoutX();
            if (mouseX1 < 0) {
                mouseX1 = 0;
            }
            if (mouseX1 > imagePanoramique.getFitWidth()) {
                mouseX1 = imagePanoramique.getFitWidth();
            }

            double mouseY1 = Y1 - pano.getLayoutY() - 109;
            if (mouseY1 < 0) {
                mouseY1 = 0;
            }
            if (mouseY1 > imagePanoramique.getFitHeight()) {
                mouseY1 = imagePanoramique.getFitHeight();
            }

            double longit, lat;
            double larg = imagePanoramique.getFitWidth();
            longit = 360.0f * mouseX1 / larg - 180;
            lat = 90.0d - 2.0f * mouseY1 / larg * 180.0f;
            panoramiquesProjet[panoActuel].getHotspotImage(numeroPoint).setLatitude(lat);
            panoramiquesProjet[panoActuel].getHotspotImage(numeroPoint).setLongitude(longit);
            point.setFill(Color.BLUE);
            point.setStroke(Color.YELLOW);
            me1.consume();

        });

        point.setOnMouseClicked((MouseEvent me1) -> {
            if (me1.isControlDown()) {
                dejaSauve = false;
                stPrincipal.setTitle(stPrincipal.getTitle().replace(" *", "") + " *");
                String chPoint = point.getId();
                chPoint = chPoint.substring(3, chPoint.length());
                int numeroPoint = Integer.parseInt(chPoint);
                Node pt;
                pt = (Node) pano.lookup("#img" + chPoint);
                pano.getChildren().remove(pt);

                for (int o = numeroPoint + 1; o < numImages; o++) {
                    pt = (Node) pano.lookup("#img" + Integer.toString(o));
                    pt.setId("img" + Integer.toString(o - 1));
                }
                /**
                 * on retire les anciennes indication de HS
                 */
                retireAffichageHotSpots();
                numImages--;
                panoramiquesProjet[panoActuel].removeHotspotImage(numeroPoint);
                /**
                 * On les cre les nouvelles
                 */
                ajouteAffichageHotspots();
            }
            valideHS();
            me1.consume();
        });

    }
}

From source file:editeurpanovisu.EditeurPanovisu.java

/**
 *
 * @return//from w ww.j a v a2  s.c om
 */
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;
}