当前位置: 首页>>代码示例>>Java>>正文


Java SnapshotParameters类代码示例

本文整理汇总了Java中javafx.scene.SnapshotParameters的典型用法代码示例。如果您正苦于以下问题:Java SnapshotParameters类的具体用法?Java SnapshotParameters怎么用?Java SnapshotParameters使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SnapshotParameters类属于javafx.scene包,在下文中一共展示了SnapshotParameters类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: take

import javafx.scene.SnapshotParameters; //导入依赖的package包/类
/**
 * Takes a snapshot of a canvas and saves it to the destination.
 * <p>
 * After the screenshot is taken it shows a dialogue to the user indicating the location of the snapshot.
 *
 * @param canvas a JavaFX {@link Canvas} object
 * @return the destination of the screenshot
 */
public String take(final Canvas canvas) {
    final WritableImage writableImage = new WritableImage((int) canvas.getWidth(), (int) canvas.getHeight());
    final WritableImage snapshot = canvas.snapshot(new SnapshotParameters(), writableImage);

    try {
        ImageIO.write(SwingFXUtils.fromFXImage(snapshot, null), FILE_FORMAT, destination);
        new InformationDialogue(
                "Snapshot taken",
                "You can find your snapshot here: " + destination.getAbsolutePath()
        ).show();
    } catch (final IOException e) {
        LOGGER.error("Snapshot could not be taken.", e);
        new ErrorDialogue(e).show();
    }

    return destination.getAbsolutePath();
}
 
开发者ID:ProgrammingLife2017,项目名称:hygene,代码行数:26,代码来源:Snapshot.java

示例2: chartsToImages

import javafx.scene.SnapshotParameters; //导入依赖的package包/类
/**
 * Converts charts to Java {@link WritableImage}s
 *
 * @param charts the charts to be converted to {@link WritableImage}s
 * @return a {@link List} of {@link WritableImage}s
 */
private List<WritableImage> chartsToImages(List<Chart> charts) {
    List<WritableImage> chartImages = new ArrayList<>();

    // Scaling the chart image gives it a higher resolution
    // which results in a better image quality when the
    // image is exported to the pdf
    SnapshotParameters snapshotParameters = new SnapshotParameters();
    snapshotParameters.setTransform(new Scale(2, 2));

    for (Chart chart : charts) {
        chartImages.add(chart.snapshot(snapshotParameters, null));
    }

    return  chartImages;
}
 
开发者ID:kwilliams3,项目名称:Recordian,代码行数:22,代码来源:GraphsTabController.java

示例3: drawSprite

import javafx.scene.SnapshotParameters; //导入依赖的package包/类
/**
 * Kirajzol egy TrainPartot a GraphicsContextre, elforgatva a sebessege iranyaba.
 */
private void drawSprite(TrainPart trainPart, Image sprite) {
    ImageView iv = new ImageView(sprite);
    Coordinate dir = trainPart.getDirection();
    // Az elforgatas szoget az (1,0) vektorhoz viszonyitjuk, mert vizszintesen es jobbra allva taroljuk a spriteokat
    Coordinate ref = new Coordinate(1, 0);
    double deg = Math.toDegrees(Math.acos(Coordinate.dot(dir, ref)));
    // Ha az elforgatas szoge > 180 fok, akkor is jo iranyba forgassuk
    if (Coordinate.cross(dir, ref) > 0) {
        deg = 360 - deg;
    }
    iv.setRotate(deg);
    SnapshotParameters param = new SnapshotParameters();
    param.setFill(Color.TRANSPARENT);
    Image rotatedImage = iv.snapshot(param, null);
    graphicsContext.drawImage(rotatedImage, trainPart.getPos().getX() - rotatedImage.getWidth() / 2, trainPart.getPos().getY() - rotatedImage.getHeight() / 2);
}
 
开发者ID:AdjustmentBeaver,项目名称:szoftlab,代码行数:20,代码来源:TrainView.java

示例4: updatePlaceholder

