com.jogamp.newt.opengl
Class GLWindow

java.lang.Object
  extended by jogamp.opengl.GLAutoDrawableBase
      extended by com.jogamp.newt.opengl.GLWindow
All Implemented Interfaces:
NEWTEventConsumer, Window, GLStateKeeper, NativeSurface, NativeWindow, SurfaceUpdatedListener, WindowClosingProtocol, FPSCounter, GLAutoDrawable, GLDrawable

public class GLWindow
extends jogamp.opengl.GLAutoDrawableBase
implements GLAutoDrawable, Window, NEWTEventConsumer, FPSCounter

An implementation of GLAutoDrawable and Window interface, using a delegated Window instance, which may be an aggregation (lifecycle: created and destroyed).

This implementation supports GL state preservation, hence isGLStatePreservationSupported() returns true.

This implementation does not make the OpenGL context current
before calling the various input EventListener callbacks, ie MouseListener etc.
This design decision is made in favor of a more performant and simplified implementation. Also the event dispatcher shall be implemented OpenGL agnostic.
To be able to use OpenGL commands from within such input NEWTEventListener,
you can inject GLRunnable objects via GLAutoDrawableBase.invoke(boolean, javax.media.opengl.GLRunnable) to the OpenGL command stream.


Nested Class Summary
 
Nested classes/interfaces inherited from interface com.jogamp.newt.Window
Window.FocusRunnable, Window.ReparentOperation
 
Nested classes/interfaces inherited from interface javax.media.nativewindow.WindowClosingProtocol
WindowClosingProtocol.WindowClosingMode
 
Nested classes/interfaces inherited from interface com.jogamp.opengl.GLStateKeeper
GLStateKeeper.Listener
 
Field Summary
 
Fields inherited from class jogamp.opengl.GLAutoDrawableBase
DEBUG
 
Fields inherited from interface javax.media.opengl.GLAutoDrawable
SCREEN_CHANGE_ACTION_ENABLED
 
Fields inherited from interface com.jogamp.newt.Window
DEBUG_IMPLEMENTATION, DEBUG_KEY_EVENT, DEBUG_MOUSE_EVENT, TIMEOUT_NATIVEWINDOW
 
Fields inherited from interface javax.media.nativewindow.NativeSurface
LOCK_SUCCESS, LOCK_SURFACE_CHANGED, LOCK_SURFACE_NOT_READY, LOCK_SURFACE_UNLOCKED
 
Fields inherited from interface javax.media.opengl.FPSCounter
DEFAULT_FRAMES_PER_INTERVAL
 
Method Summary
 boolean addChild(NativeWindow win)
           
 void addKeyListener(int index, KeyListener l)
          Inserts the given KeyListener at the specified position in the list.
 void addKeyListener(KeyListener l)
          Appends the given KeyListener to the end of the list.
 void addMouseListener(int index, MouseListener l)
          Inserts the given MouseListener at the specified position in the list.
 void addMouseListener(MouseListener l)
          Appends the given MouseListener to the end of the list.
 void addSurfaceUpdatedListener(int index, SurfaceUpdatedListener l)
          Inserts the given SurfaceUpdatedListener at the specified position in the list.
 void addSurfaceUpdatedListener(SurfaceUpdatedListener l)
          Appends the given SurfaceUpdatedListener to the end of the list.
 void addWindowListener(int index, WindowListener l)
          Inserts the given WindowListener at the specified position in the list.
 void addWindowListener(WindowListener l)
          Appends the given WindowListener to the end of the list.
 void confinePointer(boolean grab)
          Confine the pointer to this window, ie.
 boolean consumeEvent(NEWTEvent event)
          Consume the event
static GLWindow create(GLCapabilitiesImmutable caps)
          Creates a new GLWindow attaching a new Window referencing a new default Screen and default Display with the given GLCapabilities.
static GLWindow create(NativeWindow parentNativeWindow, GLCapabilitiesImmutable caps)
          Creates a new GLWindow attaching a new child Window of the given parentNativeWindow with the given GLCapabilities.
static GLWindow create(Screen screen, GLCapabilitiesImmutable caps)
          Creates a new GLWindow attaching a new Window referencing the given Screen with the given GLCapabilities.
static GLWindow create(Window window)
          Creates a new GLWindow attaching the given window.
 void destroy()
          Destroys all resources associated with this GLAutoDrawable, inclusive the GLContext.
 void display()
           Causes OpenGL rendering to be performed for this GLAutoDrawable in the following order: Calling display(..) for all registered GLEventListeners.
 void enqueueEvent(boolean wait, NEWTEvent event)
           
 CapabilitiesImmutable getChosenCapabilities()
          Gets an immutable set of chosen capabilities.
 WindowClosingProtocol.WindowClosingMode getDefaultCloseOperation()
           
 Window getDelegatedWindow()
          If the implementation uses delegation, return the delegated Window instance, otherwise return this instance.
 long getDisplayHandle()
          Convenience: Get display handle from AbstractGraphicsConfiguration .
 GLDrawableFactory getFactory()
          Return the GLDrawableFactory being used to create this instance.
 AbstractGraphicsConfiguration getGraphicsConfiguration()
          Returns the graphics configuration corresponding to this window.
 int getHeight()
          Returns the current height of this GLDrawable.
 InsetsImmutable getInsets()
          Returns the insets defined as the width and height of the window decoration on the left, right, top and bottom.
