dragImageView.setImage(node.snapshot(snapParams, null));
public static BufferedImage generate_png_from_container(Node node) { SnapshotParameters param = new SnapshotParameters(); param.setDepthBuffer(true); WritableImage snapshot = node.snapshot(param, null); BufferedImage tempImg = SwingFXUtils.fromFXImage(snapshot, null); BufferedImage img = null; byte[] imageInByte; try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); ImageIO.write(tempImg, "png", baos); baos.flush(); imageInByte = baos.toByteArray(); baos.close(); InputStream in = new ByteArrayInputStream(imageInByte); img = ImageIO.read(in); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } //the final image sent to the PDJpeg return img; }
/** * Creates a snapshot of the node with the specified parameters. * * @param parameters * the {@link SnapshotParameters} used for the snapshot (must not be {@code null}); the viewport will be * interpreted relative to this control (like the {@link #selectionProperty() selection}) * @return the {@link WritableImage} that holds the rendered viewport * @throws IllegalStateException * if {@link #nodeProperty() node} is {@code null} * @see Node#snapshot */ public WritableImage createSnapshot(SnapshotParameters parameters) throws IllegalStateException { // make sure the node and the snapshot parameters exist Objects.requireNonNull(parameters, "The argument 'parameters' must not be null."); //$NON-NLS-1$ if (getNode() == null) { throw new IllegalStateException("No snapshot can be created if the node is null (check 'getNode()')."); //$NON-NLS-1$ } // take the snapshot return getNode().snapshot(parameters, null); }
Node backgroundNode = getBackgroundNode(); backgroundNode.resize(1080, 720); backgroundNode.snapshot(new SnapshotParameters(), null);
WritableImage image = node.snapshot(new SnapshotParameters(), null); String base64String = encodeImageToString(SwingFXUtils.fromFXImage(image, null), "png"); System.out.println("Base64 String : " + base64String);
Image chartSnapshot = node.snapshot(params, null); PngEncoderFX encoder = new PngEncoderFX(chartSnapshot, true); byte[] bytes = encoder.pngEncode();
Image fxImage = node.snapshot(null, null); BufferedImage bufferedImage = SwingFXUtils.fromFXImage(fxImage, null);
/** * save a snapshot of the given node as a PNG file * @param node - the node to get a snapshot from * @param file - the file to save to */ public static synchronized void saveAsPng(Node node, File file) { Bounds bounds = node.getBoundsInParent(); WritableImage writableImage = new WritableImage((int) bounds.getWidth(), (int) bounds.getHeight()); SnapshotParameters params = new SnapshotParameters(); node.snapshot(params, writableImage); try { ImageIO.write(fromFXImage(writableImage, null), "png", file); } catch (Throwable th) { ErrorHandler.handle(th); } }
private EventHandler<? super MouseEvent> onDragDetected() { return evt -> { Node node = (Node) evt.getSource(); Dragboard db = node.startDragAndDrop(TransferMode.MOVE); db.setDragView(createSnapshot(node), evt.getX(), evt.getY()); ClipboardContent content = new ClipboardContent(); content.putString(""); db.setContent(content); evt.consume(); }; } private WritableImage createSnapshot(Node node) { SnapshotParameters snapshotParams = new SnapshotParameters(); WritableImage image = node.snapshot(snapshotParams, null); return image; }
public Node createReplacement(Node node) { Rectangle2D b = getBounds(node); Node replNode = new ImageView(node.snapshot(new SnapshotParameters(), null)); replacedNodeMap.put(node, replNode); replNode.setUserData(node); replNode.setManaged(false); replNode.setId(ANIM_REPLACE_ID); replNode.resizeRelocate(b.getMinX(), b.getMinY(), b.getWidth(), b.getHeight()); return replNode; }
node.snapshot(parameters, wi);
node.snapshot(parameters, wi);
node.snapshot(parameters, wi);
/** * Prints the specified view node completely to one single page. * * @param printerJob printer job which defines the printer, page layout, ... * @param view view node to print * @return true when the view was printed successfully */ private boolean printViewPage(final PrinterJob printerJob, final Node view) { // the view needs to be scaled to fit the selected page layout of the PrinterJob // => the passed view node can't be scaled, this would scale the displayed UI // => solution: create a snapshot image for printing and scale this image final WritableImage snapshot = view.snapshot(null, null); final ImageView ivSnapshot = new ImageView(snapshot); // compute the needed scaling (aspect ratio must be kept) final PageLayout pageLayout = printerJob.getJobSettings().getPageLayout(); final double scaleX = pageLayout.getPrintableWidth() / ivSnapshot.getImage().getWidth(); final double scaleY = pageLayout.getPrintableHeight() / ivSnapshot.getImage().getHeight(); final double scale = Math.min(scaleX, scaleY); // scale the calendar image only when it's too big for the selected page if (scale < 1.0) { ivSnapshot.getTransforms().add(new Scale(scale, scale)); } return printerJob.printPage(ivSnapshot); }
Dragboard db = node.startDragAndDrop(TransferMode.MOVE); WritableImage snapShot = node.snapshot(new SnapshotParameters(), null); PixelReader reader = snapShot.getPixelReader(); int padX = 10;
/** * {@inheritDoc} */ @Override protected void perform(Wave wave) throws CommandException { final SnapshotWaveBean wb = waveBean(wave); WritableImage image = wb.image(); if (wb.node() == null) { final Scene scene = localFacade().globalFacade().application().scene(); image = scene.snapshot(image); } else { image = wb.node().snapshot(wb.parameters(), image); } wb.image(image); }
this.imageProperty.set(((ImageView) node).getImage()); } else { final WritableImage wi = node.snapshot(new SnapshotParameters(), null); this.imageProperty.set(wi);
Dragboard db = node.startDragAndDrop(TransferMode.MOVE); WritableImage snapShot = node.snapshot(new SnapshotParameters(), null); PixelReader reader = snapShot.getPixelReader(); int padX = 10;
public static Group convertTo3D(Node node, int depth) { Group root = new Group(); root.setTranslateX(node.getLayoutX()); root.setTranslateY(node.getLayoutY()); root.setTranslateZ(-20); System.out.println("Layer " + depth + " - Node Type: " + node.getClass()); Box box = new Box(node.getBoundsInParent().getWidth(), node.getBoundsInParent().getHeight(), 0.1); box.setTranslateX(node.getLayoutX()); box.setTranslateY(node.getLayoutY()); SnapshotParameters snapshotParameters = new SnapshotParameters(); snapshotParameters.setFill(Color.TRANSPARENT); box.setMaterial(new PhongMaterial(Color.WHITE, node.snapshot(snapshotParameters, new WritableImage((int) node.getBoundsInParent().getWidth(), (int) node.getBoundsInParent().getHeight())), null, null, null)); root.getChildren().add(box); if (node instanceof Parent) { for (Node child : ((Parent) node).getChildrenUnmodifiable()) { root.getChildren().add(convertTo3D(child, depth + 1)); } } return root; }
final SnapshotParameters snapshotParameters = new SnapshotParameters(); snapshotParameters.setFill(Color.TRANSPARENT); WritableImage snapShot = n.snapshot(snapshotParameters, null); ImageView v = new ImageView(snapShot);