* more fault-tolerant on headless systems

This commit is contained in:
Reinhard Pointner 2012-04-16 12:28:04 +00:00
parent 4479b123d5
commit f84f62b6fd
1 changed files with 11 additions and 12 deletions

View File

@ -8,6 +8,7 @@ import static net.sourceforge.filebot.Settings.*;
import java.awt.DisplayMode; import java.awt.DisplayMode;
import java.awt.GraphicsDevice; import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment; import java.awt.GraphicsEnvironment;
import java.awt.HeadlessException;
import java.util.Map; import java.util.Map;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@ -115,19 +116,17 @@ public class Analytics {
config.setUserLanguage(getUserLanguage()); config.setUserLanguage(getUserLanguage());
try { try {
if (GraphicsEnvironment.isHeadless()) { if (GraphicsEnvironment.isHeadless())
// headless environment throw new HeadlessException();
config.setScreenResolution("80x25");
config.setColorDepth("1"); // desktop environment
} else { GraphicsDevice[] display = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices();
// desktop environment config.setScreenResolution(getScreenResolution(display));
GraphicsDevice[] display = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices(); config.setColorDepth(getColorDepth(display));
config.setScreenResolution(getScreenResolution(display));
config.setColorDepth(getColorDepth(display));
}
} catch (Throwable e) { } catch (Throwable e) {
// just in case // headless environment
Logger.getLogger(Analytics.class.getName()).log(Level.WARNING, e.getMessage(), e); config.setScreenResolution("80x25");
config.setColorDepth("1");
} }
return config; return config;