-
-
Notifications
You must be signed in to change notification settings - Fork 461
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unnecessary reference to Swing in headless mode causes considerable delay #398
Comments
A related problem is examined in issue #324. If I understand correctly, |
it's A suggested fix would be:
Why 238,238,238 instead of Color.GRAY? |
Similar shades of light gray are common defaults for the |
I am generating some .PNGs with some nice charts on a server, so JFreeChart is running with a headless JDK. (openjdk-8-jdk-headless)
When rendering an image, I get the error message shown below.
The root cause is this:
jfreechart/src/main/java/org/jfree/chart/JFreeChart.java
Line 141 in e2d6788
which references UIManager and thus tries to load and initialize Swing, which is pointless on a headless JDK.
A workaround is to set the following system property at startup:
-Djavax.accessibility.assistive_technologies=" "
(notice the blank space), but Swing still gets loaded and initialized on the server. On my current development machine the difference is about 150ms but the target platform is a tiny old embedded machine. When removing the reference to UIManager on the line managed above, the program runs about 2 sec(!) faster.Suggested fix: if headless, set it to some reasonable default without accessing the Swing UIManager, e.g.:
public static final Paint DEFAULT_BACKGROUND_PAINT = GraphicsEnvironment.isHeadless() ? Color.GRAY : UIManager.getColor("Panel.background");
Exception:
The text was updated successfully, but these errors were encountered: