com.sun.javafx.newt
Class Window

java.lang.Object
  extended by com.sun.javafx.newt.Window
All Implemented Interfaces:
NativeWindow
Direct Known Subclasses:
GLWindow

public abstract class Window
extends Object
implements NativeWindow


Field Summary
static int ClickTimeout
           
protected  AbstractGraphicsConfiguration config
           
static boolean DEBUG_IMPLEMENTATION
           
static boolean DEBUG_KEY_EVENT
           
static boolean DEBUG_MOUSE_EVENT
           
static boolean DEBUG_WINDOW_EVENT
           
protected  int eventMask
           
protected  boolean fullscreen
           
protected  int height
           
protected  Exception lockedStack
           
protected  Screen screen
           
protected  String title
           
protected  boolean undecorated
           
protected  boolean visible
           
protected  int width
           
protected  long windowHandle
           
protected  int x
           
protected  int y
           
 
Fields inherited from interface javax.media.nativewindow.NativeWindow
LOCK_SUCCESS, LOCK_SURFACE_CHANGED, LOCK_SURFACE_NOT_READY
 
Constructor Summary
Window()
           
 
Method Summary
 void addKeyListener(KeyListener l)
           
 void addMouseListener(MouseListener l)
           
 void addPaintListener(PaintListener l)
           
 void addWindowListener(WindowListener l)
           
protected  void clearEventMask()
           
protected abstract  void closeNative()
           
protected static Window create(String type, long parentWindowHandle, Screen screen, Capabilities caps, boolean undecorated)
           
protected static Window create(String type, Object[] cstrArguments, Screen screen, Capabilities caps, boolean undecorated)
           
protected abstract  void createNative(long parentWindowHandle, Capabilities caps)
          Create native windowHandle, ie creates a new native invisible window.
 void destroy()
          destroys the window and releases windowing related resources.
 void disposeSurfaceHandle()
          Special method to dispose a surface handle, in case of a device change _and_ where there is a different semantics of window handle and surface handle.
 long getDisplayHandle()
          Convenience: Get display handle from AbstractGraphicsConfiguration .
 AbstractGraphicsConfiguration getGraphicsConfiguration()
          Returns the graphics configuration corresponding to this window.
 int getHeight()
          Returns the height of the client area of this window
 Insets getInsets()
          Returns the insets for this native window (the difference between the size of the toplevel window with the decorations and the client area).
 KeyListener[] getKeyListeners()
           
 Exception getLockedStack()
          Return the lock-exception, or null if not locked.
 MouseListener[] getMouseListeners()
           
 Screen getScreen()
           
 int getScreenIndex()
          Convenience: Get display handle from AbstractGraphicsConfiguration .
 long getSurfaceHandle()
          Returns the handle to the surface for this NativeWindow.
 String getTitle()
           
 int getWidth()
          Returns the width of the client area of this window
 long getWindowHandle()
          Returns the window handle for this NativeWindow.
 WindowListener[] getWindowListeners()
           
 Object getWrappedWindow()
          If this Window actually wraps one from another toolkit such as the AWT, this will return a non-null value.
 int getX()
           
 int getY()
           
 boolean hasDeviceChanged()
          If the implementation is capable of detecting a device change return true and clear the status/reason of the change.
 void invalidate()
          render all native window information invalid, as if the native window was destroyed
 boolean isFullscreen()
           
 boolean isSurfaceLocked()
          Return if surface is locked
 boolean isUndecorated()
           
 boolean isVisible()
           
 int lockSurface()
          Lock the surface of this native window
 void removeKeyListener(KeyListener l)
           
 void removeMouseListener(MouseListener l)
           
 void removePaintListener(PaintListener l)
           
 void removeWindowListener(WindowListener l)
           
 void requestFocus()
           
protected  void sendKeyEvent(int eventType, int modifiers, int keyCode, char keyChar)
           
protected  void sendMouseEvent(int eventType, int modifiers, int x, int y, int button, int rotation)
           
protected  void sendPaintEvent(int eventType, int x, int y, int w, int h)
           
protected  void sendWindowEvent(int eventType)
           
 void setAutoDrawableClient(boolean b)
          If set to true, certain action will be performed by the owning AutoDrawable, ie the destroy() call within windowDestroyNotify()
abstract  boolean setFullscreen(boolean fullscreen)
           
