execute String as code in ImageJ(java)
The code is in the String, example:
String str = "IJ.run(\"FJ Edges\", \"\");";
开发者_Go百科If str is executed, the corresponding contents will run.
It's not quite clear to me what you want to do, but in the example you give there's no reason not to call IJ.run() directly - for example, in a plugin this would be:
import ij.plugin.PlugIn;
import ij.IJ;
public class Simple_PlugIn implements PlugIn {
public void run(String arg) {
IJ.run("FJ Edges","");
}
}
If you really do want to evaluate arbitrary Java code from a String, then the links Matt Ball suggested in his comments will help.
If you just want to do simple scripting in ImageJ, though, it will be easier to use the macro language or Javascript. You can find a guide to the former here:
http://rsbweb.nih.gov/ij/developer/macro/macros.html
(In most cases it's helpful to start your script by using the macro recorder (in Plugins > Macros > Record...)) I hope that's of some use.
精彩评论