javax.media.nativewindow
Class DefaultGraphicsDevice

java.lang.Object
  extended by javax.media.nativewindow.DefaultGraphicsDevice
All Implemented Interfaces:
Cloneable, AbstractGraphicsDevice
Direct Known Subclasses:
AWTGraphicsDevice, EGLGraphicsDevice, MacOSXGraphicsDevice, WindowsGraphicsDevice, X11GraphicsDevice

public class DefaultGraphicsDevice
extends Object
implements Cloneable, AbstractGraphicsDevice


Field Summary
protected  String connection
           
protected  long handle
           
protected  ToolkitLock toolkitLock
           
protected  String uniqueID
           
protected  int unitID
           
 
Fields inherited from interface javax.media.nativewindow.AbstractGraphicsDevice
DEFAULT_CONNECTION, DEFAULT_UNIT, EXTERNAL_CONNECTION
 
Constructor Summary
DefaultGraphicsDevice(String type, String connection, int unitID)
          Create an instance with the system default ToolkitLock, gathered via NativeWindowFactory#createDefaultToolkitLock().
DefaultGraphicsDevice(String type, String connection, int unitID, long handle)
          Create an instance with the system default ToolkitLock.
DefaultGraphicsDevice(String type, String connection, int unitID, long handle, ToolkitLock locker)
          Create an instance with the given ToolkitLock instance.
 
Method Summary
 Object clone()
           
 boolean close()
          Optionally closing the device.
The default implementation is a NOP operation, returning false.
The specific implementing, ie X11GraphicsDevice, shall have a enable/disable like javax.media.nativewindow.x11.X11GraphicsDevice#setCloseDisplay(boolean, boolean),
which shall be invoked at creation time to determine ownership/role of freeing the resource.
 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 AbstractGraphicsDevice.getUnitID().
 long getHandle()
          Returns the native handle of the underlying native device, if such thing exist.
 ToolkitLock getToolkitLock()
           
 String getType()
          Returns the type of the underlying subsystem, ie NativeWindowFactory.TYPE_KD, NativeWindowFactory.TYPE_X11, ..
 String getUniqueID()
          Returns a unique ID String of this device using type, connection and unitID.
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.
protected static String getUniqueID(String type, String connection, int unitID)
           
 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 AbstractGraphicsDevice.getConnection().
 void lock()
          No lock is performed on the graphics device per default, instead the aggregated recursive ToolkitLock.lock() is invoked.
protected  void setToolkitLock(ToolkitLock locker)
          Set the internal ToolkitLock, which is used within the lock() and unlock() implementation.
 String toString()
           
 void unlock()
          No lock is performed on the graphics device per default, instead the aggregated recursive ToolkitLock.unlock() is invoked.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

connection

protected String connection

unitID

protected int unitID

uniqueID

protected String uniqueID

handle

protected long handle

toolkitLock

protected ToolkitLock toolkitLock
Constructor Detail

DefaultGraphicsDevice

public DefaultGraphicsDevice(String type,
                             String connection,
                             int unitID)
Create an instance with the system default ToolkitLock, gathered via NativeWindowFactory#createDefaultToolkitLock().

Parameters:
type -

DefaultGraphicsDevice

public DefaultGraphicsDevice(String type,
                             String connection,
                             int unitID,
                             long handle)
Create an instance with the system default ToolkitLock. gathered via NativeWindowFactory#createDefaultToolkitLock().

Parameters:
type -
handle -

DefaultGraphicsDevice

public DefaultGraphicsDevice(String type,
                             String connection,
                             int unitID,
                             long handle,
                             ToolkitLock locker)
Create an instance with the given ToolkitLock instance.

Parameters:
type -
handle -
locker -
Method Detail

clone

public Object clone()
Overrides:
clone in class Object

getType

public final String getType()
Description copied from interface: AbstractGraphicsDevice
Returns the type of the underlying subsystem, ie NativeWindowFactory.TYPE_KD, NativeWindowFactory.TYPE_X11, ..

Specified by:
getType in interface AbstractGraphicsDevice

getConnection

public final String getConnection()
Description copied from interface: AbstractGraphicsDevice
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.
To support multiple local device, see AbstractGraphicsDevice.getUnitID().

Specified by:
getConnection in interface AbstractGraphicsDevice

getUnitID

public final int getUnitID()
Description copied from interface: AbstractGraphicsDevice
Returns the graphics device unit ID.
The unit ID support multiple graphics device configurations on a local machine.
To support remote device, see AbstractGraphicsDevice.getConnection().

Specified by:
getUnitID in interface AbstractGraphicsDevice
Returns:

getUniqueID

public final String getUniqueID()
Description copied from interface: AbstractGraphicsDevice
Returns a unique ID String of this device using type, connection and unitID.
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.

Specified by:
getUniqueID in interface AbstractGraphicsDevice

getHandle

public final long getHandle()
Description copied from interface: AbstractGraphicsDevice
Returns the native handle of the underlying native device, if such thing exist.

Specified by:
getHandle in interface AbstractGraphicsDevice

lock

public final void lock()
No lock is performed on the graphics device per default, instead the aggregated recursive ToolkitLock.lock() is invoked.

Specified by:
lock in interface AbstractGraphicsDevice
See Also:
DefaultGraphicsDevice#DefaultGraphicsDevice(java.lang.String, long), DefaultGraphicsDevice#DefaultGraphicsDevice(java.lang.String, long, javax.media.nativewindow.ToolkitLock)

unlock

public final void unlock()
No lock is performed on the graphics device per default, instead the aggregated recursive ToolkitLock.unlock() is invoked.

Specified by:
unlock in interface AbstractGraphicsDevice
See Also:
DefaultGraphicsDevice#DefaultGraphicsDevice(java.lang.String, long), DefaultGraphicsDevice#DefaultGraphicsDevice(java.lang.String, long, javax.media.nativewindow.ToolkitLock)

close

public boolean close()
Description copied from interface: AbstractGraphicsDevice
Optionally closing the device.
The default implementation is a NOP operation, returning false.
The specific implementing, ie X11GraphicsDevice, shall have a enable/disable like javax.media.nativewindow.x11.X11GraphicsDevice#setCloseDisplay(boolean, boolean),
which shall be invoked at creation time to determine ownership/role of freeing the resource.

Specified by:
close in interface AbstractGraphicsDevice
Returns:
true if a specialized closing operation was successfully issued, otherwise false, ie no native closing operation was issued, which doesn't imply an error at all.

toString

public String toString()
Overrides:
toString in class Object

setToolkitLock

protected void setToolkitLock(ToolkitLock locker)
Set the internal ToolkitLock, which is used within the lock() and unlock() implementation.

Parameters:
locker - the ToolkitLock, if null, NullToolkitLock is being used

getToolkitLock

public final ToolkitLock getToolkitLock()
Returns:
the used ToolkitLock
See Also:
DefaultGraphicsDevice#DefaultGraphicsDevice(java.lang.String, long), DefaultGraphicsDevice#DefaultGraphicsDevice(java.lang.String, long, javax.media.nativewindow.ToolkitLock)

getUniqueID

protected static String getUniqueID(String type,
                                    String connection,
                                    int unitID)


Copyright 2010 JogAmp Community.