From 70b495519094de5fcca37da68fbbf8762eecbe28 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 4 Sep 2011 20:25:45 +0200 Subject: Unify Immutable/WriteCloneable Usage ; Remove Clonable for ImmutableOnly types --- .../javax/media/nativewindow/CapabilitiesImmutable.java | 2 -- .../classes/javax/media/nativewindow/util/Dimension.java | 4 ++++ .../javax/media/nativewindow/util/DimensionImmutable.java | 4 +++- .../classes/javax/media/nativewindow/util/Point.java | 8 ++++++-- .../javax/media/nativewindow/util/PointImmutable.java | 4 +++- .../classes/javax/media/nativewindow/util/Rectangle.java | 14 +++++++++----- .../javax/media/nativewindow/util/RectangleImmutable.java | 4 +++- .../classes/javax/media/nativewindow/util/SurfaceSize.java | 10 +--------- 8 files changed, 29 insertions(+), 21 deletions(-) (limited to 'src/nativewindow') diff --git a/src/nativewindow/classes/javax/media/nativewindow/CapabilitiesImmutable.java b/src/nativewindow/classes/javax/media/nativewindow/CapabilitiesImmutable.java index 8fb704bad..eccdf7797 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/CapabilitiesImmutable.java +++ b/src/nativewindow/classes/javax/media/nativewindow/CapabilitiesImmutable.java @@ -101,8 +101,6 @@ public interface CapabilitiesImmutable extends WriteCloneable { */ int getTransparentAlphaValue(); - Object cloneMutable(); - /** Equality over the immutable attributes of both objects */ @Override boolean equals(Object obj); diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/Dimension.java b/src/nativewindow/classes/javax/media/nativewindow/util/Dimension.java index ebf5b9e81..0a5a94565 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/util/Dimension.java +++ b/src/nativewindow/classes/javax/media/nativewindow/util/Dimension.java @@ -45,6 +45,10 @@ public class Dimension implements Cloneable, DimensionImmutable { this.height=height; } + public Object cloneMutable() { + return clone(); + } + public Object clone() { try { return super.clone(); diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/DimensionImmutable.java b/src/nativewindow/classes/javax/media/nativewindow/util/DimensionImmutable.java index 262086ba3..d14e94c10 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/util/DimensionImmutable.java +++ b/src/nativewindow/classes/javax/media/nativewindow/util/DimensionImmutable.java @@ -29,13 +29,15 @@ package javax.media.nativewindow.util; +import com.jogamp.common.type.WriteCloneable; + /** Immutable Dimension Interface, consisting of it's read only components:
* */ -public interface DimensionImmutable extends Cloneable { +public interface DimensionImmutable extends WriteCloneable { int getHeight(); diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/Point.java b/src/nativewindow/classes/javax/media/nativewindow/util/Point.java index 89a87541e..0a5036eda 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/util/Point.java +++ b/src/nativewindow/classes/javax/media/nativewindow/util/Point.java @@ -42,6 +42,10 @@ public class Point implements Cloneable, PointImmutable { this(0, 0); } + public Object cloneMutable() { + return clone(); + } + public Object clone() { try { return super.clone(); @@ -59,11 +63,11 @@ public class Point implements Cloneable, PointImmutable { return false; } - public int getX() { + public final int getX() { return x; } - public int getY() { + public final int getY() { return y; } diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/PointImmutable.java b/src/nativewindow/classes/javax/media/nativewindow/util/PointImmutable.java index 7f42138eb..d7eb0e7b4 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/util/PointImmutable.java +++ b/src/nativewindow/classes/javax/media/nativewindow/util/PointImmutable.java @@ -29,8 +29,10 @@ package javax.media.nativewindow.util; +import com.jogamp.common.type.WriteCloneable; + /** Immutable Point interface */ -public interface PointImmutable extends Cloneable { +public interface PointImmutable extends WriteCloneable { int getX(); diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/Rectangle.java b/src/nativewindow/classes/javax/media/nativewindow/util/Rectangle.java index 67bdcbfc7..8d6bfe48f 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/util/Rectangle.java +++ b/src/nativewindow/classes/javax/media/nativewindow/util/Rectangle.java @@ -44,7 +44,11 @@ public class Rectangle implements Cloneable, RectangleImmutable { this.width=width; this.height=height; } - + + public Object cloneMutable() { + return clone(); + } + protected Object clone() { try { return super.clone(); @@ -53,10 +57,10 @@ public class Rectangle implements Cloneable, RectangleImmutable { } } - public int getX() { return x; } - public int getY() { return y; } - public int getWidth() { return width; } - public int getHeight() { return height; } + public final int getX() { return x; } + public final int getY() { return y; } + public final int getWidth() { return width; } + public final 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; } diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/RectangleImmutable.java b/src/nativewindow/classes/javax/media/nativewindow/util/RectangleImmutable.java index ede8ba9c5..d3b43c864 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/util/RectangleImmutable.java +++ b/src/nativewindow/classes/javax/media/nativewindow/util/RectangleImmutable.java @@ -28,8 +28,10 @@ package javax.media.nativewindow.util; +import com.jogamp.common.type.WriteCloneable; + /** Immutable Rectangle interface */ -public interface RectangleImmutable extends Cloneable { +public interface RectangleImmutable extends WriteCloneable { int getHeight(); diff --git a/src/nativewindow/classes/javax/media/nativewindow/util/SurfaceSize.java b/src/nativewindow/classes/javax/media/nativewindow/util/SurfaceSize.java index 19786af2a..8f21bc49b 100644 --- a/src/nativewindow/classes/javax/media/nativewindow/util/SurfaceSize.java +++ b/src/nativewindow/classes/javax/media/nativewindow/util/SurfaceSize.java @@ -35,7 +35,7 @@ package javax.media.nativewindow.util; *
  • bits per pixel
  • * */ -public class SurfaceSize implements Cloneable { +public class SurfaceSize { DimensionImmutable resolution; int bitsPerPixel; @@ -47,14 +47,6 @@ public class SurfaceSize implements Cloneable { this.bitsPerPixel=bitsPerPixel; } - public Object clone() { - try { - return super.clone(); - } catch (CloneNotSupportedException ex) { - throw new InternalError(); - } - } - public final DimensionImmutable getResolution() { return resolution; } -- cgit v1.2.3