aboutsummaryrefslogtreecommitdiffstats
path: root/src/nativewindow/classes/javax
diff options
context:
space:
mode:
Diffstat (limited to 'src/nativewindow/classes/javax')
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/NativeSurface.java166
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/NativeWindow.java166
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/SurfaceUpdatedListener.java5
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/package.html5
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/util/Dimension.java94
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/util/Insets.java106
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/util/Point.java93
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/util/Rectangle.java92
8 files changed, 584 insertions, 143 deletions
diff --git a/src/nativewindow/classes/javax/media/nativewindow/NativeSurface.java b/src/nativewindow/classes/javax/media/nativewindow/NativeSurface.java
new file mode 100644
index 000000000..3648a9a32
--- /dev/null
+++ b/src/nativewindow/classes/javax/media/nativewindow/NativeSurface.java
@@ -0,0 +1,166 @@
+/**
+ * Copyright 2010 JogAmp Community. All rights reserved.
+ * Copyright (c) 2010 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+
+package javax.media.nativewindow;
+
+/** Provides low-level information required for
+ hardware-accelerated rendering using a surface in a platform-independent manner.<P>
+
+ A NativeSurface created for a particular on- or offscreen component is
+ expected to have the same lifetime as that component. As long as
+ the component is alive and realized/visible, NativeSurface must be able
+ provide information such as the surface handle while it is locked.<P>
+*/
+public interface NativeSurface extends SurfaceUpdatedListener {
+ /** Unlocked state */
+ public static final int LOCK_SURFACE_UNLOCKED = 0;
+
+ /** Returned by {@link #lockSurface()} if the surface is not ready to be locked. */
+ public static final int LOCK_SURFACE_NOT_READY = 1;
+
+ /** Returned by {@link #lockSurface()} if the surface is locked, but has changed. */
+ public static final int LOCK_SURFACE_CHANGED = 2;
+
+ /** Returned by {@link #lockSurface()} if the surface is locked, and is unchanged. */
+ public static final int LOCK_SUCCESS = 3;
+
+ /**
+ * Lock the surface of this native window<P>
+ *
+ * The surface handle, see {@link #lockSurface()}, <br>
+ * shall be valid after a successfull call,
+ * ie return a value other than {@link #LOCK_SURFACE_NOT_READY}.<P>
+ *
+ * This call is blocking until the surface has been locked
+ * or a timeout is reached. The latter will throw a runtime exception. <P>
+ *
+ * This call allows recursion from the same thread.<P>
+ *
+ * The implementation may want to aquire the
+ * application level {@link com.jogamp.nativewindow.impl.RecursiveToolkitLock}
+ * first before proceeding with a native surface lock. <P>
+ *
+ * @return {@link #LOCK_SUCCESS}, {@link #LOCK_SURFACE_CHANGED} or {@link #LOCK_SURFACE_NOT_READY}.
+ *
+ * @throws RuntimeException after timeout when waiting for the surface lock
+ *
+ * @see com.jogamp.nativewindow.impl.RecursiveToolkitLock
+ */
+ public int lockSurface();
+
+ /**
+ * Unlock the surface of this native window
+ *
+ * Shall not modify the surface handle, see {@link #lockSurface()} <P>
+ *
+ * @throws RuntimeException if surface is not locked
+ *
+ * @see #lockSurface
+ * @see com.jogamp.nativewindow.impl.RecursiveToolkitLock
+ */
+ public void unlockSurface() throws NativeWindowException ;
+
+ /**
+ * Return if surface is locked by another thread, ie not the current one
+ */
+ public boolean isSurfaceLockedByOtherThread();
+
+ /**
+ * Return if surface is locked
+ */
+ public boolean isSurfaceLocked();
+
+ /**
+ * Return the locking owner's Thread, or null if not locked.
+ */
+ public Thread getSurfaceLockOwner();
+
+ /**
+ * Return the lock-exception, or null if not locked.
+ *
+ * The lock-exception is created at {@link #lockSurface()}
+ * and hence holds the locker's call stack.
+ */
+ public Exception getSurfaceLockStack();
+
+ /**
+ * 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.
+ *
+ * @return true if this method completed swapping the surface,
+ * otherwise false, in which case eg the GLDrawable
+ * implementation has to swap the code.
+ */
+ public boolean surfaceSwap();
+
+ /**
+ * Returns the handle to the surface for this NativeSurface. <P>
+ *
+ * The surface handle should be set/update by {@link #lockSurface()},
+ * where {@link #unlockSurface()} is not allowed to modify it.
+ * After {@link #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. <P>
+ *
+ * On X11 this returns an entity of type Window,
+ * since there is no differentiation of surface and window there. <BR>
+ * On Microsoft Windows this returns an entity of type HDC.
+ */
+ public long getSurfaceHandle();
+
+ /** Returns the current width of this surface. */
+ public int getWidth();
+
+ /** Returns the current height of this surface. */
+ public int getHeight();
+
+ /**
+ * Returns the graphics configuration corresponding to this window.
+ * @see javax.media.nativewindow.GraphicsConfigurationFactory#chooseGraphicsConfiguration(Capabilities, CapabilitiesChooser, AbstractGraphicsScreen)
+ */
+ public AbstractGraphicsConfiguration getGraphicsConfiguration();
+
+ /**
+ * Convenience: Get display handle from
+ * AbstractGraphicsConfiguration . AbstractGraphicsScreen . AbstractGraphicsDevice
+ */
+ public long getDisplayHandle();
+
+ /**
+ * Convenience: Get display handle from
+ * AbstractGraphicsConfiguration . AbstractGraphicsScreen
+ */
+ public int getScreenIndex();
+
+}
+
diff --git a/src/nativewindow/classes/javax/media/nativewindow/NativeWindow.java b/src/nativewindow/classes/javax/media/nativewindow/NativeWindow.java
index 2187f6054..d65cc8c18 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/NativeWindow.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/NativeWindow.java
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010 JogAmp Community. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -39,111 +40,18 @@
package javax.media.nativewindow;
-/** Provides the low-level information required for
- hardware-accelerated rendering in a platform-independent manner. A
- window toolkit such as the AWT may either implement this interface
+import javax.media.nativewindow.util.Point;
+
+/** Extend the {@link NativeSurface} interface with windowing
+ information such as window handle and position.<P>
+
+ A window toolkit such as the AWT may either implement this interface
directly with one of its components, or provide and register an
implementation of {@link NativeWindowFactory NativeWindowFactory}
which can create NativeWindow objects for its components. <P>
-
- A NativeWindow created for a particular on-screen component is
- expected to have the same lifetime as that component. As long as
- the component is alive, the NativeWindow must be able to control
- it, and any time it is visible and locked, provide information
- such as the window handle.
*/
-public interface NativeWindow extends SurfaceUpdatedListener {
- /** Unlocked state */
- public static final int LOCK_SURFACE_UNLOCKED = 0;
-
- /** Returned by {@link #lockSurface()} if the surface is not ready to be locked. */
- public static final int LOCK_SURFACE_NOT_READY = 1;
-
- /** Returned by {@link #lockSurface()} if the surface is locked, but has changed. */
- public static final int LOCK_SURFACE_CHANGED = 2;
-
- /** Returned by {@link #lockSurface()} if the surface is locked, and is unchanged. */
- public static final int LOCK_SUCCESS = 3;
-
- /**
- * Lock the surface of this native window<P>
- *
- * The surface handle, see {@link #lockSurface()}, <br>
- * shall be valid after a successfull call,
- * ie return a value other than {@link #LOCK_SURFACE_NOT_READY}.<P>
- *
- * This call is blocking until the surface has been locked
- * or a timeout is reached. The latter will throw a runtime exception. <P>
- *
- * This call allows recursion from the same thread.<P>
- *
- * The implementation may want to aquire the
- * application level {@link com.jogamp.nativewindow.impl.RecursiveToolkitLock}
- * first before proceeding with a native surface lock. <P>
- *
- * @return {@link #LOCK_SUCCESS}, {@link #LOCK_SURFACE_CHANGED} or {@link #LOCK_SURFACE_NOT_READY}.
- *
- * @throws RuntimeException after timeout when waiting for the surface lock
- *
- * @see com.jogamp.nativewindow.impl.RecursiveToolkitLock
- */
- public int lockSurface();
-
- /**
- * Unlock the surface of this native window
- *
- * Shall not modify the surface handle, see {@link #lockSurface()} <P>
- *
- * @throws RuntimeException if surface is not locked
- *
- * @see #lockSurface
- * @see com.jogamp.nativewindow.impl.RecursiveToolkitLock
- */
- public void unlockSurface() throws NativeWindowException ;
-
- /**
- * Return if surface is locked by another thread, ie not the current one
- */
- public boolean isSurfaceLockedByOtherThread();
-
- /**
- * Return if surface is locked
- */
- public boolean isSurfaceLocked();
-
- /**
- * Return the locking owner's Thread, or null if not locked.
- */
- public Thread getSurfaceLockOwner();
-
- /**
- * Return the lock-exception, or null if not locked.
- *
- * The lock-exception is created at {@link #lockSurface()}
- * and hence holds the locker's call stack.
- */
- public Exception getSurfaceLockStack();
-
- /**
- * 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.
- *
- * @return true if this method completed swapping the surface,
- * otherwise false, in which case eg the GLDrawable
- * implementation has to swap the code.
- */
- public boolean surfaceSwap();
-
- /**
- * render all native window information invalid,
- * as if the native window was destroyed
- *
- * @see #destroy
- */
- public void invalidate();
-
+public interface NativeWindow extends NativeSurface {
+
/**
* destroys the window and releases
* windowing related resources.
@@ -151,6 +59,11 @@ public interface NativeWindow extends SurfaceUpdatedListener {
public void destroy();
/**
+ * @return The parent NativeWindow, or null if this NativeWindow is top level.
+ */
+ public NativeWindow getParent();
+
+ /**
* Returns the window handle for this NativeWindow. <P>
*
* The window handle shall reflect the platform one
@@ -161,45 +74,20 @@ public interface NativeWindow extends SurfaceUpdatedListener {
*/
public long getWindowHandle();
- /**
- * Returns the handle to the surface for this NativeWindow. <P>
- *
- * The surface handle should be set/update by {@link #lockSurface()},
- * where {@link #unlockSurface()} is not allowed to modify it.
- * After {@link #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. <P>
- *
- * On X11 this returns an entity of type Window,
- * since there is no differentiation of surface and window there. <BR>
- * On Microsoft Windows this returns an entity of type HDC.
- */
- public long getSurfaceHandle();
-
- /** Returns the current width of this window. */
- public int getWidth();
+ /** Returns the current x position of this window, relative to it's parent. */
+ public int getX();
- /** Returns the current height of this window. */
- public int getHeight();
+ /** Returns the current y position of this window, relative to it's parent. */
+ public int getY();
- /**
- * Returns the graphics configuration corresponding to this window.
- * @see javax.media.nativewindow.GraphicsConfigurationFactory#chooseGraphicsConfiguration(Capabilities, CapabilitiesChooser, AbstractGraphicsScreen)
- */
- public AbstractGraphicsConfiguration getGraphicsConfiguration();
-
- /**
- * Convenience: Get display handle from
- * AbstractGraphicsConfiguration . AbstractGraphicsScreen . AbstractGraphicsDevice
- */
- public long getDisplayHandle();
-
- /**
- * Convenience: Get display handle from
- * AbstractGraphicsConfiguration . AbstractGraphicsScreen
+ /**
+ * Returns the current absolute location of this window.
+ * @param point if not null,
+ * {@link javax.media.nativewindow.util.Point#translate(javax.media.nativewindow.util.Point)}
+ * the passed {@link javax.media.nativewindow.util.Point} by this location on the screen and return it.
+ * @return either the passed non null translated point by the screen location of this NativeWindow,
+ * or a new instance with the screen location of this NativeWindow.
*/
- public int getScreenIndex();
-
+ public Point getLocationOnScreen(Point point);
+
}
diff --git a/src/nativewindow/classes/javax/media/nativewindow/SurfaceUpdatedListener.java b/src/nativewindow/classes/javax/media/nativewindow/SurfaceUpdatedListener.java
index 7be15408c..88e805d14 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/SurfaceUpdatedListener.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/SurfaceUpdatedListener.java
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010 JogAmp Community. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -38,9 +39,9 @@ public interface SurfaceUpdatedListener {
*
* @param updater is the caller object who updated the surface,
* e.g. a JOGL GLDrawable.
- * @param window the NativeWindow, which surface is updated
+ * @param ns the updated NativeSurface
* @param when the time in ms, when the surface was updated
*/
- public void surfaceUpdated(Object updater, NativeWindow window, long when) ;
+ public void surfaceUpdated(Object updater, NativeSurface ns, long when) ;
}
diff --git a/src/nativewindow/classes/javax/media/nativewindow/package.html b/src/nativewindow/classes/javax/media/nativewindow/package.html
index fa422b2ab..1eb1cef08 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/package.html
+++ b/src/nativewindow/classes/javax/media/nativewindow/package.html
@@ -39,8 +39,9 @@
<br>
shall be registered with {@link javax.media.nativewindow.GraphicsConfigurationFactory#registerFactory GraphicsConfigurationFactory.registerFactory(..)}.</li><br>
</ul><br>
- This protocol <i>does not</i> describe how to <i>create</i> native windows, but how to <i>bind</i> a native window to an implementation of
- {@link javax.media.nativewindow.NativeWindow NativeWindow}.<br>
+ This protocol <i>does not</i> describe how to <i>create</i> native windows, but how to <i>bind</i> a native surface to an implementation of
+ and window to an implementation of {@link javax.media.nativewindow.NativeSurface NativeSurface}.<br>
+ {@link javax.media.nativewindow.NativeWindow NativeWindow} specializes the NativeSurface.<br>
However, an implementation of this protocol (e.g. {@link com.jogamp.newt}) may support the creation.<br>
<h3>Dependencies</h3>
diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/Dimension.java b/src/nativewindow/classes/javax/media/nativewindow/util/Dimension.java
new file mode 100644
index 000000000..19ec1e259
--- /dev/null
+++ b/src/nativewindow/classes/javax/media/nativewindow/util/Dimension.java
@@ -0,0 +1,94 @@
+/**
+ * Copyright 2010 JogAmp Community. All rights reserved.
+ * Copyright (c) 2010 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+
+
+package javax.media.nativewindow.util;
+
+public class Dimension {
+ int width;
+ int height;
+
+ public Dimension() {
+ this(0, 0);
+ }
+
+ public Dimension(int width, int height) {
+ this.width=width;
+ this.height=height;
+ }
+ public int getWidth() { return width; }
+ public int getHeight() { return height; }
+ public void setWidth(int width) { this.width = width; }
+ public void setHeight(int height) { this.height = height; }
+
+ public Dimension scale(int s) {
+ width *= s;
+ height *= s;
+ return this;
+ }
+
+ public Dimension add(Dimension pd) {
+ width += pd.width ;
+ height += pd.height ;
+ return this;
+ }
+
+ public String toString() {
+ return new String("Dimension["+width+"x"+height+"]");
+ }
+
+ /**
+ * Checks whether two dimensions objects are equal. Two instances
+ * of <code>Dimension</code> are equal if the four integer values
+ * of the fields <code>height</code> and <code>width</code>
+ * are equal.
+ * @return <code>true</code> if the two dimensions are equal;
+ * otherwise <code>false</code>.
+ */
+ public boolean equals(Object obj) {
+ if (obj instanceof Dimension) {
+ Dimension p = (Dimension)obj;
+ return (height == p.height) && (width == p.width) &&
+ (height == p.height) && (width == p.width);
+ }
+ return false;
+ }
+
+ /**
+ * Returns the hash code for this Dimension.
+ *
+ * @return a hash code for this Dimension.
+ */
+ public int hashCode() {
+ int sum1 = width + height;
+ return sum1 * (sum1 + 1)/2 + width;
+ }
+
+}
+
diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/Insets.java b/src/nativewindow/classes/javax/media/nativewindow/util/Insets.java
new file mode 100644
index 000000000..4162e1099
--- /dev/null
+++ b/src/nativewindow/classes/javax/media/nativewindow/util/Insets.java
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2009 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright (c) 2010 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistribution of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistribution in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * Neither the name of Sun Microsystems, Inc. or the names of
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * This software is provided "AS IS," without a warranty of any kind. ALL
+ * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
+ * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
+ * MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
+ * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
+ * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR
+ * ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR
+ * DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
+ * DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
+ * ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
+ * SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ *
+ */
+package javax.media.nativewindow.util;
+
+/**
+ * Simple class representing insets.
+ *
+ * @author tdv
+ */
+public class Insets implements Cloneable {
+ public int top;
+ public int left;
+ public int bottom;
+ public int right;
+
+ /**
+ * Creates and initializes a new <code>Insets</code> object with the
+ * specified top, left, bottom, and right insets.
+ * @param top the inset from the top.
+ * @param left the inset from the left.
+ * @param bottom the inset from the bottom.
+ * @param right the inset from the right.
+ */
+ public Insets(int top, int left, int bottom, int right) {
+ this.top = top;
+ this.left = left;
+ this.bottom = bottom;
+ this.right = right;
+ }
+
+ /**
+ * Checks whether two insets objects are equal. Two instances
+ * of <code>Insets</code> are equal if the four integer values
+ * of the fields <code>top</code>, <code>left</code>,
+ * <code>bottom</code>, and <code>right</code> are all equal.
+ * @return <code>true</code> if the two insets are equal;
+ * otherwise <code>false</code>.
+ */
+ public boolean equals(Object obj) {
+ if (obj instanceof Insets) {
+ Insets insets = (Insets)obj;
+ return ((top == insets.top) && (left == insets.left) &&
+ (bottom == insets.bottom) && (right == insets.right));
+ }
+ return false;
+ }
+
+ /**
+ * Returns the hash code for this Insets.
+ *
+ * @return a hash code for this Insets.
+ */
+ public int hashCode() {
+ int sum1 = left + bottom;
+ int sum2 = right + top;
+ int val1 = sum1 * (sum1 + 1)/2 + left;
+ int val2 = sum2 * (sum2 + 1)/2 + top;
+ int sum3 = val1 + val2;
+ return sum3 * (sum3 + 1)/2 + val2;
+ }
+
+ public String toString() {
+ return getClass().getName() + "[top=" + top + ",left=" + left +
+ ",bottom=" + bottom + ",right=" + right + "]";
+ }
+
+ public Object clone() {
+ try {
+ return super.clone();
+ } catch (CloneNotSupportedException ex) {
+ throw new InternalError();
+ }
+ }
+
+}
diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/Point.java b/src/nativewindow/classes/javax/media/nativewindow/util/Point.java
new file mode 100644
index 000000000..a541b3cfd
--- /dev/null
+++ b/src/nativewindow/classes/javax/media/nativewindow/util/Point.java
@@ -0,0 +1,93 @@
+/**
+ * Copyright 2010 JogAmp Community. All rights reserved.
+ * Copyright (c) 2010 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+
+
+package javax.media.nativewindow.util;
+
+public class Point {
+ int x;
+ int y;
+
+ public Point() {
+ this(0, 0);
+ }
+
+ public Point(int x, int y) {
+ this.x=x;
+ this.y=y;
+ }
+ public int getX() { return x; }
+ public int getY() { return y; }
+ public void setX(int x) { this.x = x; }
+ public void setY(int y) { this.y = y; }
+
+ public Point translate(Point pd) {
+ x += pd.x ;
+ y += pd.y ;
+ return this;
+ }
+
+ public Point translate(int dx, int dy) {
+ x += dx ;
+ y += dy ;
+ return this;
+ }
+
+ public String toString() {
+ return new String("Point["+x+"/"+y+"]");
+ }
+
+ /**
+ * Checks whether two points objects are equal. Two instances
+ * of <code>Point</code> are equal if the four integer values
+ * of the fields <code>y</code> and <code>x</code>
+ * are equal.
+ * @return <code>true</code> if the two points are equal;
+ * otherwise <code>false</code>.
+ */
+ public boolean equals(Object obj) {
+ if (obj instanceof Point) {
+ Point p = (Point)obj;
+ return (y == p.y) && (x == p.x);
+ }
+ return false;
+ }
+
+ /**
+ * Returns the hash code for this Point.
+ *
+ * @return a hash code for this Point.
+ */
+ public int hashCode() {
+ int sum1 = x + y;
+ return sum1 * (sum1 + 1)/2 + x;
+ }
+
+}
+
diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/Rectangle.java b/src/nativewindow/classes/javax/media/nativewindow/util/Rectangle.java
new file mode 100644
index 000000000..84e970b9f
--- /dev/null
+++ b/src/nativewindow/classes/javax/media/nativewindow/util/Rectangle.java
@@ -0,0 +1,92 @@
+/**
+ * Copyright 2010 JogAmp Community. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * The views and conclusions contained in the software and documentation are those of the
+ * authors and should not be interpreted as representing official policies, either expressed
+ * or implied, of JogAmp Community.
+ */
+
+
+package javax.media.nativewindow.util;
+
+public class Rectangle {
+ int x;
+ int y;
+ int width;
+ int height;
+
+ public Rectangle() {
+ this(0, 0, 0, 0);
+ }
+
+ public Rectangle(int x, int y, int width, int height) {
+ this.x=x;
+ this.y=y;
+ this.width=width;
+ this.height=height;
+ }
+ public int getX() { return x; }
+ public int getY() { return y; }
+ public int getWidth() { return width; }
+ public int getHeight() { return height; }
+ public void setX(int x) { this.x = x; }
+ public void setY(int y) { this.y = y; }
+ public void setWidth(int width) { this.width = width; }
+ public void setHeight(int height) { this.height = height; }
+
+ /**
+ * Checks whether two rect objects are equal. Two instances
+ * of <code>Rectangle</code> are equal if the four integer values
+ * of the fields <code>y</code>, <code>x</code>,
+ * <code>height</code>, and <code>width</code> are all equal.
+ * @return <code>true</code> if the two rectangles are equal;
+ * otherwise <code>false</code>.
+ */
+ public boolean equals(Object obj) {
+ if (obj instanceof Rectangle) {
+ Rectangle rect = (Rectangle)obj;
+ return (y == rect.y) && (x == rect.x) &&
+ (height == rect.height) && (width == rect.width);
+ }
+ return false;
+ }
+
+ /**
+ * Returns the hash code for this Rectangle.
+ *
+ * @return a hash code for this Rectangle.
+ */
+ public int hashCode() {
+ int sum1 = x + height;
+ int sum2 = width + y;
+ int val1 = sum1 * (sum1 + 1)/2 + x;
+ int val2 = sum2 * (sum2 + 1)/2 + y;
+ int sum3 = val1 + val2;
+ return sum3 * (sum3 + 1)/2 + val2;
+ }
+
+ public String toString() {
+ return new String("Rect["+x+"/"+y+" "+width+"x"+height+"]");
+ }
+}
+