Class SharedTable

java.lang.Object
org.bonej.utilities.SharedTable

public final class SharedTable extends Object
Stores a Table, which is ordered according to the following rules:
  1. Each row has a header label, which tells you which image was measured, e.g. "bat-cochlea-volume.tif"
  2. Each column has a header, which tells you the type of the measurement, e.g. "Volume"
  3. If there are no rows with the given label, then add a new row
  4. If there are rows with the given label, but there is not a column with the given heading, then append a column, and set its value on the last row with the label.
  5. If there are rows with the given label, and there's a column with the given heading, then find the last empty cell (equals EMPTY_CELL), and add the new value there. If there are no empty cells, then append a new row.
  6. Labels and columns are kept in the order in which they were produced.
Author:
Richard Domander, Michael Doube
  • Field Details

    • EMPTY_CELL

      public static final Double EMPTY_CELL
      Sentinel value indicating an empty cell in the table.
  • Method Details

    • add

      public static void add(String label, String header, long value)
      Adds new value as a Double to the shared table.
      Parameters:
      label - the row label of the new data.
      header - the column heading of the new data.
      value - the value of the new data.
      See Also:
    • add

      public static void add(String label, String header, double value)
      Adds new value as a Double to the shared table
      Parameters:
      label - the row label of the new data.
      header - the column heading of the new data.
      value - the value of the new data.
      See Also:
    • add

      public static void add(String label, String header, Double value) throws NullPointerException
      Adds new data to the shared table according to the shared table policy.
      Parameters:
      label - the row label of the new data.
      header - the column heading of the new data.
      value - the value of the new data.
      Throws:
      NullPointerException - if value == null
    • getTable

      Gets a copy of the singleton Table.

      Returns the same copy instance on every call. However, the contents of the copy table are always cleared and copied from the actual table. That is, if you've modified the copy after the previous call, those modifications are lost.

      Returns:
      the persistent copy instance.
    • hasData

      public static boolean hasData()
      Checks whether the table contains any non-null data values.
      Returns:
      true if at least one cell contains a non-null value, false otherwise
    • reset

      public static void reset()
      Initializes the table into a new empty table