com.jogamp.nativewindow.impl.jawt
Class JAWTWindow

java.lang.Object
  extended by com.jogamp.nativewindow.impl.jawt.JAWTWindow
All Implemented Interfaces:
NativeWindow, SurfaceUpdatedListener
Direct Known Subclasses:
MacOSXJAWTWindow, WindowsJAWTWindow, X11JAWTWindow

public abstract class JAWTWindow
extends Object
implements NativeWindow


Field Summary
protected  com.jogamp.nativewindow.util.Rectangle bounds
           
protected  Component component
           
protected  AbstractGraphicsConfiguration config
           
protected static boolean DEBUG
           
protected  long drawable
           
 
Fields inherited from interface javax.media.nativewindow.NativeWindow
LOCK_SUCCESS, LOCK_SURFACE_CHANGED, LOCK_SURFACE_NOT_READY, LOCK_SURFACE_UNLOCKED
 
Constructor Summary
JAWTWindow(Object comp, AbstractGraphicsConfiguration config)
           
 
Method Summary
 void destroy()
          destroys the window and releases windowing related resources.
 com.jogamp.nativewindow.util.Rectangle getBounds()
           
 long getDisplayHandle()
          Convenience: Get display handle from AbstractGraphicsConfiguration .
 AbstractGraphicsConfiguration getGraphicsConfiguration()
          Returns the graphics configuration corresponding to this window.
 int getHeight()
          Returns the current height of this window.
 Exception getLockedStack()
          Return the lock-exception, or null if not locked.
 int getScreenIndex()
          Convenience: Get display handle from AbstractGraphicsConfiguration .
 long getSurfaceHandle()
          Returns the handle to the surface for this NativeWindow.
 int getWidth()
          Returns the current width of this window.
 long getWindowHandle()
          Returns the window handle for this NativeWindow.
 Object getWrappedWindow()
           
protected  void init(Component windowObject)
           
protected abstract  void initNative()
           
 void invalidate()
          render all native window information invalid, as if the native window was destroyed
 boolean isSurfaceLocked()
          Return if surface is locked
 int lockSurface()
          Lock the surface of this native window
protected abstract  int lockSurfaceImpl()
           
 void setSize(int width, int height)
           
 boolean surfaceSwap()
          Provide a mechanism to utilize custom (pre-) swap surface code.
 void surfaceUpdated(Object updater, NativeWindow window, long when)
          Notification of a surface update event.
 String toString()
           
 void unlockSurface()
          Unlock the surface of this native window Shall not modify the surface handle, see NativeWindow.lockSurface()
protected abstract  void unlockSurfaceImpl()
           
protected  void updateBounds(JAWT_Rectangle jawtBounds)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEBUG

protected static final boolean DEBUG

component

protected Component component

config

protected AbstractGraphicsConfiguration config

drawable

protected long drawable

bounds

protected com.jogamp.nativewindow.util.Rectangle bounds
Constructor Detail

JAWTWindow

public JAWTWindow(Object comp,
                  AbstractGraphicsConfiguration config)
Method Detail

init

protected void init(Component windowObject)
             throws NativeWindowException
Throws:
NativeWindowException

initNative

protected abstract void initNative()
                            throws NativeWindowException
Throws:
NativeWindowException

invalidate

public void invalidate()
Description copied from interface: NativeWindow
render all native window information invalid, as if the native window was destroyed

Specified by:
invalidate in interface NativeWindow
See Also:
NativeWindow.destroy()

destroy

public void destroy()
Description copied from interface: NativeWindow
destroys the window and releases windowing related resources.

Specified by:
destroy in interface NativeWindow

updateBounds

protected void updateBounds(JAWT_Rectangle jawtBounds)

lockSurfaceImpl

protected abstract int lockSurfaceImpl()
                                throws NativeWindowException
Throws:
NativeWindowException

lockSurface

public final int lockSurface()
                      throws NativeWindowException
Description copied from interface: NativeWindow
Lock the surface of this native window

The surface handle, see NativeWindow.lockSurface(),
shall be set and valid after a successfull call, ie a return value other than NativeWindow.LOCK_SURFACE_NOT_READY.

The semantics of the underlying native locked resource may be related to the ToolkitLock one. Hence it is important that implementation of both harmonize well.
The implementation may want to aquire the ToolkitLock first to become it's owner before proceeding with it's actual surface lock.

Specified by:
lockSurface in interface NativeWindow
Returns:
NativeWindow.LOCK_SUCCESS, NativeWindow.LOCK_SURFACE_CHANGED or NativeWindow.LOCK_SURFACE_NOT_READY.
Throws:
NativeWindowException - if surface is already locked
See Also:
ToolkitLock

unlockSurfaceImpl

protected abstract void unlockSurfaceImpl()
                                   throws NativeWindowException
Throws:
NativeWindowException

unlockSurface

public void unlockSurface()
Description copied from interface: NativeWindow
Unlock the surface of this native window Shall not modify the surface handle, see NativeWindow.lockSurface()

Specified by:
unlockSurface in interface NativeWindow
See Also:
NativeWindow.lockSurface(), ToolkitLock

isSurfaceLocked

public boolean isSurfaceLocked()
Description copied from interface: NativeWindow
Return if surface is locked

Specified by:
isSurfaceLocked in interface NativeWindow

getLockedStack

public Exception getLockedStack()
Description copied from interface: NativeWindow
Return the lock-exception, or null if not locked. The lock-exception is created at NativeWindow.lockSurface() and hence holds the locker's call stack.

Specified by:
getLockedStack in interface NativeWindow

surfaceSwap

public boolean surfaceSwap()
Description copied from interface: NativeWindow
Provide a mechanism to utilize custom (pre-) swap surface code. This method is called before the render toolkit (e.g. JOGL) swaps the buffer/surface. The implementation may itself apply the swapping, in which case true shall be returned.

Specified by:
surfaceSwap in interface NativeWindow
Returns:
true if this method completed swapping the surface, otherwise false, in which case eg the GLDrawable implementation has to swap the code.

surfaceUpdated

public void surfaceUpdated(Object updater,
                           NativeWindow window,
                           long when)
Description copied from interface: SurfaceUpdatedListener
Notification of a surface update event.

Specified by:
surfaceUpdated in interface SurfaceUpdatedListener
Parameters:
updater - is the caller object who updated the surface, e.g. a JOGL GLDrawable.
window - the NativeWindow, which surface is updated
when - the time in ms, when the surface was updated

getDisplayHandle

public long getDisplayHandle()
Description copied from interface: NativeWindow
Convenience: Get display handle from AbstractGraphicsConfiguration . AbstractGraphicsScreen . AbstractGraphicsDevice

Specified by:
getDisplayHandle in interface NativeWindow

getScreenIndex

public int getScreenIndex()
Description copied from interface: NativeWindow
Convenience: Get display handle from AbstractGraphicsConfiguration . AbstractGraphicsScreen

Specified by:
getScreenIndex in interface NativeWindow

getWindowHandle

public long getWindowHandle()
Description copied from interface: NativeWindow
Returns the window handle for this NativeWindow.

The window handle shall reflect the platform one for all window related operations, e.g. open, close, resize.

On X11 this returns an entity of type Window.
On Microsoft Windows this returns an entity of type HWND.

Specified by:
getWindowHandle in interface NativeWindow

getSurfaceHandle

public long getSurfaceHandle()
Description copied from interface: NativeWindow
Returns the handle to the surface for this NativeWindow.

The surface handle should be set/update by NativeWindow.lockSurface(), where NativeWindow.unlockSurface() is not allowed to modify it. After NativeWindow.unlockSurface() it is no more guaranteed that the surface handle is still valid. The surface handle shall reflect the platform one for all drawable surface operations, e.g. opengl, swap-buffer.

On X11 this returns an entity of type Window, since there is no differentiation of surface and window there.
On Microsoft Windows this returns an entity of type HDC.

Specified by:
getSurfaceHandle in interface NativeWindow

getGraphicsConfiguration

public AbstractGraphicsConfiguration getGraphicsConfiguration()
Description copied from interface: NativeWindow
Returns the graphics configuration corresponding to this window.

Specified by:
getGraphicsConfiguration in interface NativeWindow
See Also:
GraphicsConfigurationFactory.chooseGraphicsConfiguration(Capabilities, CapabilitiesChooser, AbstractGraphicsScreen)

getWrappedWindow

public Object getWrappedWindow()

setSize

public void setSize(int width,
                    int height)

getWidth

public int getWidth()
Description copied from interface: NativeWindow
Returns the current width of this window.

Specified by:
getWidth in interface NativeWindow

getHeight

public int getHeight()
Description copied from interface: NativeWindow
Returns the current height of this window.

Specified by:
getHeight in interface NativeWindow

getBounds

public com.jogamp.nativewindow.util.Rectangle getBounds()
Returns:
the JAWT_DrawingSurfaceInfo's (JAWT_Rectangle) bounds, updated with lock

toString

public String toString()
Overrides:
toString in class Object


Copyright 2010 JogAmp Community.