Insets are zero if the window is undecorated, including child windows.
 KeyListener getKeyListener(int index)
           
 KeyListener[] getKeyListeners()
           
 Point getLocationOnScreen(Point storage)
          Returns the current position of the top-left corner of the client area in screen coordinates.
 MonitorDevice getMainMonitor()
          Returns the MonitorDevice which viewport covers this window the most.
 MouseListener getMouseListener(int index)
           
 MouseListener[] getMouseListeners()
           
 NativeWindow getParent()
           
 CapabilitiesImmutable getRequestedCapabilities()
          Gets an immutable set of requested capabilities.
 Screen getScreen()
           
 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.
 String getTitle()
           
 Object getUpstreamWidget()
          Method may return the upstream UI toolkit object holding this GLAutoDrawable instance, if exist.
 int getWidth()
          Returns the current width of this GLDrawable.
 long getWindowHandle()
          Returns the window handle for this NativeWindow.
 WindowListener getWindowListener(int index)
           
 WindowListener[] getWindowListeners()
           
 int getX()
           
 int getY()
           
 boolean hasFocus()
          Returns true if this native window owns the focus, otherwise false.
 boolean isAlwaysOnTop()
           
 boolean isFullscreen()
           
 boolean isGLStatePreservationSupported()
          
 boolean isKeyboardVisible()
          Return true if the virtual on-screen keyboard is visible, otherwise false.
 boolean isNativeValid()
           
 boolean isPointerConfined()
           
 boolean isPointerVisible()
           
 boolean isSurfaceLockedByOtherThread()
          Query if surface is locked by another thread, i.e.
 boolean isUndecorated()
           
 boolean isVisible()
           
 int lockSurface()
          Lock the surface of this native window.
static void main(String[] args)
          A most simple JOGL AWT test entry
 boolean removeChild(NativeWindow win)
           
 void removeKeyListener(KeyListener l)
           
 void removeMouseListener(MouseListener l)
           
 void removeSurfaceUpdatedListener(SurfaceUpdatedListener l)
          Remove the specified SurfaceUpdatedListener from the list.
 void removeWindowListener(WindowListener l)
           
 Window.ReparentOperation reparentWindow(NativeWindow newParent)
          Change this window's parent window.
 Window.ReparentOperation reparentWindow(NativeWindow newParent, boolean forceDestroyCreate)
           
 void requestFocus()
          Request focus for this native window
 void requestFocus(boolean wait)
          Request focus for this native window
 void runOnEDTIfAvail(boolean wait, Runnable task)
           
 void sendWindowEvent(int eventType)
          Send a WindowEvent to all WindowListener.
 void setAlwaysOnTop(boolean value)
           
 CapabilitiesChooser setCapabilitiesChooser(CapabilitiesChooser chooser)
          Set the CapabilitiesChooser to help determine the native visual type.
 WindowClosingProtocol.WindowClosingMode setDefaultCloseOperation(WindowClosingProtocol.WindowClosingMode op)
           
 void setFocusAction(Window.FocusRunnable focusAction)
          Sets a Window.FocusRunnable, which Window.FocusRunnable.run() method is executed before the native focus is requested.
 boolean setFullscreen(boolean fullscreen)
          Enable or disable fullscreen mode for this window.
 boolean setFullscreen(List<MonitorDevice> monitors)
          Enable fullscreen mode for this window spanning across the given MonitorDevices or across all MonitorDevices.
 void setKeyboardFocusHandler(KeyListener l)
          Sets a KeyListener allowing focus traversal with a covered window toolkit like AWT.
 void setKeyboardVisible(boolean visible)
          In case the platform supports or even requires a virtual on-screen keyboard, this method shows or hide it depending on whether visible is true or false.
 void setPointerVisible(boolean mouseVisible)
          Makes the pointer visible or invisible.
 void setPosition(int x, int y)
          Sets the location of the window's client area, excluding insets (window decorations).
This call is ignored if in fullscreen mode.
 void setSharedContext(GLContext sharedContext)
          Specifies an OpenGL context to share with.
At native creation, setVisible(true), a drawable and context is created besides the native Window itself,
hence you shall set the shared context before.
 void setSize(int width, int height)
          Sets the size of the window's client area, excluding decorations.
 void setTitle(String title)
           
 void setTopLevelPosition(int x, int y)
          Sets the location of the top-level window inclusive insets (window decorations).
 void setTopLevelSize(int width, int height)
          Sets the size of the top-level window including insets (window decorations).
 void setUndecorated(boolean value)
           
 void setVisible(boolean visible)
          setVisible makes the window and children visible if visible is true, otherwise the window and children becomes invisible.
 void setWindowDestroyNotifyAction(Runnable r)
          Set a custom action handling destruction issued by a toolkit triggered window destroy replacing the default Window.destroy() action.
 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, eg.
 void swapBuffers()
          Swaps the front and back buffers of this drawable.
 String toString()
           
 void unlockSurface()
          Unlock the surface of this native window Shall not modify the surface handle, see NativeSurface.lockSurface()
 void warpPointer(int x, int y)
          Moves the pointer to x/y relative to this window's origin.
 void windowRepaint(int x, int y, int width, int height)
           
 
Methods inherited from class jogamp.opengl.GLAutoDrawableBase
addGLEventListener, addGLEventListener, clearPreservedGLState, createContext, defaultSwapBuffers, disposeGLEventListener, getAnimator, getAutoSwapBufferMode, getChosenGLCapabilities, getContext, getContextCreationFlags, getDelegatedDrawable, getExclusiveContextThread, getFPSStartTime, getGL, getGLEventListener, getGLEventListenerCount, getGLEventListenerInitState, getGLProfile, getHandle, getLastFPS, getLastFPSPeriod, getLastFPSUpdateTime, getNativeSurface, getPreservedGLState, getTotalFPS, getTotalFPSDuration, getTotalFPSFrames, getUpdateFPSFrames, invoke, invoke, isGLOriented, isRealized, preserveGLStateAtDestroy, removeGLEventListener, resetFPSCounter, setAnimator, setAutoSwapBufferMode, setContext, setContextCreationFlags, setExclusiveContextThread, setGL, setGLEventListenerInitState, setGLStateKeeperListener, setRealized, setUpdateFPSFrames
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface javax.media.opengl.GLAutoDrawable
addGLEventListener, addGLEventListener, createContext, disposeGLEventListener, getAnimator, getAutoSwapBufferMode, getContext, getContextCreationFlags, getDelegatedDrawable, getExclusiveContextThread, getGL, getGLEventListener, getGLEventListenerCount, getGLEventListenerInitState, invoke, invoke, removeGLEventListener, setAnimator, setAutoSwapBufferMode, setContext, setContextCreationFlags, setExclusiveContextThread, setGL, setGLEventListenerInitState
 
Methods inherited from interface javax.media.opengl.GLDrawable
getChosenGLCapabilities, getGLProfile, getHandle, getNativeSurface, isGLOriented, isRealized, setRealized
 
Methods inherited from interface javax.media.opengl.FPSCounter
getFPSStartTime, getLastFPS, getLastFPSPeriod, getLastFPSUpdateTime, getTotalFPS, getTotalFPSDuration, getTotalFPSFrames, getUpdateFPSFrames, resetFPSCounter, setUpdateFPSFrames
 

Method Detail

getUpstreamWidget

public final Object getUpstreamWidget()
Description copied from interface: GLAutoDrawable
Method may return the upstream UI toolkit object holding this GLAutoDrawable instance, if exist.

Currently known Java UI toolkits and it's known return types are:

Toolkit GLAutoDrawable Implementation ~ Return Type of getUpstreamWidget()
NEWT GLWindow has a Window
SWT GLCanvas is a Canvas
AWT GLCanvas is a Canvas
AWT GLJPanel is a JPanel
However, the result may be other object types than the listed above due to new supported toolkits.

This method may also return null if no UI toolkit is being used, as common for offscreen rendering.

Specified by:
getUpstreamWidget in interface GLAutoDrawable
Returns:

create

public static GLWindow create(GLCapabilitiesImmutable caps)
Creates a new GLWindow attaching a new Window referencing a new default Screen and default Display with the given GLCapabilities.

The lifecycle of this Window's Screen and Display is handled via Screen.addReference() and Screen.removeReference().

The default Display will be reused if already instantiated.


create

public static GLWindow create(Screen screen,
                              GLCapabilitiesImmutable caps)
Creates a new GLWindow attaching a new Window referencing the given Screen with the given GLCapabilities.

The lifecycle of this Window's Screen and Display is handled via Screen.addReference() and Screen.removeReference().


create

public static GLWindow create(Window window)
Creates a new GLWindow attaching the given window.

The lifecycle of this Window's Screen and Display is handled via Screen.addReference() and Screen.removeReference().


create

public static GLWindow create(NativeWindow parentNativeWindow,
                              GLCapabilitiesImmutable caps)
Creates a new GLWindow attaching a new child Window of the given parentNativeWindow with the given GLCapabilities.

