Java Code Examples for javafx.scene.image.ImageView#setEffect()
The following examples show how to use
javafx.scene.image.ImageView#setEffect() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ClickableBitcoinAddress.java From GreenBits with GNU General Public License v3.0 | 6 votes |
@FXML protected void showQRCode(MouseEvent event) { // Serialize to PNG and back into an image. Pretty lame but it's the shortest code to write and I'm feeling // lazy tonight. final byte[] imageBytes = QRCode .from(uri()) .withSize(320, 240) .to(ImageType.PNG) .stream() .toByteArray(); Image qrImage = new Image(new ByteArrayInputStream(imageBytes)); ImageView view = new ImageView(qrImage); view.setEffect(new DropShadow()); // Embed the image in a pane to ensure the drop-shadow interacts with the fade nicely, otherwise it looks weird. // Then fix the width/height to stop it expanding to fill the parent, which would result in the image being // non-centered on the screen. Finally fade/blur it in. Pane pane = new Pane(view); pane.setMaxSize(qrImage.getWidth(), qrImage.getHeight()); final Main.OverlayUI<ClickableBitcoinAddress> overlay = Main.instance.overlayUI(pane, this); view.setOnMouseClicked(event1 -> overlay.done()); }
Example 2
Source File: ClickableBitcoinAddress.java From green_android with GNU General Public License v3.0 | 6 votes |
@FXML protected void showQRCode(MouseEvent event) { // Serialize to PNG and back into an image. Pretty lame but it's the shortest code to write and I'm feeling // lazy tonight. final byte[] imageBytes = QRCode .from(uri()) .withSize(320, 240) .to(ImageType.PNG) .stream() .toByteArray(); Image qrImage = new Image(new ByteArrayInputStream(imageBytes)); ImageView view = new ImageView(qrImage); view.setEffect(new DropShadow()); // Embed the image in a pane to ensure the drop-shadow interacts with the fade nicely, otherwise it looks weird. // Then fix the width/height to stop it expanding to fill the parent, which would result in the image being // non-centered on the screen. Finally fade/blur it in. Pane pane = new Pane(view); pane.setMaxSize(qrImage.getWidth(), qrImage.getHeight()); final Main.OverlayUI<ClickableBitcoinAddress> overlay = Main.instance.overlayUI(pane, this); view.setOnMouseClicked(event1 -> overlay.done()); }
Example 3
Source File: ClickableBitcoinAddress.java From devcoretalk with GNU General Public License v2.0 | 6 votes |
@FXML protected void showQRCode(MouseEvent event) { // Serialize to PNG and back into an image. Pretty lame but it's the shortest code to write and I'm feeling // lazy tonight. final byte[] imageBytes = QRCode .from(uri()) .withSize(320, 240) .to(ImageType.PNG) .stream() .toByteArray(); Image qrImage = new Image(new ByteArrayInputStream(imageBytes)); ImageView view = new ImageView(qrImage); view.setEffect(new DropShadow()); // Embed the image in a pane to ensure the drop-shadow interacts with the fade nicely, otherwise it looks weird. // Then fix the width/height to stop it expanding to fill the parent, which would result in the image being // non-centered on the screen. Finally fade/blur it in. Pane pane = new Pane(view); pane.setMaxSize(qrImage.getWidth(), qrImage.getHeight()); final Main.OverlayUI<ClickableBitcoinAddress> overlay = Main.instance.overlayUI(pane, this); view.setOnMouseClicked(event1 -> overlay.done()); }
Example 4
Source File: Builders.java From PDF4Teachers with Apache License 2.0 | 6 votes |
public static ImageView buildImage(String imgPath, int width, int height, Effect effect) { ImageView imageView = new ImageView(new Image(imgPath)); if(effect != null) imageView.setEffect(effect); if(width == 0 && height == 0) return imageView; if(width == 0){ imageView.setFitHeight(height); imageView.setPreserveRatio(true); }else if(height == 0){ imageView.setFitWidth(width); imageView.setPreserveRatio(true); }else{ imageView.setFitWidth(width); imageView.setFitHeight(height); } return imageView; }
Example 5
Source File: GaussianBlurSample.java From marathonv5 with Apache License 2.0 | 5 votes |
public GaussianBlurSample() { super(48,48); ImageView sample = new ImageView(ICON_48); final GaussianBlur gaussianBlur = new GaussianBlur(); gaussianBlur.setRadius(8d); sample.setEffect(gaussianBlur); getChildren().add(sample); // REMOVE ME setControls( new SimplePropertySheet.PropDesc("GaussianBlur Level", gaussianBlur.radiusProperty(), 0d, 15d) ); // END REMOVE ME }
Example 6
Source File: CardPileView.java From Solitaire with GNU General Public License v2.0 | 5 votes |
private EventHandler<DragEvent> createDragExitedHandler(final ImageView pImageView, final Card pCard) { return new EventHandler<DragEvent>() { @Override public void handle(DragEvent pEvent) { pImageView.setEffect(null); pEvent.consume(); } }; }
Example 7
Source File: ScrollBarSample.java From marathonv5 with Apache License 2.0 | 5 votes |
@Override public void start(Stage stage) { Group root = new Group(); Scene scene = new Scene(root, 180, 180); scene.setFill(Color.BLACK); stage.setScene(scene); stage.setTitle("Scrollbar"); root.getChildren().addAll(vb, sc); shadow.setColor(Color.GREY); shadow.setOffsetX(2); shadow.setOffsetY(2); vb.setLayoutX(5); vb.setSpacing(10); sc.setLayoutX(scene.getWidth() - sc.getWidth()); sc.setMin(0); sc.setOrientation(Orientation.VERTICAL); sc.setPrefHeight(180); sc.setMax(360); for (int i = 0; i < 5; i++) { final Image image = images[i] = new Image(getClass().getResourceAsStream("fw" + (i + 1) + ".jpg")); final ImageView pic = pics[i] = new ImageView(images[i]); pic.setEffect(shadow); vb.getChildren().add(pics[i]); } sc.valueProperty().addListener((ObservableValue<? extends Number> ov, Number old_val, Number new_val) -> { vb.setLayoutY(-new_val.doubleValue()); }); stage.show(); }
Example 8
Source File: GaussianBlurSample.java From marathonv5 with Apache License 2.0 | 5 votes |
public GaussianBlurSample() { super(48,48); ImageView sample = new ImageView(ICON_48); final GaussianBlur gaussianBlur = new GaussianBlur(); gaussianBlur.setRadius(8d); sample.setEffect(gaussianBlur); getChildren().add(sample); // REMOVE ME setControls( new SimplePropertySheet.PropDesc("GaussianBlur Level", gaussianBlur.radiusProperty(), 0d, 15d) ); // END REMOVE ME }
Example 9
Source File: SepiaToneSample.java From marathonv5 with Apache License 2.0 | 5 votes |
public SepiaToneSample() { ImageView sample = new ImageView(BOAT); final SepiaTone sepiaTone = new SepiaTone(); sepiaTone.setLevel(0.5d); sample.setEffect(sepiaTone); getChildren().add(sample); // REMOVE ME setControls( new SimplePropertySheet.PropDesc("SepiaTone Level", sepiaTone.levelProperty(), 0d, 1d) ); // END REMOVE ME }
Example 10
Source File: DigitFactory.java From metastone with GNU General Public License v2.0 | 5 votes |
private static void applyFontColor(ImageView image, Color color) { ColorAdjust monochrome = new ColorAdjust(); monochrome.setSaturation(-1.0); Effect colorInput = new ColorInput(0, 0, image.getImage().getWidth(), image.getImage().getHeight(), color); Blend blend = new Blend(BlendMode.MULTIPLY, new ImageInput(image.getImage()), colorInput); image.setClip(new ImageView(image.getImage())); image.setEffect(blend); image.setCache(true); }
Example 11
Source File: SepiaToneSample.java From marathonv5 with Apache License 2.0 | 5 votes |
public SepiaToneSample() { ImageView sample = new ImageView(BOAT); final SepiaTone sepiaTone = new SepiaTone(); sepiaTone.setLevel(0.5d); sample.setEffect(sepiaTone); getChildren().add(sample); // REMOVE ME setControls( new SimplePropertySheet.PropDesc("SepiaTone Level", sepiaTone.levelProperty(), 0d, 1d) ); // END REMOVE ME }
Example 12
Source File: FxmlImageManufacture.java From MyBox with Apache License 2.0 | 5 votes |
public static Image addShadowFx(Image image, int shadow, Color color) { try { if (image == null || shadow <= 0) { return null; } double imageWidth = image.getWidth(), imageHeight = image.getHeight(); Group group = new Group(); Scene s = new Scene(group); ImageView view = new ImageView(image); view.setPreserveRatio(true); view.setFitWidth(imageWidth); view.setFitHeight(imageHeight); DropShadow dropShadow = new DropShadow(); dropShadow.setOffsetX(shadow); dropShadow.setOffsetY(shadow); dropShadow.setColor(color); view.setEffect(dropShadow); group.getChildren().add(view); SnapshotParameters parameters = new SnapshotParameters(); parameters.setFill(Color.TRANSPARENT); WritableImage newImage = group.snapshot(parameters, null); return newImage; } catch (Exception e) { // logger.error(e.toString()); return null; } }
Example 13
Source File: ImageMosaicStep.java From TweetwallFX with MIT License | 5 votes |
private Transition createMosaicTransition(final List<ImageStore> imageStores) { final SequentialTransition fadeIn = new SequentialTransition(); final List<FadeTransition> allFadeIns = new ArrayList<>(); final double width = pane.getWidth() / 6.0 - 10; final double height = pane.getHeight() / 5.0 - 8; final List<ImageStore> distillingList = new ArrayList<>(imageStores); for (int i = 0; i < 6; i++) { for (int j = 0; j < 5; j++) { int index = RANDOM.nextInt(distillingList.size()); ImageStore selectedImage = distillingList.remove(index); ImageView imageView = new ImageView(selectedImage.getImage()); imageView.setCache(true); imageView.setCacheHint(CacheHint.SPEED); imageView.setFitWidth(width); imageView.setFitHeight(height); imageView.setEffect(new GaussianBlur(0)); rects[i][j] = imageView; bounds[i][j] = new BoundingBox(i * (width + 10) + 5, j * (height + 8) + 4, width, height); rects[i][j].setOpacity(0); rects[i][j].setLayoutX(bounds[i][j].getMinX()); rects[i][j].setLayoutY(bounds[i][j].getMinY()); pane.getChildren().add(rects[i][j]); FadeTransition ft = new FadeTransition(Duration.seconds(0.3), imageView); ft.setToValue(1); allFadeIns.add(ft); } } Collections.shuffle(allFadeIns); fadeIn.getChildren().addAll(allFadeIns); return fadeIn; }
Example 14
Source File: Story.java From mars-sim with GNU General Public License v3.0 | 4 votes |
/** render the application on a stage */ public StackPane createGUI() { SwingUtilities.invokeLater(() -> { //Simulation.instance().getJConsole().write(ADDRESS,Color.ORANGE,Color.BLACK); }); // place the address content in a bordered title pane. Pane titledContent = new BorderedTitledPane(TITLE, getContent()); titledContent.getStyleClass().add("titled-address"); titledContent.setPrefSize(800, 745); // make some crumpled paper as a background. final Image paper = new Image(PAPER); final ImageView paperView = new ImageView(paper); ColorAdjust colorAdjust = new ColorAdjust(0, -.2, .2, 0); paperView.setEffect(colorAdjust); // place the address content over the top of the paper. StackPane stackedContent = new StackPane(); stackedContent.getChildren().addAll(paperView, titledContent); // manage the viewport of the paper background, to size it to the content. paperView.setViewport(new Rectangle2D(0, 0, titledContent.getPrefWidth(), titledContent.getPrefHeight())); stackedContent.layoutBoundsProperty().addListener(new ChangeListener<Bounds>() { @Override public void changed(ObservableValue<? extends Bounds> observableValue, Bounds oldValue, Bounds newValue) { paperView.setViewport(new Rectangle2D( newValue.getMinX(), newValue.getMinY(), Math.min(newValue.getWidth(), paper.getWidth()), Math.min(newValue.getHeight(), paper.getHeight()) )); } }); // blend the content into the paper and make it look old. titledContent.setMaxWidth(paper.getWidth()); titledContent.setEffect(new SepiaTone()); titledContent.setBlendMode(BlendMode.MULTIPLY); // configure and display the scene and stage. //Scene scene = new Scene(stackedContent); //scene.getStylesheets().add(getClass().getResource("/css/gettysburg.css").toExternalForm()); /* stage.setTitle(TITLE); stage.getIcons().add(new Image(ICON)); stage.setScene(scene); stage.setMinWidth(600); stage.setMinHeight(500); stage.show(); */ // make the scrollbar in the address scroll pane hide when it is not needed. makeScrollFadeable(titledContent.lookup(".address > .scroll-pane")); return stackedContent; }
Example 15
Source File: DisplayShelfSample.java From marathonv5 with Apache License 2.0 | 4 votes |
public PerspectiveImage(Image image) { ImageView imageView = new ImageView(image); imageView.setEffect(ReflectionBuilder.create().fraction(REFLECTION_SIZE).build()); setEffect(transform); getChildren().addAll(imageView); }
Example 16
Source File: Fallout4MenuApp.java From FXTutorials with MIT License | 4 votes |
private Parent createContent() { Pane root = new Pane(); ImageView imageView = new ImageView(new Image(getClass() .getResource("res/Fallout4_bg.jpg").toExternalForm())); imageView.setFitWidth(1280); imageView.setFitHeight(720); SepiaTone tone = new SepiaTone(0.85); imageView.setEffect(tone); Rectangle masker = new Rectangle(1280, 720); masker.setOpacity(0); masker.setMouseTransparent(true); MenuBox menuBox = new MenuBox(250, 350); menuBox.setTranslateX(250); menuBox.setTranslateY(230); MenuBox menuBox2 = new MenuBox(510, 350); menuBox2.setTranslateX(250 + 20 + 250); menuBox2.setTranslateY(230); menuBox.addItem(new MenuItem("CONTINUE", 250)); MenuItem itemNew = new MenuItem("NEW", 250); itemNew.setOnAction(() -> { FadeTransition ft = new FadeTransition(Duration.seconds(1.5), masker); ft.setToValue(1); ft.setOnFinished(e -> { root.getChildren().setAll(new LoadingScreen(1280, 720, () -> { masker.setOpacity(0); root.getChildren().setAll(imageView, menuBox, menuBox2, masker); })); }); ft.play(); }); menuBox.addItem(itemNew); menuBox.addItem(new MenuItem("LOAD", 250)); MenuItem itemSettings = new MenuItem("SETTINGS", 250); itemSettings.setOnAction(() -> { menuBox2.addItems( new MenuItem("GAMEPLAY", 510), new MenuItem("CONTROLS", 510), new MenuItem("DISPLAY", 510), new MenuItem("AUDIO", 510)); }); menuBox.addItem(itemSettings); menuBox.addItem(new MenuItem("CREW", 250)); MenuItem itemExit = new MenuItem("EXIT", 250); itemExit.setOnAction(() -> System.exit(0)); menuBox.addItem(itemExit); root.getChildren().addAll(imageView, menuBox, menuBox2, masker); return root; }
Example 17
Source File: DisplayShelfSample.java From marathonv5 with Apache License 2.0 | 4 votes |
public PerspectiveImage(Image image) { ImageView imageView = new ImageView(image); imageView.setEffect(ReflectionBuilder.create().fraction(REFLECTION_SIZE).build()); setEffect(transform); getChildren().addAll(imageView); }
Example 18
Source File: AboutDialog.java From JetUML with GNU General Public License v3.0 | 4 votes |
private Scene createScene() { final int verticalSpacing = 5; VBox info = new VBox(verticalSpacing); Text name = new Text(RESOURCES.getString("application.name")); name.setStyle("-fx-font-size: 18pt;"); Text version = new Text(String.format("%s %s", RESOURCES.getString("dialog.about.version"), UMLEditor.VERSION)); Text copyright = new Text(RESOURCES.getString("application.copyright")); Text license = new Text(RESOURCES.getString("dialog.about.license")); Text quotes = new Text(RESOURCES.getString("quotes.copyright")); Hyperlink link = new Hyperlink(RESOURCES.getString("dialog.about.link")); link.setBorder(Border.EMPTY); link.setPadding(new Insets(0)); link.setOnMouseClicked(e -> UMLEditor.openBrowser(RESOURCES.getString("dialog.about.url"))); link.setUnderline(true); link.setFocusTraversable(false); info.getChildren().addAll(name, version, copyright, license, link, quotes); final int padding = 15; HBox layout = new HBox(padding); layout.setStyle("-fx-background-color: gainsboro;"); layout.setPadding(new Insets(padding)); layout.setAlignment(Pos.CENTER_LEFT); ImageView logo = new ImageView(RESOURCES.getString("application.icon")); logo.setEffect(new BoxBlur()); layout.getChildren().addAll(logo, info); layout.setAlignment(Pos.TOP_CENTER); aStage.requestFocus(); aStage.addEventHandler(KeyEvent.KEY_PRESSED, pEvent -> { if (pEvent.getCode() == KeyCode.ENTER) { aStage.close(); } }); return new Scene(layout); }
Example 19
Source File: PauseView.java From CrazyAlpha with GNU General Public License v2.0 | 4 votes |
public PauseView() { root = new Pane(); Game.getInstance().resetMedia(); map = Game.getInstance().getMapManager().getCurrentMap(); mapIv = new ImageView(map.getMapImage()); mapIv.setFitWidth(Game.getInstance().getWidth()); mapIv.setFitHeight(Game.getInstance().getHeight()); nameLbl = new Label("CrazyAlpha!"); nameLbl.setTextFill(Color.WHITESMOKE); nameLbl.setFont(Game.getInstance().getResouceManager().getFont("Starcraft", 120)); nameLbl.setLayoutX(50); nameLbl.setLayoutY(50); Reflection reflection1 = new Reflection(); reflection1.setFraction(1.0); nameLbl.setEffect(reflection1); Reflection reflection02 = new Reflection(); reflection02.setFraction(0.4); resumeBtn = new ImageView(Game.getInstance().getResouceManager().getControl("btn_resume")); resumeBtn.setFitWidth(165 * 1.5); resumeBtn.setFitHeight(65 * 1.5); exitBtn = new ImageView(Game.getInstance().getResouceManager().getControl("btn_exit")); exitBtn.setFitWidth(165 * 1.5); exitBtn.setFitHeight(65 * 1.5); resumeBtn.setLayoutX(map.getWidth() - resumeBtn.getFitWidth() - 20); resumeBtn.setLayoutY(map.getHeight() - resumeBtn.getFitHeight() - exitBtn.getFitHeight() - 120); resumeBtn.setEffect(reflection02); resumeBtn.setOnMouseEntered(event -> { resumeBtn.setEffect(new Glow(0.8)); Game.getInstance().getButtonOverMusic().play(); }); resumeBtn.setOnMouseExited(event -> { resumeBtn.setEffect(reflection02); Game.getInstance().getButtonClickMusic().stop(); }); resumeBtn.setOnMousePressed(event -> { resumeBtn.setEffect(new GaussianBlur()); Game.getInstance().getButtonClickMusic().play(); Game.getInstance().resume(); }); resumeBtn.setOnMouseReleased(event -> { resumeBtn.setEffect(new Glow(0.8)); }); exitBtn.setLayoutX(map.getWidth() - exitBtn.getFitWidth() - 20); exitBtn.setLayoutY(map.getHeight() - exitBtn.getFitHeight() - 60); exitBtn.setEffect(reflection02); exitBtn.setOnMouseEntered(event -> { exitBtn.setEffect(new Glow(0.8)); Game.getInstance().getButtonOverMusic().play(); }); exitBtn.setOnMouseExited(event -> { exitBtn.setEffect(reflection02); Game.getInstance().getButtonOverMusic().stop(); }); exitBtn.setOnMousePressed(event -> { exitBtn.setEffect(new GaussianBlur()); Game.getInstance().getButtonClickMusic().play(); }); exitBtn.setOnMouseReleased(event -> { exitBtn.setEffect(new Glow(0.8)); Game.getInstance().exit(); }); root.getChildren().add(mapIv); root.getChildren().add(nameLbl); root.getChildren().add(resumeBtn); root.getChildren().add(exitBtn); makeFadeTransition(resumeBtn, 2000, 1, 0.7); makeFadeTransition(exitBtn, 2000, 1, 0.7); makeFadeTransition(mapIv, 3000, 1, 0.8); makeScaleTransition(mapIv, 10000, 0.25, 0.25); }
Example 20
Source File: OverView.java From CrazyAlpha with GNU General Public License v2.0 | 4 votes |
public OverView() { root = new Pane(); Game.getInstance().resetMedia(); GameMap map = Game.getInstance().getMapManager().getCurrentMap(); ImageView mapIv = new ImageView(map.getMapImage()); mapIv.setFitWidth(Game.getInstance().getWidth()); mapIv.setFitHeight(Game.getInstance().getHeight()); Label nameLbl = new Label("Game Over!"); nameLbl.setTextFill(Color.WHITESMOKE); nameLbl.setFont(Game.getInstance().getResouceManager().getFont("Starcraft", 80)); nameLbl.setLayoutX(50); nameLbl.setLayoutY(50); Label scoreLbl = new Label(); scoreLbl.setTextFill(Color.WHITESMOKE); scoreLbl.setFont(Game.getInstance().getResouceManager().getFont("Starcraft", 60)); scoreLbl.setLayoutX(50); scoreLbl.setLayoutY(map.getHeight() - scoreLbl.getHeight() - 140); if (Game.getInstance().getScore() > Game.getInstance().getDataManager().getHighestScore()) { // 刷新高分记录! scoreLbl.setText("New Record: " + Game.getInstance().getScore()); Game.getInstance().getDataManager().setHighestScore(Game.getInstance().getScore()); } else scoreLbl.setText("Score: " + Game.getInstance().getScore()); Reflection reflection = new Reflection(); reflection.setFraction(1.0); nameLbl.setEffect(reflection); ImageView homeBtn = new ImageView(Game.getInstance().getResouceManager().getControl("btn_home")); homeBtn.setFitWidth(165 * 1.5); homeBtn.setFitHeight(65 * 1.5); homeBtn.setLayoutX(map.getWidth() - homeBtn.getFitWidth() - 20); homeBtn.setLayoutY(map.getHeight() - homeBtn.getFitHeight() - 60); homeBtn.setEffect(reflection); homeBtn.setOnMouseEntered(event -> { homeBtn.setEffect(new Glow(0.8)); Game.getInstance().getButtonOverMusic().play(); }); homeBtn.setOnMouseExited(event -> { homeBtn.setEffect(reflection); Game.getInstance().getButtonOverMusic().stop(); }); homeBtn.setOnMousePressed(event -> { homeBtn.setEffect(new GaussianBlur()); Game.getInstance().getButtonClickMusic().play(); }); homeBtn.setOnMouseReleased(event -> { homeBtn.setEffect(new Glow(0.8)); Game.getInstance().home(); }); root.getChildren().add(mapIv); root.getChildren().add(nameLbl); root.getChildren().add(scoreLbl); root.getChildren().add(homeBtn); makeFadeTransition(homeBtn, 2000, 1, 0.7); makeFadeTransition(mapIv, 3000, 1, 0.8); makeScaleTransition(mapIv, 10000, 0.25, 0.25); }