Menu

GroupLayoutEngineer readme

Help
2010-02-05
2013-04-19
  • Yevgen Ivakhno

    Yevgen Ivakhno - 2010-02-05

    GroupLayoutEngineer readme:

     
  • Yevgen Ivakhno

    Yevgen Ivakhno - 2010-02-05

    GroupLayoutEngineer is a shell for the layout manager GroupLayout. It allows to control components' placement using simple 2-dimensional textual schemes.

    Such approach to GUI creation removes the problem of representing a 2-dimensional GUI by 1-dimensional code.

    How to use the GroupLayoutEngineer

    1. Create an instance of the GroupLayoutEngineer. The first parameter of the constructor is a reference to the container, and the rest are the lines of the textual scheme. For example:

    2. Associate the names on the scheme with concrete components, for example:

    3. Apply optional preferences (such as special alignment), for example:

    Note that the alignment in the group above could also be automatically set to Baseline by calling the method setAutoAlignJTextFields().

    4. Invoke the method

    How to control gaps

    If you wish to control the gaps yourself instead of relying on automatic gaps creation, you will have two choices.
    We recommend to deal with gaps like with components, i.e., to place the required gaps at the scheme and then to associate them with concrete parameters (types and lengthes), for example:

    Note that each gap on the scheme must be started from a dot (in order to make it looking different from components).

    Also note that any gap (associated with the required parameters) may appear on the scheme any number of times, unlike the components, which appear on the scheme only once.

    Note that you may skip the associations of the denotations "." and ".." with related and unrelated gaps respectively, because these associations are always applied by default.

    Alternatively, you may add gaps to the layout without making additional changes to the scheme. This approach requires specifying concrete sequential or parallel groups and their concrete elements near which a gap should be added, for example:

    We do not recommend to use the letter approach because it minimizes the advantages of the group layout engineer.

    How to draw schemes
    In order to avoid formal introduction to this topic, we refer to the examples in the package glengineer.demo for general introduction to the schemes.
    Here we mention specific yet essential details only.

    1. The names of components (and gaps) on the scheme may consist of letters of any case, numbers, and underscores '_'.
    2. For each layout direction (horizontal and vertical) the engineer tries to divide every non-trivial block of elements on the scheme into a sequential or a parallel (if the former is not possible) group of elements or subblocks.
    3. One may place on the scheme horizontal and vertical lines which consist of symbols '-' and '|' respectively (and optionally of symbols '+' for the intersections).
    4. If a block on the scheme is intersected by a (horizontal or vertical) line, then this block will not be divided into a sequential group of that direction. Hence, it will be divided into a parallel group.
    5. The lines do not influence the layout in the perpendicular direction (but, certainly, this layout direction is influenced by the space under the line).
    6. If a block is divided into a parallel group by a number of lines, it is divided only by those of them which have the maximum length, and the smaller lines (if they exist) are left for the subblocks.
    7. Gaps on the scheme affect sequential groups only.
    8. If two sequential subblocks are divided by a number of gaps, then these gaps will be replaced by a single gap of that type.
    9. Gaps on the scheme may lie AT lines. Such lines are considered as being continued under that gaps, and the gaps affect only the direction perpendicular to the corresponding line.
    10. A line may be intersected only by one gap.
    11. If a gap touches one of the sides of a line, it is also assumed that they intersect.

    The GUI created in this example:

     

Log in to post a comment.

MongoDB Logo MongoDB