Search in sources :

Example 11 with DefaultTable

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);
}
Also used : DefaultTable(org.knime.core.data.def.DefaultTable) DataType(org.knime.core.data.DataType) DataCell(org.knime.core.data.DataCell) DefaultRow(org.knime.core.data.def.DefaultRow) DataRow(org.knime.core.data.DataRow) IntCell(org.knime.core.data.def.IntCell)

Example 12 with DefaultTable

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);
}
Also used : DefaultTable(org.knime.core.data.def.DefaultTable)

Aggregations

DefaultTable (org.knime.core.data.def.DefaultTable)12 DataTable (org.knime.core.data.DataTable)10 DataRow (org.knime.core.data.DataRow)7 DataType (org.knime.core.data.DataType)4 RowKey (org.knime.core.data.RowKey)4 DefaultRow (org.knime.core.data.def.DefaultRow)4 Random (java.util.Random)3 DataColumnSpec (org.knime.core.data.DataColumnSpec)3 DataTableSpec (org.knime.core.data.DataTableSpec)3 DataCell (org.knime.core.data.DataCell)2 RowIterator (org.knime.core.data.RowIterator)2 IntCell (org.knime.core.data.def.IntCell)2 Hashtable (java.util.Hashtable)1 Test (org.junit.Test)1 DoubleValue (org.knime.core.data.DoubleValue)1 DoubleCell (org.knime.core.data.def.DoubleCell)1 StringCell (org.knime.core.data.def.StringCell)1 HiLiteHandler (org.knime.core.node.property.hilite.HiLiteHandler)1