|
From: Jonathan C. <jco...@gm...> - 2020-04-14 16:40:55
|
so I added a bunch of logging (of course), and ended up being a different
problem than expected (isn't it always?). The code actually doing the
writing of the screenshot of the javafx scene is getting called and
then...doing nothing! Weird. But I can fix that I imagine...so, apologies.
Computers!
That said I welcome any suggestions on less invasive ways to do this.
On Tue, Apr 14, 2020 at 22:50 Jonathan Coveney <jco...@gm...> wrote:
> So, I have a little rails-based app I want to make. I want the app to
> start, take a screen shot of all the windows, then shut down.
>
> For the swing-based stuff I have been able to get this to work...it's a
> horrible hack, but it works. I have this in GameUIManager:
>
> public void printGameState(File directory) {
> PrintGame.printPanel(statusWindow.returnPanel(), new
> File(directory, "status_window.jpg"));
> PrintGame.printPanel(orUIManager.returnPanel(), new
> File(directory, "or_window.jpg"));
> FXStockChartWindow.runOnStage(stage -> {
>
> PrintGame.printPanel(SwingFXUtils.fromFXImage(stage.getScene().snapshot(null),
> null), new File(directory, "stock_market.jpg"));
> return null;
> });
> }
>
> PrintGame is a helper I have created. Note the FXStockChartWindow piece,
> though... this is awful. Heh, the normal swing ones are bad enough, but in
> FXStockChartWindow I added this function:
>
> public static void runOnStage(Function<Stage, Void> fn) {
> Platform.runLater(() -> fn.apply(stage));
> }
>
> That said, it doesn't work. I even tried to put this code in
> FXStockChartWindow's start method:
>
>
> PrintGame.printPanel(SwingFXUtils.fromFXImage(stage.getScene().snapshot(null),
> null), new File("/Users/jcoveney/stock_market.jpg"));
>
> Just to see if that would work, and it did not. Javafx uses a fairly
> different model than the remaining code...I know there are plans to migrate
> to javafx
>
> So! I guess I have two questions:
> 1. is there an easier way to achieve the overarching goal of "a screenshot
> of all the windows"?
> 2. assuming this general hacky method is ok, how do I get a screenshot of
> the stock window?
>
> Thank you!
>
|