Table population complete but not yet fully tested

git-svn-id: http://svn.3splooges.com/romraider-arch/trunk@524 d2e2e1cd-ba16-0410-be16-b7c4453c7c2d
This commit is contained in:
Jared Gould 2007-02-19 17:06:31 +00:00
parent 339161b439
commit 5b8740768f
3 changed files with 81 additions and 31 deletions

View File

@ -40,6 +40,10 @@ public class AxisData extends TableData {
return true;
}
public int getSize() {
return metadata.getSize();
}
public byte[] returnValues() {
return null;

View File

@ -23,6 +23,7 @@ package enginuity.newmaps.ecudata;
import enginuity.newmaps.ecumetadata.Table3DMetadata;
import enginuity.newmaps.exception.DataPopulationException;
import enginuity.newmaps.util.ECUDataUtil;
import enginuity.util.ByteUtil;
public class Table3DData extends TableData {
@ -58,7 +59,7 @@ public class Table3DData extends TableData {
yAxis.populate(data);
// Now populate the table itself
int dataSize = ByteUtil.getLengthInBytes(metadata.getScale().getStorageType());
DataCell[] rawData = ECUDataUtil.buildValues(data, metadata);
return true;
}

View File

@ -21,6 +21,7 @@
package enginuity.newmaps.util;
import enginuity.newmaps.ecudata.DataCell;
import enginuity.newmaps.ecudata.TableData;
import enginuity.newmaps.ecumetadata.Scale;
import enginuity.newmaps.ecumetadata.Table3DMetadata;
@ -30,20 +31,64 @@ import enginuity.util.JEPUtil;
public final class ECUDataUtil {
public static TableData getTableData(byte[] data, TableMetadata metadata) {
if (metadata instanceof Table3DMetadata) {
}
return null;
}
public static byte[] getTableAsBytes() {
// TODO: build byte arrays from table data
return null;
}
//
// Populate 1d and 2d tables
//
public static DataCell[] buildValues(byte[] input, TableMetadata metadata) {
DataCell[] output = new DataCell[metadata.getSize()];
int dataSize = ByteUtil.getLengthInBytes(metadata.getScale().getStorageType());
int storageType = metadata.getScale().getStorageType();
int endian = metadata.getScale().getEndian();
int address = metadata.getAddress();
for (int j = 0; j < metadata.getSize(); j++) {
// Build single datacell bytes
byte[] cellBytes = new byte[dataSize];
for (int i = 0; i < dataSize; i++) {
cellBytes[i] = input[address + dataSize * j];
}
// Get DataCell and add to array
output[j] = new DataCell(cellBytes, storageType, endian);
}
return output;
}
//
// Populate 3d tables
//
public static DataCell[][] buildValues(byte[] input, Table3DMetadata metadata) {
DataCell[][] output = new DataCell[metadata.getSizeX()][metadata.getSizeY()];
int dataSize = ByteUtil.getLengthInBytes(metadata.getScale().getStorageType());
int storageType = metadata.getScale().getStorageType();
int endian = metadata.getScale().getEndian();
int address = metadata.getAddress();
for (int x = 0; x < metadata.getSizeX(); x++) {
for (int y = 0; y < metadata.getSizeY(); y++) {
// Build single datacell bytes
byte[] cellBytes = new byte[dataSize];
for (int i = 0; i < dataSize; i++) {
cellBytes[i] = input[address + dataSize * x * y];
}
// Get DataCell and add to array
output[x][y] = new DataCell(cellBytes, storageType, endian);
}
}
return output;
}
}