Login  Register

Re: Advanced Dialog boxes

Posted by John Alexander-7 on May 19, 2008; 2:50pm
URL: http://imagej.273.s1.nabble.com/Advanced-Dialog-boxes-tp3696187p3696189.html

Thank you (and everyone).

I guess I have begun to reach the limits of macro coding.  I once knew
c++ so I am rather familiar with the java syntax - but just haven't
written any real code in a decade.

Looks like now is a decent time to begin going through the plug-in
tutorials I've found.

John



Michael Schmid wrote:

> Hi John,
>
> some of the features you want are possible when writing a
> plugin and using the GenericDialog class of ImageJ (so you
> can record the options by the Macro Recorder and run the
> plugin from a macro):
>
> Register your plugin as a DialogListener, then its
> dialogItemChanged method gets called on every user action
> (typing, clicking).
> For examples, see, e.g., the Convolver.java or SpecifyROI.java
> codes.
>
> You can also use the getCheckboxes() etc. methods of the
> GenericDialog class to get references to the fields. Then
> you can enable or disable ("gray out") the fields by the usual
> java.awt commands like myCheckbox.setEnabled(true) and you
> can write into text fields.
>
> A problem with these methods is a very nasty bug on Mac OSX 10.4
> (possibly also other versions?):
> If more than one modification of a dialog, such as enabling or
> disabling a field, writing into a field, etc. is done at the same
> time, only the first of them is actually made, the others are
> delayed until the next input (clicking, typing) operation.
> E.g., it may happen that checkboxes remain disabled and the user
> cannot check or uncheck them.
>
> Browse file or Browse directory - this would require the
> addPanel method of a GenericDialog, but then you have to do
> all the coding for it, including macro options, by yourself.
> I would suggest to use a separate file or directory dialog
> istead.
>
> I see no way how to implement any of these functionalities in
> a macro (instead of a plugin). So you have to learn Java (this
> is not extremely difficult, at least much easier than C++).
>
> Michael
> ________________________________________________________________
>
> On 18 May 2008, at 04:42, John Alexander wrote:
>
>
>> Hello group,
>>
>> I am wondering about some more advanced dialog box features in a macro.
>>
>> For example, let's say I want to have a field on the box continuously
>> updated.  For example, I want one option to depend on the other.  If the
>> person types "2" in the X box, then the Y box automatically prints "4"
>> (as in 2*X).  If the person types "6" in the Y box, then the X
>> automatically is set to 3.  Basically I want the dialog box to be
>> interactive - and only commit the values to the assigned variables once
>> the person clicks "ok".
>>
>> Another thing is to have an "input directory" and an "output directory"
>> field with a "browse" button next to them.
>>
>> What about having an option grayed out if it is unecessary.
>>
>> For example: I would have a checkbox that says "process single file?" If
>> the person checks it - then the "recursively process directory" field
>> would be greyed out since it is irrelevant.
>>
>> Are such advanced dialog featuers available in ImageJ macros?  Or is
>> such interactivity for plug-ins?
>>
>> So far I am exclusively writing macros - since I have really not found
>> the need to learn how to write a plug-in.  I know that if I put a tad
>> bit of effort into learning how to write a plug-in it will be easy - ust
>> being lazy.  :P
>>
>>
>>
>> John
>>
>>
>>
>>
>> --
>> John K. Alexander, Ph.D.
>> Post-Doctoral Fellow
>> William Green Laboratory
>> University of Chicago
>> Dept. Neurobiology, Pharmacology, and Physiology
>> 947 East 58th Street
>> Abott Hall 402
>> Chicago, IL 60637
>> (off) 773-702-9386
>> (fax) 773-702-3774
>> [hidden email]
>>
>

--
John K. Alexander, Ph.D.
Post-Doctoral Fellow
William Green Laboratory
University of Chicago
Dept. Neurobiology, Pharmacology, and Physiology
947 East 58th Street
Abott Hall 402
Chicago, IL 60637
(off) 773-702-9386
(fax) 773-702-3774
[hidden email]