The Display/Screen will be compatible with the parentNativeWindow, or even identical in case it's a Newt Window. An already instantiated compatible Display will be reused.

The lifecycle of this Window's Screen and Display is handled via Screen.addReference() and Screen.removeReference().


getDefaultCloseOperation

public WindowClosingProtocol.WindowClosingMode getDefaultCloseOperation()
Specified by:
getDefaultCloseOperation in interface WindowClosingProtocol
Returns:
the current close operation value
See Also:
WindowClosingProtocol.WindowClosingMode.DISPOSE_ON_CLOSE, WindowClosingProtocol.WindowClosingMode.DO_NOTHING_ON_CLOSE

setDefaultCloseOperation

public WindowClosingProtocol.WindowClosingMode setDefaultCloseOperation(WindowClosingProtocol.WindowClosingMode op)
Specified by:
setDefaultCloseOperation in interface WindowClosingProtocol
Parameters:
op - the new close operation value
Returns:
the previous close operation value
See Also:
WindowClosingProtocol.WindowClosingMode.DISPOSE_ON_CLOSE, WindowClosingProtocol.WindowClosingMode.DO_NOTHING_ON_CLOSE

setCapabilitiesChooser

public CapabilitiesChooser setCapabilitiesChooser(CapabilitiesChooser chooser)
Description copied from interface: Window
Set the CapabilitiesChooser to help determine the native visual type.

Specified by:
setCapabilitiesChooser in interface Window
Parameters:
chooser - the new CapabilitiesChooser
Returns:
the previous CapabilitiesChooser

getChosenCapabilities

public final CapabilitiesImmutable getChosenCapabilities()
Description copied from interface: Window
Gets an immutable set of chosen capabilities.

Specified by:
getChosenCapabilities in interface Window
Returns:
the chosen capabilities

getRequestedCapabilities

public final CapabilitiesImmutable getRequestedCapabilities()
Description copied from interface: Window
Gets an immutable set of requested capabilities.

Specified by:
getRequestedCapabilities in interface Window
Returns:
the requested capabilities

getDelegatedWindow

public final Window getDelegatedWindow()
Description copied from interface: Window
If the implementation uses delegation, return the delegated Window instance, otherwise return this instance.

Specified by:
getDelegatedWindow in interface Window

getParent

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

getScreen

public final Screen getScreen()
Specified by:
getScreen in interface Window
Returns:
The associated Screen

getMainMonitor

public final MonitorDevice getMainMonitor()
Description copied from interface: Window
Returns the MonitorDevice which viewport covers this window the most.

If no coverage is detected the first MonitorDevice is returned.

Specified by:
getMainMonitor in interface Window

setTitle

public final void setTitle(String title)
Specified by:
setTitle in interface Window

getTitle

public final String getTitle()
Specified by:
getTitle in interface Window

isPointerVisible

public final boolean isPointerVisible()
Specified by:
isPointerVisible in interface Window
See Also:
Window.setPointerVisible(boolean)

setPointerVisible

public final void setPointerVisible(boolean mouseVisible)
Description copied from interface: Window
Makes the pointer visible or invisible.

Specified by:
setPointerVisible in interface Window
Parameters:
mouseVisible - defaults to true for platforms w/ visible pointer, otherwise defaults to true, eg. Android.
See Also:
Window.confinePointer(boolean)

isPointerConfined

public final boolean isPointerConfined()
Specified by:
isPointerConfined in interface Window
See Also:
Window.confinePointer(boolean)

confinePointer

public final void confinePointer(boolean grab)
Description copied from interface: Window
Confine the pointer to this window, ie. pointer jail.

Before jailing the mouse pointer, the window request the focus and the pointer is centered in the window.

In combination w/ Window.warpPointer(int, int) and maybe Window.setPointerVisible(boolean) a simple mouse navigation can be realized.

Specified by:
confinePointer in interface Window
Parameters:
grab - defaults to false.

setUndecorated

public final void setUndecorated(boolean value)
Specified by:
setUndecorated in interface Window

warpPointer

public final void warpPointer(int x,
                              int y)
Description copied from interface: Window
Moves the pointer to x/y relative to this window's origin.

Specified by:
warpPointer in interface Window
Parameters:
x - relative pointer x position within this window
y - relative pointer y position within this window
See Also:
Window.confinePointer(boolean)

isUndecorated

public final boolean isUndecorated()
Specified by:
isUndecorated in interface Window

setAlwaysOnTop

public final void setAlwaysOnTop(boolean value)
Specified by:
setAlwaysOnTop in interface Window

isAlwaysOnTop

public final boolean isAlwaysOnTop()
Specified by:
isAlwaysOnTop in interface Window

setFocusAction

public final void setFocusAction(Window.FocusRunnable focusAction)
Description copied from interface: Window
Sets a Window.FocusRunnable, which Window.FocusRunnable.run() method is executed before the native focus is requested.

