package javafx_imageprocessing;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Slider;
import javafx.scene.control.SliderBuilder;
import javafx.scene.control.Tooltip;
import javafx.scene.effect.Glow;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.HBox;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
/**
*
* @web http://java-buddy.blogspot.com/
*/
public class JavaFX_ImageProcessing extends Application {
ImageView imageView_Source, imageView_Target;
Slider sliderLevel;
@Override
public void start(Stage primaryStage) {
Image image = new Image("http://goo.gl/kYEQl");
imageView_Source = new ImageView();
imageView_Source.setImage(image);
imageView_Target = new ImageView();
imageView_Target.setImage(image);
HBox hBoxImage = new HBox();
hBoxImage.getChildren().addAll(imageView_Source, imageView_Target);
sliderLevel = SliderBuilder.create()
.prefWidth(300)
.min(0)
.max(1)
.majorTickUnit(0.2)
.showTickMarks(true)
.showTickLabels(true)
.value(0.3)
.tooltip(new Tooltip("Level"))
.build();
Button btnProcess = new Button("Process...");
btnProcess.setOnAction(btnProcessEventListener);
VBox vBox = new VBox();
vBox.getChildren().addAll(hBoxImage,
sliderLevel,
btnProcess);
StackPane root = new StackPane();
root.getChildren().add(vBox);
Scene scene = new Scene(root, 350, 330);
primaryStage.setTitle("java-buddy.blogspot.com");
primaryStage.setScene(scene);
primaryStage.show();
updateEffect();
}
public static void main(String[] args) {
launch(args);
}
EventHandler<ActionEvent> btnProcessEventListener
= new EventHandler<ActionEvent>(){
@Override
public void handle(ActionEvent t) {
updateEffect();
}
};
private void updateEffect(){
Double valueLevel = sliderLevel.valueProperty().doubleValue();
Glow glow = new Glow(valueLevel);
imageView_Target.setEffect(glow);
}
}
Tuesday, January 22, 2013
Apply effect of Glow on ImageView
javafx.scene.effect.Glow is a high-level effect that makes the input image appear to glow, based on a configurable threshold.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment