public class GLWindow extends jogamp.opengl.GLAutoDrawableBase implements GLAutoDrawable, Window, NEWTEventConsumer, FPSCounter
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, GLRunnable) to the OpenGL command stream.
Window.FocusRunnable, Window.ReparentOperationWindowClosingProtocol.WindowClosingModeGLStateKeeper.ListenerSCREEN_CHANGE_ACTION_ENABLEDDEBUG_IMPLEMENTATION, DEBUG_KEY_EVENT, DEBUG_MOUSE_EVENT, REPARENT_HINT_BECOMES_VISIBLE, REPARENT_HINT_FORCE_RECREATION, TIMEOUT_NATIVEWINDOWLOCK_SUCCESS, LOCK_SURFACE_CHANGED, LOCK_SURFACE_NOT_READY, LOCK_SURFACE_UNLOCKEDDEFAULT_FRAMES_PER_INTERVAL| Modifier and Type | Method and Description |
|---|---|
boolean |
addChild(NativeWindow win) |
void |
addGestureHandler(GestureHandler gh)
Appends the given
GestureHandler to the end of the list. |
void |
addGestureHandler(int index,
GestureHandler gh)
Inserts the given
GestureHandler at the
specified position in the list. |
void |
addGestureListener(GestureHandler.GestureListener gl)
Appends the given
GestureHandler.GestureListener to the end of the list. |
void |
addGestureListener(int index,
GestureHandler.GestureListener gl)
Inserts the given
GestureHandler.GestureListener at the
specified position in the list. |
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. |
boolean |
areDefaultGesturesEnabled()
Return true if default
GestureHandler are enabled. |
void |
confinePointer(boolean grab)
Confine the pointer to this window, ie.
|
boolean |
consumeEvent(NEWTEvent event)
Consume the event
|
int[] |
convertToPixelUnits(int[] windowUnitsAndResult)
Converts the given window units into pixel units in place.
|
Rectangle |
convertToPixelUnits(Rectangle windowUnitsAndResult)
Converts the given window units into pixel units in place.
|
int[] |
convertToWindowUnits(int[] pixelUnitsAndResult)
Converts the given pixel units into window units in place.
|
Rectangle |
convertToWindowUnits(Rectangle pixelUnitsAndResult)
Converts the given pixel units into window units in place.
|
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) |
Rectangle |
getBounds()
Returns a newly created
Rectangle containing window origin, NativeWindow.getX() & NativeWindow.getY(),
and size, NativeWindow.getWidth() & NativeWindow.getHeight(), in window units. |
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 height of the client area excluding insets (window decorations) in window units.
|
InsetsImmutable |
getInsets()
Returns the insets defined as the width and height of the window decoration
on the left, right, top and bottom in window units.
|
KeyListener |
getKeyListener(int index) |
KeyListener[] |
getKeyListeners() |
Point |
getLocationOnScreen(Point storage)
Returns the window's top-left client-area position in the screen.
|
MonitorDevice |
getMainMonitor()
|
MouseListener |
getMouseListener(int index)
Returns the
MouseListener from the list at the given index. |
MouseListener[] |
getMouseListeners()
Returns all
MouseListener |
NativeWindow |
getParent() |
Display.PointerIcon |
getPointerIcon()
Returns the current
Display.PointerIcon, which maybe null for the default. |
CapabilitiesImmutable |
getRequestedCapabilities()
Gets an immutable set of requested capabilities.
|
Screen |
getScreen() |
int |
getScreenIndex()
Convenience: Get display handle from
AbstractGraphicsConfiguration .
|
Rectangle |
getSurfaceBounds()
Returns a newly created
Rectangle containing the scaled window origin, NativeWindow.getX() & NativeWindow.getY(),
and size, NativeSurface.getSurfaceWidth() & NativeSurface.getSurfaceHeight(), in pixel units. |
long |
getSurfaceHandle()
Returns the handle to the surface for this NativeSurface.
|
int |
getSurfaceHeight()
Returns the height of this
GLDrawable's surface client area in pixel units. |
Thread |
getSurfaceLockOwner()
Return the locking owner's Thread, or null if not locked.
|
int |
getSurfaceWidth()
Returns the width of this
GLDrawable's surface client area in pixel units. |
String |
getTitle() |
Object |
getUpstreamWidget()
Method may return the upstream UI toolkit object
holding this
GLAutoDrawable instance, if exist. |
int |
getWidth()
Returns the width of the client area excluding insets (window decorations) in window units.
|
long |
getWindowHandle()
Returns the window handle for this NativeWindow.
|
WindowListener |
getWindowListener(int index) |
WindowListener[] |
getWindowListeners() |
int |
getX()
Returns the x position of the top-left corner
of the client area relative to it's parent in window units.
|
int |
getY()
Returns the current y position of the top-left corner
of the client area relative to it's parent in window units.
|
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 |
removeGestureHandler(GestureHandler gh)
Removes the given
GestureHandler from the list. |
void |
removeGestureListener(GestureHandler.GestureListener gl)
Removes the given
GestureHandler.GestureListener from the list. |
void |
removeKeyListener(KeyListener l) |
void |
removeMouseListener(MouseListener l)
Removes the given
MouseListener from the list. |
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,
int x,
int y,
boolean forceDestroyCreate)
Change this window's parent window.
|
Window.ReparentOperation |
reparentWindow(NativeWindow newParent,
int x,
int y,
int hints)
Change this window's parent window.
|
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 |
setDefaultGesturesEnabled(boolean enable)
Enable or disable default
GestureHandler. |
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 |
setPointerIcon(Display.PointerIcon pi) |
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) in window units.
This call is ignored if in fullscreen mode. |
void |
setSize(int width,
int height)
Sets the size of the window's client area in window units, excluding decorations.
|
void |
setSurfaceSize(int pixelWidth,
int pixelHeight)
Sets the size of the window's surface in pixel units which claims 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) in window units.
|
void |
setTopLevelSize(int width,
int height)
Sets the size of the top-level window including insets (window decorations) in window units.
|
void |
setUndecorated(boolean value) |
void |
setVisible(boolean visible)
Calls
setVisible(true, visible),
i.e. |
void |
setVisible(boolean wait,
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 in pixel units.
|
void |
windowRepaint(int x,
int y,
int width,
int height)
Trigger window repaint while passing the dirty region in pixel units.
|
addGLEventListener, addGLEventListener, areAllGLEventListenerInitialized, 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, setSharedAutoDrawable, setSharedContext, setUpdateFPSFramesequals, getClass, hashCode, notify, notifyAll, wait, wait, waitaddGLEventListener, addGLEventListener, createContext, disposeGLEventListener, getAnimator, getAutoSwapBufferMode, getContext, getContextCreationFlags, getDelegatedDrawable, getExclusiveContextThread, getGL, getGLEventListener, getGLEventListenerCount, getGLEventListenerInitState, invoke, invoke, removeGLEventListener, setAnimator, setAutoSwapBufferMode, setContext, setContextCreationFlags, setExclusiveContextThread, setGL, setGLEventListenerInitStategetChosenGLCapabilities, getGLProfile, getHandle, getNativeSurface, isGLOriented, isRealized, setRealizedgetFPSStartTime, getLastFPS, getLastFPSPeriod, getLastFPSUpdateTime, getTotalFPS, getTotalFPSDuration, getTotalFPSFrames, getUpdateFPSFrames, resetFPSCounter, setUpdateFPSFramespublic final Object getUpstreamWidget()
GLAutoDrawableGLAutoDrawable 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 |
This method may also return null if no UI toolkit is being used,
as common for offscreen rendering.
getUpstreamWidget in interface GLAutoDrawablepublic static GLWindow create(GLCapabilitiesImmutable caps)
The lifecycle of this Window's Screen and Display is handled via Screen.addReference()
and Screen.removeReference().
public static GLWindow create(Screen screen, GLCapabilitiesImmutable caps)
The lifecycle of this Window's Screen and Display is handled via Screen.addReference()
and Screen.removeReference().
public static GLWindow create(Window window)
The lifecycle of this Window's Screen and Display is handled via Screen.addReference()
and Screen.removeReference().
public static GLWindow create(NativeWindow parentNativeWindow, GLCapabilitiesImmutable caps)
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().
public WindowClosingProtocol.WindowClosingMode getDefaultCloseOperation()
getDefaultCloseOperation in interface WindowClosingProtocolWindowClosingProtocol.WindowClosingMode.DISPOSE_ON_CLOSE,
WindowClosingProtocol.WindowClosingMode.DO_NOTHING_ON_CLOSEpublic WindowClosingProtocol.WindowClosingMode setDefaultCloseOperation(WindowClosingProtocol.WindowClosingMode op)
setDefaultCloseOperation in interface WindowClosingProtocolop - the new close operation valueWindowClosingProtocol.WindowClosingMode.DISPOSE_ON_CLOSE,
WindowClosingProtocol.WindowClosingMode.DO_NOTHING_ON_CLOSEpublic CapabilitiesChooser setCapabilitiesChooser(CapabilitiesChooser chooser)
WindowsetCapabilitiesChooser in interface Windowchooser - the new CapabilitiesChooserpublic final CapabilitiesImmutable getChosenCapabilities()
WindowgetChosenCapabilities in interface Windowpublic final CapabilitiesImmutable getRequestedCapabilities()
WindowgetRequestedCapabilities in interface Windowpublic final Window getDelegatedWindow()
WindowWindow instance,
otherwise return this instance.getDelegatedWindow in interface Windowpublic final NativeWindow getParent()
getParent in interface NativeWindowpublic final Screen getScreen()
public final MonitorDevice getMainMonitor()
WindowMonitorDevice with the highest viewport
coverage of this window.
If no coverage is detected the first MonitorDevice is returned.
getMainMonitor in interface Windowpublic final boolean isPointerVisible()
isPointerVisible in interface WindowWindow.setPointerVisible(boolean)public final void setPointerVisible(boolean mouseVisible)
WindowsetPointerVisible in interface WindowmouseVisible - defaults to true for platforms w/ visible pointer,
otherwise defaults to true, eg. Android.Window.confinePointer(boolean)public final Display.PointerIcon getPointerIcon()
WindowDisplay.PointerIcon, which maybe null for the default.getPointerIcon in interface Window#setPointerIcon(PointerIcon)public final void setPointerIcon(Display.PointerIcon pi)
setPointerIcon in interface Windowpi - Valid Display.PointerIcon reference or null to reset the pointer icon to default.Display.PointerIcon,
Display.createPointerIcon(com.jogamp.common.util.IOUtil.ClassResources, int, int)public final boolean isPointerConfined()
isPointerConfined in interface WindowWindow.confinePointer(boolean)public final void confinePointer(boolean grab)
WindowBefore 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.
confinePointer in interface Windowgrab - defaults to false.public final void setUndecorated(boolean value)
setUndecorated in interface Windowpublic final void warpPointer(int x,
int y)
WindowwarpPointer in interface Windowx - relative pointer x position within this window in pixel unitsy - relative pointer y position within this window in pixel unitsWindow.confinePointer(boolean)public final boolean isUndecorated()
isUndecorated in interface Windowpublic final void setAlwaysOnTop(boolean value)
setAlwaysOnTop in interface Windowpublic final boolean isAlwaysOnTop()
isAlwaysOnTop in interface Windowpublic final void setFocusAction(Window.FocusRunnable focusAction)
WindowWindow.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.
setFocusAction in interface Windowpublic void setKeyboardFocusHandler(KeyListener l)
WindowKeyListener 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.
setKeyboardFocusHandler in interface Windowpublic final void requestFocus()
WindowThe request is handled on this Window EDT and blocked until finished.
requestFocus in interface WindowWindow.requestFocus(boolean)public final void requestFocus(boolean wait)
WindowThe request is handled on this Window EDT.
requestFocus in interface Windowwait - true if waiting until the request is executed, otherwise falseWindow.requestFocus()public boolean hasFocus()
NativeWindowhasFocus in interface NativeWindowpublic final InsetsImmutable getInsets()
NativeWindowInsets 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
The top-level window size isNativeWindow.getX()- getInsets().getLeftWidth()NativeWindow.getY()- getInsets().getTopHeight()
NativeWindow.getWidth()+ getInsets().getTotalWidth()NativeWindow.getHeight()+ getInsets().getTotalHeight()
getInsets in interface NativeWindowpublic final int getX()
NativeWindowIf no parent exist (top-level window), this coordinate equals the screen coordinate.
Since the position reflects the client area, it does not include the insets.
See Coordinate System.
getX in interface NativeWindowNativeWindow.getInsets(),
NativeWindow.getLocationOnScreen(Point)public final int getY()
NativeWindowIf no parent exist (top-level window), this coordinate equals the screen coordinate.
Since the position reflects the client area, it does not include the insets.
See Coordinate System.
getY in interface NativeWindowNativeWindow.getInsets(),
NativeWindow.getLocationOnScreen(Point)public final int getWidth()
NativeWindowgetWidth in interface NativeWindowNativeSurface.getSurfaceWidth()public final int getHeight()
NativeWindowgetHeight in interface NativeWindowNativeSurface.getSurfaceHeight()public final Rectangle getBounds()
WindowRectangle containing window origin, NativeWindow.getX() & NativeWindow.getY(),
and size, NativeWindow.getWidth() & NativeWindow.getHeight(), in window units.public final int getSurfaceWidth()
GLDrawableGLDrawable's surface client area in pixel units.getSurfaceWidth in interface NativeSurfacegetSurfaceWidth in interface GLDrawablegetSurfaceWidth in class jogamp.opengl.GLAutoDrawableBaseNativeSurface.getSurfaceWidth()public final int getSurfaceHeight()
GLDrawableGLDrawable's surface client area in pixel units.getSurfaceHeight in interface NativeSurfacegetSurfaceHeight in interface GLDrawablegetSurfaceHeight in class jogamp.opengl.GLAutoDrawableBaseNativeSurface.getSurfaceHeight()public final Rectangle getSurfaceBounds()
WindowRectangle containing the scaled window origin, NativeWindow.getX() & NativeWindow.getY(),
and size, NativeSurface.getSurfaceWidth() & NativeSurface.getSurfaceHeight(), in pixel units.getSurfaceBounds in interface Windowpublic final int[] convertToWindowUnits(int[] pixelUnitsAndResult)
NativeSurfaceconvertToWindowUnits in interface NativeSurfacepixelUnitsAndResult - int[2] storage holding the pixel units for the x- and y-coord to convert
and the resulting values.public final int[] convertToPixelUnits(int[] windowUnitsAndResult)
NativeSurfaceconvertToPixelUnits in interface NativeSurfacewindowUnitsAndResult - int[2] storage holding the window units for the x- and y-coord to convert
and the resulting values.public final Rectangle convertToWindowUnits(Rectangle pixelUnitsAndResult)
WindowconvertToWindowUnits in interface WindowpixelUnitsAndResult - rectangle storage holding the pixel units to convert
and the resulting conversion.public final Rectangle convertToPixelUnits(Rectangle windowUnitsAndResult)
WindowconvertToPixelUnits in interface WindowwindowUnitsAndResult - rectangle storage holding the window units to convert
and the resulting conversion.public final void setPosition(int x,
int y)
WindowsetPosition in interface Windowx - coord of the client-area's top left corner in window unitsy - coord of the client-area's top left corner in window unitsNativeWindow.getInsets()public void setTopLevelPosition(int x,
int y)
WindowNote: 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.setTopLevelPosition in interface Windowx - coord of the top-level left corner in window unitsy - coord of the top-level left corner in window unitsWindow.setPosition(int, int),
NativeWindow.getInsets()public final boolean setFullscreen(boolean fullscreen)
Window
Fullscreen mode is established on the main monitor.
setFullscreen in interface Windowfullscreen - enable or disable fullscreen modeWindow.setFullscreen(List),
Window.isFullscreen()public boolean setFullscreen(List<MonitorDevice> monitors)
WindowMonitorDevices
or across all MonitorDevices.
Disable fullscreen via Window.setFullscreen(boolean).
setFullscreen in interface Windowmonitors - if null fullscreen will be spanned across all MonitorDevices,
otherwise across the given list of MonitorDevice.Window.setFullscreen(boolean),
Window.isFullscreen()public final boolean isFullscreen()
isFullscreen in interface Windowpublic final String toString()
toString in interface GLDrawabletoString in class jogamp.opengl.GLAutoDrawableBasepublic final Window.ReparentOperation reparentWindow(NativeWindow newParent)
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.
reparentWindow in interface WindownewParent - The new parent NativeWindow. If null, this Window becomes a top level window.Window.reparentWindow(NativeWindow, int, int, boolean)public final Window.ReparentOperation reparentWindow(NativeWindow newParent, int x, int y, boolean forceDestroyCreate)
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.
reparentWindow in interface WindownewParent - The new parent NativeWindow. If null, this Window becomes a top level window.x - new top-level position, use -1 for default position.y - new top-level position, use -1 for default position.forceDestroyCreate - if true, uses re-creation strategy for reparenting, default is false.public final Window.ReparentOperation reparentWindow(NativeWindow newParent, int x, int y, int hints)
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.
reparentWindow in interface WindownewParent - The new parent NativeWindow. If null, this Window becomes a top level window.x - new top-level position in window units, use -1 for default position.y - new top-level position in window units, use -1 for default position.hints - May contain hints (bitfield values) like Window.REPARENT_HINT_FORCE_RECREATION or Window.REPARENT_HINT_BECOMES_VISIBLE.public final boolean removeChild(NativeWindow win)
removeChild in interface Windowpublic final boolean addChild(NativeWindow win)
public final void destroy()
GLAutoDrawabledispose(..) for all
registered GLEventListeners. Called automatically by the
window system toolkit upon receiving a destroy notification. This
routine may be called manually.destroy in interface Windowdestroy in interface NativeWindowdestroy in interface GLAutoDrawableWindow.destroy(),
Window.setVisible(boolean)public void setWindowDestroyNotifyAction(Runnable r)
Windowtoolkit triggered window destroy
replacing the default Window.destroy() action.
The custom action shall call Window.destroy()
but may perform further tasks before and after.
setWindowDestroyNotifyAction in interface Windowpublic final void setVisible(boolean visible)
WindowsetVisible(true, visible),
i.e. blocks until the window becomes visible.setVisible in interface WindowWindow.setVisible(boolean, boolean)public void setVisible(boolean wait,
boolean visible)
WindowsetVisible(..) makes the window and children visible if visible is true,
otherwise the window and children becomes invisible.
setVisible(wait, true) is responsible to actual create the native window.
If wait is true, method blocks until window is visible and valid,
otherwise method returns immediately.
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(wait, true) has no effect as long the parent's is not valid yet,
i.e. NativeWindow.getWindowHandle() returns null.
setVisible(wait, true) shall be repeated when the parent becomes valid.
setVisible in interface Windowpublic final void setSize(int width,
int height)
Window
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.
setSize in interface Windowwidth - of the window's client area in window unitsheight - of the window's client area in window unitsWindow.setSurfaceSize(int, int),
Window.setTopLevelSize(int, int),
NativeWindow.getInsets()public final void setSurfaceSize(int pixelWidth,
int pixelHeight)
Window
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.
setSurfaceSize in interface WindowpixelWidth - of the window's client area in pixel unitspixelHeight - of the window's client area in pixel unitsWindow.setSize(int, int),
NativeWindow.getInsets()public void setTopLevelSize(int width,
int height)
WindowNote: Insets (if supported) are available only after the window is set visible and hence has been created.
setTopLevelSize in interface Windowwidth - of the top-level window area in window unitsheight - of the top-level window area in window unitsWindow.setSize(int, int),
NativeWindow.getInsets()public final boolean isNativeValid()
isNativeValid in interface WindowsetVisible(true), otherwise false.Window.setVisible(boolean),
#destroy(boolean)public Point getLocationOnScreen(Point storage)
NativeWindow
If Point is not null, it is translated about the resulting screen position
and returned.
See Coordinate System.
Since the position reflects the client area, it does not include the insets.
getLocationOnScreen in interface NativeWindowstorage - Optional Point storage.
If not null, null, it is translated about the resulting screen position
and returned.NativeWindow.getX(),
NativeWindow.getY(),
NativeWindow.getInsets()public void display()
GLAutoDrawableCauses OpenGL rendering to be performed for this GLAutoDrawable in the following order:
display(..) for all
registered GLEventListeners. GLRunnable,
enqueued via GLAutoDrawable.invoke(boolean, GLRunnable).
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.
display in interface GLAutoDrawableGLAutoDrawable.setAnimator(javax.media.opengl.GLAnimatorControl)public final boolean isGLStatePreservationSupported()
GLWindow supports GL state preservation, hence returns true.
isGLStatePreservationSupported in interface GLStateKeeperisGLStatePreservationSupported in class jogamp.opengl.GLAutoDrawableBasetrue if GL state preservation is supported in implementation and on current platform, false otherwise.GLStateKeeper.preserveGLStateAtDestroy(boolean),
GLStateKeeper.getPreservedGLState(),
GLStateKeeper.clearPreservedGLState()public final GLDrawableFactory getFactory()
GLDrawableGLDrawableFactory being used to create this instance.getFactory in interface GLDrawablepublic final void swapBuffers()
throws GLException
GLDrawableGLAutoDrawable 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.swapBuffers in interface GLDrawableGLExceptionpublic boolean consumeEvent(NEWTEvent event)
NEWTEventConsumerconsumeEvent in interface NEWTEventConsumerpublic final void windowRepaint(int x,
int y,
int width,
int height)
WindowwindowRepaint in interface Windowx - dirty-region y-pos in pixel unitsy - dirty-region x-pos in pixel unitswidth - dirty-region width in pixel unitsheight - dirty-region height in pixel unitspublic final void enqueueEvent(boolean wait,
NEWTEvent event)
enqueueEvent in interface Windowpublic final void runOnEDTIfAvail(boolean wait,
Runnable task)
runOnEDTIfAvail in interface Windowpublic void sendWindowEvent(int eventType)
WindowWindowEvent to all WindowListener.sendWindowEvent in interface WindoweventType - a WindowEvent type, e.g. WindowEvent.EVENT_WINDOW_REPAINT.public final WindowListener getWindowListener(int index)
getWindowListener in interface Windowpublic final WindowListener[] getWindowListeners()
getWindowListeners in interface Windowpublic final void removeWindowListener(WindowListener l)
removeWindowListener in interface Windowpublic final void addWindowListener(WindowListener l)
WindowWindowListener to the end of
the list.addWindowListener in interface Windowpublic final void addWindowListener(int index,
WindowListener l)
throws IndexOutOfBoundsException
WindowWindowListener at the
specified position in the list.addWindowListener in interface Windowindex - 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 insertedIndexOutOfBoundsException - If the index is not within (0 <= index && index <= size()), or -1public final void setKeyboardVisible(boolean visible)
Windowvisible is true
or false.
One known platform where NEWT supports this feature is Android.
setKeyboardVisible in interface Windowpublic final boolean isKeyboardVisible()
Windowtrue 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.
isKeyboardVisible in interface WindowWindow.setKeyboardVisible(boolean)public final void addKeyListener(KeyListener l)
WindowKeyListener to the end of
the list.addKeyListener in interface Windowpublic final void addKeyListener(int index,
KeyListener l)
WindowKeyListener at the
specified position in the list.addKeyListener in interface Windowindex - 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 insertedpublic final void removeKeyListener(KeyListener l)
removeKeyListener in interface Windowpublic final KeyListener getKeyListener(int index)
getKeyListener in interface Windowpublic final KeyListener[] getKeyListeners()
getKeyListeners in interface Windowpublic final void addMouseListener(MouseListener l)
WindowMouseListener to the end of the list.addMouseListener in interface Windowpublic final void addMouseListener(int index,
MouseListener l)
WindowMouseListener at the
specified position in the list.addMouseListener in interface Windowindex - 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 insertedpublic final void removeMouseListener(MouseListener l)
WindowMouseListener from the list.removeMouseListener in interface Windowpublic final MouseListener getMouseListener(int index)
WindowMouseListener from the list at the given index.getMouseListener in interface Windowpublic final MouseListener[] getMouseListeners()
WindowMouseListenergetMouseListeners in interface Windowpublic void setDefaultGesturesEnabled(boolean enable)
WindowGestureHandler. Default is enabled.setDefaultGesturesEnabled in interface Windowpublic boolean areDefaultGesturesEnabled()
WindowGestureHandler are enabled.areDefaultGesturesEnabled in interface Windowpublic final void addGestureHandler(GestureHandler gh)
WindowGestureHandler to the end of the list.addGestureHandler in interface Windowpublic final void addGestureHandler(int index,
GestureHandler gh)
WindowGestureHandler at the
specified position in the list.addGestureHandler in interface Windowindex - 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().public final void removeGestureHandler(GestureHandler gh)
WindowGestureHandler from the list.removeGestureHandler in interface Windowpublic final void addGestureListener(GestureHandler.GestureListener gl)
WindowGestureHandler.GestureListener to the end of the list.addGestureListener in interface Windowpublic final void addGestureListener(int index,
GestureHandler.GestureListener gl)
WindowGestureHandler.GestureListener at the
specified position in the list.addGestureListener in interface Windowindex - 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().public final void removeGestureListener(GestureHandler.GestureListener gl)
WindowGestureHandler.GestureListener from the list.removeGestureListener in interface Windowpublic final int lockSurface()
throws NativeWindowException,
RuntimeException
NativeSurface
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).
lockSurface in interface NativeSurfaceNativeSurface.LOCK_SUCCESS, NativeSurface.LOCK_SURFACE_CHANGED or NativeSurface.LOCK_SURFACE_NOT_READY.NativeWindowException - if native locking failed, maybe platform relatedRuntimeException - after timeout when waiting for the surface lockRecursiveLockpublic final void unlockSurface()
NativeSurfaceNativeSurface.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.
unlockSurface in interface NativeSurfaceNativeSurface.lockSurface(),
RecursiveLockpublic final boolean isSurfaceLockedByOtherThread()
NativeSurface
final Thread o = getSurfaceLockOwner();
if( null != o && Thread.currentThread() != o ) { .. }
isSurfaceLockedByOtherThread in interface NativeSurfacepublic final Thread getSurfaceLockOwner()
NativeSurfacegetSurfaceLockOwner in interface NativeSurfacepublic final boolean surfaceSwap()
NativeSurfaceThe implementation may itself apply the swapping, in which case true shall be returned.
surfaceSwap in interface NativeSurfacepublic final void removeSurfaceUpdatedListener(SurfaceUpdatedListener l)
NativeSurfaceSurfaceUpdatedListener from the list.removeSurfaceUpdatedListener in interface NativeSurfacepublic final void addSurfaceUpdatedListener(SurfaceUpdatedListener l)
NativeSurfaceSurfaceUpdatedListener to the end of the list.addSurfaceUpdatedListener in interface NativeSurfacepublic final void addSurfaceUpdatedListener(int index,
SurfaceUpdatedListener l)
throws IndexOutOfBoundsException
NativeSurfaceSurfaceUpdatedListener at the
specified position in the list.addSurfaceUpdatedListener in interface NativeSurfaceindex - 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 insertedIndexOutOfBoundsException - If the index is not within (0 <= index && index <= size()), or -1public final void surfaceUpdated(Object updater, NativeSurface ns, long when)
SurfaceUpdatedListenersurfaceUpdated in interface SurfaceUpdatedListenerupdater - is the caller object who updated the surface,
e.g. a JOGL GLDrawable.ns - the updated NativeSurfacewhen - the time in ms, when the surface was updatedpublic final long getWindowHandle()
NativeWindowThe 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.
getWindowHandle in interface NativeWindowpublic final long getSurfaceHandle()
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.
getSurfaceHandle in interface NativeSurfacepublic final AbstractGraphicsConfiguration getGraphicsConfiguration()
NativeSurface
In case the implementation utilizes a delegation pattern to wrap abstract toolkits,
this method shall return the native AbstractGraphicsConfiguration via AbstractGraphicsConfiguration.getNativeGraphicsConfiguration().
getGraphicsConfiguration in interface NativeSurfaceAbstractGraphicsConfiguration.getNativeGraphicsConfiguration(),
javax.media.nativewindow.GraphicsConfigurationFactory#chooseGraphicsConfiguration(Capabilities, CapabilitiesChooser, AbstractGraphicsScreen)public final long getDisplayHandle()
NativeSurfacegetDisplayHandle in interface NativeSurfacepublic final int getScreenIndex()
NativeSurfacegetScreenIndex in interface NativeSurfacepublic static void main(String[] args)
Copyright 2010 JogAmp Community.