當前位置: 首頁>>代碼示例>>Java>>正文


Java MouseEvent.MOUSE_CLICKED屬性代碼示例

本文整理匯總了Java中javafx.scene.input.MouseEvent.MOUSE_CLICKED屬性的典型用法代碼示例。如果您正苦於以下問題:Java MouseEvent.MOUSE_CLICKED屬性的具體用法?Java MouseEvent.MOUSE_CLICKED怎麽用?Java MouseEvent.MOUSE_CLICKED使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在javafx.scene.input.MouseEvent的用法示例。


在下文中一共展示了MouseEvent.MOUSE_CLICKED屬性的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: HorizonChart

public HorizonChart(final int BANDS, final Series<T> SERIES, final boolean SMOOTHED) {
    series        = SERIES;
    scaleX        = 1;
    scaleY        = 1;
    smoothed      = SMOOTHED;
    referenceZero = true;
    noOfBands     = clamp(1, MAX_NO_OF_BANDS, BANDS);
    noOfItems     = SERIES.getNoOfItems();
    minY          = SERIES.getItems().stream().mapToDouble(Data::getY).min().getAsDouble();
    maxY          = SERIES.getItems().stream().mapToDouble(Data::getY).max().getAsDouble();
    bandWidth     = (maxY - minY) / noOfBands;
    tooltip       = new Tooltip();
    tooltip.setAnchorLocation(AnchorLocation.CONTENT_BOTTOM_LEFT);

    adjustColors();

    // Create list of points
    points = new ArrayList<>(noOfItems);
    prepareData();

    mouseListener           = mouseEvent -> {
        final EventType<? extends MouseEvent> TYPE = mouseEvent.getEventType();
        if (MouseEvent.MOUSE_CLICKED == TYPE) {
            Data<T> data = selectDataAt(mouseEvent.getX());
            tooltip.setText(createTooltipText(data));
            tooltip.setX(mouseEvent.getScreenX());
            tooltip.setY(mouseEvent.getScreenY());
            tooltip.show(getScene().getWindow());
            getSeries().fireSeriesEvent(new SeriesEvent(getSeries(), data, SeriesEventType.SELECT_DATA));
        } else if (MouseEvent.MOUSE_MOVED == TYPE) {
            tooltip.hide();
        } else if (MouseEvent.MOUSE_EXITED == TYPE) {
            tooltip.hide();
        }
    };
    seriesListener          = seriesEvent -> redraw();

    initGraphics();
    registerListeners();
}
 
開發者ID:HanSolo,項目名稱:horizon,代碼行數:40,代碼來源:HorizonChart.java

示例2: createHomeButtonInGameScreen

public HomeButton createHomeButtonInGameScreen(@NonNull GazePlay gazePlay, @NonNull Stats stats) {
    HomeButton homeButton = new HomeButton();

    EventHandler<Event> homeEvent = new EventHandler<javafx.event.Event>() {
        @Override
        public void handle(javafx.event.Event e) {

            if (e.getEventType() == MouseEvent.MOUSE_CLICKED) {

                scene.setCursor(Cursor.WAIT); // Change cursor to wait style

                stats.stop();
                GazeUtils.clear();

                log.info("stats = " + stats);

                Runnable asynchronousStatsPersistTask = new Runnable() {
                    @Override
                    public void run() {
                        stats.saveStats();
                    }
                };
                Thread asynchronousStatsPersistThread = new Thread(asynchronousStatsPersistTask);
                asynchronousStatsPersistThread.start();

                StatsContext statsContext = StatsContext.newInstance(gazePlay, stats);

                gazePlay.onDisplayStats(statsContext);

                scene.setCursor(Cursor.DEFAULT); // Change cursor to default style
            }
        }
    };

    homeButton.addEventHandler(MouseEvent.MOUSE_CLICKED, homeEvent);

    // homeButton.recomputeSizeAndPosition(scene);
    menuHBox.getChildren().add(homeButton);

    return homeButton;
}
 
開發者ID:schwabdidier,項目名稱:GazePlay,代碼行數:41,代碼來源:GameContext.java

示例3: License

public License(double X, double Y, double width, double height, GazePlay gazePlay, Scene scene, Group root) {

        super(X, Y, width, height);

        this.setFill(new ImagePattern(new Image("data/common/images/license.png"), 0, 0, 1, 1, true));

        EventHandler<Event> homeEvent = new EventHandler<javafx.event.Event>() {
            @Override
            public void handle(javafx.event.Event e) {

                if (e.getEventType() == MouseEvent.MOUSE_CLICKED) {

                    root.getChildren().add(licence(width, height));

                    gazePlay.getHomeMenuScreen();
                }
            }
        };

        this.addEventHandler(MouseEvent.MOUSE_CLICKED, homeEvent);

    }
 
開發者ID:schwabdidier,項目名稱:GazePlay,代碼行數:22,代碼來源:License.java

示例4: createHomeButtonInStatsScreen