abstract  void setPosition(int x, int y)
          Sets the location of the top left corner of the window, including decorations (so the client area will be placed at x+insets.left,y+insets.top.
abstract  void setSize(int width, int height)
          Sets the size of the client area of the window, excluding decorations Total size of the window will be width+insets.left+insets.right, height+insets.top+insets.bottom
 void setTitle(String title)
           
 void setUndecorated(boolean value)
           
abstract  void setVisible(boolean visible)
           
 boolean surfaceSwap()
          Provide a mechanism to utilize custom (pre-) swap surface code.
 void surfaceUpdated()
          Method invoked after the render toolkit (e.g.
 String toString()
           
 void unlockSurface()
          Unlock the surface of this native window Shall not modify the window handle, see NativeWindow.getWindowHandle(), or the surface handle, see NativeWindow.lockSurface()
protected  void windowDestroyed()
           
protected  void windowDestroyNotify()
           
protected static Window wrapHandle(String type, Screen screen, AbstractGraphicsConfiguration config, long windowHandle, boolean fullscreen, boolean visible, int x, int y, int width, int height)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEBUG_MOUSE_EVENT

public static final boolean DEBUG_MOUSE_EVENT

DEBUG_KEY_EVENT

public static final boolean DEBUG_KEY_EVENT

DEBUG_WINDOW_EVENT

public static final boolean DEBUG_WINDOW_EVENT

DEBUG_IMPLEMENTATION

public static final boolean DEBUG_IMPLEMENTATION

screen

protected Screen screen

config

protected AbstractGraphicsConfiguration config

windowHandle

protected long windowHandle

lockedStack

protected Exception lockedStack

fullscreen

protected boolean fullscreen

visible

protected boolean visible

width

protected int width

height

protected int height

x

protected int x

y

protected int y

eventMask

protected int eventMask

title

protected String title

undecorated

protected boolean undecorated

ClickTimeout

public static final int ClickTimeout
See Also:
Constant Field Values
Constructor Detail

Window

public Window()
Method Detail

create

protected static Window create(String type,
                               long parentWindowHandle,
                               Screen screen,
                               Capabilities caps,
                               boolean undecorated)

create

protected static Window create(String type,
                               Object[] cstrArguments,
                               Screen screen,
                               Capabilities caps,
                               boolean undecorated)

wrapHandle

protected static Window wrapHandle(String type,
                                   Screen screen,
                                   AbstractGraphicsConfiguration config,
                                   long windowHandle,
                                   boolean fullscreen,
                                   boolean visible,
                                   int x,
                                   int y,
                                   int width,
                                   int height)

createNative

protected abstract void createNative(long parentWindowHandle,
                                     Capabilities caps)
Create native windowHandle, ie creates a new native invisible window. The parentWindowHandle may be null, in which case no window parenting is requested. Shall use the capabilities to determine the graphics configuration and shall set the chosen capabilities.


closeNative

protected abstract void closeNative()

getScreen

public Screen getScreen()

toString

public String toString()
Overrides:
toString in class Object

getTitle

public String getTitle()

setTitle

public void setTitle(String title)

setUndecorated

public void setUndecorated(boolean value)

isUndecorated

public boolean isUndecorated()

requestFocus

public void requestFocus()

lockSurface

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

The window handle, see NativeWindow.getWindowHandle(), and the surface handle, see NativeWindow.lockSurface(),
shall be set and be valid after a successfull call, ie a return value other than NativeWindow.LOCK_SURFACE_NOT_READY.

The semantics of the underlying native locked resource may be related to the ToolkitLock one. Hence it is important that implementation of both harmonize well.
The implementation may want to aquire the ToolkitLock first to become it's owner before proceeding with it's actual surface lock.

Specified by:
lockSurface in interface NativeWindow
Returns:
NativeWindow.LOCK_SUCCESS, NativeWindow.LOCK_SURFACE_CHANGED or NativeWindow.LOCK_SURFACE_NOT_READY.
Throws:
NativeWindowException - if surface is already locked
See Also:
ToolkitLock

unlockSurface

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

Specified by:
unlockSurface in interface NativeWindow
See Also:
NativeWindow.lockSurface(), ToolkitLock

isSurfaceLocked

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

Specified by:
isSurfaceLocked in interface NativeWindow

getLockedStack

public Exception getLockedStack()
Description copied from interface: NativeWindow
Return the lock-exception, or null if not locked. The lock-exception is created at NativeWindow.lockSurface() and hence holds the locker's call stack.

Specified by:
getLockedStack in interface NativeWindow

destroy

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

Specified by:
destroy in interface NativeWindow

invalidate

public void invalidate()
Description copied from interface: NativeWindow
render all native window information invalid, as if the native window was destroyed

Specified by:
invalidate in interface NativeWindow
See Also:
NativeWindow.destroy()

surfaceSwap

public boolean surfaceSwap()
Description copied from interface: NativeWindow
Provide a mechanism to utilize custom (pre-) swap surface code. This method is called before the render toolkit (e.g. JOGL) swaps the buffer/surface. The implementation may itself apply the swapping, in which case true shall be returned.

Specified by:
surfaceSwap in interface NativeWindow
Returns:
true if this method completed swapping the surface, otherwise false, in which case eg the GLDrawable implementation has to swap the code.

surfaceUpdated

public void surfaceUpdated()
Description copied from interface: NativeWindow
Method invoked after the render toolkit (e.g. JOGL) swapped/changed the buffer/surface.

Specified by:
surfaceUpdated in interface NativeWindow

clearEventMask

protected void clearEventMask()

getDisplayHandle

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

Specified by:
getDisplayHandle in interface NativeWindow

getScreenIndex

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

Specified by:
getScreenIndex in interface NativeWindow

getWindowHandle

public long getWindowHandle()
Description copied from interface: NativeWindow
Returns the window handle for this NativeWindow.

The window handle should be set/update by NativeWindow.lockSurface(), where NativeWindow.unlockSurface() is not allowed to modify it.
After NativeWindow.unlockSurface() it is no more guaranteed that the window handle is still valid.

The window handle shall reflect the platform one for all window related operations, e.g. open, close, resize.

On X11 this returns an entity of type Window.
On Microsoft Windows this returns an entity of type HWND.

Specified by:
getWindowHandle in interface NativeWindow

getSurfaceHandle

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

The surface handle should be set/update by NativeWindow.lockSurface(), where NativeWindow.unlockSurface() is not allowed to modify it. After NativeWindow.unlockSurface() it is no more guaranteed that the surface handle is still valid. The surface handle shall reflect the platform one for all drawable surface operations, e.g. opengl, swap-buffer.

On X11 this returns an entity of type Window, since there is no differentiation of surface and window there.
On Microsoft Windows this returns an entity of type HDC.

Specified by:
getSurfaceHandle in interface NativeWindow

disposeSurfaceHandle

public void disposeSurfaceHandle()
Special method to dispose a surface handle, in case of a device change _and_ where there is a different semantics of window handle and surface handle. This is currently only true for Windows.


getGraphicsConfiguration

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

Specified by:
getGraphicsConfiguration in interface NativeWindow
See Also:
GraphicsConfigurationFactory.chooseGraphicsConfiguration(Capabilities, CapabilitiesChooser, AbstractGraphicsScreen)

getWidth

public int getWidth()
Returns the width of the client area of this window

Specified by:
getWidth in interface NativeWindow
Returns:
width of the client area

getHeight

public int getHeight()
Returns the height of the client area of this window

Specified by:
getHeight in interface NativeWindow
Returns:
height of the client area

getInsets

public Insets getInsets()
Returns the insets for this native window (the difference between the size of the toplevel window with the decorations and the client area).

Returns:
insets for this platform window

getWrappedWindow

public Object getWrappedWindow()
If this Window actually wraps one from another toolkit such as the AWT, this will return a non-null value.


getX

public int getX()

getY

public int getY()

isVisible

public boolean isVisible()

isFullscreen

public boolean isFullscreen()

hasDeviceChanged

public boolean hasDeviceChanged()
If the implementation is capable of detecting a device change return true and clear the status/reason of the change.


setAutoDrawableClient

public void setAutoDrawableClient(boolean b)
If set to true, certain action will be performed by the owning AutoDrawable, ie the destroy() call within windowDestroyNotify()


windowDestroyNotify

protected void windowDestroyNotify()

windowDestroyed

protected void windowDestroyed()

setVisible

public abstract void setVisible(boolean visible)

setSize

public abstract void setSize(int width,
                             int height)
Sets the size of the client area of the window, excluding decorations Total size of the window will be width+insets.left+insets.right, height+insets.top+insets.bottom

Parameters:
width - of the client area of the window
height - of the client area of the window

setPosition

public abstract void setPosition(int x,
                                 int y)
Sets the location of the top left corner of the window, including decorations (so the client area will be placed at x+insets.left,y+insets.top.

Parameters:
x - coord of the top left corner
y - coord of the top left corner

setFullscreen

public abstract boolean setFullscreen(boolean fullscreen)

addMouseListener

public void addMouseListener(MouseListener l)

removeMouseListener

public void removeMouseListener(MouseListener l)

getMouseListeners

public MouseListener[] getMouseListeners()

sendMouseEvent

protected void sendMouseEvent(int eventType,
                              int modifiers,
                              int x,
                              int y,
                              int button,
                              int rotation)

addKeyListener

public void addKeyListener(KeyListener l)

removeKeyListener

public void removeKeyListener(KeyListener l)

getKeyListeners

public KeyListener[] getKeyListeners()

sendKeyEvent

protected void sendKeyEvent(int eventType,
                            int modifiers,
                            int keyCode,
                            char keyChar)

addWindowListener

public void addWindowListener(WindowListener l)

removeWindowListener

public void removeWindowListener(WindowListener l)

getWindowListeners

public WindowListener[] getWindowListeners()

sendWindowEvent

protected void sendWindowEvent(int eventType)

addPaintListener

public void addPaintListener(PaintListener l)

removePaintListener

public void removePaintListener(PaintListener l)

sendPaintEvent

protected void sendPaintEvent(int eventType,
                              int x,
                              int y,
                              int w,
                              int h)


Copyright 2005 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.