summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarvey Harrison <[email protected]>2013-03-03 12:19:42 -0800
committerHarvey Harrison <[email protected]>2013-03-03 12:19:42 -0800
commit422177ec3c934cb0680cd85f569c267651d3c6c5 (patch)
tree1e3976a3f2c3b619b0525d065bb42f6147051f8a
parentcbcf9f3132cedb883bad5d569f1e68303f6d340d (diff)
j3dcore: move to use an Enum for valid buffer types in J3DBuffer
Signed-off-by: Harvey Harrison <[email protected]>
-rw-r--r--src/classes/share/javax/media/j3d/GeometryArrayRetained.java42
-rw-r--r--src/classes/share/javax/media/j3d/J3DBuffer.java55
2 files changed, 47 insertions, 50 deletions
diff --git a/src/classes/share/javax/media/j3d/GeometryArrayRetained.java b/src/classes/share/javax/media/j3d/GeometryArrayRetained.java
index 45b42c5..e5c8684 100644
--- a/src/classes/share/javax/media/j3d/GeometryArrayRetained.java
+++ b/src/classes/share/javax/media/j3d/GeometryArrayRetained.java
@@ -8355,14 +8355,14 @@ ArrayList<ArrayList<MorphRetained>> morphUserLists = null;
void setCoordRefBuffer(J3DBuffer coords) {
if (coords != null) {
- switch (coords.getBufferType()) {
- case J3DBuffer.TYPE_FLOAT:
+ switch (coords.bufferType) {
+ case FLOAT:
assert ((FloatBufferWrapper)coords.getBufferImpl()).isDirect();
break;
- case J3DBuffer.TYPE_DOUBLE:
+ case DOUBLE:
assert ((DoubleBufferWrapper)coords.getBufferImpl()).isDirect();
break;
- case J3DBuffer.TYPE_NULL:
+ case NULL:
throw new IllegalArgumentException(J3dI18N.getString("GeometryArray115"));
default:
@@ -8394,15 +8394,15 @@ ArrayList<ArrayList<MorphRetained>> morphUserLists = null;
vertexType &= ~PD;
vertexType &= ~PF;
}else {
- switch (coords.getBufferType()) {
- case J3DBuffer.TYPE_FLOAT:
+ switch (coords.bufferType) {
+ case FLOAT:
floatBufferRefCoords =
(FloatBufferWrapper)coords.getBufferImpl();
doubleBufferRefCoords = null;
vertexType |= PF;
vertexType &= ~PD;
break;
- case J3DBuffer.TYPE_DOUBLE:
+ case DOUBLE:
floatBufferRefCoords = null;
doubleBufferRefCoords =
(DoubleBufferWrapper)coords.getBufferImpl();
@@ -8707,14 +8707,14 @@ ArrayList<ArrayList<MorphRetained>> morphUserLists = null;
// set the color with nio buffer
void setColorRefBuffer(J3DBuffer colors) {
if (colors != null) {
- switch(colors.getBufferType()) {
- case J3DBuffer.TYPE_FLOAT:
+ switch(colors.bufferType) {
+ case FLOAT:
assert ((FloatBufferWrapper)colors.getBufferImpl()).isDirect();
break;
- case J3DBuffer.TYPE_BYTE:
+ case BYTE:
assert ((ByteBufferWrapper)colors.getBufferImpl()).isDirect();
break;
- case J3DBuffer.TYPE_NULL:
+ case NULL:
throw new IllegalArgumentException(J3dI18N.getString("GeometryArray115"));
default:
@@ -8748,13 +8748,13 @@ ArrayList<ArrayList<MorphRetained>> morphUserLists = null;
floatBufferRefColors = null;
byteBufferRefColors = null;
} else {
- switch (colors.getBufferType()) {
- case J3DBuffer.TYPE_FLOAT:
+ switch (colors.bufferType) {
+ case FLOAT:
floatBufferRefColors = (FloatBufferWrapper)colors.getBufferImpl();
byteBufferRefColors = null;
break;
- case J3DBuffer.TYPE_BYTE:
+ case BYTE:
byteBufferRefColors = (ByteBufferWrapper)colors.getBufferImpl();
floatBufferRefColors = null;
break;
@@ -8768,13 +8768,13 @@ ArrayList<ArrayList<MorphRetained>> morphUserLists = null;
vertexType &= ~CF;
vertexType &= ~CUB;
} else {
- switch (colors.getBufferType()) {
- case J3DBuffer.TYPE_FLOAT:
+ switch (colors.bufferType) {
+ case FLOAT:
vertexType |= CF;
vertexType &= ~CUB;
break;
- case J3DBuffer.TYPE_BYTE:
+ case BYTE:
vertexType |= CUB;
vertexType &= ~CF;
break;
@@ -9126,7 +9126,7 @@ ArrayList<ArrayList<MorphRetained>> morphUserLists = null;
FloatBufferWrapper bufferImpl = null;
if (normals != null) {
- if(normals.getBufferType() != J3DBuffer.TYPE_FLOAT)
+ if(normals.bufferType != J3DBuffer.Type.FLOAT)
throw new IllegalArgumentException(J3dI18N.getString("GeometryArray116"));
bufferImpl = (FloatBufferWrapper)normals.getBufferImpl();
@@ -9298,7 +9298,7 @@ ArrayList<ArrayList<MorphRetained>> morphUserLists = null;
FloatBufferWrapper bufferImpl = null;
if (texCoords != null) {
- if(texCoords.getBufferType() != J3DBuffer.TYPE_FLOAT)
+ if(texCoords.bufferType != J3DBuffer.Type.FLOAT)
throw new IllegalArgumentException(J3dI18N.getString("GeometryArray116"));
bufferImpl = (FloatBufferWrapper)texCoords.getBufferImpl();
@@ -9539,7 +9539,7 @@ ArrayList<ArrayList<MorphRetained>> morphUserLists = null;
FloatBufferWrapper bufferImpl = null;
if (vertexAttrs != null) {
- if(vertexAttrs.getBufferType() != J3DBuffer.TYPE_FLOAT)
+ if(vertexAttrs.bufferType != J3DBuffer.Type.FLOAT)
throw new IllegalArgumentException(J3dI18N.getString("GeometryArray116"));
bufferImpl = (FloatBufferWrapper)vertexAttrs.getBufferImpl();
@@ -9657,7 +9657,7 @@ ArrayList<ArrayList<MorphRetained>> morphUserLists = null;
if (vertexData != null ){
- if (vertexData.getBufferType() != J3DBuffer.TYPE_FLOAT)
+ if (vertexData.bufferType != J3DBuffer.Type.FLOAT)
throw new IllegalArgumentException(J3dI18N.getString("GeometryArray116"));
bufferImpl = (FloatBufferWrapper)vertexData.getBufferImpl();
diff --git a/src/classes/share/javax/media/j3d/J3DBuffer.java b/src/classes/share/javax/media/j3d/J3DBuffer.java
index 5df072a..778151d 100644
--- a/src/classes/share/javax/media/j3d/J3DBuffer.java
+++ b/src/classes/share/javax/media/j3d/J3DBuffer.java
@@ -50,19 +50,22 @@ import com.sun.j3d.internal.FloatBufferWrapper;
*/
public class J3DBuffer {
- static final int TYPE_NULL = 0;
- static final int TYPE_UNKNOWN = 1;
- static final int TYPE_BYTE = 2;
- static final int TYPE_CHAR = 3;
- static final int TYPE_SHORT = 4;
- static final int TYPE_INT = 5;
- static final int TYPE_LONG = 6;
- static final int TYPE_FLOAT = 7;
- static final int TYPE_DOUBLE = 8;
+
+enum Type {
+ NULL,
+ UNKNOWN,
+ BYTE,
+ CHAR,
+ SHORT,
+ INT,
+ LONG,
+ FLOAT,
+ DOUBLE,
+}
private java.nio.Buffer originalBuffer = null;
private BufferWrapper bufferImpl = null;
- private int bufferType = TYPE_NULL;
+ Type bufferType = Type.NULL;
/**
* Constructs a J3DBuffer object and initializes it with
@@ -109,50 +112,50 @@ public class J3DBuffer {
* platform.
*/
public void setBuffer(java.nio.Buffer buffer) {
- int bType = TYPE_NULL;
+ Type bType = Type.NULL;
boolean direct = false;
java.nio.ByteOrder order = java.nio.ByteOrder.BIG_ENDIAN;
if (buffer == null) {
- bType = TYPE_NULL;
+ bType = Type.NULL;
}
else if (buffer instanceof java.nio.ByteBuffer) {
- bType = TYPE_BYTE;
+ bType = Type.BYTE;
direct = ((java.nio.ByteBuffer)buffer).isDirect();
order = ((java.nio.ByteBuffer)buffer).order();
}
else if (buffer instanceof java.nio.CharBuffer) {
- bType = TYPE_CHAR;
+ bType = Type.CHAR;
direct = ((java.nio.CharBuffer)buffer).isDirect();
order = ((java.nio.CharBuffer)buffer).order();
}
else if (buffer instanceof java.nio.ShortBuffer) {
- bType = TYPE_SHORT;
+ bType = Type.SHORT;
direct = ((java.nio.ShortBuffer)buffer).isDirect();
order = ((java.nio.ShortBuffer)buffer).order();
}
else if (buffer instanceof java.nio.IntBuffer) {
- bType = TYPE_INT;
+ bType = Type.INT;
direct = ((java.nio.IntBuffer)buffer).isDirect();
order = ((java.nio.IntBuffer)buffer).order();
}
else if (buffer instanceof java.nio.LongBuffer) {
- bType = TYPE_LONG;
+ bType = Type.LONG;
direct = ((java.nio.LongBuffer)buffer).isDirect();
order = ((java.nio.LongBuffer)buffer).order();
}
else if (buffer instanceof java.nio.FloatBuffer) {
- bType = TYPE_FLOAT;
+ bType = Type.FLOAT;
direct = ((java.nio.FloatBuffer)buffer).isDirect();
order = ((java.nio.FloatBuffer)buffer).order();
}
else if (buffer instanceof java.nio.DoubleBuffer) {
- bType = TYPE_DOUBLE;
+ bType = Type.DOUBLE;
direct = ((java.nio.DoubleBuffer)buffer).isDirect();
order = ((java.nio.DoubleBuffer)buffer).order();
}
else {
- bType = TYPE_UNKNOWN;
+ bType = Type.UNKNOWN;
}
// Verify that the buffer is direct and has the correct byte order
@@ -172,19 +175,19 @@ public class J3DBuffer {
// Make a read-only view of the buffer if the type is one
// of the internally supported types: byte, float, or double
switch (bufferType) {
- case TYPE_BYTE:
+ case BYTE:
java.nio.ByteBuffer byteBuffer =
((java.nio.ByteBuffer)buffer).asReadOnlyBuffer();
byteBuffer.rewind();
bufferImpl = new ByteBufferWrapper(byteBuffer);
break;
- case TYPE_FLOAT:
+ case FLOAT:
java.nio.FloatBuffer floatBuffer =
((java.nio.FloatBuffer)buffer).asReadOnlyBuffer();
floatBuffer.rewind();
bufferImpl = new FloatBufferWrapper(floatBuffer);
break;
- case TYPE_DOUBLE:
+ case DOUBLE:
java.nio.DoubleBuffer doubleBuffer =
((java.nio.DoubleBuffer)buffer).asReadOnlyBuffer();
doubleBuffer.rewind();
@@ -205,12 +208,6 @@ public class J3DBuffer {
return originalBuffer;
}
-
- int getBufferType() {
- return bufferType;
- }
-
-
BufferWrapper getBufferImpl() {
return bufferImpl;
}