From 2ed2f09de0043bbf98a5b727854bd93a02b204ab Mon Sep 17 00:00:00 2001 From: jsimomaa Date: Wed, 20 Nov 2019 10:54:42 +0200 Subject: [PATCH] Add check for headless installations in DPIUtil gitlab #418 Change-Id: I5d7b637ad7833f7cfa60969c81be818d3d8fefc1 --- .../src/org/simantics/scenegraph/utils/DPIUtil.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/utils/DPIUtil.java b/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/utils/DPIUtil.java index 0a138b305..8c0c65dad 100644 --- a/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/utils/DPIUtil.java +++ b/bundles/org.simantics.scenegraph/src/org/simantics/scenegraph/utils/DPIUtil.java @@ -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; -- 2.47.1