0

ImaveView を作成し、Image オブジェクトに影響を与えました。画像が正しく表示されます。また、新しいステージを開くボタン (内部に画像が表示されます) と、画像処理を行うためのスライドバーもいくつか作成しました。編集を行った後、ImageView を新しいイメージで更新するにはどうすればよいですか?

これが私がやったことです:

//Boutton Traitement d'image
Button btnImageProcess = new Button("Traitement d'Image");
btnImageProcess.setOnAction(new EventHandler<ActionEvent>() {

    public void handle(ActionEvent event) {
        ImageProcess imageProcess = new ImageProcess();
        imageImageProcess = new Image(ImagePathImageProcess);
        imageViewImageProcess = ImageViewBuilder.create().image(imageImageProcess).build();
        ColorAdjust colorAdjust = ColorAdjustBuilder.create().build();
        imageViewImageProcess.setEffect(colorAdjust);
        // 
        Label saturationLabel = LabelBuilder.create().text("Saturation").build();
        GridPane.setConstraints(saturationLabel, 0, 0);
        Slider saturationSlider = SliderBuilder.create().value(50).build();
        colorAdjust.saturationProperty().bind(saturationSlider.valueProperty().divide(50).subtract(1));
        GridPane.setConstraints(saturationSlider, 1, 0);
        GridPane.setHgrow(saturationSlider, Priority.ALWAYS);
        Label saturationValueLabel = LabelBuilder.create().minWidth(75).maxWidth(75).build();
        saturationValueLabel.textProperty().bind(colorAdjust.saturationProperty().multiply(100).
                asString("%.2f%%"));
        GridPane.setConstraints(saturationValueLabel, 2, 0);
        // 
        Label hueLabel = LabelBuilder.create().text("Hue").build();
        GridPane.setConstraints(hueLabel, 0, 1);
        Slider hueSlider = SliderBuilder.create().value(50).build();
        colorAdjust.hueProperty().bind(hueSlider.valueProperty().divide(50).subtract(1));
        GridPane.setConstraints(hueSlider, 1, 1);
        GridPane.setHgrow(hueSlider, Priority.ALWAYS);
        Label hueValueLabel = LabelBuilder.create().minWidth(75).maxWidth(75).build();
        hueValueLabel.textProperty().bind(colorAdjust.hueProperty().multiply(100).asString("%.2f%%"));
        GridPane.setConstraints(hueValueLabel, 2, 1);
        // 
        Label brightnessLabel = LabelBuilder.create().text("Brightness").build();
        GridPane.setConstraints(brightnessLabel, 0, 2);
        Slider brightnessSlider = SliderBuilder.create().value(50).build();
        colorAdjust.brightnessProperty().bind(brightnessSlider.valueProperty().divide(50).subtract(1));
        GridPane.setConstraints(brightnessSlider, 1, 2);
        GridPane.setHgrow(brightnessSlider, Priority.ALWAYS);
        Label brightnessValueLabel = LabelBuilder.create().minWidth(75).maxWidth(75).build();
        brightnessValueLabel.textProperty().bind(colorAdjust.brightnessProperty().multiply(100).
                asString("%.2f%%"));
        GridPane.setConstraints(brightnessValueLabel, 2, 2);
        // 
        Label contrastLabel = LabelBuilder.create().text("Contrast").build();
        GridPane.setConstraints(contrastLabel, 0, 3);
        Slider contrastSlider = SliderBuilder.create().value(50).build();
        colorAdjust.contrastProperty().bind(contrastSlider.valueProperty().divide(50).subtract(1));
        GridPane.setConstraints(contrastSlider, 1, 3);
        GridPane.setHgrow(contrastSlider, Priority.ALWAYS);
        Label contrastValueLabel = LabelBuilder.create().minWidth(75).maxWidth(75).build();
        contrastValueLabel.textProperty().bind(colorAdjust.contrastProperty().multiply(100).asString("%.2f%%"));
        GridPane.setConstraints(contrastValueLabel, 2, 3);

        //Validate Button
        Button btnValider = new Button("Valider");
        btnValider.setOnAction(new EventHandler<ActionEvent>() {

            public void handle(ActionEvent event) {

                imageProcessStage.hide();
                ImageView imageView2 = new ImageView(imageViewImageProcess.getImage());
                imageView.setImage(imageViewImageProcess.getImage());

            }
        });

        GridPane.setConstraints(btnValider, 1, 4);
        GridPane.setHgrow(btnValider, Priority.ALWAYS);
        btnValider.setTranslateX(imageImageProcess.getWidth() / 12);
        btnValider.setTranslateY(7);

        //Validate Button
        Button btnReset = new Button("Reset");
        btnReset.setOnAction(new EventHandler<ActionEvent>() {

            public void handle(ActionEvent event) {
                ImageProcess ip = new ImageProcess();
                ip.setImagePath(ImagePathImageProcess);
                ip.start();
                imageProcessStage.close();
            }
        });
        GridPane.setConstraints(btnReset, 1, 4);
        GridPane.setHgrow(btnReset, Priority.ALWAYS);
        btnReset.setTranslateX(imageImageProcess.getWidth() / 12 + 82);
        btnReset.setTranslateY(7);

        //
        GridPane sliderGrid = GridPaneBuilder.create().children(saturationLabel, saturationSlider, saturationValueLabel,
                hueLabel, hueSlider, hueValueLabel,
                brightnessLabel, brightnessSlider, brightnessValueLabel,
                contrastLabel, contrastSlider, contrastValueLabel, btnValider, btnReset).build();

        imageViewImageProcess.setFitWidth(imageImageProcess.getWidth() / 3);
        imageViewImageProcess.setTranslateY(20);
        //imageView.setFitHeight(image.getHeight()/2);
        imageViewImageProcess.setPreserveRatio(true);
        imageViewImageProcess.setSmooth(true);
        imageViewImageProcess.setCache(true);

        rootImageProcess = BorderPaneBuilder.create().center(imageViewImageProcess).top(sliderGrid).
                build();

        imageProcessStage.setTitle("Traitement d'image");
        sceneImageProcess = new Scene(rootImageProcess);
        sceneImageProcess.getStylesheets().add(ImageProcess.class.getResource("ImageProcess.css").
                toExternalForm());
        imageProcessStage.setScene(sceneImageProcess);
        imageProcessStage.show();

    }
});
4

1 に答える 1

0

あなたが持っている...

ImageView imageView2 = new ImageView(imageViewImageProcess.getImage());
imageView.setImage(imageViewImageProcess.getImage());

それは役に立たないようです

于 2012-12-15T21:19:41.333 に答える