Issue with the Dialog.addToSameRow() feature

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

Issue with the Dialog.addToSameRow() feature

Philippe CARL
Dear all (probably Michael and/or Wayne),

Please consider the following simple macro code:

                Dialog.create("Test dialog");

                Dialog.addNumber("Red  >",0);

                Dialog.addNumber("Or ",0);

                Dialog.addToSameRow();

                Dialog.addNumber("<  Red  <",1);

                Dialog.addMessage("And");

                Dialog.addToSameRow();

                Dialog.addNumber("Green  <",1);

                Dialog.addNumber("Blue  <",1);

                Dialog.addToSameRow();

                Dialog.addMessage("And");

                Dialog.show();

As you can see the "Dialog.addToSameRow()" is working correctly in the case
of:

-                   An "Dialog.addNumber" following an "Dialog.addNumber"

-          And an "Dialog.addMessage" following an "Dialog.addNumber"

But in the case of:

-          an "Dialog.addNumber" following an "Dialog.addMessage"

the "Dialog.addNumber" seems to not show up.

Actually it shows up (it can be seen if you increase the initial size of the
dialog box to the right) but is shifted not of one position but of two
positions to the right.

I guess this issue is related to the "GridBagConstraints.RELATIVE" within
the "public void addNumericField" method within the "GenericDialog.java"
file.

I thank you very muchj in advance for your help on this issue.

Have a nice day,

Philippe

 

Philippe CARL

Laboratoire de Bioimagerie et Pathologies

UMR 7021 CNRS - Université de Strasbourg

Faculté de Pharmacie

74 route du Rhin

67401 ILLKIRCH

Tel : +33(0)3 68 85 41 84


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

Re: Issue with the Dialog.addToSameRow() feature

Herbie
Bonjour Philippe,

the list of commented macro functions tells us for "Dialog.addToSameRow()":
<http://mirror.imagej.net/developer/macro/functions.html>

"Note that addMessage uses the remaining width, so it must be the last
item of a row."

HTH

Herbie
__________________________________________

PS:
At the same place we read

"Makes the next item added appear on the same row as the previous item.
May be used for addNumericField, addSlider, addChoice, addCheckbox,
addStringField, addMessage, addPanel, and before the showDialog()
method. In the latter case, the buttons appear to the right of the
previous item."

and I wonder how "addPanel" is to be used in a macro?


:::::::::::::::::::::::::::::::::::::::::::
Am 02.05.18 um 16:42 schrieb Philippe CARL:

> Dear all (probably Michael and/or Wayne),
>
> Please consider the following simple macro code:
>
>                  Dialog.create("Test dialog");
>
>                  Dialog.addNumber("Red  >",0);
>
>                  Dialog.addNumber("Or ",0);
>
>                  Dialog.addToSameRow();
>
>                  Dialog.addNumber("<  Red  <",1);
>
>                  Dialog.addMessage("And");
>
>                  Dialog.addToSameRow();
>
>                  Dialog.addNumber("Green  <",1);
>
>                  Dialog.addNumber("Blue  <",1);
>
>                  Dialog.addToSameRow();
>
>                  Dialog.addMessage("And");
>
>                  Dialog.show();
>
> As you can see the "Dialog.addToSameRow()" is working correctly in the case
> of:
>
> -                   An "Dialog.addNumber" following an "Dialog.addNumber"
>
> -          And an "Dialog.addMessage" following an "Dialog.addNumber"
>
> But in the case of:
>
> -          an "Dialog.addNumber" following an "Dialog.addMessage"
>
> the "Dialog.addNumber" seems to not show up.
>
> Actually it shows up (it can be seen if you increase the initial size of the
> dialog box to the right) but is shifted not of one position but of two
> positions to the right.
>
> I guess this issue is related to the "GridBagConstraints.RELATIVE" within
> the "public void addNumericField" method within the "GenericDialog.java"
> file.
>
> I thank you very muchj in advance for your help on this issue.
>
> Have a nice day,
>
> Philippe
>
>  
>
> Philippe CARL
>
> Laboratoire de Bioimagerie et Pathologies
>
> UMR 7021 CNRS - Université de Strasbourg
>
> Faculté de Pharmacie
>
> 74 route du Rhin
>
> 67401 ILLKIRCH
>
> Tel : +33(0)3 68 85 41 84
>
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

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

Re: Issue with the Dialog.addToSameRow() feature

Michael Schmid-3
In reply to this post by Philippe CARL
Hi Philippe,

this behavior is intended; addMessage as well as addString with a width
or more than 8 must be the last items in a row; nothing can be added to
the same row behind them.

The reason is as follows:

The layout is based on a grid (Java GridBagLayout). So everything is
arranged in columns (otherwise it would not look nice).
If there are several items in a row, one has two options for a given item:

(a) Having the item one column wide. This is chosen for numbers,
StringFields with a width up to 8, Checkboxes and Choices.

(b) For items that are typically rather wide, the width is chosen to be
the full remainder of the line. This is for 'addMessage' and
StringFields with a width of more then 8. Technically, this is done by
specifying GridbagConstraints.REMAINDER as the width, which means "take
all the remaining space". Then, obviously you can't have anything behind
the remaining space (and if you add something to this line, the behavior
is unpredictable).

When choosing single-column width for all items you could not have a
long text with 'addMessage' or a wide StringField (e.g. for a file path)
without making all other items in the same column much wider than necessary.

I think there is not much use of having an 'addMessage' at the left of a
number: The text in 'addMessage' could simply become part of the label.
E.g. in your case
      Dialog.addNumber("And Green  <",1);

Michael
________________________________________________________________


On 02/05/2018 16:42, Philippe CARL wrote:

> Dear all (probably Michael and/or Wayne),
>
> Please consider the following simple macro code:
>
>                  Dialog.create("Test dialog");
>                  Dialog.addNumber("Red  >",0);
>                  Dialog.addNumber("Or ",0);
>                  Dialog.addToSameRow();
>                  Dialog.addNumber("<  Red  <",1);
>                  Dialog.addMessage("And");
>                  Dialog.addToSameRow();
>                  Dialog.addNumber("Green  <",1);
>                  Dialog.addNumber("Blue  <",1);
>                  Dialog.addToSameRow();
>                  Dialog.addMessage("And");
>                  Dialog.show();
>
> As you can see the "Dialog.addToSameRow()" is working correctly in the case
> of:
>
> -                   An "Dialog.addNumber" following an "Dialog.addNumber"
>
> -          And an "Dialog.addMessage" following an "Dialog.addNumber"
>
> But in the case of:
>
> -          an "Dialog.addNumber" following an "Dialog.addMessage"
>
> the "Dialog.addNumber" seems to not show up.
>
> Actually it shows up (it can be seen if you increase the initial size of the
> dialog box to the right) but is shifted not of one position but of two
> positions to the right.
>
> I guess this issue is related to the "GridBagConstraints.RELATIVE" within
> the "public void addNumericField" method within the "GenericDialog.java"
> file.
>
> I thank you very muchj in advance for your help on this issue.
>
> Have a nice day,
>
> Philippe
>
>  
>
> Philippe CARL
>
> Laboratoire de Bioimagerie et Pathologies
>
> UMR 7021 CNRS - Université de Strasbourg
>
> Faculté de Pharmacie
>
> 74 route du Rhin
>
> 67401 ILLKIRCH
>
> Tel : +33(0)3 68 85 41 84
>
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

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