This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
[gui] Implement missing datatypes in ComponentSampleModel
- From: Jerry Quinn <jlquinn at optonline dot net>
- To: java-patches at gcc dot gnu dot org
- Date: Tue, 02 Nov 2004 23:55:21 -0500
- Subject: [gui] Implement missing datatypes in ComponentSampleModel
2004-11-02 Jerry Quinn <jlquinn@optonline.net>
* java/awt/image/ComponentSampleModel.java (getDataElements,
setDataElements): Implement SHORT, FLOAT, and INT transfer types.
Index: ComponentSampleModel.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/awt/image/ComponentSampleModel.java,v
retrieving revision 1.4.72.3
retrieving revision 1.4.72.4
diff -u -r1.4.72.3 -r1.4.72.4
--- ComponentSampleModel.java 22 Sep 2004 03:20:09 -0000 1.4.72.3
+++ ComponentSampleModel.java 3 Nov 2004 03:09:50 -0000 1.4.72.4
@@ -265,6 +265,18 @@
}
return outUShort;
+ case DataBuffer.TYPE_SHORT:
+ DataBufferShort inShort = (DataBufferShort) data;
+ short[] outShort = (short[]) obj;
+ if (outShort == null) outShort = new short[numBands];
+
+ for (int b=0; b<numBands; b++)
+ {
+ int dOffset = totalBandDataOffsets[b];
+ outShort[b] = inShort.getData(bankIndices[b])[dOffset];
+ }
+ return outShort;
+
case DataBuffer.TYPE_INT:
DataBufferInt inInt = (DataBufferInt) data;
int[] outInt = (int[]) obj;
@@ -276,8 +288,31 @@
outInt[b] = inInt.getData(bankIndices[b])[dOffset];
}
return outInt;
-
- // FIXME: Fill in the other possible types.
+
+ case DataBuffer.TYPE_FLOAT:
+ DataBufferFloat inFloat = (DataBufferFloat) data;
+ float[] outFloat = (float[]) obj;
+ if (outFloat == null) outFloat = new float[numBands];
+
+ for (int b=0; b<numBands; b++)
+ {
+ int dOffset = totalBandDataOffsets[b];
+ outFloat[b] = inFloat.getData(bankIndices[b])[dOffset];
+ }
+ return outFloat;
+
+ case DataBuffer.TYPE_DOUBLE:
+ DataBufferDouble inDouble = (DataBufferDouble) data;
+ double[] outDouble = (double[]) obj;
+ if (outDouble == null) outDouble = new double[numBands];
+
+ for (int b=0; b<numBands; b++)
+ {
+ int dOffset = totalBandDataOffsets[b];
+ outDouble[b] = inDouble.getData(bankIndices[b])[dOffset];
+ }
+ return outDouble;
+
default:
throw new IllegalStateException("unknown transfer type " +
getTransferType());
@@ -449,6 +484,16 @@
return;
}
+ case DataBuffer.TYPE_SHORT:
+ {
+ DataBufferShort out = (DataBufferShort) data;
+ short[] in = (short[]) obj;
+
+ for (int b=0; b<numBands; b++)
+ out.getData(bankIndices[b])[totalBandDataOffsets[b]] = in[b];
+
+ return;
+ }
case DataBuffer.TYPE_INT:
{
DataBufferInt out = (DataBufferInt) data;
@@ -459,6 +504,26 @@
return;
}
+ case DataBuffer.TYPE_FLOAT:
+ {
+ DataBufferFloat out = (DataBufferFloat) data;
+ float[] in = (float[]) obj;
+
+ for (int b=0; b<numBands; b++)
+ out.getData(bankIndices[b])[totalBandDataOffsets[b]] = in[b];
+
+ return;
+ }
+ case DataBuffer.TYPE_DOUBLE:
+ {
+ DataBufferDouble out = (DataBufferDouble) data;
+ double[] in = (double[]) obj;
+
+ for (int b=0; b<numBands; b++)
+ out.getData(bankIndices[b])[totalBandDataOffsets[b]] = in[b];
+
+ return;
+ }
default:
throw new UnsupportedOperationException("transfer type not " +
"implemented");