Search in sources :

Example 1 with ResultsTable

use of ij.measure.ResultsTable in project imagej1 by imagej.

the class Hotkeys method listCommands.

private void listCommands() {
    String[] commands = getAllCommands();
    Hashtable classes = Menus.getCommands();
    ResultsTable rt = new ResultsTable();
    for (int i = 0; i < commands.length; i++) {
        rt.incrementCounter();
        rt.addValue("Command", commands[i]);
        rt.addValue("Plugin", (String) classes.get(commands[i]));
    }
    rt.show("Commands");
}
Also used : ResultsTable(ij.measure.ResultsTable)

Example 2 with ResultsTable

use of ij.measure.ResultsTable in project imagej1 by imagej.

the class OverlayCommands method listRois.

public static void listRois(Roi[] rois) {
    ResultsTable rt = new ResultsTable();
    for (int i = 0; i < rois.length; i++) {
        if (rois[i] == null)
            continue;
        Rectangle r = rois[i].getBounds();
        String color = Colors.colorToString(rois[i].getStrokeColor());
        String fill = Colors.colorToString(rois[i].getFillColor());
        double strokeWidth = rois[i].getStrokeWidth();
        int digits = strokeWidth == (int) strokeWidth ? 0 : 1;
        String sWidth = IJ.d2s(strokeWidth, digits);
        int position = rois[i].getPosition();
        int c = rois[i].getCPosition();
        int z = rois[i].getZPosition();
        int t = rois[i].getTPosition();
        rt.setValue("Index", i, i);
        rt.setValue("Name", i, rois[i].getName());
        rt.setValue("Type", i, rois[i].getTypeAsString());
        rt.setValue("X", i, r.x);
        rt.setValue("Y", i, r.y);
        rt.setValue("Width", i, r.width);
        rt.setValue("Height", i, r.height);
        rt.setValue("Color", i, color);
        rt.setValue("Fill", i, fill);
        rt.setValue("LWidth", i, sWidth);
        rt.setValue("Pos", i, position);
        rt.setValue("C", i, c);
        rt.setValue("Z", i, z);
        rt.setValue("T", i, t);
    }
    rt.show("Overlay Elements");
}
Also used : ResultsTable(ij.measure.ResultsTable)

Example 3 with ResultsTable

use of ij.measure.ResultsTable in project imagej1 by imagej.

the class PlotObject method getResultsTable.

/**
 * Creates a ResultsTable with the data of the plot. Returns an empty table if no data.
 * Does not write the first x column if writeFirstXColumn is false.
 * When all columns are the same length, x columns equal to the first x column are
 * not written, independent of writeFirstXColumn.
 */
public ResultsTable getResultsTable(boolean writeFirstXColumn) {
    ResultsTable rt = new ResultsTable();
    rt.showRowNumbers(false);
    // find the longest x-value data set and count the data sets
    int nDataSets = 0;
    int tableLength = 0;
    for (PlotObject plotObject : allPlotObjects) if (plotObject.xValues != null) {
        nDataSets++;
        tableLength = Math.max(tableLength, plotObject.xValues.length);
    }
    if (nDataSets == 0)
        return null;
    // enter columns one by one to lists of data and headings
    ArrayList<String> headings = new ArrayList<String>(2 * nDataSets);
    ArrayList<float[]> data = new ArrayList<float[]>(2 * nDataSets);
    int dataSetNumber = 0;
    int arrowsNumber = 0;
    PlotObject firstXYobject = null;
    boolean allSameLength = true;
    for (PlotObject plotObject : allPlotObjects) {
        if (plotObject.type == PlotObject.XY_DATA) {
            if (firstXYobject != null && firstXYobject.xValues.length != plotObject.xValues.length) {
                allSameLength = false;
                break;
            }
            if (firstXYobject == null)
                firstXYobject = plotObject;
        }
    }
    firstXYobject = null;
    for (PlotObject plotObject : allPlotObjects) {
        if (plotObject.type == PlotObject.XY_DATA) {
            boolean sameX = firstXYobject != null && Arrays.equals(firstXYobject.xValues, plotObject.xValues) && allSameLength;
            // ignore duplicates (e.g. Markers plus Curve)
            boolean sameXY = sameX && Arrays.equals(firstXYobject.yValues, plotObject.yValues);
            boolean writeX = firstXYobject == null ? writeFirstXColumn : !sameX;
            addToLists(headings, data, plotObject, dataSetNumber, writeX, /*writeY=*/
            !sameXY, nDataSets > 1);
            if (firstXYobject == null)
                firstXYobject = plotObject;
            dataSetNumber++;
        } else if (plotObject.type == PlotObject.ARROWS) {
            addToLists(headings, data, plotObject, arrowsNumber, /*writeX=*/
            true, /*writeY=*/
            true, nDataSets > 1);
            arrowsNumber++;
        }
    }
    // populate the ResultsTable
    int nColumns = headings.size();
    for (int line = 0; line < tableLength; line++) {
        for (int col = 0; col < nColumns; col++) {
            String heading = headings.get(col);
            float[] values = data.get(col);
            if (line < values.length)
                rt.setValue(heading, line, values[line]);
            else
                rt.setValue(heading, line, "");
        }
    }
    // set the decimals (precision) of the table columns
    nColumns = rt.getLastColumn() + 1;
    for (int i = 0; i < nColumns; i++) rt.setDecimalPlaces(i, getPrecision(rt.getColumn(i)));
    return rt;
}
Also used : ResultsTable(ij.measure.ResultsTable)

Example 4 with ResultsTable

use of ij.measure.ResultsTable in project imagej1 by imagej.

the class IJ method deleteRows.

/**
 * Deletes 'row1' through 'row2' of the "Results" window, where
 *		'row1' and 'row2' must be in the range 0-Analyzer.getCounter()-1.
 */
public static void deleteRows(int row1, int row2) {
    ResultsTable rt = Analyzer.getResultsTable();
    rt.deleteRows(row1, row2);
    rt.show("Results");
}
Also used : ResultsTable(ij.measure.ResultsTable)

Example 5 with ResultsTable

use of ij.measure.ResultsTable in project imagej1 by imagej.

the class SimpleCommands method resultsToImage.

private void resultsToImage() {
    ResultsTable rt = ResultsTable.getResultsTable();
    if (rt == null || rt.getCounter() == 0) {
        IJ.error("Results to Image", "The Results table is empty");
        return;
    }
    ImageProcessor ip = rt.getTableAsImage();
    if (ip == null)
        return;
    new ImagePlus("Results Table", ip).show();
}
Also used : ResultsTable(ij.measure.ResultsTable)

Aggregations

ResultsTable (ij.measure.ResultsTable)22 HashMap (java.util.HashMap)3 Calibration (ij.measure.Calibration)2 Object3D (mcib3d.geom.Object3D)2 ImagePlus (ij.ImagePlus)1 GenericDialog (ij.gui.GenericDialog)1 Roi (ij.gui.Roi)1 Analyzer (ij.plugin.filter.Analyzer)1 TextWindow (ij.text.TextWindow)1 Project (ini.trakem2.Project)1 AreaContainer (ini.trakem2.display.AreaContainer)1 Displayable (ini.trakem2.display.Displayable)1 Profile (ini.trakem2.display.Profile)1 ZDisplayable (ini.trakem2.display.ZDisplayable)1 ProjectThing (ini.trakem2.tree.ProjectThing)1 ProjectTree (ini.trakem2.tree.ProjectTree)1 Menu (java.awt.Menu)1 Point (java.awt.Point)1 Rectangle (java.awt.Rectangle)1 ActionEvent (java.awt.event.ActionEvent)1