ij.measure
Class ResultsTable

java.lang.Object
  extended by ij.measure.ResultsTable
All Implemented Interfaces:
java.lang.Cloneable

public class ResultsTable
extends java.lang.Object
implements java.lang.Cloneable

This is a table for storing measurement results as columns of numeric values. Call the static ResultsTable.getResultsTable() method to get a reference to the ResultsTable used by the Analyze/Measure command.

See Also:
Analyzer.getResultsTable()

Field Summary
static int ANGLE
           
static int AREA
           
static int AREA_FRACTION
           
static int ASPECT_RATIO
           
static int CHANNEL
           
static int CIRCULARITY
           
static int COLUMN_IN_USE
           
static int COLUMN_NOT_FOUND
           
static int FERET
           
static int FERET_ANGLE
           
static int FERET_X
           
static int FERET_Y
           
static int FRAME
           
static int INTEGRATED_DENSITY
           
static int KURTOSIS
           
static int LAST_HEADING
           
static int MAJOR
           
static int MAX
           
static int MAX_COLUMNS
          Obsolete; use getLastColumn().
static int MEAN
           
static int MEDIAN
           
static int MIN
           
static int MIN_FERET
           
static int MINOR
           
static int MODE
           
static int PERIMETER
           
static int ROI_HEIGHT
           
static int ROI_WIDTH
           
static int ROI_X
           
static int ROI_Y
           
static int ROUNDNESS
           
static int SKEWNESS
           
static int SLICE
           
static int SOLIDITY
           
static int STD_DEV
           
static int TABLE_FULL
           
static int X_CENTER_OF_MASS
           
static int X_CENTROID
           
static int Y_CENTER_OF_MASS
           
static int Y_CENTROID
           
 
Constructor Summary
ResultsTable()
          Constructs an empty ResultsTable with the counter=0 and no columns.
 
Method Summary
 void addColumns()
           
 void addLabel(java.lang.String label)
          Adds a label to the beginning of the current row.
 void addLabel(java.lang.String columnHeading, java.lang.String label)
          Adds a label to the beginning of the current row.
 void addResults()
          Adds the last row in this table to the Results window without updating it.
 void addValue(int column, double value)
          Adds a value to the end of the given column.
 void addValue(java.lang.String column, double value)
          Adds a value to the end of the given column.
 java.lang.Object clone()
          Creates a copy of this ResultsTable.
 boolean columnExists(int column)
          Returns true if the specified column exists and is not empty.
static java.lang.String d2s(double n, int decimalPlaces)
          This is a version of IJ.d2s() that uses scientific notation for small numbes that would otherwise display as zero.
 void deleteRow(int row)
          Deletes the specified row.
 void disableRowLabels()
          Set the row label column to null if the column label is "Label".
 float[] getColumn(int column)
          Returns a copy of the given column as a float array, or null if the column is empty.
 double[] getColumnAsDoubles(int column)
          Returns a copy of the given column as a double array, or null if the column is empty.
 java.lang.String getColumnHeading(int column)
          Returns the heading of the specified column or null if the column is empty.
 java.lang.String getColumnHeadings()
          Returns a tab or comma delimited string containing the column headings.
 int getColumnIndex(java.lang.String heading)
          Returns the index of the first column with the given heading.
 int getCounter()
          Returns the current value of the measurement counter.
 int getFreeColumn(java.lang.String heading)
          Sets the heading of the the first available column and returns that column's index.
 java.lang.String getLabel(int row)
          Returns the label of the specified row.
 int getLastColumn()
          Returns the index of the last used column, or -1 if no columns are used.
static ResultsTable getResultsTable()
          Returns the ResultsTable used by the Measure command.
 java.lang.String getRowAsString(int row)
          Returns a tab or comma delimited string representing the given row, where 0<=row<=counter-1.
 float getValue(int column, int row)
          Deprecated. replaced by getValueAsDouble
 double getValue(java.lang.String column, int row)
          Returns the value of the specified column and row, where column is the column heading and row is a number greater than or equal zero and less than value returned by getCounter().
 double getValueAsDouble(int column, int row)
          Returns the value of the given column and row, where column must be less than or equal the value returned by getLastColumn() and row must be greater than or equal zero and less than the value returned by getCounter().
 void incrementCounter()
          Increments the measurement counter by one.
