Class JAWTFunctions


  • public class JAWTFunctions
    extends java.lang.Object
    Bindings to the AWT native interface (jawt.h).

    The AWT native interface allows a native C or C++ application a means by which to access native structures in AWT. This is to facilitate moving legacy C and C++ applications to Java and to target the needs of the community who, at present, wish to do their own native rendering to canvases for performance reasons. Standard extensions such as Java3D also require a means to access the underlying native data structures of AWT.

    AWT Native Drawing Surface (JAWT_DrawingSurface)

    For each platform, there is a native drawing surface structure. This platform-specific structure can be found in jawt_md.h. See JAWTX11DrawingSurfaceInfo for the Linux platform, JAWTWin32DrawingSurfaceInfo for the Windows platform and MACOSX_USE_CALAYER for the OS X platform.

    • Field Detail

      • JAWT_MACOSX_USE_CALAYER

        When calling GetAWT with a JAWT version less than 1.7, you must pass this flag or you will not be able to get a valid drawing surface and GetAWT will return false. This is to maintain compatibility with applications that used the interface with Java 6 which had multiple rendering models. This flag is not necessary when JAWT version 1.7 or greater is used as this is the only supported rendering mode.

        When the native Cocoa toolkit is in use, the pointer stored in JAWT_DrawingSurfaceInfo->platformInfo points to a NSObject that conforms to the JAWT_SurfaceLayers protocol. Setting the layer property of this object will cause the specified layer to be overlaid on the Component's rectangle. If the window the Component belongs to has a CALayer attached to it, this layer will be accessible via the windowLayer property.

        
         @protocol JAWT_SurfaceLayers
             @property (readwrite, retain) CALayer *layer;
             @property (readonly) CALayer *windowLayer;
         @end
    • Method Detail

      • nJAWT_GetAWT

        public static boolean nJAWT_GetAWT​(long __functionAddress,
                                           long awt)
        
        public static boolean nJAWT_GetAWT​(long awt)
        
        Unsafe version of: GetAWT
      • JAWT_GetAWT

        public static boolean JAWT_GetAWT​(JAWT awt)
        Returns the AWT native structure.
        Parameters:
        awt - the target JAWT struct
        Returns:
        JNI_FALSE if an error occurs
      • nJAWT_DrawingSurface_Lock

        public static int nJAWT_DrawingSurface_Lock​(long __functionAddress,
                                                    long ds)
        Unsafe version of: DrawingSurface_Lock
      • JAWT_DrawingSurface_Lock

        public static int JAWT_DrawingSurface_Lock​(long __functionAddress,
                                                   JAWTDrawingSurface ds)
        Locks the surface of the target component for native rendering. When finished drawing, the surface must be unlocked with DrawingSurface_Unlock.
        Parameters:
        __functionAddress - the function address
        ds - the surface to lock
        Returns:
        a bitmask with one or more of the following values:
      • nJAWT_DrawingSurface_GetDrawingSurfaceInfo

        public static long nJAWT_DrawingSurface_GetDrawingSurfaceInfo​(long __functionAddress,
                                                                      long ds)
      • nJAWT_DrawingSurface_FreeDrawingSurfaceInfo

        public static void nJAWT_DrawingSurface_FreeDrawingSurfaceInfo​(long __functionAddress,
                                                                       long dsi)
      • JAWT_DrawingSurface_FreeDrawingSurfaceInfo

        public static void JAWT_DrawingSurface_FreeDrawingSurfaceInfo​(long __functionAddress,
                                                                      JAWTDrawingSurfaceInfo dsi)
        Frees the drawing surface info.
        Parameters:
        __functionAddress - the function address
        dsi - the JAWTDrawingSurfaceInfo to free
      • nJAWT_DrawingSurface_Unlock

        public static void nJAWT_DrawingSurface_Unlock​(long __functionAddress,
                                                       long ds)
        Unsafe version of: DrawingSurface_Unlock
      • JAWT_DrawingSurface_Unlock

        public static void JAWT_DrawingSurface_Unlock​(long __functionAddress,
                                                      JAWTDrawingSurface ds)
        Unlocks the drawing surface of the target component for native rendering.
        Parameters:
        __functionAddress - the function address
        ds - the surface to unlock
      • nJAWT_GetDrawingSurface

        public static long nJAWT_GetDrawingSurface​(long __functionAddress,
                                                   java.lang.Object target)
        Unsafe version of: GetDrawingSurface
      • JAWT_GetDrawingSurface

        @Nullable
        public static JAWTDrawingSurface JAWT_GetDrawingSurface​(long __functionAddress,
                                                                java.lang.Object target)
        Returns a drawing surface from a target jobject. This value may be cached.

        FreeDrawingSurface must be called when finished with the returned JAWTDrawingSurface.

        Parameters:
        __functionAddress - the function address
        target - must be a Component (should be a Canvas or Window for native rendering)
        Returns:
        NULL if an error has occurred
      • nJAWT_FreeDrawingSurface

        public static void nJAWT_FreeDrawingSurface​(long __functionAddress,
                                                    long ds)
        Unsafe version of: FreeDrawingSurface
      • JAWT_FreeDrawingSurface

        public static void JAWT_FreeDrawingSurface​(long __functionAddress,
                                                   JAWTDrawingSurface ds)
        Frees the drawing surface allocated in GetDrawingSurface.
        Parameters:
        __functionAddress - the function address
        ds - the JAWTDrawingSurface to free
      • nJAWT_Lock

        public static void nJAWT_Lock​(long __functionAddress)
        Unsafe version of: Lock
      • JAWT_Lock

        public static void JAWT_Lock​(long __functionAddress)
        Locks the entire AWT for synchronization purposes.
        Parameters:
        __functionAddress - the function address
      • nJAWT_Unlock

        public static void nJAWT_Unlock​(long __functionAddress)
        Unsafe version of: Unlock
      • JAWT_Unlock

        public static void JAWT_Unlock​(long __functionAddress)
        Unlocks the entire AWT for synchronization purposes.
        Parameters:
        __functionAddress - the function address
      • nJAWT_GetComponent

        @Nullable
        public static java.awt.Component nJAWT_GetComponent​(long __functionAddress,
                                                            long platformInfo)
        Unsafe version of: GetComponent
      • JAWT_GetComponent

        @Nullable
        public static java.awt.Component JAWT_GetComponent​(long __functionAddress,
                                                           long platformInfo)
        Returns a reference to a Component from a native platform handle. On Windows, this corresponds to an HWND; on Solaris and Linux, this is a Drawable. For other platforms, see the appropriate machine-dependent header file for a description. The reference returned by this function is a local reference that is only valid in this environment. This function returns a NULL reference if no component could be found with matching platform information.
        Parameters:
        __functionAddress - the function address
        platformInfo - the native platform handle
      • nJAWT_CreateEmbeddedFrame

        @Nullable
        public static java.awt.Frame nJAWT_CreateEmbeddedFrame​(long __functionAddress,
                                                               long platformInfo)
        Unsafe version of: CreateEmbeddedFrame
      • JAWT_CreateEmbeddedFrame

        @Nullable
        public static java.awt.Frame JAWT_CreateEmbeddedFrame​(long __functionAddress,
                                                              long platformInfo)
        Creates a Frame placed in a native container. Container is referenced by the native platform handle. For example on Windows this corresponds to an HWND. For other platforms, see the appropriate machine-dependent header file for a description. The reference returned by this function is a local reference that is only valid in this environment. This function returns a NULL reference if no frame could be created with matching platform information.
        Parameters:
        __functionAddress - the function address
        platformInfo - the native platform handle
        Since:
        Java 9
      • nJAWT_SetBounds

        public static void nJAWT_SetBounds​(long __functionAddress,
                                           java.awt.Frame embeddedFrame,
                                           int x,
                                           int y,
                                           int w,
                                           int h)
        Unsafe version of: SetBounds
      • JAWT_SetBounds

        public static void JAWT_SetBounds​(long __functionAddress,
                                          java.awt.Frame embeddedFrame,
                                          int x,
                                          int y,
                                          int w,
                                          int h)
        Moves and resizes the embedded frame. The new location of the top-left corner is specified by x and y parameters relative to the native parent component. The new size is specified by width and height.

        The embedded frame should be created by CreateEmbeddedFrame method, or this function will not have any effect.

        Component.setLocation(int, int) and Component.setBounds(int, int, int, int) for EmbeddedFrame really don't move it within the native parent. These methods always locate the embedded frame at (0, 0) for backward compatibility. To allow moving embedded frames this method was introduced, and it works just the same way as setLocation() and setBounds() for usual, non-embedded components.

        Using usual get/setLocation() and get/setBounds() together with this new method is not recommended.

        Parameters:
        __functionAddress - the function address
        embeddedFrame - the embedded frame
        x - the x coordinate
        y - the y coordinate
        w - the width
        h - the height
        Since:
        Java 9
      • nJAWT_SynthesizeWindowActivation

        public static void nJAWT_SynthesizeWindowActivation​(long __functionAddress,
                                                            java.awt.Frame embeddedFrame,
                                                            boolean doActivate)
        Unsafe version of: SynthesizeWindowActivation
      • JAWT_SynthesizeWindowActivation

        public static void JAWT_SynthesizeWindowActivation​(long __functionAddress,
                                                           java.awt.Frame embeddedFrame,
                                                           boolean doActivate)
        Synthesizes a native message to activate or deactivate an EmbeddedFrame window depending on the value of parameter doActivate.

        The embedded frame should be created by CreateEmbeddedFrame method, or this function will not have any effect.

        Parameters:
        __functionAddress - the function address
        embeddedFrame - the embedded frame
        doActivate - if true activates the window; otherwise, deactivates the window
        Since:
        Java 9