This allows notifying a covered window toolkit like AWT that the focus is requested, hence focus traversal can be made transparent.

Specified by:
setFocusAction in interface Window

setKeyboardFocusHandler

public void setKeyboardFocusHandler(KeyListener l)
Description copied from interface: Window
Sets a KeyListener allowing focus traversal with a covered window toolkit like AWT.

The KeyListener methods are invoked prior to all other KeyListener's allowing to suppress the KeyEvent via the NEWTEvent.consumedTag and to perform focus traversal with a 3rd party toolkit.

The KeyListener methods are not invoked for auto-repeat events.

Specified by:
setKeyboardFocusHandler in interface Window

requestFocus

public final void requestFocus()
Description copied from interface: Window
Request focus for this native window

The request is handled on this Window EDT and blocked until finished.

Specified by:
requestFocus in interface Window
See Also:
Window.requestFocus(boolean)

requestFocus

public final void requestFocus(boolean wait)
Description copied from interface: Window
Request focus for this native window

The request is handled on this Window EDT.

Specified by:
requestFocus in interface Window
Parameters:
wait - true if waiting until the request is executed, otherwise false
See Also:
Window.requestFocus()

hasFocus

public boolean hasFocus()
Description copied from interface: NativeWindow
Returns true if this native window owns the focus, otherwise false.

Specified by:
hasFocus in interface NativeWindow

getInsets

public final InsetsImmutable getInsets()
Description copied from interface: NativeWindow
Returns the insets defined as the width and height of the window decoration on the left, right, top and bottom.
Insets are zero if the window is undecorated, including child windows.

Insets are available only after the native window has been created, ie. the native window has been made visible.
The top-level window area's top-left corner is located at

   getX() - getInsets().getLeftWidth()
   getY() - getInsets().getTopHeight()
 
The top-level window size is
   getWidth()  + getInsets().getTotalWidth()
   getHeight() + getInsets().getTotalHeight()
 

Specified by:
getInsets in interface NativeWindow
Returns:
insets

getX

public final int getX()
Specified by:
getX in interface NativeWindow
Returns:
the current x position of the top-left corner of the client area relative to it's parent. Since the position reflects the client area, it does not include the insets.
See Also:
NativeWindow.getInsets()

getY

public final int getY()
Specified by:
getY in interface NativeWindow
Returns:
the current y position of the top-left corner of the client area relative to it's parent. Since the position reflects the client area, it does not include the insets.
See Also:
NativeWindow.getInsets()

getWidth

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

Specified by:
getWidth in interface NativeSurface
Specified by:
getWidth in interface GLDrawable
Overrides:
getWidth in class jogamp.opengl.GLAutoDrawableBase
Returns:
width of the client area

getHeight

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

Specified by:
getHeight in interface NativeSurface
Specified by:
getHeight in interface GLDrawable
Overrides:
getHeight in class jogamp.opengl.GLAutoDrawableBase
Returns:
height of the client area

setPosition

public final void setPosition(int x,
                              int y)
Description copied from interface: Window
Sets the location of the window's client area, excluding insets (window decorations).
This call is ignored if in fullscreen mode.

Specified by:
setPosition in interface Window
Parameters:
x - coord of the client-area's top left corner
y - coord of the client-area's top left corner
See Also:
NativeWindow.getInsets()

setTopLevelPosition

public void setTopLevelPosition(int x,
                                int y)
Description copied from interface: Window
Sets the location of the top-level window inclusive insets (window decorations).

Note: Insets (if supported) are available only after the window is set visible and hence has been created.

This call is ignored if in fullscreen mode.

Specified by:
setTopLevelPosition in interface Window
Parameters:
x - coord of the top-level left corner
y - coord of the top-level left corner
See Also:
Window.setPosition(int, int), NativeWindow.getInsets()

setFullscreen

public final boolean setFullscreen(boolean fullscreen)
Description copied from interface: Window
Enable or disable fullscreen mode for this window.

Fullscreen mode is established on the main monitor.

Specified by:
setFullscreen in interface Window
Parameters:
fullscreen - enable or disable fullscreen mode
Returns:
success
See Also:
Window.setFullscreen(List), Window.isFullscreen()

setFullscreen

public boolean setFullscreen(List<MonitorDevice> monitors)
Description copied from interface: Window
Enable fullscreen mode for this window spanning across the given MonitorDevices or across all MonitorDevices.

Disable fullscreen via Window.setFullscreen(boolean).

Specified by:
setFullscreen in interface Window
Parameters:
monitors - if null fullscreen will be spanned across all MonitorDevices, otherwise across the given list of MonitorDevice.
Returns:
success
See Also:
Window.setFullscreen(boolean), Window.isFullscreen()

isFullscreen

public final boolean isFullscreen()
Specified by:
isFullscreen in interface Window

