use of org.knime.core.data.def.DefaultTable in project knime-core by knime.
the class SorterNodeModelTest method generateUnitMatrixTable.
/**
* This method produces a unit matrix -<code>DataTable</code>.
*
* @param dimension of the matrix
* @return Unit matrix
*/
public DefaultTable generateUnitMatrixTable(final int dimension) {
// generate Column names and types
String[] columnNames = new String[dimension];
for (int i = 0; i < dimension; i++) {
columnNames[i] = "col" + i;
}
DataType[] columnTypes = new DataType[dimension];
for (int i = 0; i < dimension; i++) {
columnTypes[i] = IntCell.TYPE;
}
DataRow[] unitmatrix = new DataRow[dimension];
for (int i = 0; i < dimension; i++) {
DataCell[] myRow = new DataCell[dimension];
for (int j = 0; j < dimension; j++) {
if (i == j) {
myRow[j] = new IntCell(1);
} else {
myRow[j] = new IntCell(0);
}
}
DataRow temprow = new DefaultRow(Integer.toString(i), myRow);
unitmatrix[i] = temprow;
}
return new DefaultTable(unitmatrix, columnNames, columnTypes);
}
use of org.knime.core.data.def.DefaultTable in project knime-core by knime.
the class TableViewFrame method main.
/**
* Main method for testing purposes.
* @param args Ignored.
*/
public static void main(final String[] args) {
Object[][] os = new Object[][] { new Object[] { Integer.valueOf(1), new Double(1.1), "eins" }, new Object[] { Integer.valueOf(2), new Double(2.1), "zwei" }, new Object[] { Integer.valueOf(3), new Double(3.1), "drei" } };
DefaultTable table = new DefaultTable(os);
new TableViewFrame(table);
}
Aggregations