// read the fbr (face bounding rectangle) table
File fcsFile = new File(pathname, "fcs");
if (!fcsFile.canRead()) {
fcsFile = new File(pathname, "fcs.");
}
DcwRecordFile fcs = new DcwRecordFile(fcsFile.toString());
Vector fcsv = new Vector(fcs.getColumnCount());
while (fcs.parseRow(fcsv)) {
String fclass = ((String) fcsv.elementAt(1)).toLowerCase();
String table1 = ((String) fcsv.elementAt(2)).toLowerCase();
if ((fclass.equals("tileref")) && (table1.equals("tileref.aft"))) {
faceIDColumnName = (String) fcsv.elementAt(3);
break;
}
}
fcs.close();
if (faceIDColumnName == null) {
throw new FormatException("no faceIDColumn");
// won't be able to read the tiling info. abort
}
// Okay, we've got info on what column we use from tileref.aft
// to index
// into the fbr.
DcwRecordFile aft = new DcwRecordFile(pathname + File.separator
+ "tileref.aft");
int faceIDColumn = aft.whatColumn(faceIDColumnName.toLowerCase());
int tileNameColumn = aft.whatColumn("tile_name");
if ((faceIDColumn == -1) || (tileNameColumn == -1)) {
aft.close();
throw new FormatException("no faceIDColumn");
}
Vector aftv = new Vector(aft.getColumnCount());
// set the array size to record count + 1, to be able to
// use the tileID as the index into the array
String containedTiles[] = new String[aft.getRecordCount() + 1];
int tileid = 1;
while (aft.parseRow(aftv)) {
//int fac_num = ((Number) aftv.elementAt(faceIDColumn)).intValue();
String tilename = (String) aftv.elementAt(tileNameColumn);
char chs[] = tilename.toCharArray();
boolean goodTile = false;
for (int i = 0; i < chs.length; i++) {
if ((chs[i] != '\\') && (chs[i] != ' ')) {
goodTile = true;
chs[i] = Character.toLowerCase(chs[i]);
}
if (chs[i] == '\\') {
chs[i] = File.separatorChar;
}
}
containedTiles[tileid++] = (goodTile) ? new String(chs) : null;
}
aft.close();
return containedTiles;
}