diff options
Diffstat (limited to 'src/nativewindow/classes/javax/media/nativewindow/util')
9 files changed, 79 insertions, 57 deletions
diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/Dimension.java b/src/nativewindow/classes/javax/media/nativewindow/util/Dimension.java index 17b4930c5..b8dc53c83 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/util/Dimension.java +++ b/src/nativewindow/classes/javax/media/nativewindow/util/Dimension.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,12 +21,12 @@ * 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 implements Cloneable, DimensionImmutable { @@ -45,10 +45,12 @@ public class Dimension implements Cloneable, DimensionImmutable { this.height=height; } + @Override public Object cloneMutable() { return clone(); } - + + @Override public Object clone() { try { return super.clone(); @@ -92,7 +94,7 @@ public class Dimension implements Cloneable, DimensionImmutable { public int compareTo(final DimensionImmutable d) { final int tsq = width*height; final int xsq = d.getWidth()*d.getHeight(); - + if(tsq > xsq) { return 1; } else if(tsq < xsq) { @@ -100,13 +102,13 @@ public class Dimension implements Cloneable, DimensionImmutable { } return 0; } - + @Override public boolean equals(Object obj) { if(this == obj) { return true; } if (obj instanceof Dimension) { Dimension p = (Dimension)obj; - return height == p.height && + return height == p.height && width == p.width ; } return false; diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/DimensionImmutable.java b/src/nativewindow/classes/javax/media/nativewindow/util/DimensionImmutable.java index 22bd3f48b..e6cacf4ff 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/util/DimensionImmutable.java +++ b/src/nativewindow/classes/javax/media/nativewindow/util/DimensionImmutable.java @@ -46,12 +46,12 @@ public interface DimensionImmutable extends WriteCloneable, Comparable<Dimension /** * <p> * Compares square of size. - * </p> + * </p> * {@inheritDoc} */ @Override public int compareTo(final DimensionImmutable d); - + /** * Checks whether two dimensions objects are equal. Two instances * of <code>DimensionReadOnly</code> are equal if two components @@ -59,8 +59,10 @@ public interface DimensionImmutable extends WriteCloneable, Comparable<Dimension * @return <code>true</code> if the two dimensions are equal; * otherwise <code>false</code>. */ + @Override boolean equals(Object obj); + @Override 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 942c12c2b..c84359dcd 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/util/Insets.java +++ b/src/nativewindow/classes/javax/media/nativewindow/util/Insets.java @@ -3,14 +3,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 @@ -20,18 +20,18 @@ * 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 Insets implements Cloneable, InsetsImmutable { static final InsetsImmutable zeroInsets = new Insets(); public static final InsetsImmutable getZero() { return zeroInsets; } - + int l, r, t, b; public Insets() { @@ -44,11 +44,13 @@ public class Insets implements Cloneable, InsetsImmutable { this.t=top; this.b=bottom; } - + + @Override public Object cloneMutable() { return clone(); } - + + @Override protected Object clone() { try { return super.clone(); @@ -77,7 +79,7 @@ public class Insets implements Cloneable, InsetsImmutable { public final void setRightWidth(int right) { r = right; } public final void setTopHeight(int top) { t = top; } public final void setBottomHeight(int bottom) { b = bottom; } - + @Override public boolean equals(Object obj) { if(this == obj) { return true; } @@ -99,6 +101,7 @@ public class Insets implements Cloneable, InsetsImmutable { return sum3 * (sum3 + 1)/2 + val2; } + @Override public String toString() { return new String("[ l "+l+", r "+r+" - t "+t+", b "+b+" - "+getTotalWidth()+"x"+getTotalHeight()+"]"); } diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/InsetsImmutable.java b/src/nativewindow/classes/javax/media/nativewindow/util/InsetsImmutable.java index 075641ede..8256068cd 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/util/InsetsImmutable.java +++ b/src/nativewindow/classes/javax/media/nativewindow/util/InsetsImmutable.java @@ -41,13 +41,13 @@ public interface InsetsImmutable extends WriteCloneable { /** @return total width, ie. <code>left_width + right_width</code> */ int getTotalWidth(); - + /** @return top inset height */ int getTopHeight(); /** @return bottom inset height */ int getBottomHeight(); - + /** @return total height, ie. <code>top_height + bottom_height</code> */ int getTotalHeight(); @@ -59,8 +59,10 @@ public interface InsetsImmutable extends WriteCloneable { * @return <code>true</code> if the two Insets are equal; * otherwise <code>false</code>. */ + @Override boolean equals(Object obj); + @Override int hashCode(); } diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/Point.java b/src/nativewindow/classes/javax/media/nativewindow/util/Point.java index 4c233bb16..57c6fb716 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/util/Point.java +++ b/src/nativewindow/classes/javax/media/nativewindow/util/Point.java @@ -42,10 +42,12 @@ public class Point implements Cloneable, PointImmutable { this(0, 0); } + @Override public Object cloneMutable() { return clone(); } - + + @Override public Object clone() { try { return super.clone(); @@ -58,7 +60,7 @@ public class Point implements Cloneable, PointImmutable { public int compareTo(final PointImmutable d) { final int sq = x*y; final int xsq = d.getX()*d.getY(); - + if(sq > xsq) { return 1; } else if(sq < xsq) { @@ -66,7 +68,7 @@ public class Point implements Cloneable, PointImmutable { } return 0; } - + @Override public boolean equals(Object obj) { if(this == obj) { return true; } @@ -95,6 +97,7 @@ public class Point implements Cloneable, PointImmutable { return hash; } + @Override public String toString() { return new String( x + " / " + y ); } @@ -120,5 +123,5 @@ public class Point implements Cloneable, PointImmutable { y *= sy ; return this; } - + } diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/PointImmutable.java b/src/nativewindow/classes/javax/media/nativewindow/util/PointImmutable.java index b00329bb5..08c628cc1 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/util/PointImmutable.java +++ b/src/nativewindow/classes/javax/media/nativewindow/util/PointImmutable.java @@ -41,12 +41,12 @@ public interface PointImmutable extends WriteCloneable, Comparable<PointImmutabl /** * <p> * Compares the square of the position. - * </p> + * </p> * {@inheritDoc} */ @Override public int compareTo(final PointImmutable d); - + /** * Checks whether two points objects are equal. Two instances * of <code>PointReadOnly</code> are equal if the two components @@ -54,8 +54,10 @@ public interface PointImmutable extends WriteCloneable, Comparable<PointImmutabl * @return <code>true</code> if the two points are equal; * otherwise <code>false</code>. */ + @Override public boolean equals(Object obj); + @Override 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 bbbfa2932..8dc8f4562 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/util/Rectangle.java +++ b/src/nativewindow/classes/javax/media/nativewindow/util/Rectangle.java @@ -3,14 +3,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 @@ -20,12 +20,12 @@ * 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; import java.util.List; @@ -46,11 +46,13 @@ public class Rectangle implements Cloneable, RectangleImmutable { this.width=width; this.height=height; } - + + @Override public Object cloneMutable() { return clone(); } - + + @Override protected Object clone() { try { return super.clone(); @@ -67,7 +69,7 @@ public class Rectangle implements Cloneable, RectangleImmutable { public final int getWidth() { return width; } @Override public final int getHeight() { return height; } - + public final void set(int x, int y, int width, int height) { this.x = x; this.y = y; @@ -89,7 +91,7 @@ public class Rectangle implements Cloneable, RectangleImmutable { final int y1 = Math.min(y, ry1); final int x2 = Math.max(x + width, rx2); final int y2 = Math.max(y + height, ry2); - return new Rectangle(x1, y1, x2 - x1, y2 - y1); + return new Rectangle(x1, y1, x2 - x1, y2 - y1); } /** * Calculates the union of the given rectangles, stores it in this instance and returns this instance. @@ -109,7 +111,7 @@ public class Rectangle implements Cloneable, RectangleImmutable { set(x1, y1, x2 - x1, y2 - y1); return this; } - + @Override public final RectangleImmutable intersection(RectangleImmutable r) { return intersection(r.getX(), r.getY(), r.getX() + r.getWidth(), r.getY() + r.getHeight()); @@ -144,13 +146,13 @@ public class Rectangle implements Cloneable, RectangleImmutable { final float sqT = (float) ( width*height ); return sqI / sqT; } - + @Override public int compareTo(final RectangleImmutable d) { { final int sq = width*height; final int xsq = d.getWidth()*d.getHeight(); - + if(sq > xsq) { return 1; } else if(sq < xsq) { @@ -160,7 +162,7 @@ public class Rectangle implements Cloneable, RectangleImmutable { { final int sq = x*y; final int xsq = d.getX()*d.getY(); - + if(sq > xsq) { return 1; } else if(sq < xsq) { @@ -169,7 +171,7 @@ public class Rectangle implements Cloneable, RectangleImmutable { } return 0; } - + @Override public boolean equals(Object obj) { if(this == obj) { return true; } @@ -191,6 +193,7 @@ public class Rectangle implements Cloneable, RectangleImmutable { return sum3 * (sum3 + 1)/2 + val2; } + @Override public String toString() { return new String("[ "+x+" / "+y+" "+width+" x "+height+" ]"); } diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/RectangleImmutable.java b/src/nativewindow/classes/javax/media/nativewindow/util/RectangleImmutable.java index 440d9e000..7ca92ff53 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/util/RectangleImmutable.java +++ b/src/nativewindow/classes/javax/media/nativewindow/util/RectangleImmutable.java @@ -49,7 +49,7 @@ public interface RectangleImmutable extends WriteCloneable, Comparable<Rectangle RectangleImmutable intersection(RectangleImmutable r); /** Returns the intersection of this rectangleand the given coordinates. */ RectangleImmutable intersection(final int rx1, final int ry1, final int rx2, final int ry2); - /** + /** * Returns the coverage of given rectangle w/ this this one, i.e. between <code>0.0</code> and <code>1.0</code>. * <p> * Coverage is computed by: @@ -57,19 +57,19 @@ public interface RectangleImmutable extends WriteCloneable, Comparable<Rectangle * isect = this.intersection(r); * coverage = area( isect ) / area( this ) ; * </pre> - * </p> + * </p> */ float coverage(RectangleImmutable r); - + /** * <p> * Compares square of size 1st, if equal the square of position. - * </p> + * </p> * {@inheritDoc} */ @Override public int compareTo(final RectangleImmutable d); - + /** * Checks whether two rect objects are equal. Two instances * of <code>Rectangle</code> are equal if the four integer values @@ -78,8 +78,10 @@ public interface RectangleImmutable extends WriteCloneable, Comparable<Rectangle * @return <code>true</code> if the two rectangles are equal; * otherwise <code>false</code>. */ + @Override boolean equals(Object obj); + @Override int hashCode(); } diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/SurfaceSize.java b/src/nativewindow/classes/javax/media/nativewindow/util/SurfaceSize.java index 3084816a5..f1749dfa6 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/util/SurfaceSize.java +++ b/src/nativewindow/classes/javax/media/nativewindow/util/SurfaceSize.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,15 +21,15 @@ * 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.DimensionImmutable} size in pixels</li> @@ -56,6 +56,7 @@ public class SurfaceSize implements Comparable<SurfaceSize> { return bitsPerPixel; } + @Override public final String toString() { return new String("[ "+resolution+" x "+bitsPerPixel+" bpp ]"); } @@ -63,7 +64,7 @@ public class SurfaceSize implements Comparable<SurfaceSize> { /** * <p> * Compares {@link DimensionImmutable#compareTo(DimensionImmutable) resolution} 1st, if equal the bitsPerPixel. - * </p> + * </p> * {@inheritDoc} */ @Override @@ -72,7 +73,7 @@ public class SurfaceSize implements Comparable<SurfaceSize> { if( 0 != rres ) { return rres; } - final int xbpp = ssz.getBitsPerPixel(); + final int xbpp = ssz.getBitsPerPixel(); if(bitsPerPixel > xbpp) { return 1; } else if(bitsPerPixel < xbpp) { @@ -80,7 +81,7 @@ public class SurfaceSize implements Comparable<SurfaceSize> { } return 0; } - + /** * Checks whether two size objects are equal. Two instances * of <code>SurfaceSize</code> are equal if the two components @@ -89,6 +90,7 @@ public class SurfaceSize implements Comparable<SurfaceSize> { * @return <code>true</code> if the two dimensions are equal; * otherwise <code>false</code>. */ + @Override public final boolean equals(Object obj) { if(this == obj) { return true; } if (obj instanceof SurfaceSize) { @@ -99,6 +101,7 @@ public class SurfaceSize implements Comparable<SurfaceSize> { return false; } + @Override public final int hashCode() { // 31 * x == (x << 5) - x int hash = 31 + getResolution().hashCode(); |