import javafx.scene.SnapshotParameters; //导入依赖的package包/类
private void updatePlaceholder(Node newView) {
    if (view.getWidth() > 0 && view.getHeight() > 0) {
        SnapshotParameters parameters = new SnapshotParameters();
        parameters.setFill(Color.TRANSPARENT);
        Image placeholderImage = view.snapshot(parameters,
            new WritableImage((int) view.getWidth(), (int) view.getHeight()));
        placeholder.setImage(placeholderImage);
        placeholder.setFitWidth(placeholderImage.getWidth());
        placeholder.setFitHeight(placeholderImage.getHeight());
    } else {
        placeholder.setImage(null);
    }
    placeholder.setVisible(true);
    placeholder.setOpacity(1.0);
    view.getChildren().setAll(placeholder, newView);
    placeholder.toFront();
}
 
开发者ID:b3log,项目名称:JHosts,代码行数:18,代码来源:ExtendedAnimatedFlowContainer.java

示例5: saveSnapshot

import javafx.scene.SnapshotParameters; //导入依赖的package包/类
public static boolean saveSnapshot(QuPathViewer viewer, File file) {
    ByteArrayOutputStream byteOutput = new ByteArrayOutputStream();

    javafx.scene.canvas.Canvas canvas = viewer.getCanvas();
    WritableImage image = new WritableImage((int)canvas.getWidth(), (int)canvas.getHeight());
    image = canvas.snapshot(new SnapshotParameters(), image);

    try {
        ImageIO.write(SwingFXUtils.fromFXImage(image, null ),
                "png",
                byteOutput);
        FileOutputStream fileOutputStream = new FileOutputStream(file);
        fileOutputStream.write(byteOutput.toByteArray());
        fileOutputStream.close();
        byteOutput.close();
    } catch (IOException e) {
        e.printStackTrace();
        return false;
    }
    return true;
}
 
开发者ID:Alanocallaghan,项目名称:qupath-tracking-extension,代码行数:22,代码来源:TrackerUtils.java

示例6: node2Png

import javafx.scene.SnapshotParameters; //导入依赖的package包/类
/**
 * 把一个Node导出为png图片
 *
 * @param node      节点
 * @param saveFile  图片文件
 * @param width     宽
 * @param height    高
 * @return  是否导出成功
 */
public static boolean node2Png(Node node, File saveFile, double width, double height) {
    SnapshotParameters parameters = new SnapshotParameters();
    // 背景透明
    parameters.setFill(Color.TRANSPARENT);
    WritableImage image = node.snapshot(parameters, null);

    // 重置图片大小
    ImageView imageView = new ImageView(image);
    imageView.setFitWidth(width);
    imageView.setFitHeight(height);
    WritableImage exportImage = imageView.snapshot(parameters, null);

    try {
        return ImageIO.write(SwingFXUtils.fromFXImage(exportImage, null), "png", saveFile);
    } catch (IOException e) {
        e.printStackTrace();
    }
    return false;
}
 
开发者ID:linchaolong,项目名称:ApkToolPlus,代码行数:29,代码来源:ViewUtils.java

示例7: testCommon

import javafx.scene.SnapshotParameters; //导入依赖的package包/类
public void testCommon(String toplevel_name /*, String innerlevel_name*/, String testname,
        SnapshotParameters _sp) {

    boolean pageOpeningOk = true;
    setWaitImageDelay(300);
    try {
        testCommon(toplevel_name, "node_1", false, false);
    } catch (org.jemmy.TimeoutExpiredException ex) {
        pageOpeningOk = false;
    }

    testNodeSnapshotWithParameters (toplevel_name, innerlevel_name, _sp, testname);

    if (!pageOpeningOk) {
        throw new org.jemmy.TimeoutExpiredException("testCommon failed:" + toplevel_name + "-" + innerlevel_name);
    }
}
 
开发者ID:teamfx,项目名称:openjfx-8u-dev-tests,代码行数:18,代码来源:NodeSnaphot2Test.java

