Sto convertendo la mia vecchia app java da swing a javafx e sto riscontrando un problema.Eccezione headless screencapture JavaFX su OSX
Sto utilizzando il seguente codice per catturare screenshot:
public ScreenCapper() {
ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
gs = ge.getScreenDevices();
try {
robot = new Robot(gs[gs.length-1]);
} catch (AWTException e) {
LOGGER.getInstance().ERROR("Error creating screenshot robot instance!");
}
}
public Color capture() {
Rectangle bounds;
mode = gs[0].getDisplayMode();
bounds = new Rectangle(0, 0, mode.getWidth(), mode.getHeight());
//......
}
Questo funziona bene quando si esegue l'applicazione in Windows. Tuttavia durante l'esecuzione in OSX nel ottenere la seguente eccezione:
Exception in Application start method
Exception in thread "main" java.lang.RuntimeException: Exception in Application start method
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:403)
at com.sun.javafx.application.LauncherImpl.access$000(LauncherImpl.java:47)
at com.sun.javafx.application.LauncherImpl$1.run(LauncherImpl.java:115)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.awt.HeadlessException
at sun.java2d.HeadlessGraphicsEnvironment.getScreenDevices(HeadlessGraphicsEnvironment.java:72)
at be.beeles_place.roggbiv.utils.ScreenCapper.<init>(ScreenCapper.java:33)
at be.beeles_place.roggbiv.modes.AverageColorMode.start(AverageColorMode.java:31)
at be.beeles_place.roggbiv.modes.ColorModeContext.startCurrentColorMode(ColorModeContext.java:28)
at be.beeles_place.roggbiv.controller.RoggbivController.<init>(RoggbivController.java:42)
at be.beeles_place.roggbiv.RoggbivMain.start(RoggbivMain.java:67)
at com.sun.javafx.application.LauncherImpl$5.run(LauncherImpl.java:319)
at com.sun.javafx.application.PlatformImpl$5.run(PlatformImpl.java:215)
at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:179)
at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:176)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl$4.run(PlatformImpl.java:176)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:76)
Questo credo ha todo con JavaFX appearently esecuzione è la modalità headless su OSX, come i seguenti avvisi di debug suggeriscono: c'è qualche
013-03-10 10:44:03.795 java[1912:5903] *** WARNING: Method userSpaceScaleFactor in class NSView is deprecated on 10.7 and later. It should not be used in new applications. Use convertRectToBacking: instead.
2013-03-10 10:44:05.472 java[1912:707] [JRSAppKitAWT markAppIsDaemon]: Process manager already initialized: can't fully enable headless mode.
Is modo per farlo funzionare? O un altro modo per catturare schermate che non sono in conflitto con OSX?
codice completo @https://github.com/beele/Roggbiv
* "Questo credo ha todo con JavaFX appearently esecuzione è la modalità headless su OSX" * Perché mai sarebbe farlo? È un toolkit GUI e non sono molto utili senza uno schermo. –
Non lo so, ho aggiunto un controllo nel codice sul controllo github per GraphicsEnvironment.isHeadless() e che restituisce true, quindi ... – Beele