Class GLWindow
- java.lang.Object
-
- jogamp.opengl.GLAutoDrawableBase
-
- com.jogamp.newt.opengl.GLWindow
-
- All Implemented Interfaces:
NativeSurface,NativeSurfaceHolder,NativeWindow,ScalableSurface,SurfaceUpdatedListener,WindowClosingProtocol,NEWTEventConsumer,Window,FPSCounter,GLAutoDrawable,GLDrawable,GLSharedContextSetter,GLStateKeeper
public class GLWindow extends jogamp.opengl.GLAutoDrawableBase implements GLAutoDrawable, Window, NEWTEventConsumer, FPSCounter
An implementation ofGLAutoDrawableandWindowinterface, using a delegatedWindowinstance, which may be an aggregation (lifecycle: created and destroyed).This implementation supports
GL state preservation, henceisGLStatePreservationSupported()returnstrue.This implementation does not make the OpenGL context current
before calling the various input EventListener callbacks, ieMouseListeneretc.
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 inputNEWTEventListener,
you can injectGLRunnableobjects viaGLAutoDrawableBase.invoke(boolean, GLRunnable)to the OpenGL command stream.
OpenGL Context Sharing
To share aGLContextsee the following note in the documentation overview: context sharing as well asGLSharedContextSetter.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.jogamp.opengl.GLStateKeeper
GLStateKeeper.Listener
-
Nested classes/interfaces inherited from interface com.jogamp.newt.Window
Window.FocusRunnable, Window.ReparentOperation
-
Nested classes/interfaces inherited from interface com.jogamp.nativewindow.WindowClosingProtocol
WindowClosingProtocol.WindowClosingMode
-
-
Field Summary
-
Fields inherited from interface com.jogamp.opengl.FPSCounter
DEFAULT_FRAMES_PER_INTERVAL
-
Fields inherited from interface com.jogamp.opengl.GLAutoDrawable
SCREEN_CHANGE_ACTION_ENABLED
-
Fields inherited from interface com.jogamp.nativewindow.NativeSurface
LOCK_SUCCESS, LOCK_SURFACE_CHANGED, LOCK_SURFACE_NOT_READY, LOCK_SURFACE_UNLOCKED
-
Fields inherited from interface com.jogamp.nativewindow.ScalableSurface
AUTOMAX_PIXELSCALE, IDENTITY_PIXELSCALE
-
Fields inherited from interface com.jogamp.newt.Window
DEBUG_IMPLEMENTATION, DEBUG_KEY_EVENT, DEBUG_MOUSE_EVENT, REPARENT_HINT_BECOMES_VISIBLE, REPARENT_HINT_FORCE_RECREATION, STATE_BIT_ALWAYSONBOTTOM, STATE_BIT_ALWAYSONTOP, STATE_BIT_AUTOPOSITION, STATE_BIT_CHILDWIN, STATE_BIT_FOCUSED, STATE_BIT_FULLSCREEN, STATE_BIT_MAXIMIZED_HORZ, STATE_BIT_MAXIMIZED_VERT, STATE_BIT_POINTERCONFINED, STATE_BIT_POINTERVISIBLE, STATE_BIT_REPOSITIONABLE, STATE_BIT_RESIZABLE, STATE_BIT_STICKY, STATE_BIT_UNDECORATED, STATE_BIT_VISIBLE, STATE_MASK_ALWAYSONBOTTOM, STATE_MASK_ALWAYSONTOP, STATE_MASK_AUTOPOSITION, STATE_MASK_CHILDWIN, STATE_MASK_FOCUSED, STATE_MASK_FULLSCREEN, STATE_MASK_MAXIMIZED_HORZ, STATE_MASK_MAXIMIZED_VERT, STATE_MASK_POINTERCONFINED, STATE_MASK_POINTERVISIBLE, STATE_MASK_REPOSITIONABLE, STATE_MASK_RESIZABLE, STATE_MASK_STICKY, STATE_MASK_UNDECORATED, STATE_MASK_VISIBLE, TIMEOUT_NATIVEWINDOW
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaddChild(NativeWindow win)voidaddGestureHandler(int index, GestureHandler gh)Inserts the givenGestureHandlerat the specified position in the list.voidaddGestureHandler(GestureHandler gh)Appends the givenGestureHandlerto the end of the list.voidaddGestureListener(int index, GestureHandler.GestureListener gl)Inserts the givenGestureHandler.GestureListenerat the specified position in the list.voidaddGestureListener(GestureHandler.GestureListener gl)Appends the givenGestureHandler.GestureListenerto the end of the list.voidaddKeyListener(int index, KeyListener l)Inserts the givenKeyListenerat the specified position in the list.voidaddKeyListener(KeyListener l)Appends the givenKeyListenerto the end of the list.voidaddMouseListener(int index, MouseListener l)Inserts the givenMouseListenerat the specified position in the list.voidaddMouseListener(MouseListener l)Appends the givenMouseListenerto the end of the list.voidaddSurfaceUpdatedListener(int index, SurfaceUpdatedListener l)Inserts the givenSurfaceUpdatedListenerat the specified position in the list.voidaddSurfaceUpdatedListener(SurfaceUpdatedListener l)Appends the givenSurfaceUpdatedListenerto the end of the list.voidaddWindowListener(int index, WindowListener l)Inserts the givenWindowListenerat the specified position in the list.voidaddWindowListener(WindowListener l)Appends the givenWindowListenerto the end of the list.booleanareDefaultGesturesEnabled()Return true if defaultGestureHandlerare enabled.booleancanSetSurfaceScale()Returns true ifScalableSurface.setSurfaceScale(float[])is supported, otherwise false.voidconfinePointer(boolean grab)Confine the pointer to this window, ie.booleanconsumeEvent(NEWTEvent event)Consume the eventint[]convertToPixelUnits(int[] 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.static GLWindowcreate(NativeWindow parentNativeWindow, GLCapabilitiesImmutable caps)Creates a new GLWindow attaching a new child Window of the givenparentNativeWindowwith the given GLCapabilities.static GLWindowcreate(Screen screen, GLCapabilitiesImmutable caps)Creates a new GLWindow attaching a new Window referencing the given Screen with the given GLCapabilities.static GLWindowcreate(Window window)Creates a new GLWindow attaching the given window.static GLWindowcreate(GLCapabilitiesImmutable caps)Creates a new GLWindow attaching a new Window referencing a new default Screen and default Display with the given GLCapabilities.voiddestroy()Destroys all resources associated with this GLAutoDrawable, inclusive the GLContext.voiddisplay()Causes OpenGL rendering to be performed for this GLAutoDrawable in the following order: Callingdisplay(..)for all registeredGLEventListeners.voidenqueueEvent(boolean wait, NEWTEvent event)Enqueues aNEWT event.RectanglegetBounds()Returns a newly createdRectanglecontaining window origin,NativeWindow.getX()&NativeWindow.getY(), and size,NativeWindow.getWidth()&NativeWindow.getHeight(), in window units.CapabilitiesImmutablegetChosenCapabilities()Gets an immutable set of chosen capabilities.float[]getCurrentSurfaceScale(float[] result)Returns the current pixel scale of the associatedNativeSurface.WindowClosingProtocol.WindowClosingModegetDefaultCloseOperation()WindowgetDelegatedWindow()If the implementation uses delegation, return the delegatedWindowinstance, otherwise returnthisinstance.longgetDisplayHandle()Convenience: Get display handle from AbstractGraphicsConfiguration .GLDrawableFactorygetFactory()Return theGLDrawableFactorybeing used to create this instance.AbstractGraphicsConfigurationgetGraphicsConfiguration()Returns the graphics configuration corresponding to this window.intgetHeight()Returns the height of the client area excluding insets (window decorations) in window units.InsetsImmutablegetInsets()Returns the insets defined as the width and height of the window decoration on the left, right, top and bottom in window units.KeyListenergetKeyListener(int index)KeyListener[]getKeyListeners()PointgetLocationOnScreen(Point storage)Returns the window's top-left client-area position in the screen.RecursiveLockgetLock()Returns the implementation'sRecursiveLocksynchronizing multithreaded access if used.MonitorDevicegetMainMonitor()float[]getMaximumSurfaceScale(float[] result)Returns the maximum pixel scale of the associatedNativeSurface.float[]getMinimumSurfaceScale(float[] result)Returns the minimum pixel scale of the associatedNativeSurface.MouseListenergetMouseListener(int index)Returns theMouseListenerfrom the list at the given index.MouseListener[]getMouseListeners()Returns allMouseListenerNativeWindowgetParent()float[]getPixelsPerMM(float[] ppmmStore)Returns the pixels per millimeter of this window'sNativeSurfaceaccording to themain monitor's currentmode'ssurface resolution.Display.PointerIcongetPointerIcon()Returns the currentDisplay.PointerIcon, which maybenullfor the default.CapabilitiesImmutablegetRequestedCapabilities()Gets an immutable set of requested capabilities.float[]getRequestedSurfaceScale(float[] result)Returns therequestedpixel scale of the associatedNativeSurface.ScreengetScreen()intgetScreenIndex()Convenience: Get display handle from AbstractGraphicsConfiguration .intgetStateMask()Returns the current status mask of this instance.StringgetStateMaskString()Returns a string representation of thecurrent state mask.intgetStatePublicBitCount()Number of all public state bits.intgetStatePublicBitmask()Bitmask covering all public state bits.intgetSupportedStateMask()Returns the supportedstate maskof the implementation.StringgetSupportedStateMaskString()Returns a string representation of thesupported state mask.RectanglegetSurfaceBounds()Returns a newly createdRectanglecontaining window's surface origin and size in pixel units.longgetSurfaceHandle()Returns the handle to the surface for this NativeSurface.intgetSurfaceHeight()Returns the height of thisGLDrawable'ssurfaceclient area in pixel units.ThreadgetSurfaceLockOwner()Return the locking owner's Thread, or null if not locked.intgetSurfaceWidth()Returns the width of thisGLDrawable'ssurfaceclient area in pixel units.StringgetTitle()RecursiveLockgetUpstreamLock()Returns the recursive lock object of theupstream widgetto synchronize multithreaded access on top ofNativeSurface.lockSurface().ObjectgetUpstreamWidget()Method may return the upstream UI toolkit object holding thisGLAutoDrawableinstance, if exist.intgetWidth()Returns the width of the client area excluding insets (window decorations) in window units.longgetWindowHandle()Returns the window handle for this NativeWindow.WindowListenergetWindowListener(int index)WindowListener[]getWindowListeners()intgetX()Returns the x position of the top-left corner of the client area relative to it's parent in window units.intgetY()Returns the current y position of the top-left corner of the client area relative to it's parent in window units.booleanhasFocus()Returns true if this native window owns the focus, otherwise false.booleanisAlwaysOnBottom()booleanisAlwaysOnTop()booleanisChildWindow()Returnstrueif this window is a child window, i.e.booleanisFullscreen()booleanisGLStatePreservationSupported()booleanisKeyboardVisible()Returntrueif the virtual on-screen keyboard is visible, otherwisefalse.booleanisMaximizedHorz()booleanisMaximizedVert()booleanisNativeValid()booleanisPointerConfined()booleanisPointerVisible()booleanisResizable()booleanisSticky()booleanisSurfaceLockedByOtherThread()Query if surface is locked by another thread, i.e.booleanisUndecorated()booleanisVisible()intlockSurface()Lock the surface of this native window.static voidmain(String[] args)A most simple JOGL AWT test entrybooleanremoveChild(NativeWindow win)voidremoveGestureHandler(GestureHandler gh)Removes the givenGestureHandlerfrom the list.voidremoveGestureListener(GestureHandler.GestureListener gl)Removes the givenGestureHandler.GestureListenerfrom the list.voidremoveKeyListener(KeyListener l)voidremoveMouseListener(MouseListener l)Removes the givenMouseListenerfrom the list.voidremoveSurfaceUpdatedListener(SurfaceUpdatedListener l)Remove the specifiedSurfaceUpdatedListenerfrom the list.voidremoveWindowListener(WindowListener l)Window.ReparentOperationreparentWindow(NativeWindow newParent, int x, int y, int hints)Change this window's parent window.voidrequestFocus()Request focus for this native windowvoidrequestFocus(boolean wait)Request focus for this native windowvoidrunOnEDTIfAvail(boolean wait, Runnable task)voidsendWindowEvent(int eventType)Send aWindowEventto allWindowListener.voidsetAlwaysOnBottom(boolean value)Operation is ignored if this instanceis a child window.voidsetAlwaysOnTop(boolean value)Operation is ignored if this instanceis a child window.CapabilitiesChoosersetCapabilitiesChooser(CapabilitiesChooser chooser)Set the CapabilitiesChooser to help determine the native visual type.WindowClosingProtocol.WindowClosingModesetDefaultCloseOperation(WindowClosingProtocol.WindowClosingMode op)voidsetDefaultGesturesEnabled(boolean enable)Enable or disable defaultGestureHandler.voidsetFocusAction(Window.FocusRunnable focusAction)Sets aWindow.FocusRunnable, whichWindow.FocusRunnable.run()method is executed before the native focus is requested.booleansetFullscreen(boolean fullscreen)Enable or disable fullscreen mode for this window.booleansetFullscreen(List<MonitorDevice> monitors)Enable fullscreen mode for this window spanning across the givenMonitorDevices or across allMonitorDevices.voidsetKeyboardFocusHandler(KeyListener l)Sets aKeyListenerallowing focus traversal with a covered window toolkit like AWT.voidsetKeyboardVisible(boolean visible)In case the platform supports or even requires a virtual on-screen keyboard, this method shows or hide it depending on whethervisibleistrueorfalse.voidsetMaximized(boolean horz, boolean vert)Operation is ignored if this instanceis a child window.voidsetPointerIcon(Display.PointerIcon pi)voidsetPointerVisible(boolean mouseVisible)Makes the pointer visible or invisible.voidsetPosition(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.voidsetResizable(boolean value)Operation is ignored if this instanceis a child window.voidsetSize(int width, int height)Sets the size of the window's client area in window units, excluding decorations.voidsetSticky(boolean value)Operation is ignored if this instanceis a child window.booleansetSurfaceScale(float[] pixelScale)Request a pixel scale in x- and y-direction for the associatedNativeSurface, wheresize_in_pixel_units = pixel_scale * size_in_window_units.voidsetSurfaceSize(int pixelWidth, int pixelHeight)Sets the size of the window's surface in pixel units which claims the window's client area excluding decorations.voidsetTitle(String title)voidsetTopLevelPosition(int x, int y)Sets the location of the top-level window inclusive insets (window decorations) in window units.voidsetTopLevelSize(int width, int height)Sets the size of the top-level window including insets (window decorations) in window units.voidsetUndecorated(boolean value)voidsetVisible(boolean visible)CallssetVisible(true, visible), i.e.voidsetVisible(boolean wait, boolean visible)setVisible(..)makes the window and children visible ifvisibleis true, otherwise the window and children becomes invisible.voidsetWindowDestroyNotifyAction(Runnable r)Set a custom action handling destruction issued by atoolkit triggered window destroyreplacing the defaultWindow.destroy()action.booleansurfaceSwap()Provide a mechanism to utilize custom (pre-) swap surface code.voidsurfaceUpdated(Object updater, NativeSurface ns, long when)Notification of a surface update event, eg.voidswapBuffers()Swaps the front and back buffers of this drawable.StringtoSimpleString()Returns a simple string one-line representation of this instance usingWindow.toSimpleString(StringBuilder).StringBuildertoSimpleString(StringBuilder sb)Appends this class simple string one-line representation to the givenStringBuilderinstanceStringtoString()Returns a full string multi-line representation of this instance usingWindow.toString(StringBuilder).StringBuildertoString(StringBuilder sb)Appends this class full string multi-line representation to the givenStringBuilderinstancevoidunlockSurface()Unlock the surface of this native window Shall not modify the surface handle, seeNativeSurface.lockSurface()voidwarpPointer(int x, int y)Moves the pointer to x/y relative to this window's origin in pixel units.booleanwindowRepaint(int x, int y, int width, int height)Trigger window repaint while passing the dirty region in pixel units.-
Methods inherited from class jogamp.opengl.GLAutoDrawableBase
addGLEventListener, addGLEventListener, areAllGLEventListenerInitialized, clearPreservedGLState, createContext, defaultSwapBuffers, disposeGLEventListener, flushGLRunnables, getAnimator, getAutoSwapBufferMode, getChosenGLCapabilities, getContext, getContextCreationFlags, getDelegatedDrawable, getExclusiveContextThread, getFPSStartTime, getGL, getGLEventListener, getGLEventListenerCount, getGLEventListenerInitState, getGLProfile, getHandle, getLastFPS, getLastFPSPeriod, getLastFPSUpdateTime, getNativeSurface, getPreservedGLState, getRequestedGLCapabilities, getTotalFPS, getTotalFPSDuration, getTotalFPSFrames, getUpdateFPSFrames, invoke, invoke, invokeOnCurrentThread, invokeOnNewThread, isGLOriented, isRealized, isThreadGLCapable, preserveGLStateAtDestroy, removeGLEventListener, resetFPSCounter, setAnimator, setAutoSwapBufferMode, setContext, setContextCreationFlags, setExclusiveContextThread, setGL, setGLEventListenerInitState, setGLStateKeeperListener, setRealized, setSharedAutoDrawable, setSharedContext, setUpdateFPSFrames
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.jogamp.opengl.FPSCounter
getFPSStartTime, getLastFPS, getLastFPSPeriod, getLastFPSUpdateTime, getTotalFPS, getTotalFPSDuration, getTotalFPSFrames, getUpdateFPSFrames, resetFPSCounter, setUpdateFPSFrames
-
Methods inherited from interface com.jogamp.opengl.GLAutoDrawable
addGLEventListener, addGLEventListener, areAllGLEventListenerInitialized, createContext, disposeGLEventListener, flushGLRunnables, getAnimator, getAutoSwapBufferMode, getContext, getContextCreationFlags, getDelegatedDrawable, getExclusiveContextThread, getGL, getGLEventListener, getGLEventListenerCount, getGLEventListenerInitState, invoke, invoke, isThreadGLCapable, removeGLEventListener, setAnimator, setAutoSwapBufferMode, setContext, setContextCreationFlags, setExclusiveContextThread, setGL, setGLEventListenerInitState
-
Methods inherited from interface com.jogamp.opengl.GLDrawable
getChosenGLCapabilities, getGLProfile, getHandle, getNativeSurface, getRequestedGLCapabilities, isGLOriented, isRealized, setRealized
-
Methods inherited from interface com.jogamp.nativewindow.NativeWindow
getNativeSurface
-
-
-
-
Method Detail
-
getUpstreamWidget
public final Object getUpstreamWidget()
Description copied from interface:GLAutoDrawableMethod may return the upstream UI toolkit object holding thisGLAutoDrawableinstance, if exist.Currently known Java UI toolkits and it's known return types are:
However, the result may be other object types than the listed above due to new supported toolkits.Toolkit GLAutoDrawable Implementation ~ Return Type of getUpstreamWidget() NEWT GLWindowhas a WindowSWT GLCanvasis a CanvasAWT GLCanvasis a CanvasAWT GLJPanelis a JPanelThis method may also return
nullif no UI toolkit is being used, as common for offscreen rendering.- Specified by:
getUpstreamWidgetin interfaceGLAutoDrawable
-
getUpstreamLock
public final RecursiveLock getUpstreamLock()
Description copied from interface:GLAutoDrawableReturns the recursive lock object of theupstream widgetto synchronize multithreaded access on top ofNativeSurface.lockSurface().- Specified by:
getUpstreamLockin interfaceGLAutoDrawable
-
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
The default Display will be reused if already instantiated.Screen.addReference()andScreen.removeReference().
-
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()andScreen.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()andScreen.removeReference().
-
create
public static GLWindow create(NativeWindow parentNativeWindow, GLCapabilitiesImmutable caps)
Creates a new GLWindow attaching a new child Window of the givenparentNativeWindowwith 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()andScreen.removeReference().
-
getDefaultCloseOperation
public WindowClosingProtocol.WindowClosingMode getDefaultCloseOperation()
- Specified by:
getDefaultCloseOperationin interfaceWindowClosingProtocol- 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:
setDefaultCloseOperationin interfaceWindowClosingProtocol- 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
-
getStatePublicBitCount
public final int getStatePublicBitCount()
Description copied from interface:WindowNumber of all public state bits.- Specified by:
getStatePublicBitCountin interfaceWindow- See Also:
Window.getSupportedStateMask(),Window.getStateMask()
-
getStatePublicBitmask
public final int getStatePublicBitmask()
Description copied from interface:WindowBitmask covering all public state bits.- Specified by:
getStatePublicBitmaskin interfaceWindow- See Also:
Window.getSupportedStateMask(),Window.getStateMask()
-
getStateMask
public final int getStateMask()
Description copied from interface:WindowReturns the current status mask of this instance.- Specified by:
getStateMaskin interfaceWindow- See Also:
Window.getSupportedStateMask(),Window.STATE_MASK_VISIBLE,Window.STATE_MASK_AUTOPOSITION,Window.STATE_MASK_CHILDWIN,Window.STATE_MASK_FOCUSED,Window.STATE_MASK_UNDECORATED,Window.STATE_MASK_ALWAYSONTOP,Window.STATE_MASK_ALWAYSONBOTTOM,Window.STATE_MASK_STICKY,Window.STATE_MASK_RESIZABLE,Window.STATE_MASK_MAXIMIZED_VERT,Window.STATE_MASK_MAXIMIZED_HORZ,Window.STATE_MASK_FULLSCREEN,Window.STATE_MASK_POINTERVISIBLE,Window.STATE_MASK_POINTERCONFINED,Window.STATE_MASK_REPOSITIONABLE
-
getStateMaskString
public final String getStateMaskString()
Description copied from interface:WindowReturns a string representation of thecurrent state mask.- Specified by:
getStateMaskStringin interfaceWindow
-
getSupportedStateMask
public final int getSupportedStateMask()
Description copied from interface:WindowReturns the supportedstate maskof the implementation.Implementation provides supported
state maskvalues at runtime after native window creation, i.e. first visibility.Please note that a window's size shall also be allowed to change, i.e.
Window.setSize(int, int).Default minimum value is
Window.STATE_MASK_VISIBLE|Window.STATE_MASK_FOCUSED, i.e. the minimum requirement for all implementations.Usual desktop minimum value is
Window.STATE_MASK_VISIBLE|Window.STATE_MASK_FOCUSED|Window.STATE_MASK_FULLSCREEN|Window.STATE_MASK_RESIZABLE|Window.STATE_MASK_REPOSITIONABLE.Before native window creation
Window.getStatePublicBitmask()is returned, i.e. it is assumed all features are supported.Semantic of the supported state-mask bits (after native creation, i.e. 1st visibility):
Window.STATE_MASK_VISIBLE:Visibilitycan be toggled. Minimum requirement.Window.STATE_MASK_CHILDWIN:Native window parentingis supported.Window.STATE_MASK_FOCUSED: Windowfocus managementis supported. Minimum requirement.Window.STATE_MASK_UNDECORATED:Window decorationcan be toggled.Window.STATE_MASK_ALWAYSONTOP: Window can be setalways-on-top.Window.STATE_MASK_ALWAYSONBOTTOM: Window can be setalways-on-bottom.Window.STATE_MASK_STICKY: Window can be setsticky.Window.STATE_MASK_RESIZABLE: Windowresizabilitycan be toggled and it'ssizecan be changed.Window.STATE_MASK_MAXIMIZED_VERT: Window can bemaximized-vertically.Window.STATE_MASK_MAXIMIZED_HORZ: Window can bemaximized-horizontally.Window.STATE_MASK_FULLSCREEN: Windowfullscreencan be toggled.Window.STATE_MASK_POINTERVISIBLE: Windowpointer visibilitycan be toggled.Window.STATE_MASK_POINTERCONFINED: Windowpointer can be confined.Window.STATE_MASK_REPOSITIONABLE: Windowpositioncan be changed.
- Specified by:
getSupportedStateMaskin interfaceWindow- See Also:
Window.getStateMask()
-
getSupportedStateMaskString
public final String getSupportedStateMaskString()
Description copied from interface:WindowReturns a string representation of thesupported state mask.- Specified by:
getSupportedStateMaskStringin interfaceWindow
-
setCapabilitiesChooser
public CapabilitiesChooser setCapabilitiesChooser(CapabilitiesChooser chooser)
Description copied from interface:WindowSet the CapabilitiesChooser to help determine the native visual type.- Specified by:
setCapabilitiesChooserin interfaceWindow- Parameters:
chooser- the new CapabilitiesChooser- Returns:
- the previous CapabilitiesChooser
-
getChosenCapabilities
public final CapabilitiesImmutable getChosenCapabilities()
Description copied from interface:WindowGets an immutable set of chosen capabilities.- Specified by:
getChosenCapabilitiesin interfaceWindow- Returns:
- the chosen capabilities
-
getRequestedCapabilities
public final CapabilitiesImmutable getRequestedCapabilities()
Description copied from interface:WindowGets an immutable set of requested capabilities.- Specified by:
getRequestedCapabilitiesin interfaceWindow- Returns:
- the requested capabilities
-
getDelegatedWindow
public final Window getDelegatedWindow()
Description copied from interface:WindowIf the implementation uses delegation, return the delegatedWindowinstance, otherwise returnthisinstance.- Specified by:
getDelegatedWindowin interfaceWindow
-
getParent
public final NativeWindow getParent()
- Specified by:
getParentin interfaceNativeWindow- Returns:
- The parent NativeWindow, or null if this NativeWindow is top level.
-
getScreen
public final Screen getScreen()
-
getMainMonitor
public final MonitorDevice getMainMonitor()
Description copied from interface:WindowReturns theMonitorDevicewith the highestviewportcoverageof this window.If no coverage is detected the first
MonitorDeviceis returned.- Specified by:
getMainMonitorin interfaceWindow
-
isPointerVisible
public final boolean isPointerVisible()
- Specified by:
isPointerVisiblein interfaceWindow- See Also:
Window.setPointerVisible(boolean)
-
setPointerVisible
public final void setPointerVisible(boolean mouseVisible)
Description copied from interface:WindowMakes the pointer visible or invisible.- Specified by:
setPointerVisiblein interfaceWindow- Parameters:
mouseVisible- defaults totruefor platforms w/ visible pointer, otherwise defaults totrue, eg. Android.- See Also:
Window.confinePointer(boolean)
-
getPointerIcon
public final Display.PointerIcon getPointerIcon()
Description copied from interface:WindowReturns the currentDisplay.PointerIcon, which maybenullfor the default.- Specified by:
getPointerIconin interfaceWindow- See Also:
Window.setPointerIcon(PointerIcon)
-
setPointerIcon
public final void setPointerIcon(Display.PointerIcon pi)
- Specified by:
setPointerIconin interfaceWindow- Parameters:
pi- ValidDisplay.PointerIconreference ornullto reset the pointer icon to default.- See Also:
Display.PointerIcon,Display.createPointerIcon(com.jogamp.common.util.IOUtil.ClassResources, int, int)
-
isPointerConfined
public final boolean isPointerConfined()
- Specified by:
isPointerConfinedin interfaceWindow- See Also:
Window.confinePointer(boolean)
-
confinePointer
public final void confinePointer(boolean grab)
Description copied from interface:WindowConfine 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 maybeWindow.setPointerVisible(boolean)a simple mouse navigation can be realized.- Specified by:
confinePointerin interfaceWindow- Parameters:
grab- defaults tofalse.
-
setUndecorated
public final void setUndecorated(boolean value)
- Specified by:
setUndecoratedin interfaceWindow
-
warpPointer
public final void warpPointer(int x, int y)Description copied from interface:WindowMoves the pointer to x/y relative to this window's origin in pixel units.- Specified by:
warpPointerin interfaceWindow- Parameters:
x- relative pointer x position within this window in pixel unitsy- relative pointer y position within this window in pixel units- See Also:
Window.confinePointer(boolean)
-
isUndecorated
public final boolean isUndecorated()
- Specified by:
isUndecoratedin interfaceWindow
-
setAlwaysOnTop
public final void setAlwaysOnTop(boolean value)
Description copied from interface:WindowOperation is ignored if this instance
is a child window.- Specified by:
setAlwaysOnTopin interfaceWindow
-
isAlwaysOnTop
public final boolean isAlwaysOnTop()
- Specified by:
isAlwaysOnTopin interfaceWindow
-
setAlwaysOnBottom
public final void setAlwaysOnBottom(boolean value)
Description copied from interface:WindowOperation is ignored if this instance
is a child window.- Specified by:
setAlwaysOnBottomin interfaceWindow
-
isAlwaysOnBottom
public final boolean isAlwaysOnBottom()
- Specified by:
isAlwaysOnBottomin interfaceWindow
-
setResizable
public final void setResizable(boolean value)
Description copied from interface:WindowOperation is ignored if this instance
is a child window.- Specified by:
setResizablein interfaceWindow
-
isResizable
public final boolean isResizable()
- Specified by:
isResizablein interfaceWindow
-
setSticky
public final void setSticky(boolean value)
Description copied from interface:WindowOperation is ignored if this instance
is a child window.
-
setMaximized
public final void setMaximized(boolean horz, boolean vert)Description copied from interface:WindowOperation is ignored if this instance
is a child window.- Specified by:
setMaximizedin interfaceWindow
-
isMaximizedVert
public final boolean isMaximizedVert()
- Specified by:
isMaximizedVertin interfaceWindow
-
isMaximizedHorz
public final boolean isMaximizedHorz()
- Specified by:
isMaximizedHorzin interfaceWindow
-
setFocusAction
public final void setFocusAction(Window.FocusRunnable focusAction)
Description copied from interface:WindowSets aWindow.FocusRunnable, whichWindow.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:
setFocusActionin interfaceWindow
-
setKeyboardFocusHandler
public void setKeyboardFocusHandler(KeyListener l)
Description copied from interface:WindowSets aKeyListenerallowing focus traversal with a covered window toolkit like AWT.The
KeyListenermethods are invoked prior to all otherKeyListener's allowing to suppress theKeyEventvia theNEWTEvent.consumedTagand to perform focus traversal with a 3rd party toolkit.The
KeyListenermethods are not invoked forauto-repeatevents.- Specified by:
setKeyboardFocusHandlerin interfaceWindow
-
requestFocus
public final void requestFocus()
Description copied from interface:WindowRequest focus for this native windowThe request is handled on this Window EDT and blocked until finished.
- Specified by:
requestFocusin interfaceWindow- See Also:
Window.requestFocus(boolean)
-
requestFocus
public final void requestFocus(boolean wait)
Description copied from interface:WindowRequest focus for this native windowThe request is handled on this Window EDT.
- Specified by:
requestFocusin interfaceWindow- Parameters:
wait- true if waiting until the request is executed, otherwise false- See Also:
Window.requestFocus()
-
hasFocus
public boolean hasFocus()
Description copied from interface:NativeWindowReturns true if this native window owns the focus, otherwise false.- Specified by:
hasFocusin interfaceNativeWindow
-
getInsets
public final InsetsImmutable getInsets()
Description copied from interface:NativeWindowReturns the insets defined as the width and height of the window decoration on the left, right, top and bottom in window units.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
The top-level window size isNativeWindow.getX()- getInsets().getLeftWidth()NativeWindow.getY()- getInsets().getTopHeight()NativeWindow.getWidth()+ getInsets().getTotalWidth()NativeWindow.getHeight()+ getInsets().getTotalHeight()- Specified by:
getInsetsin interfaceNativeWindow- Returns:
- insets
-
getX
public final int getX()
Description copied from interface:NativeWindowReturns the x position of the top-left corner of the client area relative to it's parent in window units.If 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.
- Specified by:
getXin interfaceNativeWindow- See Also:
NativeWindow.getInsets(),NativeWindow.getLocationOnScreen(Point)
-
getY
public final int getY()
Description copied from interface:NativeWindowReturns the current y position of the top-left corner of the client area relative to it's parent in window units.If 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.
- Specified by:
getYin interfaceNativeWindow- See Also:
NativeWindow.getInsets(),NativeWindow.getLocationOnScreen(Point)
-
getWidth
public final int getWidth()
Description copied from interface:NativeWindowReturns the width of the client area excluding insets (window decorations) in window units.- Specified by:
getWidthin interfaceNativeWindow- Returns:
- width of the client area in window units
- See Also:
NativeSurface.getSurfaceWidth()
-
getHeight
public final int getHeight()
Description copied from interface:NativeWindowReturns the height of the client area excluding insets (window decorations) in window units.- Specified by:
getHeightin interfaceNativeWindow- Returns:
- height of the client area in window units
- See Also:
NativeSurface.getSurfaceHeight()
-
getBounds
public final Rectangle getBounds()
Description copied from interface:NativeWindowReturns a newly createdRectanglecontaining window origin,NativeWindow.getX()&NativeWindow.getY(), and size,NativeWindow.getWidth()&NativeWindow.getHeight(), in window units.- Specified by:
getBoundsin interfaceNativeWindow
-
getSurfaceWidth
public final int getSurfaceWidth()
Description copied from interface:GLDrawableReturns the width of thisGLDrawable'ssurfaceclient area in pixel units.- Specified by:
getSurfaceWidthin interfaceGLDrawable- Specified by:
getSurfaceWidthin interfaceNativeSurface- Overrides:
getSurfaceWidthin classjogamp.opengl.GLAutoDrawableBase- Returns:
- width of the client area in pixel units
- See Also:
NativeSurface.getSurfaceWidth()
-
getSurfaceHeight
public final int getSurfaceHeight()
Description copied from interface:GLDrawableReturns the height of thisGLDrawable'ssurfaceclient area in pixel units.- Specified by:
getSurfaceHeightin interfaceGLDrawable- Specified by:
getSurfaceHeightin interfaceNativeSurface- Overrides:
getSurfaceHeightin classjogamp.opengl.GLAutoDrawableBase- Returns:
- height of the client area in pixel units
- See Also:
NativeSurface.getSurfaceHeight()
-
getSurfaceBounds
public final Rectangle getSurfaceBounds()
Description copied from interface:NativeWindowReturns a newly createdRectanglecontaining window's surface origin and size in pixel units.- Specified by:
getSurfaceBoundsin interfaceNativeWindow
-
convertToWindowUnits
public final int[] convertToWindowUnits(int[] pixelUnitsAndResult)
Description copied from interface:NativeSurfaceConverts the given pixel units into window units in place.- Specified by:
convertToWindowUnitsin interfaceNativeSurface- Parameters:
pixelUnitsAndResult- int[2] storage holding the pixel units for the x- and y-coord to convert and the resulting values.- Returns:
- result int[2] storage pixelUnitsAndResult for chaining holding the converted values
- See Also:
ScalableSurface
-
convertToPixelUnits
public final int[] convertToPixelUnits(int[] windowUnitsAndResult)
Description copied from interface:NativeSurfaceConverts the given window units into pixel units in place.- Specified by:
convertToPixelUnitsin interfaceNativeSurface- Parameters:
windowUnitsAndResult- int[2] storage holding the window units for the x- and y-coord to convert and the resulting values.- Returns:
- result int[2] storage windowUnitsAndResult for chaining holding the converted values
- See Also:
ScalableSurface
-
canSetSurfaceScale
public final boolean canSetSurfaceScale()
Returns true ifScalableSurface.setSurfaceScale(float[])is supported, otherwise false.For pure downstream scalable surfaces like AWT widgets, setting the picel scale is not supported since the pixel scale is set by the underlying toolkit.
This implementation returns true, i.e. supporting manual change of pixel-scale.
- Specified by:
canSetSurfaceScalein interfaceScalableSurface
-
setSurfaceScale
public final boolean setSurfaceScale(float[] pixelScale)
Description copied from interface:ScalableSurfaceRequest a pixel scale in x- and y-direction for the associatedNativeSurface, wheresize_in_pixel_units = pixel_scale * size_in_window_units.Default pixel scale request for both directions is
ScalableSurface.AUTOMAX_PIXELSCALE.If
ScalableSurface.canSetSurfaceScale()returns false, requested pixel scale isScalableSurface.AUTOMAX_PIXELSCALE, immutable and method returns false.In case platform only supports uniform pixel scale, i.e. one scale for both directions, either
ScalableSurface.AUTOMAX_PIXELSCALEor the maximum requested pixel scale component is used.The requested pixel scale will be validated against platform limits before native scale-setup, i.e. clipped to
ScalableSurface.IDENTITY_PIXELSCALEif not supported or clipped to the platform maximum. It can be queried viaScalableSurface.getRequestedSurfaceScale(float[]).The actual realized pixel scale values of the
NativeSurfacecan be queried viaScalableSurface.getCurrentSurfaceScale(float[])or computed viasurface.convertToPixelUnits(new int[] { 1, 1 })- Specified by:
setSurfaceScalein interfaceScalableSurface- Parameters:
pixelScale- requested surface pixel scale float[2] values for x- and y-direction.- Returns:
trueif thecurrent pixel scalehas changed, otherwisefalse.- See Also:
ScalableSurface.getRequestedSurfaceScale(float[]),ScalableSurface.canSetSurfaceScale()
-
getRequestedSurfaceScale
public final float[] getRequestedSurfaceScale(float[] result)
Description copied from interface:ScalableSurfaceReturns therequestedpixel scale of the associatedNativeSurface.If
ScalableSurface.canSetSurfaceScale()returns false, requested pixel scale isScalableSurface.AUTOMAX_PIXELSCALEand immutable.- Specified by:
getRequestedSurfaceScalein interfaceScalableSurface- Parameters:
result- float[2] storage for the result- Returns:
- the passed storage containing the current pixelScale for chaining
- See Also:
ScalableSurface.setSurfaceScale(float[]),ScalableSurface.canSetSurfaceScale()
-
getCurrentSurfaceScale
public final float[] getCurrentSurfaceScale(float[] result)
Description copied from interface:ScalableSurfaceReturns the current pixel scale of the associatedNativeSurface.- Specified by:
getCurrentSurfaceScalein interfaceScalableSurface- Parameters:
result- float[2] storage for the result- Returns:
- the passed storage containing the current pixelScale for chaining
-
getMinimumSurfaceScale
public final float[] getMinimumSurfaceScale(float[] result)
Description copied from interface:ScalableSurfaceReturns the minimum pixel scale of the associatedNativeSurface.- Specified by:
getMinimumSurfaceScalein interfaceScalableSurface- Parameters:
result- float[2] storage for the result- Returns:
- the passed storage containing the minimum pixelScale for chaining
-
getMaximumSurfaceScale
public final float[] getMaximumSurfaceScale(float[] result)
Description copied from interface:ScalableSurfaceReturns the maximum pixel scale of the associatedNativeSurface.The maximum pixel scale maybe used to determine the proper dpi value of the monitor displaying this
NativeSurface.surfacePpMM = monitorPpMM * currentSurfaceScale / nativeSurfaceScale, with PpMM == pixel per millimeter- Specified by:
getMaximumSurfaceScalein interfaceScalableSurface- Parameters:
result- float[2] storage for the result- Returns:
- the passed storage containing the maximum pixelScale for chaining
-
getPixelsPerMM
public final float[] getPixelsPerMM(float[] ppmmStore)
Description copied from interface:WindowReturns the pixels per millimeter of this window'sNativeSurfaceaccording to themain monitor's currentmode'ssurface resolution.Method takes the
current surface-scaleandnative surface-scaleinto account, i.e.:surfacePpMM = monitorPpMM * currentSurfaceScale / nativeSurfaceScale, with PpMM == pixel per millimeterTo convert the result to dpi, i.e. dots-per-inch, multiply both components with
25.4f.- Specified by:
getPixelsPerMMin interfaceWindow- Parameters:
ppmmStore- float[2] storage for the ppmm result- Returns:
- the passed storage containing the ppmm for chaining
-
setPosition
public final void setPosition(int x, int y)Description copied from interface:WindowSets the location of the window's client area excluding insets (window decorations) in window units.
This call is ignored if in fullscreen mode.- Specified by:
setPositionin interfaceWindow- Parameters:
x- coord of the client-area's top left corner in window unitsy- coord of the client-area's top left corner in window units- See Also:
NativeWindow.getInsets()
-
setTopLevelPosition
public void setTopLevelPosition(int x, int y)Description copied from interface:WindowSets the location of the top-level window inclusive insets (window decorations) in window units.
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:
setTopLevelPositionin interfaceWindow- Parameters:
x- coord of the top-level left corner in window unitsy- coord of the top-level left corner in window units- See Also:
Window.setPosition(int, int),NativeWindow.getInsets()
-
setFullscreen
public final boolean setFullscreen(boolean fullscreen)
Description copied from interface:WindowEnable or disable fullscreen mode for this window.Fullscreen mode is established on the
main monitor.This method is lifecycle heavy.
- Specified by:
setFullscreenin interfaceWindow- 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:WindowEnable fullscreen mode for this window spanning across the givenMonitorDevices or across allMonitorDevices.Disable fullscreen via
Window.setFullscreen(boolean).This method is lifecycle heavy.
- Specified by:
setFullscreenin interfaceWindow- Parameters:
monitors- ifnullfullscreen will be spanned across allMonitorDevices, otherwise across the given list ofMonitorDevice.- Returns:
- success
- See Also:
Window.setFullscreen(boolean),Window.isFullscreen()
-
isFullscreen
public final boolean isFullscreen()
- Specified by:
isFullscreenin interfaceWindow
-
isVisible
public final boolean isVisible()
- Specified by:
isVisiblein interfaceWindow- See Also:
Window.STATE_BIT_VISIBLE,Window.setVisible(boolean, boolean)
-
toSimpleString
public final StringBuilder toSimpleString(StringBuilder sb)
Description copied from interface:WindowAppends this class simple string one-line representation to the givenStringBuilderinstance- Specified by:
toSimpleStringin interfaceWindow- Parameters:
sb- given instance where this class simple string representation is added to- Returns:
- the given
StringBuilderfor chaining
-
toSimpleString
public final String toSimpleString()
Description copied from interface:WindowReturns a simple string one-line representation of this instance usingWindow.toSimpleString(StringBuilder).- Specified by:
toSimpleStringin interfaceWindow
-
toString
public final StringBuilder toString(StringBuilder sb)
Description copied from interface:WindowAppends this class full string multi-line representation to the givenStringBuilderinstance- Specified by:
toStringin interfaceWindow- Parameters:
sb- given instance where this class full string representation is added to- Returns:
- the given
StringBuilderfor chaining
-
toString
public final String toString()
Description copied from interface:WindowReturns a full string multi-line representation of this instance usingWindow.toString(StringBuilder).- Specified by:
toStringin interfaceGLDrawable- Specified by:
toStringin interfaceWindow- Overrides:
toStringin classjogamp.opengl.GLAutoDrawableBase
-
reparentWindow
public final Window.ReparentOperation reparentWindow(NativeWindow newParent, int x, int y, int hints)
Description copied from interface:WindowChange 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.This method is lifecycle heavy.
- Specified by:
reparentWindowin interfaceWindow- Parameters:
newParent- 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) likeWindow.REPARENT_HINT_FORCE_RECREATIONorWindow.REPARENT_HINT_BECOMES_VISIBLE.- Returns:
- The issued reparent action type (strategy) as defined in Window.ReparentAction
-
isChildWindow
public final boolean isChildWindow()
Description copied from interface:WindowReturnstrueif this window is a child window, i.e. has beenreparented.Otherwise return
false, i.e. this window is a top-level window.- Specified by:
isChildWindowin interfaceWindow
-
removeChild
public final boolean removeChild(NativeWindow win)
- Specified by:
removeChildin interfaceWindow
-
addChild
public final boolean addChild(NativeWindow win)
-
destroy
public final void destroy()
Description copied from interface:GLAutoDrawableDestroys 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 callingdispose(..)for all registeredGLEventListeners. Called automatically by the window system toolkit upon receiving a destroy notification. This routine may be called manually.- Specified by:
destroyin interfaceGLAutoDrawable- Specified by:
destroyin interfaceNativeWindow- Specified by:
destroyin interfaceWindow- See Also:
Window.destroy(),Window.setVisible(boolean)
-
setWindowDestroyNotifyAction
public void setWindowDestroyNotifyAction(Runnable r)
Description copied from interface:WindowSet a custom action handling destruction issued by atoolkit triggered window destroyreplacing the defaultWindow.destroy()action.The custom action shall call
Window.destroy()but may perform further tasks before and after.- Specified by:
setWindowDestroyNotifyActionin interfaceWindow
-
setVisible
public final void setVisible(boolean visible)
Description copied from interface:WindowCallssetVisible(true, visible), i.e. blocks until the window becomes visible.This method is lifecycle heavy.
- Specified by:
setVisiblein interfaceWindow- See Also:
Window.setVisible(boolean, boolean),Window.STATE_BIT_VISIBLE
-
setVisible
public void setVisible(boolean wait, boolean visible)Description copied from interface:WindowsetVisible(..)makes the window and children visible ifvisibleis true, otherwise the window and children becomes invisible.Native instance gets created at first visibility, following NEWT's lazy creation pattern.
If
waitis true, method blocks until window isvisibleandvalid, 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 windowand has aNativeWindowparent,
setVisible(wait, true)has no effect as long the parent's is not valid yet, i.e.NativeWindow.getWindowHandle()returnsnull.
setVisible(wait, true)shall be repeated when the parent becomes valid.This method is lifecycle heavy.
- Specified by:
setVisiblein interfaceWindow- See Also:
Window.STATE_BIT_VISIBLE
-
setSize
public final void setSize(int width, int height)Description copied from interface:WindowSets the size of the window's client area in window units, 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:
setSizein interfaceWindow- Parameters:
width- of the window's client area in window unitsheight- of the window's client area in window units- See Also:
Window.setSurfaceSize(int, int),Window.setTopLevelSize(int, int),NativeWindow.getInsets()
-
setSurfaceSize
public final void setSurfaceSize(int pixelWidth, int pixelHeight)Description copied from interface:WindowSets the size of the window's surface in pixel units which claims the window's client area excluding decorations.In multiple monitor mode, setting the window's surface size in pixel units might not be possible due to unknown scale values of the target display. Hence re-setting the pixel unit size after window creation is recommended.
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:
setSurfaceSizein interfaceWindow- Parameters:
pixelWidth- of the window's client area in pixel unitspixelHeight- of the window's client area in pixel units- See Also:
Window.setSize(int, int),NativeWindow.getInsets()
-
setTopLevelSize
public void setTopLevelSize(int width, int height)Description copied from interface:WindowSets the size of the top-level window including insets (window decorations) in window units.Note: Insets (if supported) are available only after the window is set visible and hence has been created.
- Specified by:
setTopLevelSizein interfaceWindow- Parameters:
width- of the top-level window area in window unitsheight- of the top-level window area in window units- See Also:
Window.setSize(int, int),NativeWindow.getInsets()
-
isNativeValid
public final boolean isNativeValid()
- Specified by:
isNativeValidin interfaceWindow- 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:NativeWindowReturns the window's top-left client-area position in the screen.If
Pointis notnull, 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.
- Specified by:
getLocationOnScreenin interfaceNativeWindow- Parameters:
storage- OptionalPointstorage. If not null,null, it is translated about the resulting screen position and returned.- See Also:
NativeWindow.getX(),NativeWindow.getY(),NativeWindow.getInsets()
-
display
public void display()
Description copied from interface:GLAutoDrawableCauses OpenGL rendering to be performed for this GLAutoDrawable in the following order:
- Calling
display(..)for all registeredGLEventListeners. - Executes all one-shot
GLRunnable, enqueued viaGLAutoDrawable.invoke(boolean, GLRunnable).
May be called periodically by a running
GLAnimatorControlimplementation,
which must register itself withGLAutoDrawable.setAnimator(com.jogamp.opengl.GLAnimatorControl).Called automatically by the window system toolkit upon receiving a repaint() request,
except anGLAnimatorControlimplementationGLAnimatorControl.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 registeredGLEventListeners before making the actualdisplay(..)calls, in case this has not been done yet.- Specified by:
displayin interfaceGLAutoDrawable- See Also:
GLAutoDrawable.setAnimator(com.jogamp.opengl.GLAnimatorControl)
- Calling
-
isGLStatePreservationSupported
public final boolean isGLStatePreservationSupported()
GLWindow supports GL state preservation, hence returns
true.- Specified by:
isGLStatePreservationSupportedin interfaceGLStateKeeper- Overrides:
isGLStatePreservationSupportedin classjogamp.opengl.GLAutoDrawableBase- Returns:
trueif GL state preservation is supported in implementation and on current platform,falseotherwise.- See Also:
GLStateKeeper.preserveGLStateAtDestroy(boolean),GLStateKeeper.getPreservedGLState(),GLStateKeeper.clearPreservedGLState()
-
getFactory
public final GLDrawableFactory getFactory()
Description copied from interface:GLDrawableReturn theGLDrawableFactorybeing used to create this instance.- Specified by:
getFactoryin interfaceGLDrawable
-
swapBuffers
public final void swapBuffers() throws GLExceptionDescription copied from interface:GLDrawableSwaps the front and back buffers of this drawable. ForGLAutoDrawableimplementations, 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:
swapBuffersin interfaceGLDrawable- Throws:
GLException
-
consumeEvent
public boolean consumeEvent(NEWTEvent event)
Description copied from interface:NEWTEventConsumerConsume the event- Specified by:
consumeEventin interfaceNEWTEventConsumer- Returns:
- true if the event has been consumed, otherwise it returns false for later propagation.
-
windowRepaint
public final boolean windowRepaint(int x, int y, int width, int height)Description copied from interface:WindowTrigger window repaint while passing the dirty region in pixel units.- Specified by:
windowRepaintin interfaceWindow- Parameters:
x- 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 units- Returns:
- true if window
Window.isNativeValid()
-
enqueueEvent
public final void enqueueEvent(boolean wait, NEWTEvent event)Description copied from interface:WindowEnqueues aNEWT event.- Specified by:
enqueueEventin interfaceWindow- Parameters:
wait- Passingtruewill block until the event has been processed, otherwise method returns immediately.event- Theeventto enqueue.
-
runOnEDTIfAvail
public final void runOnEDTIfAvail(boolean wait, Runnable task)- Specified by:
runOnEDTIfAvailin interfaceWindow
-
sendWindowEvent
public void sendWindowEvent(int eventType)
Description copied from interface:WindowSend aWindowEventto allWindowListener.- Specified by:
sendWindowEventin interfaceWindow- Parameters:
eventType- aWindowEventtype, e.g.WindowEvent.EVENT_WINDOW_REPAINT.
-
getWindowListener
public final WindowListener getWindowListener(int index)
- Specified by:
getWindowListenerin interfaceWindow
-
getWindowListeners
public final WindowListener[] getWindowListeners()
- Specified by:
getWindowListenersin interfaceWindow
-
removeWindowListener
public final void removeWindowListener(WindowListener l)
- Specified by:
removeWindowListenerin interfaceWindow
-
addWindowListener
public final void addWindowListener(WindowListener l)
Description copied from interface:WindowAppends the givenWindowListenerto the end of the list.- Specified by:
addWindowListenerin interfaceWindow
-
addWindowListener
public final void addWindowListener(int index, WindowListener l) throws IndexOutOfBoundsExceptionDescription copied from interface:WindowInserts the givenWindowListenerat the specified position in the list.- Specified by:
addWindowListenerin interfaceWindow- 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:WindowIn case the platform supports or even requires a virtual on-screen keyboard, this method shows or hide it depending on whethervisibleistrueorfalse.One known platform where NEWT supports this feature is
Android.- Specified by:
setKeyboardVisiblein interfaceWindow
-
isKeyboardVisible
public final boolean isKeyboardVisible()
Description copied from interface:WindowReturntrueif the virtual on-screen keyboard is visible, otherwisefalse.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:
isKeyboardVisiblein interfaceWindow- See Also:
Window.setKeyboardVisible(boolean)
-
addKeyListener
public final void addKeyListener(KeyListener l)
Description copied from interface:WindowAppends the givenKeyListenerto the end of the list.- Specified by:
addKeyListenerin interfaceWindow
-
addKeyListener
public final void addKeyListener(int index, KeyListener l)Description copied from interface:WindowInserts the givenKeyListenerat the specified position in the list.- Specified by:
addKeyListenerin interfaceWindow- 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:
removeKeyListenerin interfaceWindow
-
getKeyListener
public final KeyListener getKeyListener(int index)
- Specified by:
getKeyListenerin interfaceWindow
-
getKeyListeners
public final KeyListener[] getKeyListeners()
- Specified by:
getKeyListenersin interfaceWindow
-
addMouseListener
public final void addMouseListener(MouseListener l)
Description copied from interface:WindowAppends the givenMouseListenerto the end of the list.- Specified by:
addMouseListenerin interfaceWindow
-
addMouseListener
public final void addMouseListener(int index, MouseListener l)Description copied from interface:WindowInserts the givenMouseListenerat the specified position in the list.- Specified by:
addMouseListenerin interfaceWindow- 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)
Description copied from interface:WindowRemoves the givenMouseListenerfrom the list.- Specified by:
removeMouseListenerin interfaceWindow
-
getMouseListener
public final MouseListener getMouseListener(int index)
Description copied from interface:WindowReturns theMouseListenerfrom the list at the given index.- Specified by:
getMouseListenerin interfaceWindow
-
getMouseListeners
public final MouseListener[] getMouseListeners()
Description copied from interface:WindowReturns allMouseListener- Specified by:
getMouseListenersin interfaceWindow
-
setDefaultGesturesEnabled
public void setDefaultGesturesEnabled(boolean enable)
Description copied from interface:WindowEnable or disable defaultGestureHandler. Default is enabled.- Specified by:
setDefaultGesturesEnabledin interfaceWindow
-
areDefaultGesturesEnabled
public boolean areDefaultGesturesEnabled()
Description copied from interface:WindowReturn true if defaultGestureHandlerare enabled.- Specified by:
areDefaultGesturesEnabledin interfaceWindow
-
addGestureHandler
public final void addGestureHandler(GestureHandler gh)
Description copied from interface:WindowAppends the givenGestureHandlerto the end of the list.- Specified by:
addGestureHandlerin interfaceWindow
-
addGestureHandler
public final void addGestureHandler(int index, GestureHandler gh)Description copied from interface:WindowInserts the givenGestureHandlerat the specified position in the list.- Specified by:
addGestureHandlerin interfaceWindow- 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().
-
removeGestureHandler
public final void removeGestureHandler(GestureHandler gh)
Description copied from interface:WindowRemoves the givenGestureHandlerfrom the list.- Specified by:
removeGestureHandlerin interfaceWindow
-
addGestureListener
public final void addGestureListener(GestureHandler.GestureListener gl)
Description copied from interface:WindowAppends the givenGestureHandler.GestureListenerto the end of the list.- Specified by:
addGestureListenerin interfaceWindow
-
addGestureListener
public final void addGestureListener(int index, GestureHandler.GestureListener gl)Description copied from interface:WindowInserts the givenGestureHandler.GestureListenerat the specified position in the list.- Specified by:
addGestureListenerin interfaceWindow- 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().
-
removeGestureListener
public final void removeGestureListener(GestureHandler.GestureListener gl)
Description copied from interface:WindowRemoves the givenGestureHandler.GestureListenerfrom the list.- Specified by:
removeGestureListenerin interfaceWindow
-
getLock
public RecursiveLock getLock()
Description copied from interface:NativeSurfaceReturns the implementation'sRecursiveLocksynchronizing multithreaded access if used. Otherwisenullis being returned.NativeSurface'sRecursiveLockis only exposed to resolve special situations within the implementation and its usage is not advised if not absolutely necessary.Note that certain
NativeSurfaceimplementations only use theRecursiveLockas an upfront re-entrance lock vehicle, but actually acquire and release the underlying windowing toolkit's lock facility on the first or last re-entrance lock, respectively.- Specified by:
getLockin interfaceNativeSurface
-
lockSurface
public final int lockSurface() throws NativeWindowException, RuntimeExceptionDescription copied from interface:NativeSurfaceLock 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_UNLOCKEDandNativeSurface.LOCK_SURFACE_NOT_READY, which isboolean 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
RecursiveLockfirst before proceeding with a native surface lock.The implementation shall also invoke
AbstractGraphicsDevice.lock()for the initial lock (recursive count zero).- Specified by:
lockSurfacein interfaceNativeSurface- Returns:
NativeSurface.LOCK_SUCCESS,NativeSurface.LOCK_SURFACE_CHANGEDorNativeSurface.LOCK_SURFACE_NOT_READY.- Throws:
NativeWindowException- if native locking failed, maybe platform relatedRuntimeException- after timeout when waiting for the surface lock- See Also:
RecursiveLock
-
unlockSurface
public final void unlockSurface()
Description copied from interface:NativeSurfaceUnlock the surface of this native window Shall not modify the surface handle, seeNativeSurface.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:
unlockSurfacein interfaceNativeSurface- See Also:
NativeSurface.lockSurface(),RecursiveLock
-
isSurfaceLockedByOtherThread
public final boolean isSurfaceLockedByOtherThread()
Description copied from interface:NativeSurfaceQuery 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:
isSurfaceLockedByOtherThreadin interfaceNativeSurface
-
getSurfaceLockOwner
public final Thread getSurfaceLockOwner()
Description copied from interface:NativeSurfaceReturn the locking owner's Thread, or null if not locked.- Specified by:
getSurfaceLockOwnerin interfaceNativeSurface
-
surfaceSwap
public final boolean surfaceSwap()
Description copied from interface:NativeSurfaceProvide 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:
surfaceSwapin interfaceNativeSurface- Returns:
- true if this method completed swapping the surface, otherwise false, in which case eg the GLDrawable implementation has to swap the code.
-
removeSurfaceUpdatedListener
public final void removeSurfaceUpdatedListener(SurfaceUpdatedListener l)
Description copied from interface:NativeSurfaceRemove the specifiedSurfaceUpdatedListenerfrom the list.- Specified by:
removeSurfaceUpdatedListenerin interfaceNativeSurface
-
addSurfaceUpdatedListener
public final void addSurfaceUpdatedListener(SurfaceUpdatedListener l)
Description copied from interface:NativeSurfaceAppends the givenSurfaceUpdatedListenerto the end of the list.- Specified by:
addSurfaceUpdatedListenerin interfaceNativeSurface
-
addSurfaceUpdatedListener
public final void addSurfaceUpdatedListener(int index, SurfaceUpdatedListener l) throws IndexOutOfBoundsExceptionDescription copied from interface:NativeSurfaceInserts the givenSurfaceUpdatedListenerat the specified position in the list.- Specified by:
addSurfaceUpdatedListenerin interfaceNativeSurface- 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
-
surfaceUpdated
public final void surfaceUpdated(Object updater, NativeSurface ns, long when)
Description copied from interface:SurfaceUpdatedListenerNotification of a surface update event, eg. after a swap buffer operation.- Specified by:
surfaceUpdatedin interfaceSurfaceUpdatedListener- Parameters:
updater- 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 updated
-
getWindowHandle
public final long getWindowHandle()
Description copied from interface:NativeWindowReturns 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:
getWindowHandlein interfaceNativeWindow
-
getSurfaceHandle
public final long getSurfaceHandle()
Description copied from interface:NativeSurfaceReturns the handle to the surface for this NativeSurface.The surface handle should be set/update by
NativeSurface.lockSurface(), whereNativeSurface.unlockSurface()is not allowed to modify it. AfterNativeSurface.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:
getSurfaceHandlein interfaceNativeSurface
-
getGraphicsConfiguration
public final AbstractGraphicsConfiguration getGraphicsConfiguration()
Description copied from interface:NativeSurfaceReturns 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
AbstractGraphicsConfigurationviaAbstractGraphicsConfiguration.getNativeGraphicsConfiguration().- Specified by:
getGraphicsConfigurationin interfaceNativeSurface- See Also:
AbstractGraphicsConfiguration.getNativeGraphicsConfiguration(),com.jogamp.nativewindow.GraphicsConfigurationFactory#chooseGraphicsConfiguration(Capabilities, CapabilitiesChooser, AbstractGraphicsScreen)
-
getDisplayHandle
public final long getDisplayHandle()
Description copied from interface:NativeSurfaceConvenience: Get display handle from AbstractGraphicsConfiguration . AbstractGraphicsScreen . AbstractGraphicsDevice- Specified by:
getDisplayHandlein interfaceNativeSurface
-
getScreenIndex
public final int getScreenIndex()
Description copied from interface:NativeSurfaceConvenience: Get display handle from AbstractGraphicsConfiguration . AbstractGraphicsScreen- Specified by:
getScreenIndexin interfaceNativeSurface
-
main
public static void main(String[] args)
A most simple JOGL AWT test entry
-
-