Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8172962

Add API to get the scale factor of GraphicsDevice

XMLWordPrintable

    • x86
    • os_x

      A DESCRIPTION OF THE REQUEST :
      This is already available on CGraphicsDevice to internally support Retina screens on Macs - http://hg.openjdk.java.net/jdk9/client/jdk/file/1089d8a8a6e1/src/java.desktop/macosx/classes/sun/awt/CGraphicsDevice.java and the getScaleFactor API.

      I'm requesting to expose this as public API so that external developers can query for the presence of high-resolution screens and adjust their rendering accordingly

      JUSTIFICATION :
      See http://bulenkov.com/2013/06/23/retina-support-in-oracle-jdk-1-7/ for how IntelliJ is using reflection to query the GraphicsDevice object on Mac machines. That way now fails on JDK 9 early access:

      java.lang.IllegalAccessException: class UIUtil$DetectRetinaKit cannot access class sun.awt.CGraphicsDevice (in module java.desktop) because module java.desktop does not export sun.awt to unnamed module @7a2858
      at java.base/jdk.internal.reflect.Reflection.throwIllegalAccessException(Reflection.java:445)
      at java.base/jdk.internal.reflect.Reflection.throwIllegalAccessException(Reflection.java:436)
      at java.base/jdk.internal.reflect.Reflection.ensureMemberAccess(Reflection.java:112)
      at java.base/java.lang.reflect.AccessibleObject.slowCheckMemberAccess(AccessibleObject.java:407)
      at java.base/java.lang.reflect.AccessibleObject.checkAccess(AccessibleObject.java:399)
      at java.base/java.lang.reflect.Method.invoke(Method.java:530)
      at UIUtil$DetectRetinaKit.isOracleMacRetinaDevice(UIUtil.java:66)


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      I'd like to have a public API to officially query the scale factor / hi DPI "presence" on a specific GraphicsDevice object.
      ACTUAL -
      There is no such public API available.

      CUSTOMER SUBMITTED WORKAROUND :
      Use reflection to access CGraphicsDevice. Works on JDK 8 but fails on JDK 9.

            kaddepalli Krishna Addepalli
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: