在 ImageJ(java) 中将 String 作为代码执行
代码在String中,例如:
String str = "IJ.run(\"FJ Edges\", \"\");";
如果执行str,就会运行相应的内容。
The code is in the String, example:
String str = "IJ.run(\"FJ Edges\", \"\");";
If str is executed, the corresponding contents will run.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不太清楚你想做什么,但在你给出的示例中,没有理由不直接调用 IJ.run() - 例如,在插件中,这将是:
如果你确实想评估任意 Java如果来自字符串的代码,那么 Matt Ball 在他的评论中建议的链接将会有所帮助。
不过,如果您只想在 ImageJ 中编写简单的脚本,那么使用宏语言或 Javascript 会更容易。您可以在这里找到前者的指南:
http://rsbweb.nih.gov /ij/developer/macro/macros.html
(在大多数情况下,使用宏记录器启动脚本会很有帮助(在插件 > 宏 > 记录...中))我希望这有一些用处。
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:
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.