35package com.jogamp.newt;
37import java.security.PrivilegedAction;
38import java.util.Arrays;
40import com.jogamp.nativewindow.AbstractGraphicsConfiguration;
41import com.jogamp.nativewindow.AbstractGraphicsDevice;
42import com.jogamp.nativewindow.AbstractGraphicsScreen;
43import com.jogamp.nativewindow.CapabilitiesImmutable;
44import com.jogamp.nativewindow.NativeWindow;
45import com.jogamp.nativewindow.NativeWindowException;
46import com.jogamp.nativewindow.NativeWindowFactory;
48import com.jogamp.common.util.IOUtil;
49import com.jogamp.common.util.PropertyAccess;
50import com.jogamp.common.util.SecurityUtil;
52import jogamp.newt.Debug;
53import jogamp.newt.DisplayImpl;
54import jogamp.newt.ScreenImpl;
55import jogamp.newt.WindowImpl;
62 private static IOUtil.ClassResources defaultWindowIcons;
63 private static String sysPaths =
"jogamp/newt/assets/jogamp-16x16.png jogamp/newt/assets/jogamp-32x32.png";
66 SecurityUtil.doPrivileged(
new PrivilegedAction<Object>() {
72 final String[] paths = PropertyAccess.getProperty(
"newt.window.icons",
true, sysPaths).split(
"[\\s,]");
73 if( paths.length < 2 ) {
74 throw new IllegalArgumentException(
"Property 'newt.window.icons' did not specify at least two PNG icons, but "+Arrays.toString(paths));
76 defaultWindowIcons =
new IOUtil.ClassResources(paths,
NewtFactory.class.getClassLoader(),
null);
92 public static IOUtil.ClassResources
getWindowIcons() {
return defaultWindowIcons; }
100 public static void setWindowIcons(
final IOUtil.ClassResources cres) { defaultWindowIcons = cres; }
102 public static Class<?>
getCustomClass(
final String packageName,
final String classBaseName) {
103 Class<?> clazz =
null;
104 final String clazzName;
105 if(packageName!=
null && classBaseName!=
null) {
106 if( packageName.startsWith(
".") ) {
109 clazzName = packageName +
"." + classBaseName ;
112 clazz = Class.forName(clazzName);
113 }
catch (
final Throwable t) {
114 throw new NativeWindowException(
"Failed to find or initialize class <"+packageName+
"."+classBaseName+
"> -> <"+clazzName+
">: "+t.getMessage(), t);
119 if(
null == clazz ) {
120 throw new NativeWindowException(
"Failed to determine class <"+packageName+
"."+classBaseName+
"> -> <"+clazzName+
">");
125 private static boolean useEDT =
true;
132 public static synchronized void setUseEDT(
final boolean onoff) {
206 return DisplayImpl.create(type, name, 0, reuse);
220 return ScreenImpl.create(display, index);
251 return WindowImpl.create(
null, 0, screen, caps);
278 if(
null == parentWindow ) {
279 return createWindowImpl(type, caps);
282 Window newtParentWindow =
null;
284 if ( parentWindow instanceof
Window ) {
286 newtParentWindow = (
Window) parentWindow ;
291 if(
null!=parentConfig) {
301 final Window win = WindowImpl.create(parentWindow, 0, screen, caps);
304 if (
null != newtParentWindow ) {
314 return WindowImpl.create(
null, 0, screen, caps);
330 return WindowImpl.create(
null, parentWindowHandle, screen, caps);
341 return WindowImpl.create(cstrArguments, screen, caps);
348 return DisplayImpl.create(type,
null, handle, reuse);
357 final DisplayImpl childDisplay = (DisplayImpl) childScreen.
getDisplay();
358 final String parentDisplayName = childDisplay.validateDisplayName(
null, parentDevice.
getHandle());
359 final String childDisplayName = childDisplay.
getName();
360 if( ! parentDisplayName.equals( childDisplayName ) ) {
380 if(
null != childScreen) {
382 final DisplayImpl childDisplay = (DisplayImpl) childScreen.
getDisplay();
383 final String parentDisplayName = childDisplay.validateDisplayName(
null, parentDevice.
getHandle());
384 final String childDisplayName = childDisplay.
getName();
385 final boolean displayEqual = parentDisplayName.equals( childDisplayName );
386 final boolean screenEqual = parentScreen.
getIndex() == childScreen.
getIndex();
388 System.err.println(
"NewtFactory.createCompatibleScreen: Display: "+
389 parentDisplayName+
" =? "+childDisplayName+
" : "+displayEqual+
"; Screen: "+
392 if( displayEqual && screenEqual ) {
A generic exception for OpenGL errors used throughout the binding as a substitute for RuntimeExceptio...
Provides a pluggable mechanism for arbitrary window toolkits to adapt their components to the NativeW...
static synchronized void initSingleton()
Static one time initialization of this factory.
static String getNativeWindowType(final boolean useCustom)
abstract String getName()
static Window createWindow(final Object[] cstrArguments, final Screen screen, final CapabilitiesImmutable caps)
Ability to try a Window type with a constructor argument, if supported ..
static boolean isScreenCompatible(final NativeWindow parent, final Screen childScreen)
static Window createWindow(final String displayConnection, final int screenIdx, final long parentWindowHandle, final CapabilitiesImmutable caps)
Create a child Window entity attached to the given parent, incl native creation
static Class<?> getCustomClass(final String packageName, final String classBaseName)
static Display createDisplay(final String name)
Create a Display entity.
static final String DRIVER_DEFAULT_ROOT_PACKAGE
static Display createDisplay(final String type, final String name, final boolean reuse)
Create a Display entity.
static Window createWindow(final Screen screen, final CapabilitiesImmutable caps)
Create a top level Window entity.
static Display createDisplay(final String name, final boolean reuse)
Create a Display entity.
static final boolean DEBUG_IMPLEMENTATION
static Display createDisplay(final String type, final String name)
Create a Display entity.
static synchronized void setUseEDT(final boolean onoff)
Toggles the usage of an EventDispatchThread while creating a Display.
static Window createWindow(final NativeWindow parentWindow, final CapabilitiesImmutable caps)
Create a child Window entity attached to the given parent.
static Window createWindow(final CapabilitiesImmutable caps)
Create a top level Window entity on the default Display and default Screen.
static void setWindowIcons(final IOUtil.ClassResources cres)
Allow user to set custom window icons, only applicable at application start before creating any NEWT ...
static Screen createCompatibleScreen(final NativeWindow parent, final Screen childScreen)
static IOUtil.ClassResources getWindowIcons()
Returns the application window icon resources to be used.
static Screen createCompatibleScreen(final NativeWindow parent)
static Screen createScreen(final Display display, final int index)
Create a Screen entity.
static Display createDisplay(final String type, final long handle, final boolean reuse)
Instantiate a Display entity using the native handle.
A screen may span multiple MonitorDevices representing their combined virtual size.
abstract Display getDisplay()
A marker interface describing a graphics configuration, visual, or pixel format in a toolkit-independ...
AbstractGraphicsScreen getScreen()
Return the screen this graphics configuration is valid for.
A interface describing a graphics device in a toolkit-independent manner.
long getHandle()
Returns the native handle of the underlying native device, if such thing exist.
A interface describing a graphics screen in a toolkit-independent manner.
int getIndex()
Returns the screen index this graphics screen is valid for.
AbstractGraphicsDevice getDevice()
Return the device this graphics configuration is valid for.
Specifies an immutable set of capabilities that a window's rendering context must support,...
AbstractGraphicsConfiguration getGraphicsConfiguration()
Returns the graphics configuration corresponding to this window.
Extend the NativeSurface interface with windowing information such as window-handle,...
int getHeight()
Returns the height of the client area excluding insets (window decorations) in window units.
int getWidth()
Returns the width of the client area excluding insets (window decorations) in window units.
Specifying NEWT's Window functionality:
boolean addChild(NativeWindow win)
void setSize(int width, int height)
Sets the size of the window's client area in window units, excluding decorations.
void setVisible(boolean visible)
Calls setVisible(true, visible), i.e.