当前位置: 首页>>代码示例>>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;未经允许,请勿转载。