public Object getDataElements(int x, int y, Object obj, DataBuffer data) { if ((x < 0) || (y < 0) || (x >= width) || (y >= height)) { throw new ArrayIndexOutOfBoundsException("Coordinate out of bounds!"); }  int type = getTransferType(); int bitnum = dataBitOffset + x * pixelBitStride; int shift = dataElementSize - (bitnum & (dataElementSize - 1)) - pixelBitStride; int element = 0;  switch (type) {  case DataBuffer.TYPE_BYTE :  byte[] bdata;  if (obj == null) bdata = new byte[1]; else bdata = (byte[]) obj;  element = data.getElem(y * scanlineStride + bitnum / dataElementSize); bdata[0] = (byte) ((element >> shift) & bitMask);  obj = bdata; break;  case DataBuffer.TYPE_USHORT :  short[] sdata;  if (obj == null) sdata = new short[1]; else sdata = (short[]) obj;  element = data.getElem(y * scanlineStride + bitnum / dataElementSize); sdata[0] = (short) ((element >> shift) & bitMask);  obj = sdata; break;  case DataBuffer.TYPE_INT :  int[] idata;  if (obj == null) idata = new int[1]; else idata = (int[]) obj;  element = data.getElem(y * scanlineStride + bitnum / dataElementSize); idata[0] = (element >> shift) & bitMask;  obj = idata; break; }  return obj; }
public Object getDataElements(int x, int y, Object obj, DataBuffer data) { int pixel = getSample(x, y, 0, data); switch (getTransferType()) { case DataBuffer.TYPE_BYTE: if (obj == null) obj = new byte[1]; ((byte[])obj)[0] = (byte)pixel; return obj; case DataBuffer.TYPE_USHORT: if (obj == null) obj = new short[1]; ((short[])obj)[0] = (short)pixel; return obj; case DataBuffer.TYPE_INT: if (obj == null) obj = new int[1]; ((int[])obj)[0] = pixel; return obj; default:  throw new ClassCastException(); } }
	public Object getDataElements(int x, int y, Object obj, DataBuffer data) {		if ((x < 0) || (y < 0) || (x >= width) || (y >= height)) {			throw new ArrayIndexOutOfBoundsException("Coordinate out of bounds!");		}		int type = getTransferType();		int bitnum = dataBitOffset + x * pixelBitStride;		int shift = dataElementSize - (bitnum & (dataElementSize - 1)) - pixelBitStride;		int element = 0;		switch (type) {			case DataBuffer.TYPE_BYTE :				byte[] bdata;				if (obj == null)					bdata = new byte[1];				else					bdata = (byte[]) obj;				element = data.getElem(y * scanlineStride + bitnum / dataElementSize);				bdata[0] = (byte) ((element >> shift) & bitMask);				obj = bdata;				break;			case DataBuffer.TYPE_USHORT :				short[] sdata;				if (obj == null)					sdata = new short[1];				else					sdata = (short[]) obj;				element = data.getElem(y * scanlineStride + bitnum / dataElementSize);				sdata[0] = (short) ((element >> shift) & bitMask);				obj = sdata;				break;			case DataBuffer.TYPE_INT :				int[] idata;				if (obj == null)					idata = new int[1];				else					idata = (int[]) obj;				element = data.getElem(y * scanlineStride + bitnum / dataElementSize);				idata[0] = (element >> shift) & bitMask;				obj = idata;				break;		}		return obj;	}