Java Code Examples for ij.measure.ResultsTable#getHeadings()

The following examples show how to use ij.measure.ResultsTable#getHeadings() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LabelToValuePlugin.java    From MorphoLibJ with GNU Lesser General Public License v3.0 5 votes vote down vote up
private GenericDialog createDialog()
	{
		// Get the list of windows containing tables
		TextWindow[] textWindows = getTableWindows();
		if (textWindows.length == 0)
		{
			IJ.error("Requires at least one Table window");
			return null;
		}
		String[] tableNames = new String[textWindows.length];
		for (int i = 0; i < textWindows.length; i++) {
			tableNames[i] = textWindows[i].getTitle();
//			IJ.log("Found table: " + tableNames[i]);
		}
		
		// Choose current table
		TextPanel tp = textWindows[0].getTextPanel();
		ResultsTable table = tp.getResultsTable();
		this.table = table;
		
		// Choose current heading
		String[] headings = table.getHeadings();
		String defaultHeading = headings[0];
		if (defaultHeading.equals("Label") && headings.length > 1)
		{
			defaultHeading = headings[1];
		}

		double[] extent = computeColumnExtent(table, defaultHeading);

		this.gd = new GenericDialog("Assign Measure to Label");
		gd.addChoice("Results Table:", tableNames, tableNames[0]);
		gd.addChoice("Column:", headings, defaultHeading);
		gd.addNumericField("Min Value", extent[0], this.nDigits, 10, null);
		gd.addNumericField("Max Value", extent[1], this.nDigits, 10, null);
		gd.addDialogListener(this);
		
		return gd;
	}
 
Example 2
Source File: LabelToValuePlugin.java    From MorphoLibJ with GNU Lesser General Public License v3.0 5 votes vote down vote up
private double[] getColumnValues(ResultsTable table, String heading)
{
    String[] allHeaders = table.getHeadings();

    // Check if column header corresponds to row label header
    boolean hasRowLabels = hasRowLabelColumn(table);
    if (hasRowLabels && heading.equals(allHeaders[0]))
    {
        // need to parse row label column
        int nr = table.size();
        double[] values = new double[nr];
        for (int r = 0; r < nr; r++)
        {
            String label = table.getLabel(r);
            values[r] = Double.parseDouble(label);
        }
        return values;
    }

    // determine index of column
    int index = table.getColumnIndex(heading);
    if (index == ResultsTable.COLUMN_NOT_FOUND)
    {
        throw new RuntimeException("Unable to find column index from header: " + heading);
    }
    return table.getColumnAsDoubles(index);
}
 
Example 3
Source File: DrawTableValuesPlugin.java    From MorphoLibJ with GNU Lesser General Public License v3.0 5 votes vote down vote up
private double[] getColumnValues(ResultsTable table, String heading)
{
    String[] allHeaders = table.getHeadings();

    // Check if column header corresponds to row label header
    boolean hasRowLabels = hasRowLabelColumn(table);
    if (hasRowLabels && heading.equals(allHeaders[0]))
    {
        // need to parse row label column
        int nr = table.size();
        double[] values = new double[nr];
        for (int r = 0; r < nr; r++)
        {
            String label = table.getLabel(r);
            values[r] = Double.parseDouble(label);
        }
        return values;
    }

    // determine index of column
    int index = table.getColumnIndex(heading);
    if (index == ResultsTable.COLUMN_NOT_FOUND)
    {
        throw new RuntimeException("Unable to find column index from header: " + heading);
    }
    return table.getColumnAsDoubles(index);
}
 
Example 4
Source File: LabelToValuePlugin.java    From MorphoLibJ with GNU Lesser General Public License v3.0 4 votes vote down vote up
private static final boolean hasRowLabelColumn(ResultsTable table)
{
    return table.getLastColumn() == (table.getHeadings().length-2);
}
 
Example 5
Source File: DrawTableValuesPlugin.java    From MorphoLibJ with GNU Lesser General Public License v3.0 4 votes vote down vote up
private GenericDialog createDialog()
{
	// Get the list of windows containing tables
	TextWindow[] textWindows = IJUtils.getTableWindows();
	if (textWindows.length == 0)
	{
		IJ.error("Requires at least one Table window");
		return null;
	}
	String[] tableNames = new String[textWindows.length];
	for (int i = 0; i < textWindows.length; i++) {
		tableNames[i] = textWindows[i].getTitle();
	}
	
	// Choose current table
	TextPanel tp = textWindows[0].getTextPanel();
	ResultsTable table = tp.getResultsTable();
	this.table = table;
	
	// Choose current heading
	String[] headings = table.getHeadings();
	String defaultHeading = headings[0];
	if (defaultHeading.equals("Label") && headings.length > 1)
	{
		defaultHeading = headings[1];
	}

	this.gd = new GenericDialog("Draw Text from Column");
	gd.addChoice("Results Table:", tableNames, tableNames[0]);
       gd.addCheckbox("Calibrated Position:", false);
       gd.addChoice("X-Position:", headings, defaultHeading);
       gd.addChoice("Y-Position:", headings, defaultHeading);
       gd.addNumericField("X-Offset:", this.xOffset, 0, 5, "pixels");
       gd.addNumericField("Y-Offset:", this.yOffset, 0, 5, "pixels");
       gd.addChoice("Values:", headings, defaultHeading);
       gd.addStringField("Pattern:", "%5.2f", 10);
       
       @SuppressWarnings("unchecked")
       Vector<Choice> choices = gd.getChoices();
       replaceStrings(choices.get(1), headings, chooseDefaultHeading(headings, xPosHeaderName));
       replaceStrings(choices.get(2), headings, chooseDefaultHeading(headings, yPosHeaderName));
       replaceStrings(choices.get(3), headings, chooseDefaultHeading(headings, valueHeaderName));

       gd.addDialogListener(this);
	
	return gd;
}
 
Example 6
Source File: DrawTableValuesPlugin.java    From MorphoLibJ with GNU Lesser General Public License v3.0 4 votes vote down vote up
private static final boolean hasRowLabelColumn(ResultsTable table)
{
    return table.getLastColumn() == (table.getHeadings().length-2);
}