From: jsimomaa Date: Wed, 20 Nov 2019 08:54:42 +0000 (+0200) Subject: Add check for headless installations in DPIUtil X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=refs%2Fheads%2Frelease%2F1.35.2;p=simantics%2Fplatform.git Add check for headless installations in DPIUtil gitlab #418 Change-Id: I5d7b637ad7833f7cfa60969c81be818d3d8fefc1 (cherry picked from commit 2ed2f09de0043bbf98a5b727854bd93a02b204ab) --- 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;