summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenneth Russel <[email protected]>2006-01-13 07:29:23 +0000
committerKenneth Russel <[email protected]>2006-01-13 07:29:23 +0000
commit16e23f079b1e5fdc15b64bf1593cbda8e8dcffc0 (patch)
tree8cf430f395f2a2691d152c9a61ca212d7a6c1f55 /src
parent688ffdc8cc190c51c3e7355a4893e3e475efa29f (diff)
Renamed com.sun.opengl.utils to com.sun.opengl.util. Moved
TextureIO-related classes to com.sun.opengl.util.texture and TextureProvider, TextureWriter and format-specific readers to com.sun.opengl.util.texture.spi. Renamed BufferUtils to BufferUtil. Added ImageUtil and FileUtil. Cleaned up javadoc. Updated demos. Cleaned up some imports. git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@538 232f8b59-042b-4e1e-8c03-345bb8c30851
Diffstat (limited to 'src')
-rw-r--r--src/classes/com/sun/gluegen/runtime/BufferFactory.java33
-rw-r--r--src/classes/com/sun/opengl/impl/Debug.java2
-rwxr-xr-xsrc/classes/com/sun/opengl/impl/Project.java4
-rwxr-xr-xsrc/classes/com/sun/opengl/util/Animator.java (renamed from src/classes/com/sun/opengl/utils/Animator.java)2
-rw-r--r--src/classes/com/sun/opengl/util/BitmapCharRec.java (renamed from src/classes/com/sun/opengl/utils/BitmapCharRec.java)2
-rw-r--r--src/classes/com/sun/opengl/util/BitmapFontRec.java (renamed from src/classes/com/sun/opengl/utils/BitmapFontRec.java)2
-rwxr-xr-x[-rw-r--r--]src/classes/com/sun/opengl/util/BufferUtil.java (renamed from src/classes/com/sun/opengl/utils/BufferUtils.java)6
-rw-r--r--src/classes/com/sun/opengl/util/CoordRec.java (renamed from src/classes/com/sun/opengl/utils/CoordRec.java)2
-rwxr-xr-xsrc/classes/com/sun/opengl/util/FPSAnimator.java (renamed from src/classes/com/sun/opengl/utils/FPSAnimator.java)2
-rwxr-xr-xsrc/classes/com/sun/opengl/util/FileUtil.java81
-rw-r--r--src/classes/com/sun/opengl/util/GLUT.java (renamed from src/classes/com/sun/opengl/utils/GLUT.java)2
-rw-r--r--src/classes/com/sun/opengl/util/GLUTBitmap8x13.java (renamed from src/classes/com/sun/opengl/utils/GLUTBitmap8x13.java)2
-rw-r--r--src/classes/com/sun/opengl/util/GLUTBitmap9x15.java (renamed from src/classes/com/sun/opengl/utils/GLUTBitmap9x15.java)2
-rw-r--r--src/classes/com/sun/opengl/util/GLUTBitmapHelvetica10.java (renamed from src/classes/com/sun/opengl/utils/GLUTBitmapHelvetica10.java)2
-rw-r--r--src/classes/com/sun/opengl/util/GLUTBitmapHelvetica12.java (renamed from src/classes/com/sun/opengl/utils/GLUTBitmapHelvetica12.java)2
-rw-r--r--src/classes/com/sun/opengl/util/GLUTBitmapHelvetica18.java (renamed from src/classes/com/sun/opengl/utils/GLUTBitmapHelvetica18.java)2
-rw-r--r--src/classes/com/sun/opengl/util/GLUTBitmapTimesRoman10.java (renamed from src/classes/com/sun/opengl/utils/GLUTBitmapTimesRoman10.java)2
-rw-r--r--src/classes/com/sun/opengl/util/GLUTBitmapTimesRoman24.java (renamed from src/classes/com/sun/opengl/utils/GLUTBitmapTimesRoman24.java)2
-rw-r--r--src/classes/com/sun/opengl/util/GLUTStrokeMonoRoman.java (renamed from src/classes/com/sun/opengl/utils/GLUTStrokeMonoRoman.java)2
-rw-r--r--src/classes/com/sun/opengl/util/GLUTStrokeRoman.java (renamed from src/classes/com/sun/opengl/utils/GLUTStrokeRoman.java)2
-rwxr-xr-xsrc/classes/com/sun/opengl/util/ImageUtil.java64
-rwxr-xr-xsrc/classes/com/sun/opengl/util/JOGLAppletLauncher.java (renamed from src/classes/com/sun/opengl/utils/JOGLAppletLauncher.java)4
-rwxr-xr-xsrc/classes/com/sun/opengl/util/Screenshot.java (renamed from src/classes/com/sun/opengl/utils/Screenshot.java)10
-rw-r--r--src/classes/com/sun/opengl/util/StrokeCharRec.java (renamed from src/classes/com/sun/opengl/utils/StrokeCharRec.java)2
-rw-r--r--src/classes/com/sun/opengl/util/StrokeFontRec.java (renamed from src/classes/com/sun/opengl/utils/StrokeFontRec.java)2
-rw-r--r--src/classes/com/sun/opengl/util/StrokeRec.java (renamed from src/classes/com/sun/opengl/utils/StrokeRec.java)2
-rw-r--r--src/classes/com/sun/opengl/util/Version.java (renamed from src/classes/com/sun/opengl/utils/Version.java)2
-rwxr-xr-xsrc/classes/com/sun/opengl/util/texture/Texture.java (renamed from src/classes/com/sun/opengl/utils/Texture.java)2
-rwxr-xr-xsrc/classes/com/sun/opengl/util/texture/TextureCoords.java (renamed from src/classes/com/sun/opengl/utils/TextureCoords.java)2
-rwxr-xr-xsrc/classes/com/sun/opengl/util/texture/TextureData.java (renamed from src/classes/com/sun/opengl/utils/TextureData.java)5
-rwxr-xr-xsrc/classes/com/sun/opengl/util/texture/TextureIO.java (renamed from src/classes/com/sun/opengl/utils/TextureIO.java)69
-rwxr-xr-xsrc/classes/com/sun/opengl/util/texture/spi/DDSImage.java (renamed from src/classes/com/sun/opengl/utils/DDSImage.java)2
-rwxr-xr-xsrc/classes/com/sun/opengl/util/texture/spi/LEDataInputStream.java (renamed from src/classes/com/sun/opengl/utils/LEDataInputStream.java)2
-rwxr-xr-xsrc/classes/com/sun/opengl/util/texture/spi/SGIImage.java (renamed from src/classes/com/sun/opengl/utils/SGIImage.java)4
-rwxr-xr-xsrc/classes/com/sun/opengl/util/texture/spi/TGAImage.java (renamed from src/classes/com/sun/opengl/utils/TGAImage.java)4
-rwxr-xr-xsrc/classes/com/sun/opengl/util/texture/spi/TextureProvider.java (renamed from src/classes/com/sun/opengl/utils/TextureProvider.java)4
-rwxr-xr-xsrc/classes/com/sun/opengl/util/texture/spi/TextureWriter.java (renamed from src/classes/com/sun/opengl/utils/TextureWriter.java)4
37 files changed, 224 insertions, 116 deletions
diff --git a/src/classes/com/sun/gluegen/runtime/BufferFactory.java b/src/classes/com/sun/gluegen/runtime/BufferFactory.java
index dd8856a43..ce46d145f 100644
--- a/src/classes/com/sun/gluegen/runtime/BufferFactory.java
+++ b/src/classes/com/sun/gluegen/runtime/BufferFactory.java
@@ -40,15 +40,14 @@
package com.sun.gluegen.runtime;
import java.nio.*;
-import com.sun.opengl.utils.BufferUtils;
public class BufferFactory {
-
- public static int SIZEOF_FLOAT = BufferUtils.SIZEOF_FLOAT;
- public static int SIZEOF_DOUBLE = BufferUtils.SIZEOF_DOUBLE;
- public static int SIZEOF_INT = BufferUtils.SIZEOF_INT;
- public static int SIZEOF_SHORT = BufferUtils.SIZEOF_SHORT;
- public static int SIZEOF_LONG = BufferUtils.SIZEOF_LONG;
+ public static final int SIZEOF_BYTE = 1;
+ public static final int SIZEOF_SHORT = 2;
+ public static final int SIZEOF_INT = 4;
+ public static final int SIZEOF_FLOAT = 4;
+ public static final int SIZEOF_LONG = 8;
+ public static final int SIZEOF_DOUBLE = 8;
public static ByteBuffer newDirectByteBuffer(int size) {
ByteBuffer buf = ByteBuffer.allocateDirect(size);
@@ -93,15 +92,15 @@ public class BufferFactory {
if(buf instanceof ByteBuffer) {
return (buf.position());
} else if (buf instanceof FloatBuffer) {
- return (buf.position() * BufferUtils.SIZEOF_FLOAT);
+ return (buf.position() * SIZEOF_FLOAT);
} else if (buf instanceof IntBuffer) {
- return (buf.position() * BufferUtils.SIZEOF_INT);
+ return (buf.position() * SIZEOF_INT);
} else if (buf instanceof ShortBuffer) {
- return (buf.position() * BufferUtils.SIZEOF_SHORT);
+ return (buf.position() * SIZEOF_SHORT);
} else if (buf instanceof DoubleBuffer) {
- return (buf.position() * BufferUtils.SIZEOF_DOUBLE);
+ return (buf.position() * SIZEOF_DOUBLE);
} else if (buf instanceof LongBuffer) {
- return (buf.position() * BufferUtils.SIZEOF_LONG);
+ return (buf.position() * SIZEOF_LONG);
}
throw new RuntimeException("Disallowed array backing store type in buffer "
@@ -148,15 +147,15 @@ public class BufferFactory {
if(buf instanceof ByteBuffer) {
return (((ByteBuffer)buf).arrayOffset() + pos);
} else if(buf instanceof FloatBuffer) {
- return (BufferUtils.SIZEOF_FLOAT*(((FloatBuffer)buf).arrayOffset() + pos));
+ return (SIZEOF_FLOAT*(((FloatBuffer)buf).arrayOffset() + pos));
} else if(buf instanceof IntBuffer) {
- return (BufferUtils.SIZEOF_INT*(((IntBuffer)buf).arrayOffset() + pos));
+ return (SIZEOF_INT*(((IntBuffer)buf).arrayOffset() + pos));
} else if(buf instanceof ShortBuffer) {
- return (BufferUtils.SIZEOF_SHORT*(((ShortBuffer)buf).arrayOffset() + pos));
+ return (SIZEOF_SHORT*(((ShortBuffer)buf).arrayOffset() + pos));
} else if(buf instanceof DoubleBuffer) {
- return (BufferUtils.SIZEOF_DOUBLE*(((DoubleBuffer)buf).arrayOffset() + pos));
+ return (SIZEOF_DOUBLE*(((DoubleBuffer)buf).arrayOffset() + pos));
} else if(buf instanceof LongBuffer) {
- return (BufferUtils.SIZEOF_LONG*(((LongBuffer)buf).arrayOffset() + pos));
+ return (SIZEOF_LONG*(((LongBuffer)buf).arrayOffset() + pos));
}
throw new RuntimeException("Unknown buffer type " + buf.getClass().getName());
diff --git a/src/classes/com/sun/opengl/impl/Debug.java b/src/classes/com/sun/opengl/impl/Debug.java
index 8d25db304..a2490d1ef 100644
--- a/src/classes/com/sun/opengl/impl/Debug.java
+++ b/src/classes/com/sun/opengl/impl/Debug.java
@@ -40,7 +40,7 @@
package com.sun.opengl.impl;
import java.security.*;
-import com.sun.opengl.utils.Version;
+import com.sun.opengl.util.Version;
/** Helper routines for logging and debugging. */
diff --git a/src/classes/com/sun/opengl/impl/Project.java b/src/classes/com/sun/opengl/impl/Project.java
index ea24062f6..183bd7e16 100755
--- a/src/classes/com/sun/opengl/impl/Project.java
+++ b/src/classes/com/sun/opengl/impl/Project.java
@@ -107,7 +107,7 @@ package com.sun.opengl.impl;
import java.nio.*;
import javax.media.opengl.*;
-import com.sun.opengl.utils.*;
+import com.sun.opengl.util.*;
/**
* Project.java
@@ -162,7 +162,7 @@ public class Project {
// Slice up one big buffer because some NIO implementations
// allocate a huge amount of memory to back even the smallest of
// buffers.
- DoubleBuffer buf = BufferUtils.newDoubleBuffer(128);
+ DoubleBuffer buf = BufferUtil.newDoubleBuffer(128);
int pos = 0;
int sz = 16;
matrixBuf = slice(buf, pos, sz);
diff --git a/src/classes/com/sun/opengl/utils/Animator.java b/src/classes/com/sun/opengl/util/Animator.java
index 5920b93b9..417fc776d 100755
--- a/src/classes/com/sun/opengl/utils/Animator.java
+++ b/src/classes/com/sun/opengl/util/Animator.java
@@ -37,7 +37,7 @@
* and developed by Kenneth Bradley Russell and Christopher John Kline.
*/
-package com.sun.opengl.utils;
+package com.sun.opengl.util;
import java.awt.Component;
import java.awt.EventQueue;
diff --git a/src/classes/com/sun/opengl/utils/BitmapCharRec.java b/src/classes/com/sun/opengl/util/BitmapCharRec.java
index a24ab1122..b20781ba1 100644
--- a/src/classes/com/sun/opengl/utils/BitmapCharRec.java
+++ b/src/classes/com/sun/opengl/util/BitmapCharRec.java
@@ -37,7 +37,7 @@
* and developed by Kenneth Bradley Russell and Christopher John Kline.
*/
-package com.sun.opengl.utils;
+package com.sun.opengl.util;
/* Copyright (c) Mark J. Kilgard, 1994, 1998. */
diff --git a/src/classes/com/sun/opengl/utils/BitmapFontRec.java b/src/classes/com/sun/opengl/util/BitmapFontRec.java
index c300ad159..95b7a7346 100644
--- a/src/classes/com/sun/opengl/utils/BitmapFontRec.java
+++ b/src/classes/com/sun/opengl/util/BitmapFontRec.java
@@ -37,7 +37,7 @@
* and developed by Kenneth Bradley Russell and Christopher John Kline.
*/
-package com.sun.opengl.utils;
+package com.sun.opengl.util;
/* Copyright (c) Mark J. Kilgard, 1994, 1998. */
diff --git a/src/classes/com/sun/opengl/utils/BufferUtils.java b/src/classes/com/sun/opengl/util/BufferUtil.java
index 995fa0646..e16c5685d 100644..100755
--- a/src/classes/com/sun/opengl/utils/BufferUtils.java
+++ b/src/classes/com/sun/opengl/util/BufferUtil.java
@@ -37,14 +37,14 @@
* and developed by Kenneth Bradley Russell and Christopher John Kline.
*/
-package com.sun.opengl.utils;
+package com.sun.opengl.util;
import java.nio.*;
import java.util.*;
/** Utility routines for dealing with direct buffers. */
-public class BufferUtils {
+public class BufferUtil {
public static final int SIZEOF_BYTE = 1;
public static final int SIZEOF_SHORT = 2;
public static final int SIZEOF_INT = 4;
@@ -52,6 +52,8 @@ public class BufferUtils {
public static final int SIZEOF_LONG = 8;
public static final int SIZEOF_DOUBLE = 8;
+ private BufferUtil() {}
+
//----------------------------------------------------------------------
// Allocation routines
//
diff --git a/src/classes/com/sun/opengl/utils/CoordRec.java b/src/classes/com/sun/opengl/util/CoordRec.java
index 44f786377..6a1cba8fb 100644
--- a/src/classes/com/sun/opengl/utils/CoordRec.java
+++ b/src/classes/com/sun/opengl/util/CoordRec.java
@@ -37,7 +37,7 @@
* and developed by Kenneth Bradley Russell and Christopher John Kline.
*/
-package com.sun.opengl.utils;
+package com.sun.opengl.util;
/* Copyright (c) Mark J. Kilgard, 1994, 1998. */
diff --git a/src/classes/com/sun/opengl/utils/FPSAnimator.java b/src/classes/com/sun/opengl/util/FPSAnimator.java
index c45ff15c4..fae0ce0ae 100755
--- a/src/classes/com/sun/opengl/utils/FPSAnimator.java
+++ b/src/classes/com/sun/opengl/util/FPSAnimator.java
@@ -37,7 +37,7 @@
* and developed by Kenneth Bradley Russell and Christopher John Kline.
*/
-package com.sun.opengl.utils;
+package com.sun.opengl.util;
import java.util.*;
import javax.media.opengl.*;
diff --git a/src/classes/com/sun/opengl/util/FileUtil.java b/src/classes/com/sun/opengl/util/FileUtil.java
new file mode 100755
index 000000000..6ff3e2bbd
--- /dev/null
+++ b/src/classes/com/sun/opengl/util/FileUtil.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2005 Sun Microsystems, Inc. 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.
+ *
+ * You acknowledge that this software is not designed or intended for use
+ * in the design, construction, operation or maintenance of any nuclear
+ * facility.
+ *
+ * Sun gratefully acknowledges that this software was originally authored
+ * and developed by Kenneth Bradley Russell and Christopher John Kline.
+ */
+
+package com.sun.opengl.util;
+
+import java.io.*;
+
+/** Utilities for dealing with files. */
+
+public class FileUtil {
+ private FileUtil() {}
+
+ /**
+ * Returns the suffix of the given file name for identifying the
+ * file to the configured TextureProviders.
+ *
+ * @param file name of the file
+ */
+
+ public static String getFileSuffix(File file) {
+ return getFileSuffix(file.getName());
+ }
+
+ /**
+ * Returns the suffix of the given file name for identifying the
+ * file to the configured TextureProviders.
+ *
+ * @param filename name of the file
+ */
+ public static String getFileSuffix(String filename) {
+ int lastDot = filename.lastIndexOf('.');
+ if (lastDot < 0) {
+ return null;
+ }
+ return toLowerCase(filename.substring(lastDot + 1));
+ }
+
+ private static String toLowerCase(String arg) {
+ if (arg == null) {
+ return null;
+ }
+
+ return arg.toLowerCase();
+ }
+}
diff --git a/src/classes/com/sun/opengl/utils/GLUT.java b/src/classes/com/sun/opengl/util/GLUT.java
index 2896729e2..07264b240 100644
--- a/src/classes/com/sun/opengl/utils/GLUT.java
+++ b/src/classes/com/sun/opengl/util/GLUT.java
@@ -37,7 +37,7 @@
* and developed by Kenneth Bradley Russell and Christopher John Kline.
*/
-package com.sun.opengl.utils;
+package com.sun.opengl.util;
import javax.media.opengl.*;
import javax.media.opengl.glu.*;
diff --git a/src/classes/com/sun/opengl/utils/GLUTBitmap8x13.java b/src/classes/com/sun/opengl/util/GLUTBitmap8x13.java
index a373aeb8d..55a213c02 100644
--- a/src/classes/com/sun/opengl/utils/GLUTBitmap8x13.java
+++ b/src/classes/com/sun/opengl/util/GLUTBitmap8x13.java
@@ -37,7 +37,7 @@
* and developed by Kenneth Bradley Russell and Christopher John Kline.
*/
-package com.sun.opengl.utils;
+package com.sun.opengl.util;
class GLUTBitmap8x13 {
diff --git a/src/classes/com/sun/opengl/utils/GLUTBitmap9x15.java b/src/classes/com/sun/opengl/util/GLUTBitmap9x15.java
index c1668967d..d6e0de05f 100644
--- a/src/classes/com/sun/opengl/utils/GLUTBitmap9x15.java
+++ b/src/classes/com/sun/opengl/util/GLUTBitmap9x15.java
@@ -37,7 +37,7 @@
* and developed by Kenneth Bradley Russell and Christopher John Kline.
*/
-package com.sun.opengl.utils;
+package com.sun.opengl.util;
class GLUTBitmap9x15 {
diff --git a/src/classes/com/sun/opengl/utils/GLUTBitmapHelvetica10.java b/src/classes/com/sun/opengl/util/GLUTBitmapHelvetica10.java
index 9a329f6a3..f2fc8ab76 100644
--- a/src/classes/com/sun/opengl/utils/GLUTBitmapHelvetica10.java
+++ b/src/classes/com/sun/opengl/util/GLUTBitmapHelvetica10.java
@@ -37,7 +37,7 @@
* and developed by Kenneth Bradley Russell and Christopher John Kline.
*/
-package com.sun.opengl.utils;
+package com.sun.opengl.util;
class GLUTBitmapHelvetica10 {
diff --git a/src/classes/com/sun/opengl/utils/GLUTBitmapHelvetica12.java b/src/classes/com/sun/opengl/util/GLUTBitmapHelvetica12.java
index e27431c4e..97a3fffbf 100644
--- a/src/classes/com/sun/opengl/utils/GLUTBitmapHelvetica12.java
+++ b/src/classes/com/sun/opengl/util/GLUTBitmapHelvetica12.java
@@ -37,7 +37,7 @@
* and developed by Kenneth Bradley Russell and Christopher John Kline.
*/
-package com.sun.opengl.utils;
+package com.sun.opengl.util;
class GLUTBitmapHelvetica12 {
diff --git a/src/classes/com/sun/opengl/utils/GLUTBitmapHelvetica18.java b/src/classes/com/sun/opengl/util/GLUTBitmapHelvetica18.java
index baf95d818..f172de683 100644
--- a/src/classes/com/sun/opengl/utils/GLUTBitmapHelvetica18.java
+++ b/src/classes/com/sun/opengl/util/GLUTBitmapHelvetica18.java
@@ -37,7 +37,7 @@
* and developed by Kenneth Bradley Russell and Christopher John Kline.
*/
-package com.sun.opengl.utils;
+package com.sun.opengl.util;
class GLUTBitmapHelvetica18 {
diff --git a/src/classes/com/sun/opengl/utils/GLUTBitmapTimesRoman10.java b/src/classes/com/sun/opengl/util/GLUTBitmapTimesRoman10.java
index 00cf2975c..fc06ddea3 100644
--- a/src/classes/com/sun/opengl/utils/GLUTBitmapTimesRoman10.java
+++ b/src/classes/com/sun/opengl/util/GLUTBitmapTimesRoman10.java
@@ -37,7 +37,7 @@
* and developed by Kenneth Bradley Russell and Christopher John Kline.
*/
-package com.sun.opengl.utils;
+package com.sun.opengl.util;
class GLUTBitmapTimesRoman10 {
diff --git a/src/classes/com/sun/opengl/utils/GLUTBitmapTimesRoman24.java b/src/classes/com/sun/opengl/util/GLUTBitmapTimesRoman24.java
index 22d2a19a2..3a03e3893 100644
--- a/src/classes/com/sun/opengl/utils/GLUTBitmapTimesRoman24.java
+++ b/src/classes/com/sun/opengl/util/GLUTBitmapTimesRoman24.java
@@ -37,7 +37,7 @@
* and developed by Kenneth Bradley Russell and Christopher John Kline.
*/
-package com.sun.opengl.utils;
+package com.sun.opengl.util;
class GLUTBitmapTimesRoman24 {
diff --git a/src/classes/com/sun/opengl/utils/GLUTStrokeMonoRoman.java b/src/classes/com/sun/opengl/util/GLUTStrokeMonoRoman.java
index 39aaf8a18..8c9910994 100644
--- a/src/classes/com/sun/opengl/utils/GLUTStrokeMonoRoman.java
+++ b/src/classes/com/sun/opengl/util/GLUTStrokeMonoRoman.java
@@ -37,7 +37,7 @@
* and developed by Kenneth Bradley Russell and Christopher John Kline.
*/
-package com.sun.opengl.utils;
+package com.sun.opengl.util;
class GLUTStrokeMonoRoman {
diff --git a/src/classes/com/sun/opengl/utils/GLUTStrokeRoman.java b/src/classes/com/sun/opengl/util/GLUTStrokeRoman.java
index de040508a..8345c15e8 100644
--- a/src/classes/com/sun/opengl/utils/GLUTStrokeRoman.java
+++ b/src/classes/com/sun/opengl/util/GLUTStrokeRoman.java
@@ -37,7 +37,7 @@
* and developed by Kenneth Bradley Russell and Christopher John Kline.
*/
-package com.sun.opengl.utils;
+package com.sun.opengl.util;
class GLUTStrokeRoman {
diff --git a/src/classes/com/sun/opengl/util/ImageUtil.java b/src/classes/com/sun/opengl/util/ImageUtil.java
new file mode 100755
index 000000000..1ce77fecf
--- /dev/null
+++ b/src/classes/com/sun/opengl/util/ImageUtil.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2005 Sun Microsystems, Inc. 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.
+ *
+ * You acknowledge that this software is not designed or intended for use
+ * in the design, construction, operation or maintenance of any nuclear
+ * facility.
+ *
+ * Sun gratefully acknowledges that this software was originally authored
+ * and developed by Kenneth Bradley Russell and Christopher John Kline.
+ */
+
+package com.sun.opengl.util;
+
+import java.awt.image.*;
+
+/** Utilities for dealing with images. */
+
+public class ImageUtil {
+ private ImageUtil() {}
+
+ /** Flips the supplied BufferedImage vertically. This is often a
+ necessary conversion step to display a Java2D image correctly
+ with OpenGL and vice versa. */
+ public static void flipImageVertically(BufferedImage image) {
+ WritableRaster raster = image.getRaster();
+ Object scanline1 = null;
+ Object scanline2 = null;
+
+ for (int i = 0; i < image.getHeight() / 2; i++) {
+ scanline1 = raster.getDataElements(0, i, image.getWidth(), 1, scanline1);
+ scanline2 = raster.getDataElements(0, image.getHeight() - i - 1, image.getWidth(), 1, scanline2);
+ raster.setDataElements(0, i, image.getWidth(), 1, scanline2);
+ raster.setDataElements(0, image.getHeight() - i - 1, image.getWidth(), 1, scanline1);
+ }
+ }
+}
diff --git a/src/classes/com/sun/opengl/utils/JOGLAppletLauncher.java b/src/classes/com/sun/opengl/util/JOGLAppletLauncher.java
index 0ba85f799..d3a460053 100755
--- a/src/classes/com/sun/opengl/utils/JOGLAppletLauncher.java
+++ b/src/classes/com/sun/opengl/util/JOGLAppletLauncher.java
@@ -40,7 +40,7 @@
* facility.
*/
-package com.sun.opengl.utils;
+package com.sun.opengl.util;
import java.awt.BorderLayout;
import java.awt.Color;
@@ -75,7 +75,7 @@ import javax.media.opengl.*;
*
* Sample applet code:
* <pre>
- * &lt;applet code="com.sun.opengl.utils.JOGLAppletLauncher"
+ * &lt;applet code="com.sun.opengl.util.JOGLAppletLauncher"
* width=600
* height=400
* codebase="/lib"
diff --git a/src/classes/com/sun/opengl/utils/Screenshot.java b/src/classes/com/sun/opengl/util/Screenshot.java
index 82e0bc0e1..dfbc44b02 100755
--- a/src/classes/com/sun/opengl/utils/Screenshot.java
+++ b/src/classes/com/sun/opengl/util/Screenshot.java
@@ -34,7 +34,7 @@
* facility.
*/
-package com.sun.opengl.utils;
+package com.sun.opengl.util;
import java.awt.image.*;
import java.io.*;
@@ -50,6 +50,8 @@ import javax.media.opengl.glu.*;
public class Screenshot {
private static final int TARGA_HEADER_SIZE = 18;
+ private Screenshot() {}
+
/**
* Takes a fast screenshot of the current OpenGL drawable to a Targa
* file. Requires the OpenGL context for the desired drawable to be
@@ -140,7 +142,7 @@ public class Screenshot {
psm.restore(gl);
// Must flip BufferedImage vertically for correct results
- TextureIO.flipImageVertically(image);
+ ImageUtil.flipImageVertically(image);
return image;
}
@@ -164,9 +166,9 @@ public class Screenshot {
int width,
int height) throws IOException, GLException {
BufferedImage image = readToBufferedImage(width, height);
- if (!ImageIO.write(image, TextureIO.getFileSuffix(file), file)) {
+ if (!ImageIO.write(image, FileUtil.getFileSuffix(file), file)) {
throw new IOException("Unsupported file format " +
- TextureIO.getFileSuffix(file));
+ FileUtil.getFileSuffix(file));
}
}
diff --git a/src/classes/com/sun/opengl/utils/StrokeCharRec.java b/src/classes/com/sun/opengl/util/StrokeCharRec.java
index 8601e4079..5c6f14b6c 100644
--- a/src/classes/com/sun/opengl/utils/StrokeCharRec.java
+++ b/src/classes/com/sun/opengl/util/StrokeCharRec.java
@@ -37,7 +37,7 @@
* and developed by Kenneth Bradley Russell and Christopher John Kline.
*/
-package com.sun.opengl.utils;
+package com.sun.opengl.util;
/* Copyright (c) Mark J. Kilgard, 1994, 1998. */
diff --git a/src/classes/com/sun/opengl/utils/StrokeFontRec.java b/src/classes/com/sun/opengl/util/StrokeFontRec.java
index 2ea2d21ac..825bed7c5 100644
--- a/src/classes/com/sun/opengl/utils/StrokeFontRec.java
+++ b/src/classes/com/sun/opengl/util/StrokeFontRec.java
@@ -37,7 +37,7 @@
* and developed by Kenneth Bradley Russell and Christopher John Kline.
*/
-package com.sun.opengl.utils;
+package com.sun.opengl.util;
/* Copyright (c) Mark J. Kilgard, 1994, 1998. */
diff --git a/src/classes/com/sun/opengl/utils/StrokeRec.java b/src/classes/com/sun/opengl/util/StrokeRec.java
index bc875856e..ed5bec48f 100644
--- a/src/classes/com/sun/opengl/utils/StrokeRec.java
+++ b/src/classes/com/sun/opengl/util/StrokeRec.java
@@ -37,7 +37,7 @@
* and developed by Kenneth Bradley Russell and Christopher John Kline.
*/
-package com.sun.opengl.utils;
+package com.sun.opengl.util;
/* Copyright (c) Mark J. Kilgard, 1994, 1998. */
diff --git a/src/classes/com/sun/opengl/utils/Version.java b/src/classes/com/sun/opengl/util/Version.java
index 1ba5a63a0..8f0acef0e 100644
--- a/src/classes/com/sun/opengl/utils/Version.java
+++ b/src/classes/com/sun/opengl/util/Version.java
@@ -31,7 +31,7 @@
* design, construction, operation or maintenance of any nuclear facility.
*/
-package com.sun.opengl.utils;
+package com.sun.opengl.util;
/**
* The version and build number of this implementation.
diff --git a/src/classes/com/sun/opengl/utils/Texture.java b/src/classes/com/sun/opengl/util/texture/Texture.java
index 924161d69..9987551e2 100755
--- a/src/classes/com/sun/opengl/utils/Texture.java
+++ b/src/classes/com/sun/opengl/util/texture/Texture.java
@@ -34,7 +34,7 @@
* facility.
*/
-package com.sun.opengl.utils;
+package com.sun.opengl.util.texture;
import java.nio.*;
diff --git a/src/classes/com/sun/opengl/utils/TextureCoords.java b/src/classes/com/sun/opengl/util/texture/TextureCoords.java
index ec3760026..dca1d1e01 100755
--- a/src/classes/com/sun/opengl/utils/TextureCoords.java
+++ b/src/classes/com/sun/opengl/util/texture/TextureCoords.java
@@ -34,7 +34,7 @@
* facility.
*/
-package com.sun.opengl.utils;
+package com.sun.opengl.util.texture;
/** Specifies texture coordinates for a rectangular area of a
texture. Note that some textures are inherently flipped vertically
diff --git a/src/classes/com/sun/opengl/utils/TextureData.java b/src/classes/com/sun/opengl/util/texture/TextureData.java
index d2b0c75ab..83a1c983e 100755
--- a/src/classes/com/sun/opengl/utils/TextureData.java
+++ b/src/classes/com/sun/opengl/util/texture/TextureData.java
@@ -34,7 +34,7 @@
* facility.
*/
-package com.sun.opengl.utils;
+package com.sun.opengl.util.texture;
import java.awt.AlphaComposite;
import java.awt.Color;
@@ -45,6 +45,7 @@ import java.awt.image.*;
import java.nio.*;
import javax.media.opengl.*;
+import com.sun.opengl.util.*;
/**
* Represents the data for an OpenGL texture. This is separated from
@@ -316,7 +317,7 @@ public class TextureData {
private void createNIOBufferFromImage(BufferedImage image, boolean flipVertically) {
if (flipVertically) {
- TextureIO.flipImageVertically(image);
+ ImageUtil.flipImageVertically(image);
}
//
diff --git a/src/classes/com/sun/opengl/utils/TextureIO.java b/src/classes/com/sun/opengl/util/texture/TextureIO.java
index d1f62cd5c..c1e5bcf8b 100755
--- a/src/classes/com/sun/opengl/utils/TextureIO.java
+++ b/src/classes/com/sun/opengl/util/texture/TextureIO.java
@@ -37,7 +37,7 @@
* and developed by Kenneth Bradley Russell and Christopher John Kline.
*/
-package com.sun.opengl.utils;
+package com.sun.opengl.util.texture;
import java.awt.Graphics;
import java.awt.image.*;
@@ -49,6 +49,8 @@ import javax.imageio.*;
import javax.media.opengl.*;
import javax.media.opengl.glu.*;
+import com.sun.opengl.util.*;
+import com.sun.opengl.util.texture.spi.*;
/** <P> Provides input and output facilities for both loading OpenGL
textures from disk and streams as well as writing textures already
@@ -438,7 +440,7 @@ public class TextureIO {
* OpenGL error occurred
*/
public static Texture newTexture(File file, boolean mipmap) throws IOException, GLException {
- TextureData data = newTextureData(file, mipmap, getFileSuffix(file));
+ TextureData data = newTextureData(file, mipmap, FileUtil.getFileSuffix(file));
Texture texture = newTexture(data);
data.flush();
return texture;
@@ -645,53 +647,6 @@ public class TextureIO {
}
//----------------------------------------------------------------------
- // Helper function for above TextureProviders
- /**
- * Returns the suffix of the given file name for identifying the
- * file to the configured TextureProviders.
- *
- * @param file name of the file
- */
-
- public static String getFileSuffix(File file) {
- return getFileSuffix(file.getName());
- }
-
- /**
- * Returns the suffix of the given file name for identifying the
- * file to the configured TextureProviders.
- *
- * @param filename name of the file
- */
- public static String getFileSuffix(String filename) {
- int lastDot = filename.lastIndexOf('.');
- if (lastDot < 0) {
- return null;
- }
- return toLowerCase(filename.substring(lastDot + 1));
- }
-
- //----------------------------------------------------------------------
- // Helper function which may be more generally useful
- //
-
- /** Flips the supplied BufferedImage vertically. This is often a
- necessary conversion step to display a Java2D image correctly
- with OpenGL and vice versa. */
- public static void flipImageVertically(BufferedImage image) {
- WritableRaster raster = image.getRaster();
- Object scanline1 = null;
- Object scanline2 = null;
-
- for (int i = 0; i < image.getHeight() / 2; i++) {
- scanline1 = raster.getDataElements(0, i, image.getWidth(), 1, scanline1);
- scanline2 = raster.getDataElements(0, image.getHeight() - i - 1, image.getWidth(), 1, scanline2);
- raster.setDataElements(0, i, image.getWidth(), 1, scanline2);
- raster.setDataElements(0, image.getHeight() - i - 1, image.getWidth(), 1, scanline1);
- }
- }
-
- //----------------------------------------------------------------------
// SPI support
//
@@ -879,7 +834,7 @@ public class TextureIO {
boolean mipmap,
String fileSuffix) throws IOException {
if (DDS.equals(fileSuffix) ||
- DDS.equals(getFileSuffix(file))) {
+ DDS.equals(FileUtil.getFileSuffix(file))) {
final DDSImage image = DDSImage.read(file);
DDSImage.ImageInfo info = image.getMipMap(0);
if (pixelFormat == 0) {
@@ -995,7 +950,7 @@ public class TextureIO {
internalFormat,
pixelFormat,
mipmap,
- ((fileSuffix != null) ? fileSuffix : getFileSuffix(file)));
+ ((fileSuffix != null) ? fileSuffix : FileUtil.getFileSuffix(file)));
} finally {
inStream.close();
}
@@ -1132,10 +1087,10 @@ public class TextureIO {
}
// Flip image vertically for the user's convenience
- flipImageVertically(image);
+ ImageUtil.flipImageVertically(image);
// Happened to notice that writing RGBA images to JPEGS is broken
- if (JPG.equals(getFileSuffix(file)) &&
+ if (JPG.equals(FileUtil.getFileSuffix(file)) &&
image.getType() == BufferedImage.TYPE_4BYTE_ABGR) {
BufferedImage tmpImage = new BufferedImage(image.getWidth(), image.getHeight(),
BufferedImage.TYPE_3BYTE_BGR);
@@ -1145,7 +1100,7 @@ public class TextureIO {
image = tmpImage;
}
- return ImageIO.write(image, getFileSuffix(file), file);
+ return ImageIO.write(image, FileUtil.getFileSuffix(file), file);
}
throw new IOException("ImageIO writer doesn't support this pixel format / type (only GL_RGB/A + bytes)");
@@ -1158,7 +1113,7 @@ public class TextureIO {
static class DDSTextureWriter implements TextureWriter {
public boolean write(File file,
TextureData data) throws IOException {
- if (DDS.equals(getFileSuffix(file))) {
+ if (DDS.equals(FileUtil.getFileSuffix(file))) {
// See whether the DDS writer can handle this TextureData
int pixelFormat = data.getPixelFormat();
int pixelType = data.getPixelType();
@@ -1207,7 +1162,7 @@ public class TextureIO {
static class SGITextureWriter implements TextureWriter {
public boolean write(File file,
TextureData data) throws IOException {
- String fileSuffix = getFileSuffix(file);
+ String fileSuffix = FileUtil.getFileSuffix(file);
if (SGI.equals(fileSuffix) ||
SGI_RGB.equals(fileSuffix)) {
// See whether the SGI writer can handle this TextureData
@@ -1251,7 +1206,7 @@ public class TextureIO {
static class TGATextureWriter implements TextureWriter {
public boolean write(File file,
TextureData data) throws IOException {
- if (TGA.equals(getFileSuffix(file))) {
+ if (TGA.equals(FileUtil.getFileSuffix(file))) {
// See whether the TGA writer can handle this TextureData
int pixelFormat = data.getPixelFormat();
int pixelType = data.getPixelType();
diff --git a/src/classes/com/sun/opengl/utils/DDSImage.java b/src/classes/com/sun/opengl/util/texture/spi/DDSImage.java
index 305e77348..486515628 100755
--- a/src/classes/com/sun/opengl/utils/DDSImage.java
+++ b/src/classes/com/sun/opengl/util/texture/spi/DDSImage.java
@@ -37,7 +37,7 @@
* and developed by Kenneth Bradley Russell and Christopher John Kline.
*/
-package com.sun.opengl.utils;
+package com.sun.opengl.util.texture.spi;
import java.io.*;
import java.nio.*;
diff --git a/src/classes/com/sun/opengl/utils/LEDataInputStream.java b/src/classes/com/sun/opengl/util/texture/spi/LEDataInputStream.java
index eb041c161..edbb6e35e 100755
--- a/src/classes/com/sun/opengl/utils/LEDataInputStream.java
+++ b/src/classes/com/sun/opengl/util/texture/spi/LEDataInputStream.java
@@ -37,7 +37,7 @@
* and developed by Kenneth Bradley Russell and Christopher John Kline.
*/
-package com.sun.opengl.utils;
+package com.sun.opengl.util.texture.spi;
import java.io.DataInput;
import java.io.DataInputStream;
diff --git a/src/classes/com/sun/opengl/utils/SGIImage.java b/src/classes/com/sun/opengl/util/texture/spi/SGIImage.java
index f06c10b56..12523eb18 100755
--- a/src/classes/com/sun/opengl/utils/SGIImage.java
+++ b/src/classes/com/sun/opengl/util/texture/spi/SGIImage.java
@@ -37,11 +37,11 @@
* and developed by Kenneth Bradley Russell and Christopher John Kline.
*/
-package com.sun.opengl.utils;
+package com.sun.opengl.util.texture.spi;
import java.io.*;
import javax.media.opengl.*;
-import com.sun.opengl.utils.*;
+import com.sun.opengl.util.*;
// Test harness
import java.awt.image.*;
diff --git a/src/classes/com/sun/opengl/utils/TGAImage.java b/src/classes/com/sun/opengl/util/texture/spi/TGAImage.java
index c676d1a6a..8ab095643 100755
--- a/src/classes/com/sun/opengl/utils/TGAImage.java
+++ b/src/classes/com/sun/opengl/util/texture/spi/TGAImage.java
@@ -37,13 +37,13 @@
* and developed by Kenneth Bradley Russell and Christopher John Kline.
*/
-package com.sun.opengl.utils;
+package com.sun.opengl.util.texture.spi;
import java.io.*;
import java.nio.*;
import java.nio.channels.*;
import javax.media.opengl.*;
-import com.sun.opengl.utils.*;
+import com.sun.opengl.util.*;
/**
* Targa image reader and writer adapted from sources of the <a href =
diff --git a/src/classes/com/sun/opengl/utils/TextureProvider.java b/src/classes/com/sun/opengl/util/texture/spi/TextureProvider.java
index fcc62c894..1c822ef02 100755
--- a/src/classes/com/sun/opengl/utils/TextureProvider.java
+++ b/src/classes/com/sun/opengl/util/texture/spi/TextureProvider.java
@@ -37,11 +37,13 @@
* and developed by Kenneth Bradley Russell and Christopher John Kline.
*/
-package com.sun.opengl.utils;
+package com.sun.opengl.util.texture.spi;
import java.io.*;
import java.net.*;
+import com.sun.opengl.util.texture.*;
+
/** Plug-in interface to TextureIO to support reading OpenGL textures
from new file formats. For all methods, either internalFormat or
pixelFormat may be 0 in which case they must be inferred as
diff --git a/src/classes/com/sun/opengl/utils/TextureWriter.java b/src/classes/com/sun/opengl/util/texture/spi/TextureWriter.java
index 38b976b9d..423a3b3e5 100755
--- a/src/classes/com/sun/opengl/utils/TextureWriter.java
+++ b/src/classes/com/sun/opengl/util/texture/spi/TextureWriter.java
@@ -37,10 +37,12 @@
* and developed by Kenneth Bradley Russell and Christopher John Kline.
*/
-package com.sun.opengl.utils;
+package com.sun.opengl.util.texture.spi;
import java.io.*;
+import com.sun.opengl.util.texture.*;
+
/** Plug-in interface to TextureIO to support writing OpenGL textures
to new file formats. */