Posted by
Bill Mohler on
Sep 13, 2010; 1:01am
URL: http://imagej.273.s1.nabble.com/Detecting-animated-state-in-a-macro-tp3686936p3686939.html
Jerome, Ved, & Wayne
Thanks for your advice. I guess I'll have to experiment to find out how
much lag there might be in the disk-access required (I think) for the
prefs approach, versus the need to wait for a frame change in the
getSliceNumber approach. I'm trying to set up a very quick response in
the UI to a keystroke, but need to know whether the stack is currently
animated before choosing which actions to perform. It would be best, I
think, if a macro command could directly return the current value of
StackWindow.getAnimate(). Obviously this means work for Wayne, but I
think it would be useful.
Thanks to all,
Bill
On 9/12/10 3:35 p.m., Jerome Mutterer wrote:
> Bill, Ved,
>
> The following macro retrieves the animation state of the current stack using
> a javascript call. The state is returned using the built-in preferences
> mechanism, because the eval() macro function cannot return a value.
>
> s="Prefs.set('is.animated',WindowManager."+
> "getCurrentImage().getWindow()."+
> "getAnimate());";
> eval("script",s)
> a = call ('ij.Prefs.get','is.animated',false);
> print ("animated: "+a);
>
>
> Jerome
>
> On Sat, Sep 11, 2010 at 12:25 AM, Ved Sharma<
[hidden email]> wrote:
>
>> Hi Bill,
>>
>> You can try the following code. You might have to adjust the wait time,
>> depending on the your stack size and speed.
>>
>> ------------------------------------
>> a = getSliceNumber();
>> wait(1000);
>> b = getSliceNumber();
>>
>> if(a!=b)
>> print("Stack is animated.");
>> else
>> print("Stack is not animated.");
>> -------------------------------------
>>
>> Ved
>>