示例8: testNodeSnapshotWithParameters

import javafx.scene.SnapshotParameters; //导入依赖的package包/类
public void testNodeSnapshotWithParameters (String toplevel_name, String innerlevel_name,
        final SnapshotParameters _sp, final String param_name) {

    final Wrap<? extends Node> noda = ScreenshotUtils.getPageContent();
    doRenderToImageAndWait(noda, _sp);

    org.jemmy.TimeoutExpiredException saved_ex = null;
    try {

            Wrap<? extends Node> imViewWrap =
                    Lookups.byID(getScene(), "ViewOfNodeSnapshot", ImageView.class);

            ScreenshotUtils.checkScreenshot(new StringBuilder(getName()).append("-")
                    .append(param_name).toString(), imViewWrap);

    } catch (org.jemmy.TimeoutExpiredException ex) {
        saved_ex = ex;
    } finally {
        restoreSceneRoot();
    }
    if ( null != saved_ex) {
        throw saved_ex;
    }
}
 
开发者ID:teamfx,项目名称:openjfx-8u-dev-tests,代码行数:25,代码来源:TestBase.java

示例9: export

import javafx.scene.SnapshotParameters; //导入依赖的package包/类
@Override
public WritableImage export(int width, int height) {
    VBox root = new VBox();
    root.setStyle("-fx-background-color: transparent;");
    root.setPadding(new Insets(25));
    
    root.getChildren().add(generate(false));         
    
    Stage newStage = new Stage();
    newStage.initModality(Modality.NONE);
    newStage.setScene(new Scene(root, width, height));
    newStage.setResizable(false);       
    newStage.show();
    
    SnapshotParameters sp = new SnapshotParameters();
    sp.setTransform(Transform.scale(width / root.getWidth(), height / root.getHeight()));
    newStage.close();
    
    return root.snapshot(sp, null);
}
 
开发者ID:deadlocker8,项目名称:BudgetMaster,代码行数:21,代码来源:MonthLineChart.java

示例10: write

import javafx.scene.SnapshotParameters; //导入依赖的package包/类
@Override
public void write(final ReportSummaryWriter writer) {

	// Snapshots must be taken on the application thread, so tell the application thread to take care of this when it has a chance...
	final Task<WritableImage> getImageSnapshotTask = new Task<WritableImage>() {

		@Override
		protected WritableImage call() throws Exception {
			new Scene(HeatMapSummaryComponent.this.chart, -1, -1);
			return HeatMapSummaryComponent.this.chart.snapshot(new SnapshotParameters(), null);
		}
	};
	Platform.runLater(getImageSnapshotTask);

	// Wait for the application thread to do it's stuff, then write the image
	try {
		final WritableImage image = getImageSnapshotTask.get();
		writer.writeImage(SwingFXUtils.fromFXImage(image, null));
	} catch (InterruptedException | ExecutionException e) {
		throw new RuntimeException(e);
	}
}
 
开发者ID:mizitch,项目名称:story-inspector,代码行数:23,代码来源:HeatMapSummaryComponent.java

示例11: renderPath

import javafx.scene.SnapshotParameters; //导入依赖的package包/类
public void renderPath(Path2D p2d, Path p, WritableImage wimg) {
    if (useJava2D) {
        BufferedImage bimg = new BufferedImage(TESTW, TESTH, BufferedImage.TYPE_INT_ARGB);
        Graphics2D g2d = bimg.createGraphics();
        g2d.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL,
                             RenderingHints.VALUE_STROKE_PURE);
        g2d.setColor(java.awt.Color.WHITE);
        g2d.fillRect(0, 0, TESTW, TESTH);
        g2d.setColor(java.awt.Color.BLACK);
        if (useJava2DClip) {
            g2d.setClip(p2d);
            g2d.fillRect(0, 0, TESTW, TESTH);
            g2d.setClip(null);
        } else {
            g2d.fill(p2d);
        }
        copy(bimg, wimg);
    } else {
        setPath(p, p2d);
        SnapshotParameters sp = new SnapshotParameters();
        sp.setViewport(new Rectangle2D(0, 0, TESTW, TESTH));
        p.snapshot(sp, wimg);
    }
}
 
开发者ID:bourgesl,项目名称:marlin-fx,代码行数:25,代码来源:TestNonAARasterization.java

示例12: createImage

import javafx.scene.SnapshotParameters; //导入依赖的package包/类
/**
 * Adapted from http://wecode4fun.blogspot.co.uk/2015/07/particles.html (Roland C.)
 *
 * Snapshot an image out of a node, consider transparency.
 */
private static Image createImage(Node node) {
    SnapshotParameters parameters = new SnapshotParameters();
    parameters.setFill(Color.TRANSPARENT);

    int imageWidth = (int) node.getBoundsInLocal().getWidth();
    int imageHeight = (int) node.getBoundsInLocal().getHeight();

    WritableImage image = new WritableImage(imageWidth, imageHeight);

    Async.startFX(() -> {
        node.snapshot(parameters, image);
    }).await();

    return image;
}
 
开发者ID:AlmasB,项目名称:FXGL,代码行数:21,代码来源:ParticleEmitter.java

示例13: layoutChildren

import javafx.scene.SnapshotParameters; //导入依赖的package包/类
@Override protected void layoutChildren() {
    super.layoutChildren();
    if (getParent() != null && isVisible()) {
        setVisible(false);
        getChildren().remove(imageView);

        SnapshotParameters parameters = new SnapshotParameters();
        Point2D startPointInScene = this.localToScene(0, 0);

        Rectangle2D toPaint = new Rectangle2D(startPointInScene.getX(), startPointInScene.getY(),
                getLayoutBounds().getWidth(), getLayoutBounds().getHeight());
        parameters.setViewport(toPaint);
        WritableImage image = new WritableImage(100, 100);
        image = getScene().getRoot().snapshot(parameters, image);
        imageView.setImage(image);

        getChildren().add(imageView);
        imageView.toBack();
        setClip(new Rectangle(toPaint.getWidth(), toPaint.getHeight()));
        setVisible(true);
    }
}
 
开发者ID:truffle-hog,项目名称:truffle-hog,代码行数:23,代码来源:BlurPane.java

示例14: startTimer

import javafx.scene.SnapshotParameters; //导入依赖的package包/类
private void startTimer()
{
    timer = new AnimationTimer()
    {

        @Override
        public void handle(long now)
        {
            WritableImage image = dash.snapshot(new SnapshotParameters(), null);
            WritableImage imageCrop = new WritableImage(image.getPixelReader(), (int) getLayoutX(), (int) getLayoutY(), (int) getPrefWidth(), (int) getPrefHeight());
            view.setImage(imageCrop);
        }
    };

    timer.start();
}
 
开发者ID:mars-sim,项目名称:mars-sim,代码行数:17,代码来源:FrostedPanel.java

示例15: repaint

import javafx.scene.SnapshotParameters; //导入依赖的package包/类
/**
 * Repaints the view.
 */
private void repaint() {

    wrapper.snapshot(new SnapshotParameters(), new WritableImage(5, 5));
    if (graph != null) {
        if (model == null) {
            model = new GraphContainer(graph, reference);
        }
        if (diagram == null) {
            diagram = new StackedMutationContainer(model.getBucketCache(),
                    visibleSequences);
        }

        view = new TileView(this,
                wrapper.getBoundsInParent().getHeight() * 0.9);
        diagramView = new DiagramView();

        scrollPane.hvalueProperty().addListener(
                (observable, oldValue, newValue) -> {
                    repaintPosition(newValue.doubleValue());
                });

        repaintPosition(scrollPane.hvalueProperty().doubleValue());
    }
    getMiniMapController().drawMiniMap();
}
 
开发者ID:ProgrammingLife2015,项目名称:LifeTiles,代码行数:29,代码来源:GraphController.java


注:本文中的javafx.scene.SnapshotParameters类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。