summaryrefslogtreecommitdiffstats
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/util/Rectangle.java50
-rw-r--r--src/nativewindow/classes/javax/media/nativewindow/util/SurfaceSize.java5
2 files changed, 43 insertions, 12 deletions
diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/Rectangle.java b/src/nativewindow/classes/javax/media/nativewindow/util/Rectangle.java
index d0d8bfb13..57535c26e 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/util/Rectangle.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/util/Rectangle.java
@@ -40,7 +40,7 @@ public class Rectangle implements Cloneable, RectangleImmutable {
this(0, 0, 0, 0);
}
- public Rectangle(int x, int y, int width, int height) {
+ public Rectangle(final int x, final int y, final int width, final int height) {
this.x=x;
this.y=y;
this.width=width;
@@ -70,16 +70,16 @@ public class Rectangle implements Cloneable, RectangleImmutable {
@Override
public final int getHeight() { return height; }
- public final void set(int x, int y, int width, int height) {
+ public final void set(final int x, final int y, final int width, final int height) {
this.x = x;
this.y = y;
this.width = width;
this.height = height;
}
- public final void setX(int x) { this.x = x; }
- public final void setY(int y) { this.y = y; }
- public final void setWidth(int width) { this.width = width; }
- public final void setHeight(int height) { this.height = height; }
+ public final void setX(final int x) { this.x = x; }
+ public final void setY(final int y) { this.y = y; }
+ public final void setWidth(final int width) { this.width = width; }
+ public final void setHeight(final int height) { this.height = height; }
@Override
public final RectangleImmutable union(final RectangleImmutable r) {
@@ -113,7 +113,7 @@ public class Rectangle implements Cloneable, RectangleImmutable {
}
@Override
- public final RectangleImmutable intersection(RectangleImmutable r) {
+ public final RectangleImmutable intersection(final RectangleImmutable r) {
return intersection(r.getX(), r.getY(), r.getX() + r.getWidth(), r.getY() + r.getHeight());
}
@Override
@@ -140,13 +140,43 @@ public class Rectangle implements Cloneable, RectangleImmutable {
return new Rectangle (ix, iy, iwidth, iheight);
}
@Override
- public final float coverage(RectangleImmutable r) {
+ public final float coverage(final RectangleImmutable r) {
final RectangleImmutable isect = intersection(r);
- final float sqI = (float) ( isect.getWidth()*isect.getHeight() );
- final float sqT = (float) ( width*height );
+ final float sqI = isect.getWidth()*isect.getHeight();
+ final float sqT = width*height;
return sqI / sqT;
}
+ /**
+ * Scale this instance's components,
+ * i.e. multiply them by the given scale factors.
+ * @param sx scale factor for x
+ * @param sy scale factor for y
+ * @return this instance for scaling
+ */
+ public final Rectangle scale(int sx, int sy) {
+ x *= sx ;
+ y *= sy ;
+ width *= sx ;
+ height *= sy ;
+ return this;
+ }
+
+ /**
+ * Inverse scale this instance's components,
+ * i.e. divide them by the given scale factors.
+ * @param sx inverse scale factor for x
+ * @param sy inverse scale factor for y
+ * @return this instance for scaling
+ */
+ public final Rectangle scaleInv(int sx, int sy) {
+ x /= sx ;
+ y /= sy ;
+ width /= sx ;
+ height /= sy ;
+ return this;
+ }
+
@Override
public int compareTo(final RectangleImmutable d) {
{
diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/SurfaceSize.java b/src/nativewindow/classes/javax/media/nativewindow/util/SurfaceSize.java
index 77619731f..6b4d2f19c 100644
--- a/src/nativewindow/classes/javax/media/nativewindow/util/SurfaceSize.java
+++ b/src/nativewindow/classes/javax/media/nativewindow/util/SurfaceSize.java
@@ -32,7 +32,7 @@ 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>
+ * <li>{@link javax.media.nativewindow.util.DimensionImmutable size in pixels}</li>
* <li><code>bits per pixel</code></li>
* </ul>
*/
@@ -48,6 +48,7 @@ public class SurfaceSize implements Comparable<SurfaceSize> {
this.bitsPerPixel=bitsPerPixel;
}
+ /** Returns the resolution in pixel units */
public final DimensionImmutable getResolution() {
return resolution;
}
@@ -58,7 +59,7 @@ public class SurfaceSize implements Comparable<SurfaceSize> {
@Override
public final String toString() {
- return "[ "+resolution+" x "+bitsPerPixel+" bpp ]";
+ return "[ "+resolution+" pixels x "+bitsPerPixel+" bpp ]";
}
/**