Class PlotTable

java.lang.Object
com.eco.bio7.spatial.PlotTable

public final class PlotTable extends Object
The data of the active sheet of the Bio7 table for plots (see Plot3D): the columns as numbers or texts and a dialog to select the columns of the roles of a plot (e.g., X, Y, Z and an optional group). If cells are selected in the table (also several ranges with Ctrl/Cmd or Shift) the dialog uses only the selected cells (an option of the dialog, see fromSelection).
PlotTable.Selection s = PlotTable.select("Scatter Plot", "Select the columns", "X", "Y", "Z", "Group?");
if (s != null) {
        double[] x = s.numbers(0), y = s.numbers(1), z = s.numbers(2);
        String[] group = s.has(3) ? s.texts(3) : null;
}
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final record 
    The settings of the plot of the dialog: the title, the axis titles and the logarithmic axes (null for a plot without axes, e.g., a pie chart), the color map and the export action.
    static final record 
    The selected columns of the roles of a plot.
  • Method Summary

    Modifier and Type
    Method
    Description
    static String
    columnLetters(int column)
    The name of a column like a spreadsheet (0 = A, 25 = Z, 26 = AA).
    The names of the columns (the first row or the titles of the columns).
    int
    The number of the columns.
    static String
    formatRanges(List<int[]> ranges)
    Formats ranges of cells {fromColumn, fromRow, toColumn, toRow} (0 based) like a spreadsheet, e.g., "B2:B51; D2:D51".
    static PlotTable
    Reads the active sheet of the Bio7 table (in the user interface thread).
    static PlotTable
    Reads the selected cells of the active sheet of the Bio7 table (also several separate ranges, selected with Ctrl/Cmd or Shift): the columns with a selected cell and the rows with a selected cell (not selected cells are empty).
    boolean
    True if the first row contains the names of the columns (detected, see setFirstRowNames).
    double[]
    numbers(int column)
    The values of a column as numbers (NaN for empty cells and texts).
    double
    numericShare(int column)
    The share of the numbers in a column (0 - 1).
    static List<int[]>
    parseRanges(String text, int rows)
    Parses ranges of cells like a spreadsheet: "B2:B51", "B2", "B:B" or "B" (the whole column), several separated by ';' (a sheet name before '.' or '!' and '$' are ignored).
    int
    The number of the data rows (without a row of names).
    select(String title, String description, String... roles)
    Opens a dialog to select the data of the roles of a plot in the active sheet of the Bio7 table, like the data ranges of a chart in LibreOffice: each role has a range of cells (e.g., B2:B51, several ranges separated by ';'), typed, chosen as a column or selected in the table with the button "Select" (the dialog is reduced to a bar and the selection of the table is taken over).
    void
    setFirstRowNames(boolean firstRowNames)
    Sets if the first row contains the names of the columns.
    The name of the sheet.
    texts(int column)
    The values of a column as texts.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • fromActiveSheet

      public static PlotTable fromActiveSheet()
      Reads the active sheet of the Bio7 table (in the user interface thread).
      Returns:
      the data or null if no table is available
    • fromSelection

      public static PlotTable fromSelection()
      Reads the selected cells of the active sheet of the Bio7 table (also several separate ranges, selected with Ctrl/Cmd or Shift): the columns with a selected cell and the rows with a selected cell (not selected cells are empty).
      Returns:
      the data or null if no table or no cell is selected
    • sheet

      public String sheet()
      The name of the sheet.
    • isFirstRowNames

      public boolean isFirstRowNames()
      True if the first row contains the names of the columns (detected, see setFirstRowNames).
    • setFirstRowNames

      public void setFirstRowNames(boolean firstRowNames)
      Sets if the first row contains the names of the columns.
    • columns

      public int columns()
      The number of the columns.
    • rows

      public int rows()
      The number of the data rows (without a row of names).
    • columnNames

      public String[] columnNames()
      The names of the columns (the first row or the titles of the columns).
    • numbers

      public double[] numbers(int column)
      The values of a column as numbers (NaN for empty cells and texts).
    • texts

      public String[] texts(int column)
      The values of a column as texts.
    • numericShare

      public double numericShare(int column)
      The share of the numbers in a column (0 - 1).
    • select

      public static PlotTable.Selection select(String title, String description, String... roles)
      Opens a dialog to select the data of the roles of a plot in the active sheet of the Bio7 table, like the data ranges of a chart in LibreOffice: each role has a range of cells (e.g., B2:B51, several ranges separated by ';'), typed, chosen as a column or selected in the table with the button "Select" (the dialog is reduced to a bar and the selection of the table is taken over). The dialog doesn't block the table. A role with a '?' at the end is optional (e.g., "Group?"). The dialog has the settings of the plot, too: the title, the titles of the axes (with the names of the first three roles, not for less than three roles, e.g., a pie chart), logarithmic axes, the color map and the export action (see Selection.apply). If cells are selected in the table when the dialog is opened, the selected columns are the default ranges.
      Parameters:
      title - the title of the dialog (e.g., the plot)
      description - a description (or null)
      roles - the roles (e.g., "X", "Y", "Z", "Group?")
      Returns:
      the selection or null (canceled or no table data)
    • columnLetters

      public static String columnLetters(int column)
      The name of a column like a spreadsheet (0 = A, 25 = Z, 26 = AA).
    • formatRanges

      public static String formatRanges(List<int[]> ranges)
      Formats ranges of cells {fromColumn, fromRow, toColumn, toRow} (0 based) like a spreadsheet, e.g., "B2:B51; D2:D51".
    • parseRanges

      public static List<int[]> parseRanges(String text, int rows)
      Parses ranges of cells like a spreadsheet: "B2:B51", "B2", "B:B" or "B" (the whole column), several separated by ';' (a sheet name before '.' or '!' and '$' are ignored).
      Parameters:
      text - the ranges
      rows - the number of the rows of the sheet (for whole columns)
      Returns:
      the ranges {fromColumn, fromRow, toColumn, toRow} (0 based)
      Throws:
      IllegalArgumentException - if the text is not a range