diff options
Diffstat (limited to 'src/nativewindow/classes')
10 files changed, 358 insertions, 97 deletions
diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/impl/x11/X11Util.java b/src/nativewindow/classes/com/jogamp/nativewindow/impl/x11/X11Util.java index 3e991e52e..5a864cab9 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/impl/x11/X11Util.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/impl/x11/X11Util.java @@ -34,9 +34,6 @@ package com.jogamp.nativewindow.impl.x11; import java.util.HashMap; import java.util.Map; -import java.util.Collection; -import java.util.ArrayList; -import java.util.Iterator; import com.jogamp.common.util.LongObjectHashMap; import com.jogamp.common.util.locks.RecursiveLock; @@ -46,7 +43,6 @@ import com.jogamp.nativewindow.impl.*; import java.nio.Buffer; import java.nio.IntBuffer; import java.nio.ShortBuffer; -import java.security.AccessController; /** * Contains a thread safe X11 utility to retrieve thread local display connection,<br> diff --git a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java index 7897460a0..a269051b1 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java +++ b/src/nativewindow/classes/javax/media/nativewindow/NativeWindowFactory.java @@ -51,22 +51,22 @@ import java.lang.reflect.Method; public abstract class NativeWindowFactory { protected static final boolean DEBUG = Debug.debug("NativeWindow"); - /** OpenKODE/EGL type */ + /** OpenKODE/EGL type, as retrieved with {@link #getNativeWindowType(boolean)}*/ public static final String TYPE_EGL = "EGL"; - /** Microsoft Windows type */ + /** Microsoft Windows type, as retrieved with {@link #getNativeWindowType(boolean)} */ public static final String TYPE_WINDOWS = "Windows"; - /** X11 type */ + /** X11 type, as retrieved with {@link #getNativeWindowType(boolean)} */ public static final String TYPE_X11 = "X11"; - /** Mac OS X type */ + /** Mac OS X type, as retrieved with {@link #getNativeWindowType(boolean)} */ public static final String TYPE_MACOSX = "MacOSX"; - /** Generic AWT type */ + /** Generic AWT type, as retrieved with {@link #getNativeWindowType(boolean)} */ public static final String TYPE_AWT = "AWT"; - /** Generic DEFAULT type, where platform implementation don't care */ + /** Generic DEFAULT type, where platform implementation don't care, as retrieved with {@link #getNativeWindowType(boolean)} */ public static final String TYPE_DEFAULT = "default"; private static NativeWindowFactory defaultFactory; @@ -229,10 +229,18 @@ public abstract class NativeWindowFactory { /** @return true if not headless, AWT Component and NativeWindow's AWT part available */ public static boolean isAWTAvailable() { return isAWTAvailable; } + /** + * @param useCustom if false return the native value, if true return a custom value if set, otherwise fallback to the native value. + * @return the native OS name + */ public static String getNativeOSName(boolean useCustom) { return useCustom?nativeOSNameCustom:nativeOSNamePure; } + /** + * @param useCustom if false return the native value, if true return a custom value if set, otherwise fallback to the native value. + * @return a define native window type, like {@link #TYPE_X11}, .. + */ public static String getNativeWindowType(boolean useCustom) { return useCustom?nativeWindowingTypeCustom:nativeWindowingTypePure; } diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/Dimension.java b/src/nativewindow/classes/javax/media/nativewindow/util/Dimension.java index 19ec1e259..f7826c6eb 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/util/Dimension.java +++ b/src/nativewindow/classes/javax/media/nativewindow/util/Dimension.java @@ -27,10 +27,9 @@ * or implied, of JogAmp Community. */ - package javax.media.nativewindow.util; -public class Dimension { +public class Dimension implements Cloneable, DimensionReadOnly { int width; int height; @@ -39,20 +38,35 @@ public class Dimension { } public Dimension(int width, int height) { + if(width<0 || height<0) { + throw new IllegalArgumentException("width and height must be within: ["+0+".."+Integer.MAX_VALUE+"]"); + } this.width=width; this.height=height; } + + public Object clone() { + try { + return super.clone(); + } catch (CloneNotSupportedException ex) { + throw new InternalError(); + } + } + 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 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 ; @@ -60,35 +74,23 @@ public class Dimension { } public String toString() { - return new String("Dimension["+width+"x"+height+"]"); + 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 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; + // 31 * x == (x << 5) - x + int hash = 31 + width; + hash = ((hash << 5) - hash) + height; + return hash; } - } diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/DimensionReadOnly.java b/src/nativewindow/classes/javax/media/nativewindow/util/DimensionReadOnly.java new file mode 100644 index 000000000..442afd4ba --- /dev/null +++ b/src/nativewindow/classes/javax/media/nativewindow/util/DimensionReadOnly.java @@ -0,0 +1,55 @@ +/** + * 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; + +/** Immutable Dimension Interface, consisting of it's read only components:<br> + * <ul> + * <li><code>width</code></li> + * <li><code>height</code></li> + * </ul> + */ +public interface DimensionReadOnly extends Cloneable { + + int getHeight(); + + int getWidth(); + + /** + * Checks whether two dimensions objects are equal. Two instances + * of <code>DimensionReadOnly</code> are equal if two components + * <code>height</code> and <code>width</code> are equal. + * @return <code>true</code> if the two dimensions are equal; + * otherwise <code>false</code>. + */ + boolean equals(Object obj); + + int hashCode(); + +} diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/Insets.java b/src/nativewindow/classes/javax/media/nativewindow/util/Insets.java index 4162e1099..c7fa247bf 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/util/Insets.java +++ b/src/nativewindow/classes/javax/media/nativewindow/util/Insets.java @@ -43,6 +43,7 @@ public class Insets implements Cloneable { public int left; public int bottom; public int right; + public int hash; /** * Creates and initializes a new <code>Insets</code> object with the @@ -57,6 +58,7 @@ public class Insets implements Cloneable { this.left = left; this.bottom = bottom; this.right = right; + this.hash = computeHashCode(); } /** @@ -82,12 +84,7 @@ public class Insets implements Cloneable { * @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; + return hash; } public String toString() { @@ -103,4 +100,12 @@ public class Insets implements Cloneable { } } + protected int computeHashCode() { + 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; + } } diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/Point.java b/src/nativewindow/classes/javax/media/nativewindow/util/Point.java index a541b3cfd..1ece49ffb 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/util/Point.java +++ b/src/nativewindow/classes/javax/media/nativewindow/util/Point.java @@ -4,14 +4,14 @@ * * 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 @@ -21,29 +21,62 @@ * 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 { +public class Point implements Cloneable, PointReadOnly { int x; int y; + public Point(int x, int y) { + this.x=x; + this.y=y; + } + public Point() { this(0, 0); } - public Point(int x, int y) { - this.x=x; - this.y=y; + public Object clone() { + try { + return super.clone(); + } catch (CloneNotSupportedException ex) { + throw new InternalError(); + } } - public int getX() { return x; } - public int getY() { return y; } + + public boolean equals(Object obj) { + if (obj instanceof Point) { + Point p = (Point)obj; + return y == p.y && x == p.x; + } + return false; + } + + public int getX() { + return x; + } + + public int getY() { + return y; + } + + public int hashCode() { + // 31 * x == (x << 5) - x + int hash = 31 + x; + hash = ((hash << 5) - hash) + y; + return hash; + } + + public String toString() { + return new String("Point[" + x + " / " + y + "]"); + } + public void setX(int x) { this.x = x; } public void setY(int y) { this.y = y; } @@ -59,35 +92,4 @@ public class Point { 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/PointReadOnly.java b/src/nativewindow/classes/javax/media/nativewindow/util/PointReadOnly.java new file mode 100644 index 000000000..9caaf7fee --- /dev/null +++ b/src/nativewindow/classes/javax/media/nativewindow/util/PointReadOnly.java @@ -0,0 +1,50 @@ +/** + * 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; + +/** Immutable Point interface */ +public interface PointReadOnly extends Cloneable { + + int getX(); + + int getY(); + + /** + * Checks whether two points objects are equal. Two instances + * of <code>PointReadOnly</code> are equal if the two components + * <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); + + public int hashCode(); + +} diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/Rectangle.java b/src/nativewindow/classes/javax/media/nativewindow/util/Rectangle.java index 84e970b9f..015a78a32 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/util/Rectangle.java +++ b/src/nativewindow/classes/javax/media/nativewindow/util/Rectangle.java @@ -26,10 +26,9 @@ * or implied, of JogAmp Community. */ - package javax.media.nativewindow.util; -public class Rectangle { +public class Rectangle implements Cloneable, RectangleReadOnly { int x; int y; int width; @@ -45,6 +44,15 @@ public class Rectangle { this.width=width; this.height=height; } + + protected Object clone() { + try { + return super.clone(); + } catch (CloneNotSupportedException ex) { + throw new InternalError(); + } + } + public int getX() { return x; } public int getY() { return y; } public int getWidth() { return width; } @@ -54,14 +62,6 @@ public class Rectangle { 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; @@ -71,11 +71,6 @@ public class Rectangle { 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; diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/RectangleReadOnly.java b/src/nativewindow/classes/javax/media/nativewindow/util/RectangleReadOnly.java new file mode 100644 index 000000000..9ffa07373 --- /dev/null +++ b/src/nativewindow/classes/javax/media/nativewindow/util/RectangleReadOnly.java @@ -0,0 +1,54 @@ +/** + * 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; + +/** Immutable Rectangle interface */ +public interface RectangleReadOnly { + + /** + * 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>. + */ + boolean equals(Object obj); + + int getHeight(); + + int getWidth(); + + int getX(); + + int getY(); + + int hashCode(); + +} diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/SurfaceSize.java b/src/nativewindow/classes/javax/media/nativewindow/util/SurfaceSize.java new file mode 100644 index 000000000..2973f5a86 --- /dev/null +++ b/src/nativewindow/classes/javax/media/nativewindow/util/SurfaceSize.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; + +/** Immutable SurfaceSize Class, consisting of it's read only components:<br> + * <ul> + * <li>{@link javax.media.nativewindow.util.DimensionReadOnly} size in pixels</li> + * <li><code>bits per pixel</code></li> + * </ul> + */ +public class SurfaceSize implements Cloneable { + DimensionReadOnly resolution; + int bitsPerPixel; + + public SurfaceSize(DimensionReadOnly resolution, int bitsPerPixel) { + if(null==resolution || bitsPerPixel<=0) { + throw new IllegalArgumentException("resolution must be set and bitsPerPixel greater 0"); + } + this.resolution=resolution; + this.bitsPerPixel=bitsPerPixel; + } + + public Object clone() { + try { + return super.clone(); + } catch (CloneNotSupportedException ex) { + throw new InternalError(); + } + } + + public final DimensionReadOnly getResolution() { + return resolution; + } + + public final int getBitsPerPixel() { + return bitsPerPixel; + } + + public final String toString() { + return new String("SurfaceSize["+resolution+" x "+bitsPerPixel+" bpp]"); + } + + /** + * Checks whether two size objects are equal. Two instances + * of <code>SurfaceSize</code> are equal if the two components + * <code>resolution</code> and <code>bitsPerPixel</code> + * are equal. + * @return <code>true</code> if the two dimensions are equal; + * otherwise <code>false</code>. + */ + public final boolean equals(Object obj) { + if (obj instanceof SurfaceSize) { + SurfaceSize p = (SurfaceSize)obj; + return getResolution().equals(p.getResolution()) && + getBitsPerPixel() == p.getBitsPerPixel(); + } + return false; + } + + public final int hashCode() { + // 31 * x == (x << 5) - x + int hash = 31 + getResolution().hashCode(); + hash = ((hash << 5) - hash) + getBitsPerPixel(); + return hash; + } +} + |