isVisible

public final boolean isVisible()
Specified by:
isVisible in interface Window

toString

public final String toString()
Specified by:
toString in interface GLDrawable
Overrides:
toString in class jogamp.opengl.GLAutoDrawableBase

reparentWindow

public final Window.ReparentOperation reparentWindow(NativeWindow newParent)
Description copied from interface: Window
Change this window's parent window.

In case the old parent is not null and a Window, this window is removed from it's list of children.
In case the new parent is not null and a Window, this window is added to it's list of children.

Specified by:
reparentWindow in interface Window
Parameters:
newParent - The new parent NativeWindow. If null, this Window becomes a top level window.
Returns:
The issued reparent action type (strategy) as defined in Window.ReparentAction

reparentWindow

public final Window.ReparentOperation reparentWindow(NativeWindow newParent,
                                                     boolean forceDestroyCreate)
Specified by:
reparentWindow in interface Window

removeChild

public final boolean removeChild(NativeWindow win)
Specified by:
removeChild in interface Window

addChild

public final boolean addChild(NativeWindow win)
Specified by:
addChild in interface Window

destroy

public final void destroy()
Description copied from interface: GLAutoDrawable
Destroys all resources associated with this GLAutoDrawable, inclusive the GLContext. If a window is attached to it's implementation, it shall be closed. Causes disposing of all OpenGL resources by calling dispose(..) for all registered GLEventListeners. Called automatically by the window system toolkit upon receiving a destroy notification. This routine may be called manually.

Specified by:
destroy in interface Window
Specified by:
destroy in interface NativeWindow
Specified by:
destroy in interface GLAutoDrawable
See Also:
Window.destroy(), Window.setVisible(boolean)

setWindowDestroyNotifyAction

public void setWindowDestroyNotifyAction(Runnable r)
Description copied from interface: Window
Set a custom action handling destruction issued by a toolkit triggered window destroy replacing the default Window.destroy() action.

The custom action shall call Window.destroy() but may perform further tasks before and after.

Specified by:
setWindowDestroyNotifyAction in interface Window

setVisible

public final void setVisible(boolean visible)
Description copied from interface: Window
setVisible makes the window and children visible if visible is true, otherwise the window and children becomes invisible.

The setVisible(true) is responsible to actual create the native window.

Zero size semantics are respected, see Window.setSize(int,int):

 if ( 0 == windowHandle && visible ) {
   this.visible = visible;
   if( 0 < width && 0 < height ) {
     createNative();
   }
 } else if ( this.visible != visible ) {
   this.visible = visible;
   setNativeSizeImpl();
 }
 

In case this window is a child window and has a NativeWindow parent,
setVisible(true) has no effect as long the parent's is not valid yet, i.e. NativeWindow.getWindowHandle() returns null.
setVisible(true) shall be repeated when the parent becomes valid.

Specified by:
setVisible in interface Window

setSize

public final void setSize(int width,
                          int height)
Description copied from interface: Window
Sets the size of the window's client area, excluding decorations.

Zero size semantics are respected, see Window.setVisible(boolean):

 if ( visible && 0 != windowHandle && ( 0 ≥ width || 0 ≥ height ) ) {
   setVisible(false);
 } else if ( visible && 0 == windowHandle && 0 < width && 0 < height ) {
   setVisible(true);
 } else {
   // as expected ..
 }
 

This call is ignored if in fullscreen mode.

Specified by:
setSize in interface Window
Parameters:
width - of the window's client area
height - of the window's client area
See Also:
NativeWindow.getInsets()

setTopLevelSize

public void setTopLevelSize(int width,
                            int height)
Description copied from interface: Window
Sets the size of the top-level window including insets (window decorations).

Note: Insets (if supported) are available only after the window is set visible and hence has been created.

Specified by:
setTopLevelSize in interface Window
Parameters:
width - of the top-level window area
height - of the top-level window area
See Also:
Window.setSize(int, int), NativeWindow.getInsets()

isNativeValid

public final boolean isNativeValid()
Specified by:
isNativeValid in interface Window
Returns:
true if the native window handle is valid and ready to operate, ie if the native window has been created via setVisible(true), otherwise false.
See Also:
Window.setVisible(boolean), #destroy(boolean)

getLocationOnScreen

public Point getLocationOnScreen(Point storage)
Description copied from interface: NativeWindow
Returns the current position of the top-left corner of the client area in screen coordinates.

Since the position reflects the client area, it does not include the insets.

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.

setSharedContext

public void setSharedContext(GLContext sharedContext)
Specifies an OpenGL context to share with.
At native creation, setVisible(true), a drawable and context is created besides the native Window itself,
hence you shall set the shared context before.

Parameters:
sharedContext - The OpenGL context shared by this GLWindow's one

display

public void display()
Description copied from interface: GLAutoDrawable