static ResultsTable open(java.lang.String path)
          Opens a tab or comma delimited text file as a ResultsTable.
 void reset()
          Clears all the columns and sets the counter to zero.
 void saveAs(java.lang.String path)
          Saves this ResultsTable as a tab or comma delimited text file.
 void setDefaultHeadings()
          Sets the headings used by the Measure command ("Area", "Mean", etc.).
 void setHeading(int column, java.lang.String heading)
          Deprecated. replaced by addValue(String,double) and setValue(String,int,double)
 void setLabel(java.lang.String label, int row)
          Adds a label to the beginning of the specified row, or updates an existing lable, where 0<=row
 void setPrecision(int precision)
          Sets the number of digits to the right of decimal point.
 void setValue(int column, int row, double value)
          Sets the value of the given column and row, where where 0<=column<=(lastRow+1 and 0<=row<counter.
 void setValue(java.lang.String column, int row, double value)
          Sets the value of the given column and row, where where 0<=row<counter.
 void show(java.lang.String windowTitle)
          Displays the contents of this ResultsTable in a window with the specified title.
 java.lang.String toString()
           
 void update(int measurements, ImagePlus imp, Roi roi)
           
 void updateResults()
          Updates the Results window.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MAX_COLUMNS

public static final int MAX_COLUMNS
Obsolete; use getLastColumn().

See Also:
Constant Field Values

COLUMN_NOT_FOUND

public static final int COLUMN_NOT_FOUND
See Also:
Constant Field Values

COLUMN_IN_USE

public static final int COLUMN_IN_USE
See Also:
Constant Field Values

TABLE_FULL

public static final int TABLE_FULL
See Also:
Constant Field Values

AREA

public static final int AREA
See Also:
Constant Field Values

MEAN

public static final int MEAN
See Also:
Constant Field Values

STD_DEV

public static final int STD_DEV
See Also:
Constant Field Values

MODE

public static final int MODE
See Also:
Constant Field Values

MIN

public static final int MIN
See Also:
Constant Field Values

MAX

public static final int MAX
See Also:
Constant Field Values

X_CENTROID

public static final int X_CENTROID
See Also:
Constant Field Values

Y_CENTROID

public static final int Y_CENTROID
See Also:
Constant Field Values

X_CENTER_OF_MASS

public static final int X_CENTER_OF_MASS
See Also:
Constant Field Values

Y_CENTER_OF_MASS

public static final int Y_CENTER_OF_MASS
See Also:
Constant Field Values

PERIMETER

public static final int PERIMETER
See Also:
Constant Field Values

ROI_X

public static final int ROI_X
See Also:
Constant Field Values

ROI_Y

public static final int ROI_Y
See Also:
Constant Field Values

ROI_WIDTH

public static final int ROI_WIDTH
See Also:
Constant Field Values

ROI_HEIGHT

public static final int ROI_HEIGHT
See Also:
Constant Field Values

MAJOR

public static final int MAJOR
See Also:
Constant Field Values

MINOR

public static final int MINOR
See Also:
Constant Field Values

ANGLE

public static final int ANGLE
See Also:
Constant Field Values

CIRCULARITY

public static final int CIRCULARITY
See Also:
Constant Field Values

FERET

public static final int FERET
See Also:
Constant Field Values

INTEGRATED_DENSITY

public static final int INTEGRATED_DENSITY
See Also:
Constant Field Values

MEDIAN

public static final int MEDIAN
See Also:
Constant Field Values

SKEWNESS

public static final int SKEWNESS
See Also:
Constant Field Values

KURTOSIS

public static final int KURTOSIS
See Also:
Constant Field Values

AREA_FRACTION

public static final int AREA_FRACTION
See Also:
Constant Field Values

CHANNEL

public static final int CHANNEL
See Also:
Constant Field Values

SLICE

public static final int SLICE
See Also:
Constant Field Values

FRAME

public static final int FRAME
See Also:
Constant Field Values

FERET_X

public static final int FERET_X
See Also:
Constant Field Values

FERET_Y

public static final int FERET_Y
See Also:
Constant Field Values

FERET_ANGLE

public static final int FERET_ANGLE
See Also:
Constant Field Values

MIN_FERET

public static final int MIN_FERET
See Also:
Constant Field Values

ASPECT_RATIO

public static final int ASPECT_RATIO
See Also:
Constant Field Values

ROUNDNESS

public static final int ROUNDNESS
See Also:
Constant Field Values

SOLIDITY

public static final int SOLIDITY
See Also:
Constant Field Values

LAST_HEADING

public static final int LAST_HEADING
See Also:
Constant Field Values
Constructor Detail

ResultsTable

public ResultsTable()
Constructs an empty ResultsTable with the counter=0 and no columns.

Method Detail

getResultsTable

public static ResultsTable getResultsTable()
Returns the ResultsTable used by the Measure command. This table must be displayed in the "Results" window.


incrementCounter

public void incrementCounter()
Increments the measurement counter by one.


addColumns

public void addColumns()

getCounter

public int getCounter()
Returns the current value of the measurement counter.


addValue

public void addValue(int column,
                     double value)
Adds a value to the end of the given column. Counter must be >0.


addValue

public void addValue(java.lang.String column,
                     double value)
Adds a value to the end of the given column. If the column does not exist, it is created. Counter must be >0.


addLabel

public void addLabel(java.lang.String label)
Adds a label to the beginning of the current row. Counter must be >0.


addLabel

public void addLabel(java.lang.String columnHeading,
                     java.lang.String label)
Adds a label to the beginning of the current row. Counter must be >0.


setLabel

public void setLabel(java.lang.String label,
                     int row)
Adds a label to the beginning of the specified row, or updates an existing lable, where 0<=rowshow() to update the window displaying the table.


disableRowLabels

public void disableRowLabels()
Set the row label column to null if the column label is "Label".


getColumn

public float[] getColumn(int column)
Returns a copy of the given column as a float array, or null if the column is empty.


getColumnAsDoubles

public double[] getColumnAsDoubles(int column)
Returns a copy of the given column as a double array, or null if the column is empty.


columnExists

public boolean columnExists(int column)
Returns true if the specified column exists and is not empty.


getColumnIndex

public int getColumnIndex(java.lang.String heading)
Returns the index of the first column with the given heading. heading. If not found, returns COLUMN_NOT_FOUND.


getFreeColumn

public int getFreeColumn(java.lang.String heading)
Sets the heading of the the first available column and returns that column's index. Returns COLUMN_IN_USE if this is a duplicate heading.


getValueAsDouble

public double getValueAsDouble(int column,
                               int row)
Returns the value of the given column and row, where column must be less than or equal the value returned by getLastColumn() and row must be greater than or equal zero and less than the value returned by getCounter().


getValue

public float getValue(int column,
                      int row)
Deprecated. replaced by getValueAsDouble


getValue

public double getValue(java.lang.String column,
                       int row)
Returns the value of the specified column and row, where column is the column heading and row is a number greater than or equal zero and less than value returned by getCounter(). Throws an IllegalArgumentException if this ResultsTable does not have a column with the specified heading.


getLabel

public java.lang.String getLabel(int row)
Returns the label of the specified row. Returns null if the row does not have a label.


setValue

public void setValue(java.lang.String column,
                     int row,
                     double value)
Sets the value of the given column and row, where where 0<=row<counter. If the specified column does not exist, it is created. When adding columns, show() must be called to update the window that displays the table.


setValue

public void setValue(int column,
                     int row,
                     double value)
Sets the value of the given column and row, where where 0<=column<=(lastRow+1 and 0<=row<counter.


getColumnHeadings

public java.lang.String getColumnHeadings()
Returns a tab or comma delimited string containing the column headings.


getColumnHeading

public java.lang.String getColumnHeading(int column)
Returns the heading of the specified column or null if the column is empty.


getRowAsString

public java.lang.String getRowAsString(int row)
Returns a tab or comma delimited string representing the given row, where 0<=row<=counter-1.


setHeading

public void setHeading(int column,
                       java.lang.String heading)
Deprecated. replaced by addValue(String,double) and setValue(String,int,double)


setDefaultHeadings

public void setDefaultHeadings()
Sets the headings used by the Measure command ("Area", "Mean", etc.).


setPrecision

public void setPrecision(int precision)
Sets the number of digits to the right of decimal point.


d2s

public static java.lang.String d2s(double n,
                                   int decimalPlaces)
This is a version of IJ.d2s() that uses scientific notation for small numbes that would otherwise display as zero.


deleteRow

public void deleteRow(int row)
Deletes the specified row.


reset

public void reset()
Clears all the columns and sets the counter to zero.


getLastColumn

public int getLastColumn()
Returns the index of the last used column, or -1 if no columns are used.


addResults

public void addResults()
Adds the last row in this table to the Results window without updating it.


updateResults

public void updateResults()
Updates the Results window.


show

public void show(java.lang.String windowTitle)
Displays the contents of this ResultsTable in a window with the specified title. Opens a new window if there is no open text window with this title. The title must be "Results" if this table was obtained using ResultsTable.getResultsTable or Analyzer.getResultsTable .


update

public void update(int measurements,
                   ImagePlus imp,
                   Roi roi)

open

public static ResultsTable open(java.lang.String path)
                         throws java.io.IOException
Opens a tab or comma delimited text file as a ResultsTable. Displays a file open dialog if 'path' is empty or null. Displays non-numeric tables in a TextWindow and returns null.

Throws:
java.io.IOException

saveAs

public void saveAs(java.lang.String path)
            throws java.io.IOException
Saves this ResultsTable as a tab or comma delimited text file. ThnonNumericIne table is saved as a CSV (comma-separated values) file if 'path' ends with ".csv". Displays a file save dialog if 'path' is empty or null.

Throws:
java.io.IOException

clone

public java.lang.Object clone()
Creates a copy of this ResultsTable.

Overrides:
clone in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object