LinkProperties propertiesBuffer)
throws IOException {
Debug.message("linkdetail", "LinkGrid: reading from link.");
OMGrid grid = null;
float lat = 0;
float lon = 0;
int x = 0;
int y = 0;
int renderType = dis.readByte();
switch (renderType) {
case RENDERTYPE_OFFSET:
lat = dis.readFloat();
lon = dis.readFloat();
Debug.message("linkdetail", "LinkGrid: Offset Lat/Lon = " + lat
+ "/" + lon + " with");
// Fall through...
case RENDERTYPE_XY:
x = dis.readInt();
y = dis.readInt();
Debug.message("linkdetail", "LinkGrid: x/y = " + x + "/" + y);
break;
case RENDERTYPE_LATLON:
default:
lat = dis.readFloat();
lon = dis.readFloat();
Debug.message("linkdetail", "LinkGrid: Lat/Lon = " + lat + "/"
+ lon);
}
int rows = dis.readInt();
int columns = dis.readInt();
float orientation = dis.readFloat();
float vResolution = dis.readFloat();
float hResolution = dis.readFloat();
int major = dis.readByte();
int length = dis.readInt();
Debug.message("linkdetail", "LinkGrid details: rows = "
+ rows
+ ", columns = "
+ columns
+ ", orientation = "
+ orientation
+ ", vertical resolution = "
+ vResolution
+ ", horizontal resolution = "
+ hResolution
+ ", major dimension = "
+ (major == LinkGraphicConstants.COLUMN_MAJOR ? "COLUMN_MAJOR"
: "ROW_MAJOR") + ", with number of points = " + length);
int[][] data;
if (major == LinkGraphicConstants.COLUMN_MAJOR) {
data = new int[columns][rows];
} else {
data = new int[rows][columns];
}
for (int i = 0; i < data.length; i++) {
for (int j = 0; j < data[0].length; j++) {
data[i][j] = dis.readInt();
// Debug.message("linkdetail", "LinkGrid reading " +
// (rows*i + j) + " " +
// (major !=
// LinkGraphicConstants.COLUMN_MAJOR?"column":"row")+
// " " + j + " = " + Integer.toHexString(data[i][j]) +
// " (" + data[i][j] + ")");
}
// Debug.message("linkdetail", "LinkGrid reading " +
// (major ==
// LinkGraphicConstants.COLUMN_MAJOR?"column":"row")+
// " " + i);
}
Debug.message("linkdetail", "LinkGrid read all the data.");
switch (renderType) {
case RENDERTYPE_OFFSET:
grid = new OMGrid(lat, lon, x, y, vResolution, hResolution, data);
break;
case RENDERTYPE_XY:
grid = new OMGrid(x, y, vResolution, hResolution, data);
break;
case RENDERTYPE_LATLON:
default:
grid = new OMGrid(lat, lon, vResolution, hResolution, data);
}
Debug.message("linkdetail", "LinkGrid created OMGrid.");
if (grid != null) {
grid.setMajor(major == LinkGraphicConstants.COLUMN_MAJOR ? true
: false);
grid.setOrientation(orientation);
LinkProperties.loadPropertiesIntoOMGraphic(dis, grid, propertiesBuffer);
}
Debug.message("linkdetail", "LinkGrid done.");