Causes OpenGL rendering to be performed for this GLAutoDrawable in the following order:

May be called periodically by a running GLAnimatorControl implementation,
which must register itself with GLAutoDrawable.setAnimator(javax.media.opengl.GLAnimatorControl).

Called automatically by the window system toolkit upon receiving a repaint() request,
except an GLAnimatorControl implementation GLAnimatorControl.isAnimating().

This routine may also be called manually for better control over the rendering process. It is legal to call another GLAutoDrawable's display method from within the display(..) callback.

In case of a new generated OpenGL context, the implementation shall call init(..) for all registered GLEventListeners before making the actual display(..) calls, in case this has not been done yet.

Specified by:
display in interface GLAutoDrawable
See Also:
GLAutoDrawable.setAnimator(javax.media.opengl.GLAnimatorControl)

isGLStatePreservationSupported

public final boolean isGLStatePreservationSupported()

GLWindow supports GL state preservation, hence returns true.

Specified by:
isGLStatePreservationSupported in interface GLStateKeeper
Overrides:
isGLStatePreservationSupported in class jogamp.opengl.GLAutoDrawableBase
Returns:
true if GL state preservation is supported in implementation and on current platform, false otherwise.
See Also:
GLStateKeeper.preserveGLStateAtDestroy(boolean), GLStateKeeper.getPreservedGLState(), GLStateKeeper.clearPreservedGLState()

getFactory

public final GLDrawableFactory getFactory()
Description copied from interface: GLDrawable
Return the GLDrawableFactory being used to create this instance.

Specified by:
getFactory in interface GLDrawable

swapBuffers

public final void swapBuffers()
                       throws GLException
Description copied from interface: GLDrawable
Swaps the front and back buffers of this drawable. For GLAutoDrawable implementations, when automatic buffer swapping is enabled (as is the default), this method is called automatically and should not be called by the end user.

Specified by:
swapBuffers in interface GLDrawable
Throws:
GLException

consumeEvent

public boolean consumeEvent(NEWTEvent event)
Description copied from interface: NEWTEventConsumer
Consume the event

Specified by:
consumeEvent in interface NEWTEventConsumer
Returns:
true if the event has been consumed, otherwise it returns false for later propagation.

windowRepaint

public final void windowRepaint(int x,
                                int y,
                                int width,
                                int height)
Specified by:
windowRepaint in interface Window

enqueueEvent

public final void enqueueEvent(boolean wait,
                               NEWTEvent event)
Specified by:
enqueueEvent in interface Window

runOnEDTIfAvail

public final void runOnEDTIfAvail(boolean wait,
                                  Runnable task)
Specified by:
runOnEDTIfAvail in interface Window

removeSurfaceUpdatedListener

public final void removeSurfaceUpdatedListener(SurfaceUpdatedListener l)
Description copied from interface: NativeSurface
Remove the specified SurfaceUpdatedListener from the list.

Specified by:
removeSurfaceUpdatedListener in interface NativeSurface

addSurfaceUpdatedListener

public final void addSurfaceUpdatedListener(SurfaceUpdatedListener l)
Description copied from interface: NativeSurface
Appends the given SurfaceUpdatedListener to the end of the list.

Specified by:
addSurfaceUpdatedListener in interface NativeSurface

addSurfaceUpdatedListener

public final void addSurfaceUpdatedListener(int index,
                                            SurfaceUpdatedListener l)
                                     throws IndexOutOfBoundsException
Description copied from interface: NativeSurface
Inserts the given SurfaceUpdatedListener at the specified position in the list.

Specified by:
addSurfaceUpdatedListener in interface NativeSurface
Parameters:
index - Position where the listener will be inserted. Should be within (0 <= index && index <= size()). An index value of -1 is interpreted as the end of the list, size().
l - The listener object to be inserted
Throws:
IndexOutOfBoundsException - If the index is not within (0 <= index && index <= size()), or -1

sendWindowEvent

public void sendWindowEvent(int eventType)
Description copied from interface: Window
Send a WindowEvent to all WindowListener.

Specified by:
sendWindowEvent in interface Window
Parameters:
eventType - a WindowEvent type, e.g. WindowEvent.EVENT_WINDOW_REPAINT.

getWindowListener

public final WindowListener getWindowListener(int index)
Specified by:
getWindowListener in interface Window

getWindowListeners

public final WindowListener[] getWindowListeners()
Specified by:
getWindowListeners in interface Window

removeWindowListener

public final void removeWindowListener(WindowListener l)
Specified by:
removeWindowListener in interface Window

addWindowListener

public final void addWindowListener(WindowListener l)
Description copied from interface: Window
Appends the given WindowListener to the end of the list.

Specified by:
addWindowListener in interface Window

addWindowListener

public final void addWindowListener(int index,
                                    WindowListener l)
                             throws IndexOutOfBoundsException