public static HomeButton createHomeButtonInStatsScreen(GazePlay gazePlay, StatsContext statsContext) {

        EventHandler<Event> homeEvent = new EventHandler<javafx.event.Event>() {
            @Override
            public void handle(javafx.event.Event e) {

                if (e.getEventType() == MouseEvent.MOUSE_CLICKED) {

                    statsContext.getScene().setCursor(Cursor.WAIT); // Change cursor to wait style

                    gazePlay.onReturnToMenu();

                    statsContext.getScene().setCursor(Cursor.DEFAULT); // Change cursor to default style
                }
            }
        };

        HomeButton homeButton = new HomeButton();
        homeButton.addEventHandler(MouseEvent.MOUSE_CLICKED, homeEvent);

        return homeButton;
    }
 
開發者ID:schwabdidier,項目名稱:GazePlay,代碼行數:22,代碼來源:StatsDisplay.java

示例5: createHomeButtonInConfigurationManagementScreen

private HomeButton createHomeButtonInConfigurationManagementScreen(@NonNull GazePlay gazePlay) {

        HomeButton homeButton = new HomeButton();

        EventHandler<Event> homeEvent = new EventHandler<javafx.event.Event>() {
            @Override
            public void handle(javafx.event.Event e) {

                if (e.getEventType() == MouseEvent.MOUSE_CLICKED) {

                    scene.setCursor(Cursor.WAIT); // Change cursor to wait style

                    gazePlay.onReturnToMenu();

                    scene.setCursor(Cursor.DEFAULT); // Change cursor to default style
                }
            }
        };

        homeButton.addEventHandler(MouseEvent.MOUSE_CLICKED, homeEvent);

        return homeButton;
    }
 
開發者ID:schwabdidier,項目名稱:GazePlay,代碼行數:23,代碼來源:ConfigurationContext.java

示例6: buildBravoEvent

private  EventHandler<Event> buildBravoEvent() {
    return new EventHandler<Event>() {
        @Override
        public void handle(Event e) {



            if (e.getEventType() == MouseEvent.MOUSE_CLICKED || e.getEventType() == GazeEvent.GAZE_ENTERED) {

                canvas.getChildren().removeAll(imgViewTriangle, imgViewSquare, imgViewTrapez);
                canvas.add(imgViewBravo, 3, 3);

                String musicFileBravo = "samplesAmela/sounds/applause.mp3";

                Media soundBravo = new Media(new File(musicFileBravo).toURI().toString());
                MediaPlayer mediaPlayerBravo = new MediaPlayer(soundBravo);
                mediaPlayerBravo.play();

                System.out.println("Image 1 Clicked! BRAVO!");

                Animation animation = new Transition() {

                    {
                        setCycleDuration(Duration.millis(5000));
                        canvas.getChildren().add(bubble);


                    }

                    @Override
                    protected void interpolate(double frac) {
                        final int n = Math.round(100 * (float) frac);

                    }

                };
                animation.play();
                animation.setOnFinished(new EventHandler<ActionEvent>() {


                    @Override
                    public void handle(ActionEvent actionEvent) {
                        canvas.getChildren().remove(imgViewBravo);
                        canvas.getChildren().remove(bubble);

                        count=0;
                        Image image = canvas.snapshot(new SnapshotParameters(), null);
                        ImagePattern pattern = new ImagePattern(image, 0, 0, 0, 0, false);
                        pattern=createGridPattern();
                    }
                });

            }

        }
    };

}
 
開發者ID:schwabdidier,項目名稱:GazePlay,代碼行數:58,代碼來源:Circles_handler.java

示例7: createAnimation

private  EventHandler<Event> createAnimation() {
    return new EventHandler<Event>() {
        @Override
        public void handle(Event e) {



            if (e.getEventType() == MouseEvent.MOUSE_CLICKED || e.getEventType() == GazeEvent.GAZE_ENTERED) {

                System.out.println("Image Clicked! BRAVO!");

                Animation animation = new Transition() {

                    {
                        setCycleDuration(Duration.millis(3000));
                        hboxFirst.getChildren().removeAll(imgView1, imgView2, imgView3);
                        hboxFirst.getChildren().add(imgView4);
                        String musicFileBravo =  System.getProperties().getProperty("user.home") + File.separator + "GazePlay" + File.separator + "files" + File.separator + "myGame"+File.separator+"applause.mp3";
                        File fSound = new File(musicFileBravo);

                        Media firstSound = new Media(fSound.toURI().toString());
                        MediaPlayer mediaPlayerBravo = new MediaPlayer(firstSound);
                        mediaPlayerBravo.play();
                    }

                    @Override
                    protected void interpolate(double frac) {
                        final int n = Math.round(3000 * (float) frac);

                    }
                };

                animation.play();

                animation.setOnFinished(new EventHandler<ActionEvent>() {


                    @Override
                    public void handle(ActionEvent actionEvent) {
                        hboxFirst.getChildren().removeAll(imgView4);
                        createGame(sceneFirst, hboxFirst);

                    }
                });

            }

        }
    };

}
 
開發者ID:schwabdidier,項目名稱:GazePlay,代碼行數:51,代碼來源:JeuAnimaux_handler.java


注:本文中的javafx.scene.input.MouseEvent.MOUSE_CLICKED屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。