Can't call ROIManager from Macro/java/javascript/beanshell

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Can't call ROIManager from Macro/java/javascript/beanshell

ImgInterp123
Hello,

I am working in ImageJ 2.0.0-rfc-59/1.51n with Java 1.80_66 (64Bit) and am
try to call the RoiManager as a variable via a macro to acces its list. This
is neccesary for the automation of some functions I am currently working.
*It seems to me that the class is not being recognized/found by imageJ. *

the following is code generated from ImageJ's recording function:

rm = RoiManager.getInstance();
if (rm==null) rm = new RoiManager();
imp = IJ.openImage(FOLDERNAME);

rm.addRoi(imp.getRoi());

This throws the following error: "Sourced file: null : Attempt to resolve
method: getInstance() on undefined variable or class name: RoiManager : at
Line: 1 : in file: <unknown file> : RoiManager .getInstance ( ) " in
beanshell.

*Similar complaints are thrown in different programming languages but i can
use the application without any difficulties. * I have tried different
version of ImageJ to no avail (with Java 8) but so far hasn't manage to
solve this issue. Does anyone have a suggestion?



--
Sent from: http://imagej.1557.x6.nabble.com/

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Can't call ROIManager from Macro/java/javascript/beanshell

ctrueden
Hi David,

You need to import the class first. In BeanShell for example, prepend the
following line:

  import ij.plugin.frame.RoiManager;

Be aware that "macro" here specifically refers to the ImageJ macro language
[1]. This language is designed to be easy to learn, but is less powerful
than the other scripting languages, with a limited syntax and selection of
built-in functions [2]. It is not straightforward to translate macro code
to/from the other scripting languages.

Regards,
Curtis

[1] https://imagej.net/Macro
[2] https://imagej.net/developer/macro/functions.html

--
Curtis Rueden
LOCI software architect - https://loci.wisc.edu/software
ImageJ2 lead, Fiji maintainer - https://imagej.net/User:Rueden
Did you know ImageJ has a forum? http://forum.imagej.net/


On Mon, Oct 30, 2017 at 8:54 AM, ImgInterp123 <
[hidden email]> wrote:

> Hello,
>
> I am working in ImageJ 2.0.0-rfc-59/1.51n with Java 1.80_66 (64Bit) and am
> try to call the RoiManager as a variable via a macro to acces its list.
> This
> is neccesary for the automation of some functions I am currently working.
> *It seems to me that the class is not being recognized/found by imageJ. *
>
> the following is code generated from ImageJ's recording function:
>
> rm = RoiManager.getInstance();
> if (rm==null) rm = new RoiManager();
> imp = IJ.openImage(FOLDERNAME);
>
> rm.addRoi(imp.getRoi());
>
> This throws the following error: "Sourced file: null : Attempt to resolve
> method: getInstance() on undefined variable or class name: RoiManager : at
> Line: 1 : in file: <unknown file> : RoiManager .getInstance ( ) " in
> beanshell.
>
> *Similar complaints are thrown in different programming languages but i can
> use the application without any difficulties. * I have tried different
> version of ImageJ to no avail (with Java 8) but so far hasn't manage to
> solve this issue. Does anyone have a suggestion?
>
>
>
> --
> Sent from: http://imagej.1557.x6.nabble.com/
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html