Description copied from interface: Window
Inserts the given WindowListener at the specified position in the list.

Specified by:
addWindowListener in interface Window
Parameters:
index - Position where the listener will be inserted. Should be within (0 <= index && index <= size()). An index value of -1 is interpreted as the end of the list, size().
l - The listener object to be inserted
Throws:
IndexOutOfBoundsException - If the index is not within (0 <= index && index <= size()), or -1

setKeyboardVisible

public final void setKeyboardVisible(boolean visible)
Description copied from interface: Window
In case the platform supports or even requires a virtual on-screen keyboard, this method shows or hide it depending on whether visible is true or false.

One known platform where NEWT supports this feature is Android.

Specified by:
setKeyboardVisible in interface Window

isKeyboardVisible

public final boolean isKeyboardVisible()
Description copied from interface: Window
Return true if the virtual on-screen keyboard is visible, otherwise false.

Currently on Android, the only supported platform right now, there is no way to reliably be notified of the current keyboard state.
It would be best, if your code does not rely on this information.

Specified by:
isKeyboardVisible in interface Window
See Also:
Window.setKeyboardVisible(boolean)

addKeyListener

public final void addKeyListener(KeyListener l)
Description copied from interface: Window
Appends the given KeyListener to the end of the list.

Specified by:
addKeyListener in interface Window

addKeyListener

public final void addKeyListener(int index,
                                 KeyListener l)
Description copied from interface: Window
Inserts the given KeyListener at the specified position in the list.

Specified by:
addKeyListener in interface Window
Parameters:
index - Position where the listener will be inserted. Should be within (0 <= index && index <= size()). An index value of -1 is interpreted as the end of the list, size().
l - The listener object to be inserted

removeKeyListener

public final void removeKeyListener(KeyListener l)
Specified by:
removeKeyListener in interface Window

getKeyListener

public final KeyListener getKeyListener(int index)
Specified by:
getKeyListener in interface Window

getKeyListeners

public final KeyListener[] getKeyListeners()
Specified by:
getKeyListeners in interface Window

addMouseListener

public final void addMouseListener(MouseListener l)
Description copied from interface: Window
Appends the given MouseListener to the end of the list.

Specified by:
addMouseListener in interface Window

addMouseListener

public final void addMouseListener(int index,
                                   MouseListener l)
Description copied from interface: Window
Inserts the given MouseListener at the specified position in the list.

Specified by:
addMouseListener in interface Window
Parameters:
index - Position where the listener will be inserted. Should be within (0 <= index && index <= size()). An index value of -1 is interpreted as the end of the list, size().
l - The listener object to be inserted

removeMouseListener

public final void removeMouseListener(MouseListener l)
Specified by:
removeMouseListener in interface Window

getMouseListener

public final MouseListener getMouseListener(int index)
Specified by:
getMouseListener in interface Window

getMouseListeners

public final MouseListener[] getMouseListeners()
Specified by:
getMouseListeners in interface Window

lockSurface

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

The surface handle shall be valid after a successfull call, ie return a value other than NativeSurface.LOCK_SURFACE_UNLOCKED and NativeSurface.LOCK_SURFACE_NOT_READY, which is

 
    boolean ok = LOCK_SURFACE_NOT_READY < lockSurface(); 
 

The caller may need to take care of the result NativeSurface.LOCK_SURFACE_CHANGED, where the surface handle is valid but has changed.

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 - if native locking failed, maybe platform related
RuntimeException - after timeout when waiting for the surface lock
See Also:
RecursiveLock

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).

The implementation shall be fail safe, i.e. tolerant in case the native resources are already released / unlocked. In this case the implementation shall simply ignore the call.

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

isSurfaceLockedByOtherThread

public final boolean isSurfaceLockedByOtherThread()
Description copied from interface: NativeSurface
Query if surface is locked by another thread, i.e. not the current one.
Convenient shortcut for:
   final Thread o = getSurfaceLockOwner();
   if( null != o && Thread.currentThread() != o ) { .. }
 

Specified by:
isSurfaceLockedByOtherThread 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 if double buffering is enabled.

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.

getWindowHandle

public final 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 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.

In case the implementation utilizes a delegation pattern to wrap abstract toolkits, this method shall return the native AbstractGraphicsConfiguration via AbstractGraphicsConfiguration.getNativeGraphicsConfiguration().

Specified by:
getGraphicsConfiguration in interface NativeSurface
See Also:
AbstractGraphicsConfiguration.getNativeGraphicsConfiguration(), 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

surfaceUpdated

public final void surfaceUpdated(Object updater,
                                 NativeSurface ns,
                                 long when)
Description copied from interface: SurfaceUpdatedListener
Notification of a surface update event, eg. after a swap buffer operation.

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

main

public static void main(String[] args)
A most simple JOGL AWT test entry



Copyright 2010 JogAmp Community.