case _DOUBLE:
_maxValue = Double.MAX_VALUE;
break;
default:
throw new InternalErrorException(this, null,
"Invalid value for _dataFormat private variable. "
+ "DoubleMatrixToJAI actor (" + getFullName()
+ ") on data type " + _dataFormat);
}
if ((_dataFormat == _DOUBLE) || (_dataFormat == _FLOAT)) {
System.out.println("DoubleMatrixTOJAI:0");
for (int i = 0; i < width; i++) {
for (int j = 0; j < height; j++) {
// There is some confusion about which order the
// array should be in.
// We go with i*height + j here so that we
// can read in data from the SDF VQ actors.
// newData[i*height + j] = data[i][j];
// newData[i*height + j] = newData[i*height + j] - 0.5D;
// newData[i*height + j] = newData[i*height + j]*2;
// newData[i*height + j] = newData[i*height + j]*_maxValue;
newData[i + (j * width)] = data[i][j];
newData[i + (j * width)] = newData[i + (j * width)] - 0.5D;
newData[i + (j * width)] = newData[i + (j * width)] * 2;
newData[i + (j * width)] = newData[i + (j * width)]
* _maxValue;
}
}
} else {
for (int i = 0; i < width; i++) {
for (int j = 0; j < height; j++) {
// newData[i*height + j] =
// data[i][j]*(_maxValue - _minValue) + _minValue;
newData[i + (j * width)] = (data[i][j] * (_maxValue - _minValue))
+ _minValue;
}
}
}
} else {
// Convert the matrix of doubles into an array of doubles
for (int i = 0; i < width; i++) {
for (int j = 0; j < height; j++) {
// newData[i*height + j] = data[i][j];
newData[i + (j * width)] = data[i][j];
}
}
}
// Create a new dataBuffer from the array of doubles
DataBufferDouble dataBuffer = new DataBufferDouble(newData, width
* height);
// The length of the bandOffset array indicates how many bands
// there are. Since we are just dealing with a single
// DoubleMatrixToken, the length of this array will be one.
// The values of the array indicate the offset to be added
// To the bands. This is set to 0.
int[] bandOffset = new int[1];
bandOffset[0] = 0;
// Create a ComponentSampleModel, with type double, the same width
// and height as the matrix, a pixel stride of one (the final image
// is single-banded), and a scanline stride equal to the width.
ComponentSampleModelJAI sampleModel = new ComponentSampleModelJAI(
DataBuffer.TYPE_DOUBLE, width, height, 1, width, bandOffset);
// Create a new raster that has its origin at (0, 0).
Raster raster = Raster.createWritableRaster(sampleModel, dataBuffer,
new Point());
// Create a grayscale colormodel.
ComponentColorModel colorModel = new ComponentColorModel(
new ICC_ColorSpace(ICC_Profile.getInstance(ColorSpace.CS_GRAY)),
false, false, Transparency.OPAQUE, DataBuffer.TYPE_DOUBLE);
TiledImage tiledImage = new TiledImage(0, 0, width, height, 0, 0,
sampleModel, colorModel);
tiledImage.setData(raster);
ParameterBlock parameters = new ParameterBlock();
parameters.addSource(tiledImage);
switch (_dataFormat) {
case _BYTE:
parameters.add(DataBuffer.TYPE_BYTE);
break;
case _DOUBLE:
parameters.add(DataBuffer.TYPE_DOUBLE);
break;
case _FLOAT:
parameters.add(DataBuffer.TYPE_FLOAT);
break;
case _INT:
parameters.add(DataBuffer.TYPE_INT);
break;
case _SHORT:
parameters.add(DataBuffer.TYPE_SHORT);
break;
case _USHORT:
parameters.add(DataBuffer.TYPE_USHORT);
break;
default:
throw new InternalErrorException(this, null,
"Invalid value for _dataFormat private variable. "
+ "DoubleMatrixToJAI actor (" + getFullName()
+ ") on data type " + _dataFormat);
}