本文整理汇总了Java中javafx.scene.SnapshotParameters.setTransform方法的典型用法代码示例。如果您正苦于以下问题:Java SnapshotParameters.setTransform方法的具体用法?Java SnapshotParameters.setTransform怎么用?Java SnapshotParameters.setTransform使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.SnapshotParameters
的用法示例。
在下文中一共展示了SnapshotParameters.setTransform方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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);
}
示例3: screenshot
import javafx.scene.SnapshotParameters; //导入方法依赖的package包/类
/**
* 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);
}
示例4: SnapshotWithParametersTest_rotate
import javafx.scene.SnapshotParameters; //导入方法依赖的package包/类
/**
* test Node.snapshot with SnapshotParameters
*/
@Test
public void SnapshotWithParametersTest_rotate() throws InterruptedException {
SnapshotParameters param = new SnapshotParameters();
param.setTransform(new Rotate(45,0,0));
testCommon(Pages.DropShadow.name(),"rotate", param);
}
示例5: getChartImage
import javafx.scene.SnapshotParameters; //导入方法依赖的package包/类
/**
* Get a Image of the Chart, scaled according to the requested resolution as required.
*
* @return
*/
public Image getChartImage() {
// Create a snapshot at the requested resolution
double scale = exportResolutionProperty.get().getScale();
int w = (int)(chart.getWidth() * scale + 0.5);
int h = (int)(chart.getHeight() * scale + 0.5);
SnapshotParameters params = new SnapshotParameters();
params.setTransform(Transform.scale(scale, scale));
return chart.snapshot(params, new WritableImage(w, h));
}
示例6: 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));
HBox generatedChart = generate();
root.getChildren().add(generatedChart);
VBox.setVgrow(generatedChart, Priority.ALWAYS);
Region spacer = new Region();
spacer.setMinHeight(30);
root.getChildren().add(spacer);
root.getChildren().add(generateLegend());
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);
}
示例7: 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.setSpacing(10);
root.getChildren().add(generate(titleIncomes, true));
root.getChildren().add(generate(titlePayments, false));
Region spacer = new Region();
spacer.setMinHeight(25);
root.getChildren().add(spacer);
VBox.setVgrow(spacer, Priority.ALWAYS);
root.getChildren().add(generateFullLegend());
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);
}
示例8: onExportAsPngFile
import javafx.scene.SnapshotParameters; //导入方法依赖的package包/类
@FXML
private void onExportAsPngFile(ActionEvent e) {
if (csgObject == null) {
Action response = Dialogs.create()
.title("Error")
.message("Cannot export PNG. There is no geometry :(")
.lightweight()
.showError();
return;
}
FileChooser fileChooser = new FileChooser();
fileChooser.setTitle("Export PNG File");
fileChooser.getExtensionFilters().add(
new FileChooser.ExtensionFilter(
"Image files (*.png)",
"*.png"));
File f = fileChooser.showSaveDialog(null);
if (f == null) {
return;
}
String fName = f.getAbsolutePath();
if (!fName.toLowerCase().endsWith(".png")) {
fName += ".png";
}
int snWidth = 1024;
int snHeight = 1024;
double realWidth = viewGroup.getBoundsInLocal().getWidth();
double realHeight = viewGroup.getBoundsInLocal().getHeight();
double scaleX = snWidth / realWidth;
double scaleY = snHeight / realHeight;
double scale = Math.min(scaleX, scaleY);
PerspectiveCamera snCam = new PerspectiveCamera(false);
snCam.setTranslateZ(-200);
SnapshotParameters snapshotParameters = new SnapshotParameters();
snapshotParameters.setTransform(new Scale(scale, scale));
snapshotParameters.setCamera(snCam);
snapshotParameters.setDepthBuffer(true);
snapshotParameters.setFill(Color.TRANSPARENT);
WritableImage snapshot = new WritableImage(snWidth, (int) (realHeight * scale));
viewGroup.snapshot(snapshotParameters, snapshot);
try {
ImageIO.write(SwingFXUtils.fromFXImage(snapshot, null),
"png", new File(fName));
} catch (IOException ex) {
Logger.getLogger(MainController.class.getName()).
log(Level.SEVERE, null, ex);
}
}