Search in sources :

Example 1 with LongArray

use of org.scijava.util.LongArray in project imagej-omero by imagej.

the class TableUtils method populateArrayColumn.

// -- Helper methods --
@SuppressWarnings("unchecked")
private static void populateArrayColumn(final DefaultColumn<?> col, final Object[] data) {
    if (col.getType().equals(FloatArray.class)) {
        for (int i = 0; i < data.length; i++) {
            final Float[] f = (Float[]) data[i];
            ((DefaultColumn<FloatArray>) col).add(i, new FloatArray(ArrayUtils.toPrimitive(f)));
        }
    } else if (col.getType().equals(LongArray.class)) {
        for (int i = 0; i < data.length; i++) {
            final Long[] f = (Long[]) data[i];
            ((DefaultColumn<LongArray>) col).add(i, new LongArray(ArrayUtils.toPrimitive(f)));
        }
    } else if (col.getType().equals(DoubleArray.class)) {
        for (int i = 0; i < data.length; i++) {
            final Double[] f = (Double[]) data[i];
            ((DefaultColumn<DoubleArray>) col).add(i, new DoubleArray(ArrayUtils.toPrimitive(f)));
        }
    }
}
Also used : LongArray(org.scijava.util.LongArray) FloatArray(org.scijava.util.FloatArray) DefaultColumn(net.imagej.table.DefaultColumn) DoubleArray(org.scijava.util.DoubleArray)

Example 2 with LongArray

use of org.scijava.util.LongArray in project imagej-omero by imagej.

the class DownloadTableTest method downloadLongArrayTable.

@SuppressWarnings("unchecked")
@Test
public void downloadLongArrayTable() throws PermissionDeniedException, CannotCreateSessionException, ServerError, DSOutOfServiceException, ExecutionException, DSAccessException {
    // Setup OMERO data structures
    final TableDataColumn[] tdc = new TableDataColumn[] { new TableDataColumn("Header 1", 0, Long[].class), new TableDataColumn("Header 2", 1, Long[].class) };
    final Object[][] data = new Object[2][];
    data[0] = new Long[][] { { 0l, -9223372036854775808l }, { 134l, 9223372036854775807l } };
    data[1] = new Long[][] { { -2139847l, 1023894l }, { 12l, 23415l } };
    final TableData table = new TableData(tdc, data);
    table.setNumberOfRows(2);
    // Create expectations
    setUpMethodCalls(table);
    final Table<?, ?> imageJTable = ((DefaultOMEROService) service).downloadTable(credentials, 0);
    // Tests
    assertTrue(GenericTable.class.isInstance(imageJTable));
    assertEquals(imageJTable.getColumnCount(), 2);
    assertEquals(imageJTable.getRowCount(), 2);
    assertEquals(imageJTable.get(0).size(), 2);
    assertEquals(imageJTable.getColumnHeader(0), "Header 1");
    assertEquals(imageJTable.getColumnHeader(1), "Header 2");
    for (int r = 0; r < imageJTable.getRowCount(); r++) {
        for (int c = 0; c < imageJTable.getColumnCount(); c++) {
            assertTrue(DefaultColumn.class.isInstance(imageJTable.get(c)));
            assertTrue(imageJTable.get(c).getType() == LongArray.class);
            final Long[] l = (Long[]) data[c][r];
            final Object[] ijl = ((DefaultColumn<LongArray>) imageJTable.get(c)).get(r).toArray();
            assertArrayEquals(l, ijl);
        }
    }
}
Also used : DefaultColumn(net.imagej.table.DefaultColumn) GenericTable(net.imagej.table.GenericTable) LongArray(org.scijava.util.LongArray) TableDataColumn(omero.gateway.model.TableDataColumn) TableData(omero.gateway.model.TableData) Test(org.junit.Test)

Aggregations

DefaultColumn (net.imagej.table.DefaultColumn)2 LongArray (org.scijava.util.LongArray)2 GenericTable (net.imagej.table.GenericTable)1 TableData (omero.gateway.model.TableData)1 TableDataColumn (omero.gateway.model.TableDataColumn)1 Test (org.junit.Test)1 DoubleArray (org.scijava.util.DoubleArray)1 FloatArray (org.scijava.util.FloatArray)1