public class ResultsTableData extends Object implements JIPipeData, TableModel
ResultsTable
Modifier and Type | Class and Description |
---|---|
static class |
ResultsTableData.Deserializer |
static class |
ResultsTableData.Index
Points to a cell in the table
|
static class |
ResultsTableData.IntegratingColumnOperationEntry
An entry for obtaining statistics/integrated values
|
static class |
ResultsTableData.RowBuilder
Helper class for adding a row into the table
|
static class |
ResultsTableData.Serializer |
Constructor and Description |
---|
ResultsTableData()
Creates a new instance
|
ResultsTableData(Collection<TableColumn> columns)
Creates a table from a list of columns.
|
ResultsTableData(Map<String,TableColumn> columns)
Creates a table from a map of column name to column data
|
ResultsTableData(ij.measure.ResultsTable table)
Wraps a results table
|
ResultsTableData(ResultsTableData other)
Creates a copy
|
Modifier and Type | Method and Description |
---|---|
ResultsTableData.RowBuilder |
addAndModifyRow()
Adds a new row and returns a
ResultsTableData.RowBuilder for setting values conveniently |
int |
addColumn(String name,
boolean stringColumn)
Adds a column with the given name.
|
int |
addColumn(String name,
TableColumn data,
boolean extendRows)
Adds a column with the given name.
|
void |
addColumns(Collection<ResultsTableData> others,
boolean makeUnique,
TableColumnNormalization normalization)
Adds columns from another table
|
int |
addNumericColumn(String name)
Adds a string column with the given name.
|
int |
addRow()
Adds a new row
|
int |
addRow(Map<String,Object> values)
Adds a new row and writes the provided values into the table
|
ResultsTableData.RowBuilder |
addRowBuilder()
Deprecated.
Use addAndModifyRow() instead
|
void |
addRows(int rows)
Adds multiple rows
|
void |
addRows(ResultsTableData other)
Merges another results table into this one
|
int |
addStringColumn(String name)
Adds a string column with the given name.
|
void |
addTableModelListener(TableModelListener l) |
void |
addToTable(ij.measure.ResultsTable destination)
Adds the table to an existing table
|
void |
applyOperation(List<ResultsTableData.Index> selectedCells,
ConvertingColumnOperation operation)
Applies an operation to the selected cells
|
boolean |
containsColumn(String columnName)
Returns true if the column exists
|
void |
convertToNumericColumn(int column)
Converts the column into a numeric column.
|
void |
convertToStringColumn(int column)
Converts the column into a string column.
|
void |
copyColumnSchemaFrom(ResultsTableData other)
Adds missing columns from the other table
|
JIPipeThumbnailData |
createThumbnail(int width,
int height,
JIPipeProgressInfo progressInfo)
This function generates a thumbnail for this data
Can return null
|
static String |
createXLSXSheetName(String name,
Collection<String> existing)
Creates a valid XLSX sheet name from a string
|
void |
display(String displayName,
JIPipeWorkbench workbench,
JIPipeDataSource source)
This function should display the data in the GUI.
|
JIPipeData |
duplicate(JIPipeProgressInfo progressInfo)
Duplicates the data
|
void |
duplicateColumn(int column,
String newColumn)
Duplicates a column
|
void |
exportData(JIPipeWriteDataStorage storage,
String name,
boolean forceName,
JIPipeProgressInfo progressInfo)
Saves the data to a folder
|
void |
fireChangedEvent(TableModelEvent event)
Fires a
TableModelEvent to all listeners |
static ResultsTableData |
fromCSV(Path path) |
static ResultsTableData |
fromCSV(Path path,
String cellSeparator) |
static ResultsTableData |
fromPython(org.python.core.PyDictionary tableDict)
Converts a Python dictionary of column name to row data list to a results table
|
static ResultsTableData |
fromTableModel(TableModel model,
TableColumnModel columnModel,
boolean stripColumnNameHtml)
Imports a table from a table model and column model
|
static Map<String,ResultsTableData> |
fromXLSX(Path xlsxFile) |
Class<?> |
getColumnClass(int columnIndex) |
TableColumn |
getColumnCopy(int index)
Returns a column as vector.
|
int |
getColumnCount() |
int |
getColumnIndex(String id)
Returns the index of an existing column
|
String |
getColumnName(int columnIndex) |
List<String> |
getColumnNames() |
TableColumn |
getColumnReference(int index)
Returns a column as vector.
|
TableColumn |
getColumnReference(String columnName)
Returns a column as vector.
|
Map<Map<String,Object>,List<Integer>> |
getEquivalentRows(Set<String> columns)
Returns the row indices grouped by the values of the provided columns
|
TableColumn |
getMergedColumn(Set<String> columns,
String separator,
String equals)
Returns a column that contains all values of the selected columns
|
int |
getOrCreateColumnIndex(String id,
boolean stringColumn)
Returns the index of an existing column or creates a new column if it does not exist
|
ResultsTableData |
getRow(int row) |
int |
getRowCount() |
ResultsTableData |
getRows(Collection<Integer> rows) |
ResultsTableData |
getRows(int start,
int end)
Extracts rows
|
ResultsTableData |
getStatistics(List<ResultsTableData.IntegratingColumnOperationEntry> operations,
Set<String> categories)
Generates a new table that contains statistics.
|
ij.measure.ResultsTable |
getTable() |
double |
getValueAsDouble(int rowIndex,
int columnIndex)
Returns a table value as double.
|
double |
getValueAsDouble(int rowIndex,
String columnName)
Returns a table value as double
|
String |
getValueAsString(int rowIndex,
int columnIndex)
Returns a table value as string
|
String |
getValueAsString(int rowIndex,
String columnName)
Returns a table value as string
|
Object |
getValueAt(int rowIndex,
int columnIndex) |
static ResultsTableData |
importData(JIPipeReadDataStorage storage,
JIPipeProgressInfo progressInfo) |
boolean |
isCellEditable(int rowIndex,
int columnIndex) |
boolean |
isNumericColumn(int columnIndex)
Returns true if a column is numeric
|
boolean |
isNumericColumn(String columnName) |
boolean |
isStringColumn(int col) |
boolean |
isStringColumn(String columnName) |
void |
mergeColumns(List<Integer> sourceColumns,
String newColumn,
String separator,
String equals)
Creates a new column that consists of a combination of the selected values.
|
Component |
preview(int width,
int height)
This function generates a preview component for usage within the GUI
Can return null
|
boolean |
removeColumn(String columnName)
Removes a column with given name
|
void |
removeColumnAt(int col)
Removes the column with the specified index
|
void |
removeColumns(Collection<String> removedColumns)
Removes the columns with given headings
|
void |
removeRow(int removedRow) |
void |
removeRows(Collection<Integer> rows) |
void |
removeTableModelListener(TableModelListener l) |
void |
renameColumn(String column,
String newName)
Renames a column
|
void |
saveAsCSV(Path path)
Saves the table as CSV
|
void |
saveAsXLSX(Path path)
Saves the table as Excel file
|
void |
saveToXLSXSheet(org.apache.poi.ss.usermodel.Sheet sheet)
Saves the table data to an Excel sheet
|
void |
setColumn(String columnName,
TableColumn column)
Sets a column from another table column.
|
void |
setColumn(String columnName,
TableColumn column,
boolean numeric)
Sets a column from another table column.
|
int |
setColumnToValue(String name,
Object value)
Sets a column to a value.
|
void |
setLastValue(Object aValue,
String column) |
void |
setTable(ij.measure.ResultsTable table) |
void |
setValueAt(Object aValue,
int rowIndex,
int columnIndex) |
void |
setValueAt(Object aValue,
int rowIndex,
String column) |
Map<String,ResultsTableData> |
splitBy(TableColumn externalColumn)
Splits this table into multiple tables according to an internal or external column
|
static ResultsTableData |
stringModelFromTableModel(TableModel model)
Converts a table model into a string results table
|
org.python.core.PyDictionary |
toPython()
Converts this table into its equivalent Python form (as dictionary of columns)
|
String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
close, exportThumbnails, getDescriptionOf, getMenuPathOf, getNameOf, getSortedList, getStorageDocumentation, getStorageSchema, groupByMenuPath, isCommon, isHeavy, isHidden, toDetailedString
public ResultsTableData()
public ResultsTableData(Map<String,TableColumn> columns)
columns
- key is column headingpublic ResultsTableData(Collection<TableColumn> columns)
columns
- the columnspublic ResultsTableData(ij.measure.ResultsTable table)
table
- wrapped tablepublic ResultsTableData(ResultsTableData other)
other
- the originalpublic static ResultsTableData importData(JIPipeReadDataStorage storage, JIPipeProgressInfo progressInfo)
public static ResultsTableData fromPython(org.python.core.PyDictionary tableDict)
tableDict
- the dictionarypublic static ResultsTableData fromCSV(Path path)
public static ResultsTableData fromCSV(Path path, String cellSeparator)
public static ResultsTableData stringModelFromTableModel(TableModel model)
model
- the modelpublic static ResultsTableData fromTableModel(TableModel model, TableColumnModel columnModel, boolean stripColumnNameHtml)
model
- the table modelcolumnModel
- the column model (can be null)stripColumnNameHtml
- if enabled, remove HTML from column namespublic static Map<String,ResultsTableData> fromXLSX(Path xlsxFile)
public static String createXLSXSheetName(String name, Collection<String> existing)
name
- the string. if null or empty, will be assumed to be "Sheet"existing
- existing namespublic void copyColumnSchemaFrom(ResultsTableData other)
other
- the other tablepublic org.python.core.PyDictionary toPython()
public Component preview(int width, int height)
JIPipeData
preview
in interface JIPipeData
width
- the target widthheight
- the target heightpublic JIPipeThumbnailData createThumbnail(int width, int height, JIPipeProgressInfo progressInfo)
JIPipeData
createThumbnail
in interface JIPipeData
width
- the widthheight
- the heightprogressInfo
- the progress infopublic void saveAsXLSX(Path path)
path
- the pathpublic void saveToXLSXSheet(org.apache.poi.ss.usermodel.Sheet sheet)
sheet
- the sheetpublic void saveAsCSV(Path path)
path
- the output filepublic void applyOperation(List<ResultsTableData.Index> selectedCells, ConvertingColumnOperation operation)
selectedCells
- the selected cellsoperation
- the operationpublic TableColumn getMergedColumn(Set<String> columns, String separator, String equals)
columns
- the columns to mergeseparator
- the separator characterequals
- the equals characterpublic Map<Map<String,Object>,List<Integer>> getEquivalentRows(Set<String> columns)
columns
- the columns to group bypublic ResultsTableData getStatistics(List<ResultsTableData.IntegratingColumnOperationEntry> operations, Set<String> categories)
operations
- the operationscategories
- columns considered as categorical. They are added to the output without changes.public void addRows(int rows)
rows
- the number of rows to addpublic TableColumn getColumnReference(String columnName)
columnName
- the column namepublic TableColumn getColumnReference(int index)
index
- the column indexpublic TableColumn getColumnCopy(int index)
index
- the column indexpublic void exportData(JIPipeWriteDataStorage storage, String name, boolean forceName, JIPipeProgressInfo progressInfo)
JIPipeData
exportData
in interface JIPipeData
storage
- The storage where the data should be writtenname
- A name reference that can be used to generate filename(s)forceName
- If enabled, the data is saved potentially destructively. Generated files must always contain the name parameter. This is used to collect results for humans or other algorithms.progressInfo
- the progresspublic void mergeColumns(List<Integer> sourceColumns, String newColumn, String separator, String equals)
sourceColumns
- the source columnsnewColumn
- the new columnseparator
- separator character e.g. ", "equals
- equals character e.g. "="public void duplicateColumn(int column, String newColumn)
column
- the input columnnewColumn
- the new column namepublic JIPipeData duplicate(JIPipeProgressInfo progressInfo)
JIPipeData
duplicate
in interface JIPipeData
progressInfo
- the progress of duplicating the datapublic void display(String displayName, JIPipeWorkbench workbench, JIPipeDataSource source)
JIPipeData
JIPipeDataDisplayOperation
that can be registered separately.
This item will always be shown as "Default" in the list of operations.display
in interface JIPipeData
displayName
- a name that can be usedworkbench
- the workbenchsource
- optional source of the data. Can be null or any kind of data type (e.g. JIPipeDataSlot
)public ij.measure.ResultsTable getTable()
public void setTable(ij.measure.ResultsTable table)
public int getColumnIndex(String id)
id
- the column IDpublic int getOrCreateColumnIndex(String id, boolean stringColumn)
id
- the column IDstringColumn
- if a new column is a string columnpublic void addToTable(ij.measure.ResultsTable destination)
destination
- Target tablepublic int getRowCount()
getRowCount
in interface TableModel
public int getColumnCount()
getColumnCount
in interface TableModel
public String getColumnName(int columnIndex)
getColumnName
in interface TableModel
public Class<?> getColumnClass(int columnIndex)
getColumnClass
in interface TableModel
public boolean isCellEditable(int rowIndex, int columnIndex)
isCellEditable
in interface TableModel
public boolean isNumericColumn(int columnIndex)
public boolean isNumericColumn(String columnName)
public Object getValueAt(int rowIndex, int columnIndex)
getValueAt
in interface TableModel
public void setValueAt(Object aValue, int rowIndex, int columnIndex)
setValueAt
in interface TableModel
public double getValueAsDouble(int rowIndex, int columnIndex)
rowIndex
- the rowcolumnIndex
- the columnpublic String getValueAsString(int rowIndex, int columnIndex)
rowIndex
- the rowcolumnIndex
- the columnpublic double getValueAsDouble(int rowIndex, String columnName)
rowIndex
- the rowcolumnName
- the columnpublic String getValueAsString(int rowIndex, String columnName)
rowIndex
- the rowcolumnName
- the columnpublic void renameColumn(String column, String newName)
column
- the columnnewName
- the new namepublic void fireChangedEvent(TableModelEvent event)
TableModelEvent
to all listenersevent
- the eventpublic void addTableModelListener(TableModelListener l)
addTableModelListener
in interface TableModel
public void removeTableModelListener(TableModelListener l)
removeTableModelListener
in interface TableModel
public void removeColumnAt(int col)
col
- column indexpublic void addRows(ResultsTableData other)
other
- the other datapublic void addColumns(Collection<ResultsTableData> others, boolean makeUnique, TableColumnNormalization normalization)
others
- the other tablesmakeUnique
- if true, the columns will be made unique. Otherwise, existing columns will be skipped.public Map<String,ResultsTableData> splitBy(TableColumn externalColumn)
externalColumn
- the columnpublic int addStringColumn(String name)
name
- column name. cannot be empty.public int addNumericColumn(String name)
name
- column name. cannot be empty.public int addColumn(String name, boolean stringColumn)
name
- column name. cannot be empty.stringColumn
- if the new column is a string columnpublic int addColumn(String name, TableColumn data, boolean extendRows)
name
- column name. cannot be empty.data
- the dataextendRows
- if true, add rows if needed to contain all non-generated information in the columnpublic int setColumnToValue(String name, Object value)
name
- the column namevalue
- the value. Can be numeric or stringpublic void convertToStringColumn(int column)
column
- column indexpublic void convertToNumericColumn(int column)
column
- column indexpublic boolean containsColumn(String columnName)
columnName
- the column namepublic int addRow(Map<String,Object> values)
values
- map of column name and value. Automatically creates columns if needed@Deprecated public ResultsTableData.RowBuilder addRowBuilder()
ResultsTableData.RowBuilder
for setting values convenientlypublic ResultsTableData.RowBuilder addAndModifyRow()
ResultsTableData.RowBuilder
for setting values convenientlypublic int addRow()
public void removeColumns(Collection<String> removedColumns)
removedColumns
- the columns to removepublic void setColumn(String columnName, TableColumn column)
columnName
- the column namecolumn
- the column datapublic void setColumn(String columnName, TableColumn column, boolean numeric)
columnName
- the column namecolumn
- the column datanumeric
- if the table column should be numericpublic void removeRow(int removedRow)
public void removeRows(Collection<Integer> rows)
public ResultsTableData getRows(Collection<Integer> rows)
public ResultsTableData getRows(int start, int end)
start
- the first row index (inclusive)end
- the last row index (exclusive)public ResultsTableData getRow(int row)
public boolean isStringColumn(String columnName)
public boolean isStringColumn(int col)
public boolean removeColumn(String columnName)
columnName
- the column nameCopyright © 2020–2024 Leibniz Institute for Natural Product Research and Infection Biology - Hans Knöll Institute (HKI). All rights reserved.