Java 类javafx.scene.SnapshotParameters 实例源码
项目:hygene
文件:Snapshot.java
/**
* 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();
}
项目:Recordian
文件:GraphsTabController.java
/**
* 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;
}
项目:szoftlab
文件:TrainView.java
/**
* 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);
}
项目:JHosts
文件:ExtendedAnimatedFlowContainer.java
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();
}
项目:qupath-tracking-extension
文件:TrackerUtils.java
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;
}
项目:ApkToolPlus
文件:ViewUtils.java
/**
* 把一个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;
}
项目:openjfx-8u-dev-tests
文件:NodeSnaphot2Test.java
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);
}
}
项目:openjfx-8u-dev-tests
文件:TestBase.java
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;
}
}
项目:BudgetMaster
文件:MonthLineChart.java
@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);
}
项目:story-inspector
文件:HeatMapSummaryComponent.java
@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);
}
}
项目:marlin-fx
文件:TestNonAARasterization.java
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);
}
}
项目:FXGL
文件:ParticleEmitter.java
/**
* 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;
}
项目:truffle-hog
文件:BlurPane.java
@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);
}
}
项目:mars-sim
文件:FrostedPanel.java
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();
}
项目:LifeTiles
文件:GraphController.java
/**
* 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();
}
项目:JFoenix
文件:ExtendedAnimatedFlowContainer.java
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();
}
项目:ShootOFF
文件:TargetSlide.java
@Override
public void newTarget(File targetFile) {
final Optional<TargetComponents> targetComponents = TargetIO.loadTarget(targetFile);
if (!targetComponents.isPresent()) {
logger.error("Notified of a new target that cannot be loaded: {}", targetFile.getAbsolutePath());
return;
}
final Image targetImage = targetComponents.get().getTargetGroup().snapshot(new SnapshotParameters(), null);
final ImageView targetImageView = new ImageView(targetImage);
targetImageView.setFitWidth(60);
targetImageView.setFitHeight(60);
targetImageView.setPreserveRatio(true);
targetImageView.setSmooth(true);
final String targetPath = targetFile.getPath();
final String targetName = targetPath
.substring(targetPath.lastIndexOf(File.separator) + 1, targetPath.lastIndexOf('.')).replace("_", " ");
itemPane.addButton(targetFile, targetName, Optional.of(targetImageView), Optional.empty());
}
项目:roda-in
文件:FontAwesomeImageCreator.java
/**
* Converts an unicode char to an Image using the FontAwesome font.
* <p/>
* <p>
* Based on the code presented here: <a href=
* "http://news.kynosarges.org/2014/01/07/javafx-text-icons-as-images-files/">
* javafx-text-icons-as-images-files </a>
* </p>
*
* @param unicode
* The String with the unicode which will be turned into an image.
* @param color
* The color of the font.
* @param size
* The size of the image.
* @return An Image with the unicode char converted to an image.
*/
public static Image generate(String unicode, Paint color, int size) {
Font newFont;
if (size == SIZE) {
newFont = FONT;
} else {
InputStream fontIS = FontAwesomeImageCreator.class.getResourceAsStream("/fonts/fontawesome-webfont.ttf");
newFont = Font.loadFont(fontIS, size);
}
final Canvas canvas = new Canvas(size, size);
final GraphicsContext gc = canvas.getGraphicsContext2D();
gc.setFill(color);
gc.setFont(newFont);
gc.setTextAlign(TextAlignment.CENTER);
gc.setTextBaseline(VPos.CENTER);
gc.fillText(unicode, size / 2, size / 2);
final SnapshotParameters params = new SnapshotParameters();
params.setFill(Color.TRANSPARENT);
return canvas.snapshot(params, null);
}
项目:metastone
文件:DigitFactory.java
public static void saveAllDigits() {
Stage stage = new Stage(StageStyle.TRANSPARENT);
DigitTemplate root = new DigitTemplate();
Scene scene = new Scene(root);
stage.setScene(scene);
stage.show();
SnapshotParameters snapshotParams = new SnapshotParameters();
snapshotParams.setFill(Color.TRANSPARENT);
root.digit.setText("-");
for (int i = 0; i <= 10; i++) {
WritableImage image = root.digit.snapshot(snapshotParams, null);
File file = new File("src/" + IconFactory.RESOURCE_PATH + "/img/common/digits/" + root.digit.getText() + ".png");
try {
ImageIO.write(SwingFXUtils.fromFXImage(image, null), "png", file);
} catch (IOException e) {
e.printStackTrace();
}
root.digit.setText("" + i);
}
stage.close();
}
项目:contentment
文件:JfxUtility.java
public static void capture(Node node)
{
WritableImage image = node.snapshot(new SnapshotParameters(), null);
// TODO: probably use a file chooser here
File file = new File("output_0.png");
int i=1;
while(file.exists()) file = new File("output_"+ i++ +".png");
try
{
ImageIO.write(SwingFXUtils.fromFXImage(image, null), "png", file);
}
catch (IOException e)
{
}
}
项目:TweetwallFX
文件:TweetsToTori.java
private BufferedImage snapshotTweet(final Parent tweetContainer) throws InterruptedException {
final CountDownLatch latch = new CountDownLatch(1);
// render the chart in an offscreen scene (scene is used to allow css processing) and snapshot it to an image.
// the snapshot is done in runlater as it must occur on the javafx application thread.
final SimpleObjectProperty<BufferedImage> imageProperty = new SimpleObjectProperty<>();
Platform.runLater(() -> {
Scene snapshotScene = new Scene(tweetContainer);
final SnapshotParameters params = new SnapshotParameters();
params.setFill(Color.WHITESMOKE);
tweetContainer.snapshot(result -> {
imageProperty.set(SwingFXUtils.fromFXImage(result.getImage(), null));
latch.countDown();
return null;
}, params, null);
});
latch.await();
return imageProperty.get();
}
项目:Desktop
文件:GalleryPopup.java
private Node createPopupItem(final GalleryItem item)
{
SnapshotParameters snapshotParameters = new SnapshotParameters();
snapshotParameters.setFill(Color.TRANSPARENT);
Image image = item.getGraphic().snapshot(snapshotParameters, null);
ToggleButton button = new ToggleButton(item.getName());
button.setContentDisplay(ContentDisplay.TOP);
button.setGraphic(new ImageView(image));
button.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
gallery.setSelectedItem(item);
}
});
buttonGroup.getToggles().add(button);
galleryItemButton.put(item, button);
return button;
}
项目:logbook-kai
文件:Tools.java
/**
* ノードの内容をPNGファイルとして出力します
*
* @param ndoe ノード
* @param title タイトル及びファイル名
* @param own 親ウインドウ
*/
public static void storeSnapshot(Node node, String title, Window own) {
try {
FileChooser chooser = new FileChooser();
chooser.setTitle(title + "の保存");
chooser.setInitialFileName(title + ".png");
chooser.getExtensionFilters().addAll(
new ExtensionFilter("PNG Files", "*.png"));
File f = chooser.showSaveDialog(own);
if (f != null) {
SnapshotParameters sp = new SnapshotParameters();
sp.setFill(Color.WHITESMOKE);
WritableImage image = node.snapshot(sp, null);
try (OutputStream out = Files.newOutputStream(f.toPath())) {
ImageIO.write(SwingFXUtils.fromFXImage(image, null), "png", out);
}
}
} catch (Exception e) {
alert(AlertType.WARNING, "画像ファイルに保存出来ませんでした", "指定された場所へ画像ファイルを書き込みできませんでした", e, own);
}
}
项目:TweetwallFX-Legacy
文件:TweetsToTori.java
private BufferedImage snapshotTweet(final Parent tweetContainer) throws InterruptedException {
final CountDownLatch latch = new CountDownLatch(1);
// render the chart in an offscreen scene (scene is used to allow css processing) and snapshot it to an image.
// the snapshot is done in runlater as it must occur on the javafx application thread.
final SimpleObjectProperty<BufferedImage> imageProperty = new SimpleObjectProperty<>();
Platform.runLater(() -> {
Scene snapshotScene = new Scene(tweetContainer);
final SnapshotParameters params = new SnapshotParameters();
params.setFill(Color.WHITESMOKE);
tweetContainer.snapshot(result -> {
imageProperty.set(SwingFXUtils.fromFXImage(result.getImage(), null));
latch.countDown();
return null;
},params,null);
});
latch.await();
return imageProperty.get();
}
项目:Whiteboard
文件:WhiteboardMenu.java
/**
* Save a screenshot in a user-specified location.
*/
public void saveScreenShot() {
// Save the image in memory.
WritableImage img = canvas.snapshot(new SnapshotParameters(), null);
BufferedImage buffImg = SwingFXUtils.fromFXImage(img, null);
// Open the file Chooser.
File file = fileChooser.showSaveDialog(null);
if (file != null) {
try {
String extension = file.getPath().substring(file.getPath().lastIndexOf('.') + 1);
System.out.println(extension);
ImageIO.write(buffImg, extension, file);
} catch (IOException e) {
e.printStackTrace();
}
}
}
项目:ui4j
文件:WebKitPage.java
@Override
public void captureScreen(OutputStream os) {
final AnimationTimer timer = new AnimationTimer() {
private int pulseCounter;
@Override
public void handle(long now) {
pulseCounter += 1;
if (pulseCounter > 2) {
stop();
WebView view = (WebView) getView();
WritableImage snapshot = view.snapshot(new SnapshotParameters(), null);
BufferedImage image = fromFXImage(snapshot, null);
try (OutputStream stream = os) {
ImageIO.write(image, "png", stream);
} catch (IOException e) {
throw new Ui4jException(e);
}
}
}
};
timer.start();
}
项目:CanvasImageGrid
文件:ImageContainer.java
public void drawImageToCanvas(final GraphicsContext gc, final double start) {
lastDrawingStartPosition = start;
if (imageRef.get() == null) {
try {
final Image img = factory.createImage(imagePath, maxWidth, maxHight);
drawAsync(gc, img);
drawSync(gc, img);
} catch (Exception e) {
e.printStackTrace();
}
// TODO move placeholder creation to factory
if (imageRef.get() == null)
imageRef = new SoftReference<Image>(new Rectangle(getScaledX(), getScaledY()).snapshot(new SnapshotParameters(), null));
}
gc.drawImage(imageRef.get(), getStartX(), start, getScaledX(), getScaledY());
}
项目:jointry
文件:ImageUtil.java
public static Image justResize(Canvas canvas) {
SnapshotParameters params = new SnapshotParameters();
params.setFill(Color.TRANSPARENT);
PixelReader reader = canvas.snapshot(params, null).getPixelReader();
double canvasWidth = canvas.getWidth();
double canvasHeight = canvas.getHeight();
int startX = getStartX(reader, canvasWidth, canvasHeight);
int startY = getStartY(reader, canvasWidth, canvasHeight);
int endX = getEndX(reader, canvasWidth, canvasHeight);
int endY = getEndY(reader, canvasWidth, canvasHeight);
//何も描かれていないキャンバス
if (startX == 0 && startY == 0 && endX == 0 && endY == 0) {
return null;
}
return new WritableImage(reader, startX, startY, endX - startX, endY - startY);
}
项目:testing-video
文件:CanvasYCbCr.java
public void overlay(Parent parent) {
overlay(image -> {
new Scene(parent, image.getWidth(), image.getHeight());
SnapshotParameters params = new SnapshotParameters();
params.setFill(TRANSPARENT);
parent.snapshot(params, image);
});
}
项目:j-demo
文件:ScreenshotController.java
@FXML
public void onCopyClicked() {
WritableImage wim = new WritableImage(canvasWidth, canvasHeight);
SnapshotParameters params = new SnapshotParameters();
params.setFill(Color.TRANSPARENT);
canvas.snapshot(params, wim);
copyImageToClipboard(wim);
}
项目:CalendarFX
文件:IntroPaneSkin.java
private void snapshotNode(Scene scene, Node node) {
SnapshotParameters params = new SnapshotParameters();
Bounds layoutBounds = node.getLayoutBounds();
Bounds bounds = node.localToScene(layoutBounds);
if (!(bounds.getWidth() > 0 && bounds.getHeight() > 0)) {
return;
}
params.setViewport(new Rectangle2D(bounds.getMinX(), bounds.getMinY(), bounds.getWidth(), bounds.getHeight()));
WritableImage writable = new WritableImage((int) bounds.getWidth(), (int) bounds.getHeight());
writable = scene.getRoot().snapshot(params, writable);
ImageView imageView = new ImageView(writable);
imageView.getStyleClass().add("snapshot-image");
imageView.setManaged(false);
imageView.setLayoutX(bounds.getMinX());
imageView.setLayoutY(bounds.getMinY());
imageView.setFitWidth(bounds.getWidth());
imageView.setFitHeight(bounds.getHeight());
Region rect = new Region();
rect.getStyleClass().add("snapshot-background");
rect.setLayoutX(bounds.getMinX() - 5);
rect.setLayoutY(bounds.getMinY() - 5);
rect.resize(bounds.getWidth() + 10, bounds.getHeight() + 10);
rect.setManaged(false);
Line line = new Line();
line.setStartX(bounds.getMaxX() + 4);
line.setStartY(bounds.getMaxY() + 4);
line.setEndX(bounds.getMaxX() + 200);
line.setEndY(bounds.getMaxY() + 200);
line.setStroke(imagePattern);
line.setStrokeWidth(5);
line.setManaged(false);
getChildren().addAll(rect, imageView); //, line);
}
项目:GazePlay
文件:Circles_handler.java
public ImagePattern createGridPattern() {
Collections.shuffle(array_sizes);
index = array_sizes.get(0);
size = arraypts[ index ].length;
//size = 10;
indicator = new ProgressIndicator(0);
double w = gridSize;
double h = gridSize;
circle = new Circle();
circle.setRadius(45.0f);
circle.setOpacity(1);
circle.setFill(Color.LIGHTBLUE);
circle.setVisible(true);
canvas.setGridLinesVisible(true);
GazeUtils.addEventFilter(circle);
enterEvent = buildEvent();
circle.addEventFilter(MouseEvent.ANY, enterEvent);
circle.addEventFilter(GazeEvent.ANY, enterEvent);
indicator.setOpacity(0.0);
canvas.add(indicator, arraypts[index][count], arraypts[index][count+1]);
canvas.add(circle,arraypts[index][count], arraypts[index][count+1]);
Image image = canvas.snapshot(new SnapshotParameters(), null);
ImagePattern pattern = new ImagePattern(image, 0, 0, w, h, false);
return pattern;
}
项目:GazePlay
文件:Circles_points_handler.java
public ImagePattern createGridPattern() {
Collections.shuffle(array_sizes);
index = array_sizes.get(0);
size = arraypts[ index ].length;
//size = 10;
indicator = new ProgressIndicator(0);
double w = gridSize;
double h = gridSize;
circle = new Circle();
circle.setRadius(45.0f);
circle.setOpacity(1);
circle.setFill(Color.BLUE);
circle.setVisible(true);
canvas.setGridLinesVisible(true);
GazeUtils.addEventFilter(circle);
enterEvent = buildEvent();
circle.addEventFilter(MouseEvent.ANY, enterEvent);
circle.addEventFilter(GazeEvent.ANY, enterEvent);
indicator.setOpacity(0.0);
canvas.add(indicator, arraypts[index][count], arraypts[index][count+1]);
canvas.add(circle,arraypts[index][count], arraypts[index][count+1]);
Image image = canvas.snapshot(new SnapshotParameters(), null);
ImagePattern pattern = new ImagePattern(image, 0, 0, w, h, false);
return pattern;
}
项目:GazePlay
文件:Circles_handler2.java
public ImagePattern createGridPattern() {
Collections.shuffle(array_sizes);
index = array_sizes.get(0);
size = arraypts[ index ].length;
//size = 10;
indicator = new ProgressIndicator(0);
double w = gridSize;
double h = gridSize;
circle = new Circle();
circle.setRadius(45.0f);
circle.setOpacity(1);
circle.setFill(Color.LIGHTBLUE);
circle.setVisible(true);
canvas.setGridLinesVisible(true);
GazeUtils.addEventFilter(circle);
enterEvent = buildEvent();
circle.addEventFilter(MouseEvent.ANY, enterEvent);
circle.addEventFilter(GazeEvent.ANY, enterEvent);
indicator.setOpacity(0.0);
canvas.add(indicator, arraypts[index][count], arraypts[index][count+1]);
canvas.add(circle,arraypts[index][count], arraypts[index][count+1]);
Image image = canvas.snapshot(new SnapshotParameters(), null);
ImagePattern pattern = new ImagePattern(image, 0, 0, w, h, false);
return pattern;
}
项目:GazePlay
文件:Circles_points_handler2.java
public ImagePattern createGridPattern() {
Collections.shuffle(array_sizes);
index = array_sizes.get(0);
size = arraypts[ index ].length;
//size = 10;
indicator = new ProgressIndicator(0);
double w = gridSize;
double h = gridSize;
circle = new Circle();
circle.setRadius(45.0f);
circle.setOpacity(1);
circle.setFill(Color.BLUE);
circle.setVisible(true);
canvas.setGridLinesVisible(true);
GazeUtils.addEventFilter(circle);
enterEvent = buildEvent();
circle.addEventFilter(MouseEvent.ANY, enterEvent);
circle.addEventFilter(GazeEvent.ANY, enterEvent);
indicator.setOpacity(0.0);
canvas.add(indicator, arraypts[index][count], arraypts[index][count+1]);
canvas.add(circle,arraypts[index][count], arraypts[index][count+1]);
Image image = canvas.snapshot(new SnapshotParameters(), null);
ImagePattern pattern = new ImagePattern(image, 0, 0, w, h, false);
return pattern;
}
项目:candlelight
文件:LayeredCanvasPane.java
@Override
public WritableImage toWritableImage(Rectangle2D viewport)
{
SnapshotParameters params = new SnapshotParameters();
params.setViewport(viewport);
params.setFill(Color.TRANSPARENT);
return this.snapshot(params, null);
}
项目:candlelight
文件:ResizeableLayeredCanvasPane.java
@Override
public WritableImage toWritableImage(Rectangle2D viewport)
{
SnapshotParameters params = new SnapshotParameters();
params.setViewport(viewport);
params.setFill(Color.TRANSPARENT);
return this.snapshot(params, null);
}
项目:gomoku
文件:Main.java
/**
* Take a pixel-aware screenshot of some pane.
* @param pane Input pane
* @param pixelScale Scaling factor applied to snapshot (1 is no scaling)
* @return WritableImage snapshot, scaled by given amount
*/
public static WritableImage screenshot(Pane pane, double pixelScale) {
int width = (int) Math.rint(pixelScale * pane.getWidth());
int height = (int) Math.rint(pixelScale * pane.getHeight());
WritableImage writableImage = new WritableImage(width, height);
SnapshotParameters params = new SnapshotParameters();
params.setTransform(Transform.scale(pixelScale, pixelScale));
return pane.snapshot(params, writableImage);
}
项目:octoBubbles
文件:AbstractDiagramController.java
public WritableImage getSnapShot(){
SnapshotParameters sp = new SnapshotParameters();
Bounds bounds = scrollPane.getViewportBounds();
//Not sure why abs is needed, the minX/Y values are negative.
sp.setViewport(new Rectangle2D(Math.abs(bounds.getMinX()), Math.abs(bounds.getMinY()), bounds.getWidth(), bounds.getHeight()));
return drawPane.snapshot(sp, new WritableImage((int)bounds.getWidth(),(int)bounds.getHeight()));
}
项目:charts
文件:Helper.java
public static final void saveAsPng(final Node NODE, final String FILE_NAME) {
final WritableImage SNAPSHOT = NODE.snapshot(new SnapshotParameters(), null);
final String NAME = FILE_NAME.replace("\\.[a-zA-Z]{3,4}", "");
final File FILE = new File(NAME + ".png");
try {
ImageIO.write(SwingFXUtils.fromFXImage(SNAPSHOT, null), "png", FILE);
} catch (IOException exception) {
// handle exception here
}
}