]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Add check for headless installations in DPIUtil 93/3593/1
authorjsimomaa <jani.simomaa@gmail.com>
Wed, 20 Nov 2019 08:54:42 +0000 (10:54 +0200)
committerJani Simomaa <jani.simomaa@semantum.fi>
Thu, 21 Nov 2019 05:51:38 +0000 (05:51 +0000)
gitlab #418

Change-Id: I5d7b637ad7833f7cfa60969c81be818d3d8fefc1
(cherry picked from commit 2ed2f09de0043bbf98a5b727854bd93a02b204ab)

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;