Class JAWTUtil

java.lang.Object
jogamp.nativewindow.jawt.JAWTUtil

public class JAWTUtil extends Object
  • Field Details

    • DEBUG

      public static final boolean DEBUG
    • JAWT_MACOSX_USE_CALAYER

      public static final int JAWT_MACOSX_USE_CALAYER
      OSX JAWT version option to use CALayer
      See Also:
    • JAWT_MacOSXCALayerMinVersion

      public static final com.jogamp.common.util.VersionNumber JAWT_MacOSXCALayerMinVersion
      OSX JAWT CALayer availability on Mac OS X >= 10.6 Update 4 (recommended)
    • JAWT_MacOSXCALayerRequiredForJavaVersion

      public static final com.jogamp.common.util.VersionNumber JAWT_MacOSXCALayerRequiredForJavaVersion
      OSX JAWT CALayer required with Java >= 1.7.0 (implies OS X >= 10.7
    • JAWT_OSX_CALAYER_QUIRK_SIZE

      public static final int JAWT_OSX_CALAYER_QUIRK_SIZE
      CALayer size needs to be set using the AWT component size.

      AWT's super-calayer, i.e. the AWT's own component CALayer, does not layout our root-calayer in respect to this component's position and size, at least when resizing programmatically.

      As of today, this flag is enabled for all known AWT versions.

      Sync w/ NativeWindowProtocols.h

      See Also:
    • JAWT_OSX_CALAYER_QUIRK_POSITION

      public static final int JAWT_OSX_CALAYER_QUIRK_POSITION
      CALayer position needs to be set to zero.

      AWT's super-calayer, i.e. the AWT's own component CALayer, has a broken layout and needs it's sub-layers to be located at position 0/0.

      See http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7172187.

      Further more a re-layout seems to be required in this case, i.e. a programmatic forced resize +1 and it's inverted resize -1.

      This flag is enabled w/ AWT invalid input: '<' 1.7.0_40.

      Sync w/ NativeWindowProtocols.h

      See Also:
    • JAWT_OSX_CALAYER_QUIRK_LAYOUT

      public static final int JAWT_OSX_CALAYER_QUIRK_LAYOUT
      CALayer position needs to be derived from AWT position in relation to super CALayer.

      AWT's super-calayer, i.e. the AWT top-container's CALayer, does not layout our root-calayer in respect to this component's position and size, at least when resizing programmatically.

      CALayer position has origin 0/0 at bottom/left, where AWT component has origin 0/0 at top/left.

      The super-calayer bounds exclude the frame's heavyweight border/insets.

      The super-calayer lies within the AWT top-container client space (content).

      Component's location in super-calayer:

            p0 = c.locationOnScreen();
            p0 -= c.getOutterComp.getPos();
            p0 -= c.getOutterComp.getInsets();
       
      Where 'locationOnScreen()' is:
           p0 = 0/0;
           while( null != c ) {
             p0 += c.getPos();
           }
       

      This flags also sets JAWT_OSX_CALAYER_QUIRK_SIZE, i.e. they are related.

      As of today, this flag is enabled for w/ AWT >= 1.7.0_40.

      Sync w/ NativeWindowProtocols.h

      See Also:
  • Constructor Details

    • JAWTUtil

      public JAWTUtil()
  • Method Details

    • isOffscreenLayerSupported

      public static boolean isOffscreenLayerSupported()
      Returns true if this platform's JAWT implementation supports offscreen layer.
    • isOffscreenLayerRequired

      public static boolean isOffscreenLayerRequired()
      Returns true if this platform's JAWT implementation requires using offscreen layer.
    • getOSXCALayerQuirks

      public static int getOSXCALayerQuirks()
      Returns bitfield of required JAWT OSX CALayer quirks to mediate AWT impl. bugs.

      Returns zero, if platform is not Platform.OSType.MACOS or not supporting CALayer, i.e. OSX invalid input: '<' 10.6.4.

      Otherwise includes

    • getJAWT

      public static jogamp.nativewindow.jawt.JAWT getJAWT(boolean useOffscreenLayerIfAvailable)
      Parameters:
      useOffscreenLayerIfAvailable -
      Returns:
    • isJAWTUsingOffscreenLayer

      public static boolean isJAWTUsingOffscreenLayer(jogamp.nativewindow.jawt.JAWT jawt)
    • initSingleton

      public static void initSingleton()
      Called by NativeWindowFactory.initSingleton()
    • shutdown

      public static void shutdown()
      Called by
      invalid @link
      NativeWindowFactory#shutdown()
    • hasJava2D

      public static boolean hasJava2D()
    • isJava2DQueueFlusherThread

      public static boolean isJava2DQueueFlusherThread()
    • isHeadlessMode

      public static boolean isHeadlessMode()
    • lockToolkit

      public static void lockToolkit() throws com.jogamp.nativewindow.NativeWindowException
      Locks the AWT's global ReentrantLock.

      JAWT's native Lock() function calls SunToolkit.awtLock(), which just uses AWT's global ReentrantLock.

      AWT locking is wrapped through a recursive lock object.

      Throws:
      com.jogamp.nativewindow.NativeWindowException
    • unlockToolkit

      public static void unlockToolkit()
      Unlocks the AWT's global ReentrantLock.

      JAWT's native Unlock() function calls SunToolkit.awtUnlock(), which just uses AWT's global ReentrantLock.

      AWT unlocking is wrapped through a recursive lock object.

    • validateLocked

      public static final void validateLocked() throws RuntimeException
      Throws:
      RuntimeException
    • getJAWTToolkitLock

      public static com.jogamp.nativewindow.ToolkitLock getJAWTToolkitLock()
    • disableBackgroundErase

      public static boolean disableBackgroundErase(Component component)
      Calls sun.awt.SunToolkit.disableBackgroundErase(Component component) if available.

      Disables the AWT's erasing of the given native Component's background since Java SE 6. This feature can also be enabled by setting the system property sun.awt.noerasebackground = true.

      Parameters:
      component -
      Returns:
      true if available and successful, otherwise false
    • getMonitorDisplayID

      public static final Integer getMonitorDisplayID(GraphicsDevice device)
      Queries the Monitor's display ID of the given device

      Currently only supported for OSX on Javainvalid input: '<'9

      Parameters:
      device - for which the display id is being queried
      Returns:
      null if not supported (Java9+ or !OSX), otherwise the monitor displayID
    • getPixelScale

      public static final boolean getPixelScale(GraphicsDevice device, float[] minScale, float[] maxScale)
      Returns the pixel scale factor of the given GraphicsDevice, if supported.

      This method is generally supported on Java9+

      If the component does not support pixel scaling or SKIP_AWT_HIDPI is set, the default value one is returned.

      Parameters:
      device - the GraphicsDevice instance used to query the pixel scale
      minScale - current and output min scale values
      maxScale - current and output max scale values
      Returns:
      true if the given min and max scale values have changed, otherwise false.
    • getPixelScale

      public static final boolean getPixelScale(GraphicsConfiguration gc, float[] minScale, float[] maxScale)
      Returns the pixel scale factor of the given GraphicsConfiguration's GraphicsDevice, if supported.

      This method is generally supported on Java9+

      If the GraphicsDevice is null, one is returned.

      If the component does not support pixel scaling or SKIP_AWT_HIDPI is set, the default value one is returned.

      Parameters:
      gc - the GraphicsConfiguration instance used to query the pixel scale
      minScale - current and output min scale values
      maxScale - current and output max scale values
      Returns:
      true if the given min and max scale values have changed, otherwise false.
    • createDevice

      public static com.jogamp.nativewindow.AbstractGraphicsDevice createDevice(Component awtComp) throws IllegalArgumentException
      Parameters:
      awtComp - must be displayable and must have a GraphicsConfiguration
      Returns:
      AbstractGraphicsDevice instance reflecting the awtComp
      Throws:
      IllegalArgumentException - if awtComp is not displayable or has null GraphicsConfiguration.
      See Also:
    • getAbstractGraphicsScreen

      public static com.jogamp.nativewindow.AbstractGraphicsScreen getAbstractGraphicsScreen(Component awtComp) throws IllegalArgumentException
      Parameters:
      awtComp - must be displayable and must have a GraphicsConfiguration
      Returns:
      AbstractGraphicsScreen instance reflecting the awtComp
      Throws:
      IllegalArgumentException - if awtComp is not displayable or has null GraphicsConfiguration.
      See Also: