com.jogamp.nativewindow.impl.jawt
Class JAWTWindow

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

public abstract class JAWTWindow
extends Object
implements NativeWindow


Field Summary
protected  Rectangle bounds
           
protected  Component component
           
protected  AbstractGraphicsConfiguration config
           
protected static boolean DEBUG
           
protected  long drawable
           
 
Fields inherited from interface javax.media.nativewindow.NativeSurface
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.
 Component getAWTComponent()
           
 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 surface.
 Point getLocationOnScreen(Point storage)
          Returns the current absolute location of this window.
protected abstract  Point getLocationOnScreenImpl(int x, int y)
           
 NativeWindow getParent()
           
 int getScreenIndex()
          Convenience: Get display handle from AbstractGraphicsConfiguration .
 long getSurfaceHandle()
          Returns the handle to the surface for this NativeSurface.
 Thread getSurfaceLockOwner()
          Return the locking owner's Thread, or null if not locked.
 int getWidth()
          Returns the current width of this surface.
 long getWindowHandle()
          Returns the window handle for this NativeWindow.
 int getX()
          Returns the current x position of this window, relative to it's parent.
 int getY()
          Returns the current y position of this window, relative to it's parent.
protected  void invalidate()
           
 boolean isSurfaceLocked()
          Return if surface is locked
 boolean isSurfaceLockedByOtherThread()
          Return if surface is locked by another thread, ie not the current one
 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, NativeSurface ns, long when)
          Notification of a surface update event.
 void surfaceUpdated(Object updater, NativeWindow window, long when)
           
 String toString()
           
 void unlockSurface()
          Unlock the surface of this native window Shall not modify the surface handle, see NativeSurface.lockSurface()
protected abstract  void unlockSurfaceImpl()
           
protected  void updateBounds(JAWT_Rectangle jawtBounds)
           
protected abstract  void validateNative()
           
 
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 Rectangle bounds
Constructor Detail

JAWTWindow

public JAWTWindow(Object comp,
                  AbstractGraphicsConfiguration config)
Method Detail

validateNative

protected abstract void validateNative()
                                throws NativeWindowException
Throws:
NativeWindowException

invalidate

protected void invalidate()

updateBounds

protected final void updateBounds(JAWT_Rectangle jawtBounds)

getBounds

public final Rectangle getBounds()
Returns:
the JAWT_DrawingSurfaceInfo's (JAWT_Rectangle) bounds, updated with lock

getAWTComponent

public final Component getAWTComponent()

surfaceUpdated

public final void surfaceUpdated(Object updater,
                                 NativeSurface ns,
                                 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.
ns - the updated NativeSurface
when - the time in ms, when the surface was updated

lockSurfaceImpl

protected abstract int lockSurfaceImpl()
                                throws NativeWindowException
Throws:
NativeWindowException

lockSurface

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

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

This call is blocking until the surface has been locked or a timeout is reached. The latter will throw a runtime exception.

This call allows recursion from the same thread.

The implementation may want to aquire the application level RecursiveLock first before proceeding with a native surface lock.

The implementation shall also invoke AbstractGraphicsDevice.lock() for the initial lock (recursive count zero).

Specified by:
lockSurface in interface NativeSurface
Returns:
NativeSurface.LOCK_SUCCESS, NativeSurface.LOCK_SURFACE_CHANGED or NativeSurface.LOCK_SURFACE_NOT_READY.
Throws:
NativeWindowException
See Also:
RecursiveLock

unlockSurfaceImpl

protected abstract void unlockSurfaceImpl()
                                   throws NativeWindowException
Throws:
NativeWindowException

unlockSurface

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

The implementation shall also invoke AbstractGraphicsDevice.unlock() for the final unlock (recursive count zero).

Specified by:
unlockSurface in interface NativeSurface
See Also:
NativeSurface.lockSurface(), RecursiveLock

isSurfaceLockedByOtherThread

public final boolean isSurfaceLockedByOtherThread()
Description copied from interface: NativeSurface
Return if surface is locked by another thread, ie not the current one

Specified by:
isSurfaceLockedByOtherThread in interface NativeSurface

isSurfaceLocked

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

Specified by:
isSurfaceLocked in interface NativeSurface

getSurfaceLockOwner

public final Thread getSurfaceLockOwner()
Description copied from interface: NativeSurface
Return the locking owner's Thread, or null if not locked.

Specified by:
getSurfaceLockOwner in interface NativeSurface

surfaceSwap

public final boolean surfaceSwap()
Description copied from interface: NativeSurface
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 NativeSurface
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 final void surfaceUpdated(Object updater,
                                 NativeWindow window,
                                 long when)

getSurfaceHandle

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

The surface handle should be set/update by NativeSurface.lockSurface(), where NativeSurface.unlockSurface() is not allowed to modify it. After NativeSurface.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 NativeSurface

getGraphicsConfiguration

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

Specified by:
getGraphicsConfiguration in interface NativeSurface
See Also:
javax.media.nativewindow.GraphicsConfigurationFactory#chooseGraphicsConfiguration(Capabilities, CapabilitiesChooser, AbstractGraphicsScreen)

getDisplayHandle

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

Specified by:
getDisplayHandle in interface NativeSurface

getScreenIndex

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

Specified by:
getScreenIndex in interface NativeSurface

setSize

public final void setSize(int width,
                          int height)

getWidth

public final int getWidth()
Description copied from interface: NativeSurface
Returns the current width of this surface.

Specified by:
getWidth in interface NativeSurface

getHeight

public final int getHeight()
Description copied from interface: NativeSurface
Returns the current height of this surface.

Specified by:
getHeight in interface NativeSurface

destroy

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

Specified by:
destroy in interface NativeWindow

getParent

public final NativeWindow getParent()
Specified by:
getParent in interface NativeWindow
Returns:
The parent NativeWindow, or null if this NativeWindow is top level.

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

getX

public final int getX()
Description copied from interface: NativeWindow
Returns the current x position of this window, relative to it's parent.

Specified by:
getX in interface NativeWindow

getY

public final int getY()
Description copied from interface: NativeWindow
Returns the current y position of this window, relative to it's parent.

Specified by:
getY in interface NativeWindow

getLocationOnScreen

public Point getLocationOnScreen(Point storage)
Description copied from interface: NativeWindow
Returns the current absolute location of this window.

Specified by:
getLocationOnScreen in interface NativeWindow
Parameters:
storage - if not null, Point.translate(javax.media.nativewindow.util.Point) the passed Point by this location on the screen and return it.
Returns:
either the passed non null translated point by the screen location of this NativeWindow, or a new instance with the screen location of this NativeWindow.

getLocationOnScreenImpl

protected abstract Point getLocationOnScreenImpl(int x,
                                                 int y)

toString

public String toString()
Overrides:
toString in class Object


Copyright 2010 JogAmp Community.