protected MatrixJDBC createMatrix(CharacterData pMesqMatrix) {
ContinuousData continuousData = (ContinuousData) pMesqMatrix;
ContinuousMatrix m = new ContinuousMatrix();
ContinuousMatrixJDBC matrixJDBC = new ContinuousMatrixJDBC(m, continuousData, this);
int numChars = continuousData.getNumChars();
int numItems = continuousData.getNumItems();
mItemDefinitions = new Double2DArray[numItems];
mItemDefinitionNames = new String[numItems];
Set<ItemDefinition> itemDefs = new HashSet<ItemDefinition>();
List<MatrixColumnJDBC> columnJDBCs = new ArrayList<MatrixColumnJDBC>();
List<ItemDefinitionJDBC> itemDefJDBCs = new ArrayList<ItemDefinitionJDBC>();
// add Item definitions if there are any:
for (int j = 0; j < numItems; j++) {
Double2DArray anItem = continuousData.getItem(j);
String itemName = continuousData.getItemName(j);
mItemDefinitionNames[j] = itemName;
mItemDefinitions[j] = anItem;
// This can be null, means the default definition 'AVG' is used.
ItemDefinition definition = getItemDefinition(itemName);
//ItemDefinitionJDBC itemDefJDBC = new ItemDefinitionJDBC();
//itemDefJDBC.setColumnIndex(pNewColumnIndex);
//itemDefJDBC.setItemDefinitionDesc(itemName);
if (definition != null) {
itemDefs.add(definition);
getItemDefMap().put(anItem, definition);
}
}
if (!itemDefs.isEmpty()) {
m.setItemDefinitions(itemDefs);
}
// add character/column:
for (int i = 0; i < numChars; i++) {
//MatrixColumn aColumn = new MatrixColumn();
MatrixColumnJDBC aColumnJDBC = new MatrixColumnJDBC();
ContinuousChar tbChar = new ContinuousChar();
String charName = continuousData.getCharacterName(i);
tbChar.setDescription(charName);
//aColumn.setCharacter(tbChar);
aColumnJDBC.setPhyloChar(tbChar);
//Note: Set for itemDefs per column. Disabled for now.
// if (!itemDefs.isEmpty()) {
// aColumn.setItemDefinitions(itemDefs);
// }
//m.addColumn(aColumn);
columnJDBCs.add(aColumnJDBC);
}
matrixJDBC.setMatrixColumnJDBCs(columnJDBCs);
return matrixJDBC;
}