Change selection brush size in macro

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

Change selection brush size in macro

Josh Doe-2
Hello,
I'm trying to change the size of the selection brush tool in a macro. I
haven't had any luck figuring out how to do it. The size seems to be set in
ij.gui.Toolbar. There is a public static int getBrushSize, but I see no
matching setBrushSize. Is there some other way that I could change the brush
size from a macro?
Thanks,
-Josh
Reply | Threaded
Open this post in threaded view
|

Re: Change selection brush size in macro

Wayne Rasband
On Nov 21, 2008, at 3:41 PM, Josh D wrote:

> Hello,
> I'm trying to change the size of the selection brush tool in a macro. I
> haven't had any luck figuring out how to do it. The size seems to be
> set in
> ij.gui.Toolbar. There is a public static int getBrushSize, but I see no
> matching setBrushSize. Is there some other way that I could change the
> brush
> size from a macro?

You can set the size of the selection brush tool in a macro using

     call("ij.gui.Toolbar.setBrushSize", size);

The Toolbar.setBrushSize() method was added in ImageJ 1.41o.

You can get the current size using

     size = call("ij.gui.Toolbar.getBrushSize");

-wayne
Reply | Threaded
Open this post in threaded view
|

Re: Change selection brush size in macro

Josh Doe-2
Agh, egg on my face for not checking the latest source. I was referencing
the browseable API source, which is 1.41k. Sorry for that.

But thanks for pointing it out, so glad to see you read my mind months ago!

-Josh

On Fri, Nov 21, 2008 at 3:56 PM, Wayne Rasband <[hidden email]> wrote:

>  On Nov 21, 2008, at 3:41 PM, Josh D wrote:
>
> Hello,
>> I'm trying to change the size of the selection brush tool in a macro. I
>> haven't had any luck figuring out how to do it. The size seems to be set
>> in
>> ij.gui.Toolbar. There is a public static int getBrushSize, but I see no
>> matching setBrushSize. Is there some other way that I could change the
>> brush
>> size from a macro?
>>
>
> You can set the size of the selection brush tool in a macro using
>
>    call("ij.gui.Toolbar.setBrushSize", size);
>
> The Toolbar.setBrushSize() method was added in ImageJ 1.41o.
>
> You can get the current size using
>
>    size = call("ij.gui.Toolbar.getBrushSize");
>
> -wayne
>
Reply | Threaded
Open this post in threaded view
|

Re: Change selection brush size in macro

dscho
In reply to this post by Josh Doe-2
Hi,

On Fri, 21 Nov 2008, Josh D wrote:

> I'm trying to change the size of the selection brush tool in a macro. I
> haven't had any luck figuring out how to do it. The size seems to be set
> in ij.gui.Toolbar. There is a public static int getBrushSize, but I see
> no matching setBrushSize. Is there some other way that I could change
> the brush size from a macro?

This is stored in the brushSize member of ij.gui.Toolbar, which is
private, unfortunately.

You can play games with java.lang.reflect.Field.setAccessible(), but that
is rather dirty.

Ciao,
Dscho
Reply | Threaded
Open this post in threaded view
|

Re: Change selection brush size in macro

dscho
In reply to this post by Wayne Rasband
Hi,

On Fri, 21 Nov 2008, Wayne Rasband wrote:

> The Toolbar.setBrushSize() method was added in ImageJ 1.41o.

Ah, I see that I based my analysis on 1.41n.  Bad luck.

Sorry,
Dscho