javax.media.nativewindow
Class NativeWindowFactory

java.lang.Object
  extended by javax.media.nativewindow.NativeWindowFactory

public abstract class NativeWindowFactory
extends Object

Provides a pluggable mechanism for arbitrary window toolkits to adapt their components to the NativeWindow interface, which provides a platform-independent mechanism of accessing the information required to perform operations like hardware-accelerated rendering using the OpenGL API.


Field Summary
protected static boolean DEBUG
           
static String TYPE_AWT
          Generic AWT type
static String TYPE_DEFAULT
          Generic DEFAULT type, where platform implementation don't care
static String TYPE_EGL
          OpenKODE/EGL type
static String TYPE_MACOSX
          Mac OS X type
static String TYPE_WINDOWS
          Microsoft Windows type
static String TYPE_X11
          X11 type
 
Constructor Summary
protected NativeWindowFactory()
          Creates a new NativeWindowFactory instance.
 
Method Summary
static NativeWindowFactory getDefaultFactory()
          Gets the default NativeWindowFactory.
static NativeWindowFactory getFactory(Class windowClass)
          Returns the appropriate NativeWindowFactory to handle window objects of the given type.
static String getNativeOSName(boolean useCustom)
           
static NativeWindow getNativeWindow(Object winObj, AbstractGraphicsConfiguration config)
          Converts the given window object and it's AbstractGraphicsConfiguration into a NativeWindow which can be operated upon by a custom toolkit, e.g.
protected abstract  NativeWindow getNativeWindowImpl(Object winObj, AbstractGraphicsConfiguration config)
          Performs the conversion from a toolkit's window object to a NativeWindow.
static String getNativeWindowType(boolean useCustom)
           
abstract  ToolkitLock getToolkitLock()
          Returns the object which provides support for synchronizing with the underlying window toolkit.
protected static void registerFactory(Class windowClass, NativeWindowFactory factory)
          Registers a NativeWindowFactory handling window objects of the given class.
static void setDefaultFactory(NativeWindowFactory factory)
          Sets the default NativeWindowFactory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEBUG

protected static final boolean DEBUG

TYPE_EGL

public static final String TYPE_EGL
OpenKODE/EGL type

See Also:
Constant Field Values

TYPE_WINDOWS

public static final String TYPE_WINDOWS
Microsoft Windows type

See Also:
Constant Field Values

TYPE_X11

public static final String TYPE_X11
X11 type

See Also:
Constant Field Values

TYPE_MACOSX

public static final String TYPE_MACOSX
Mac OS X type

See Also:
Constant Field Values

TYPE_AWT

public static final String TYPE_AWT
Generic AWT type

See Also:
Constant Field Values

TYPE_DEFAULT

public static final String TYPE_DEFAULT
Generic DEFAULT type, where platform implementation don't care

See Also:
Constant Field Values
Constructor Detail

NativeWindowFactory

protected NativeWindowFactory()
Creates a new NativeWindowFactory instance. End users do not need to call this method.

Method Detail

getNativeOSName

public static String getNativeOSName(boolean useCustom)

getNativeWindowType

public static String getNativeWindowType(boolean useCustom)

setDefaultFactory

public static void setDefaultFactory(NativeWindowFactory factory)
Sets the default NativeWindowFactory. Certain operations on X11 platforms require synchronization, and the implementation of this synchronization may be specific to the window toolkit in use. It is impractical to require that all of the APIs that might require synchronization receive a ToolkitLock as argument. For this reason the concept of a default NativeWindowFactory is introduced. The toolkit lock provided via getToolkitLock from this default NativeWindowFactory will be used for synchronization within the Java binding to OpenGL. By default, if the AWT is available, the default toolkit will support the AWT.


getDefaultFactory

public static NativeWindowFactory getDefaultFactory()
Gets the default NativeWindowFactory. Certain operations on X11 platforms require synchronization, and the implementation of this synchronization may be specific to the window toolkit in use. It is impractical to require that all of the APIs that might require synchronization receive a ToolkitLock as argument. For this reason the concept of a default NativeWindowFactory is introduced. The toolkit lock provided via getToolkitLock from this default NativeWindowFactory will be used for synchronization within the Java binding to OpenGL. By default, if the AWT is available, the default toolkit will support the AWT.


getFactory

public static NativeWindowFactory getFactory(Class windowClass)
                                      throws IllegalArgumentException
Returns the appropriate NativeWindowFactory to handle window objects of the given type. The windowClass might be NativeWindow, in which case the client has already assumed the responsibility of creating a compatible NativeWindow implementation, or it might be that of a toolkit class like Component.

Throws:
IllegalArgumentException

registerFactory

protected static void registerFactory(Class windowClass,
                                      NativeWindowFactory factory)
Registers a NativeWindowFactory handling window objects of the given class. This does not need to be called by end users, only implementors of new NativeWindowFactory subclasses.


getNativeWindow

public static NativeWindow getNativeWindow(Object winObj,
                                           AbstractGraphicsConfiguration config)
                                    throws IllegalArgumentException,
                                           NativeWindowException
Converts the given window object and it's AbstractGraphicsConfiguration into a NativeWindow which can be operated upon by a custom toolkit, e.g. javax.media.opengl.GLDrawableFactory.
The object may be a component for a particular window toolkit, such as an AWT Canvas. It may also be a NativeWindow object itself.
You shall utilize GraphicsConfigurationFactory to construct a proper AbstractGraphicsConfiguration.
The particular implementation of the NativeWindowFactory is responsible for handling objects from a particular window toolkit. The built-in NativeWindowFactory handles NativeWindow instances as well as AWT Components.

Throws:
IllegalArgumentException - if the given window object could not be handled by any of the registered NativeWindowFactory instances
NativeWindowException
See Also:
GraphicsConfigurationFactory.chooseGraphicsConfiguration(Capabilities, CapabilitiesChooser, AbstractGraphicsScreen)

getNativeWindowImpl

protected abstract NativeWindow getNativeWindowImpl(Object winObj,
                                                    AbstractGraphicsConfiguration config)
                                             throws IllegalArgumentException
Performs the conversion from a toolkit's window object to a NativeWindow. Implementors of concrete NativeWindowFactory subclasses should override this method.

Throws:
IllegalArgumentException

getToolkitLock

public abstract ToolkitLock getToolkitLock()
Returns the object which provides support for synchronizing with the underlying window toolkit.

See Also:
ToolkitLock


Copyright 2005 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.