Interface AbstractGraphicsDevice

All Superinterfaces:
Cloneable
All Known Implementing Classes:
AWTGraphicsDevice, DefaultGraphicsDevice, EGLGraphicsDevice, MacOSXGraphicsDevice, WindowsGraphicsDevice, X11GraphicsDevice

public interface AbstractGraphicsDevice extends Cloneable
A interface describing a graphics device in a toolkit-independent manner.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final boolean
     
    static final String
    Dummy connection value for a default connection where no native support for multiple devices is available
    static final int
    Default unit id for the 1st device: 0
    static final String
    Dummy connection value for an external connection where no native support for multiple devices is available
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
     
    boolean
    Optionally closing the device if handle is not null.
    Returns the semantic GraphicsDevice connection.
    On platforms supporting remote devices, eg via tcp/ip network, the implementation shall return a unique name for each remote address.
    On X11 for example, the connection string should be as the following example.
    :0.0 for a local connection remote.host.net:0.0 for a remote connection To support multiple local device, see getUnitID().
    long
    Returns the native handle of the underlying native device, if such thing exist.
    Returns the type of the underlying subsystem, ie NativeWindowFactory.TYPE_KD, NativeWindowFactory.TYPE_X11, ..
    Returns a unique ID object of this device using type, connection and unitID as it's key components.
    int
    Returns the graphics device unit ID.
    The unit ID support multiple graphics device configurations on a local machine.
    To support remote device, see getConnection().
    boolean
     
    void
    Optionally locking the device, utilizing eg ToolkitLock.lock().
    boolean
    Optionally [re]opening the device if handle is null.
    void
    Optionally unlocking the device, utilizing eg ToolkitLock.unlock().
    void
     
  • Field Details

    • DEBUG

      static final boolean DEBUG
    • DEFAULT_CONNECTION

      static final String DEFAULT_CONNECTION
      Dummy connection value for a default connection where no native support for multiple devices is available
      See Also:
    • EXTERNAL_CONNECTION

      static final String EXTERNAL_CONNECTION
      Dummy connection value for an external connection where no native support for multiple devices is available
      See Also:
    • DEFAULT_UNIT

      static final int DEFAULT_UNIT
      Default unit id for the 1st device: 0
      See Also:
  • Method Details

    • clone

      Object clone()
    • getType

      String getType()
      Returns the type of the underlying subsystem, ie NativeWindowFactory.TYPE_KD, NativeWindowFactory.TYPE_X11, ..
    • getConnection

      String getConnection()
      Returns the semantic GraphicsDevice connection.
      On platforms supporting remote devices, eg via tcp/ip network, the implementation shall return a unique name for each remote address.
      On X11 for example, the connection string should be as the following example.
      • :0.0 for a local connection
      • remote.host.net:0.0 for a remote connection
      To support multiple local device, see getUnitID().
    • getUnitID

      int getUnitID()
      Returns the graphics device unit ID.
      The unit ID support multiple graphics device configurations on a local machine.
      To support remote device, see getConnection().
      Returns:
    • getUniqueID

      String getUniqueID()
      Returns a unique ID object of this device using type, connection and unitID as it's key components.

      The unique ID does not reflect the instance of the device, hence the handle is not included. The unique ID may be used as a key for semantic device mapping.

      The returned string object reference is unique using String.intern() and hence can be used as a key itself.

    • getHandle

      long getHandle()
      Returns the native handle of the underlying native device, if such thing exist.
    • lock

      void lock()
      Optionally locking the device, utilizing eg ToolkitLock.lock(). The lock implementation must be recursive.
    • unlock

      void unlock()
      Optionally unlocking the device, utilizing eg ToolkitLock.unlock(). The lock implementation must be recursive.
      Throws:
      RuntimeException - in case the lock is not acquired by this thread.
    • validateLocked

      void validateLocked() throws RuntimeException
      Throws:
      RuntimeException - if current thread does not hold the lock
    • open

      boolean open()
      Optionally [re]opening the device if handle is null.

      The default implementation is a NOP.

      Example implementations like X11GraphicsDevice or EGLGraphicsDevice issue the native open operation in case handle is null.

      Returns:
      true if the handle was null and opening was successful, otherwise false.
    • close

      boolean close()
      Optionally closing the device if handle is not null.

      The default implementation dispose it's ToolkitLock and sets the handle to null.

      Example implementations like X11GraphicsDevice or EGLGraphicsDevice issue the native close operation or skip it depending on the handles's ownership.

      Returns:
      true if the handle was not null and closing was successful, otherwise false.
    • isHandleOwner

      boolean isHandleOwner()
      Returns:
      true if instance owns the handle to issue close(), otherwise false.
    • clearHandleOwner

      void clearHandleOwner()