[Home] DMelt member access. Java source code: ij.measure.ResultsTableMacros
package ij.measure;
import ij.plugin.filter.Analyzer;
import ij.plugin.frame.Recorder;
import ij.plugin.*;
import ij.*;
import ij.gui.*;
import ij.text.*;
import java.awt.*;
import java.awt.event.*;
/** This class implements the Apply Macro command in tables.
* @author Michael Schmid
*/
public class ResultsTableMacros implements Runnable, DialogListener, ActionListener, KeyListener {
private static String NAME = "TableMacro.ijm";
private String defaultMacro = "Sin=sin(row*0.1);\nCos=cos(row*0.1);\nSqr=Sin*Sin+Cos*Cos;";
private GenericDialog gd;
private ResultsTable rt, rtBackup;
private Button runButton, resetButton, openButton, saveButton;
private String title;
private int runCount;
private TextArea ta;
public ResultsTableMacros(ResultsTable rt) {
this.rt = rt;
title = rt!=null?rt.getTitle():null;
Thread thread = new Thread(this, "ResultTableMacros");
thread.start();
}
private void showDialog() {
if (rt==null)
rt = Analyzer.getResultsTable();
if (rt==null || rt.size()==0) {
IJ.error("Results Table required");
return;
}
String[] temp = rt.getHeadingsAsVariableNames();
String[] variableNames = new String[temp.length+2];
variableNames[0] = "Insert...";
variableNames[1] = "row";
for (int i=2; iMacro Equations for Results Tables
"+
"- The macro, or a selection, is applied to each row of the table."+
"
- A new variable starting with an Uppercase character creates
a new column."+
" - A new variable starting with a lowercase character is temporary."+
"
- The variable row (row index) is pre-defined.\n"+
"
- String operations are supported for the 'Label' column only (if
enabled"+
"with Analyze>Set Measurements>Display Label)."+
" - Click \"Run\", or press "+(IJ.isMacOSX()?"cmd":"ctrl") + "-r, to apply the macro code to the table."+
"
- Select a line and press "+(IJ.isMacOSX()?"cmd":"ctrl") + "-r to apply a line of macro code."+
"
- Click \"Reset\" to revert to the original version of the table."+
"
- The code is saved at macros/TableMacro.ijm, and the
\"Apply Macro\" command is recorded, when you click \"OK\"."+
" - All Table. macro functions (such as Table.size) refer to the
current (frontmost) table unless the table name is given."+
"