Add check for headless installations in DPIUtil 72/3572/2
authorjsimomaa <jani.simomaa@gmail.com>
Wed, 20 Nov 2019 08:54:42 +0000 (10:54 +0200)
committerJani Simomaa <jani.simomaa@semantum.fi>
Wed, 20 Nov 2019 08:54:56 +0000 (08:54 +0000)
gitlab #418

Change-Id: I5d7b637ad7833f7cfa60969c81be818d3d8fefc1

bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/utils/DPIUtil.java

index 0a138b305f885a7e821a88441b84fda422133ec5..8c0c65dad1762f05f628fa0a2799b48995bc2cbe 100644 (file)
@@ -11,6 +11,7 @@
  *******************************************************************************/
 package org.simantics.scenegraph.utils;
 
+import java.awt.GraphicsEnvironment;
 import java.awt.Point;
 import java.awt.Rectangle;
 import java.awt.Toolkit;
@@ -35,7 +36,11 @@ public class DPIUtil {
                if (initialized)
                        return;
 
-               double dpi = Toolkit.getDefaultToolkit().getScreenResolution();
+               double dpi;
+               if (!GraphicsEnvironment.isHeadless())
+                       dpi = Toolkit.getDefaultToolkit().getScreenResolution();
+               else
+                       dpi = 96;
                double baseDpi = 96;
                int zoom = (int) Math.round(100.0 * dpi / baseDpi);
                hasZoom = zoom != 100;