Class PlotTable
java.lang.Object
com.eco.bio7.spatial.PlotTable
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 ClassesModifier and TypeClassDescriptionstatic final recordThe 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 recordThe selected columns of the roles of a plot. -
Method Summary
Modifier and TypeMethodDescriptionstatic StringcolumnLetters(int column) The name of a column like a spreadsheet (0 = A, 25 = Z, 26 = AA).String[]The names of the columns (the first row or the titles of the columns).intcolumns()The number of the columns.static StringformatRanges(List<int[]> ranges) Formats ranges of cells {fromColumn, fromRow, toColumn, toRow} (0 based) like a spreadsheet, e.g., "B2:B51; D2:D51".static PlotTableReads the active sheet of the Bio7 table (in the user interface thread).static PlotTableReads 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).booleanTrue 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).doublenumericShare(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).introws()The number of the data rows (without a row of names).static PlotTable.SelectionOpens 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).voidsetFirstRowNames(boolean firstRowNames) Sets if the first row contains the names of the columns.sheet()The name of the sheet.String[]texts(int column) The values of a column as texts.
-
Method Details
-
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
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
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
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
The values of a column as texts. -
select
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
The name of a column like a spreadsheet (0 = A, 25 = Z, 26 = AA). -
formatRanges
-
parseRanges
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 rangesrows- 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
-