Class BorderLayout

java.lang.Object
tripleplay.ui.Layout
tripleplay.ui.layout.BorderLayout

public class BorderLayout extends Layout
Arranges up to 5 elements, one central and one on each edge. Added elements must have a constraint from the class' listing (e.g. CENTER), which determines the position in the layout and stretching.

This is how the layout looks. Note north/south and east/west behavior is not quite symmetric because east and west fit between the bottom of the north and top of the south:

     |-----------------------------|
     |            north            |
     |-----------------------------|
     |      |               |      |
     |      |               |      |
     |      |               |      |
     | west |    center     | east |
     |      |               |      |
     |      |               |      |
     |-----------------------------|
     |            south            |
     |-----------------------------|
 
When an element is not stretched, it obeys the Style.HAlign and Style.VAlign bindings.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    Implements the constraints.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    Constraint to position an element in the center of its parent.
    Constraint to position an element along the right edge of its parent.
    float
    The horizontal gap between components.
    Constraint to position an element along the top edge of its parent.
    Constraint to position an element along the bottom edge of its parent.
    float
    The vertical gap between components.
    Constraint to position an element along the right edge of its parent.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a new border layout with no gaps.
    BorderLayout(float gaps)
    Constructs a new border layout with the specified gap between components.
    BorderLayout(float hgap, float vgap)
    Constructs a new border layout with the specified horizontal and vertical gaps between components.
  • Method Summary

    Modifier and Type
    Method
    Description
    pythagoras.f.Dimension
    computeSize(Container<?> elems, float hintX, float hintY)
    Computes and returns the size needed to arrange children of the supplied container according to their preferred size, given the specified x and y size hints.
    gaps(float gaps)
    Sets the gap, in pixels, to use between components.
    gaps(float hgap, float vgap)
    Sets the gap, in pixels, to use between components.
    void
    layout(Container<?> elems, float left, float top, float width, float height)
    Lays out the supplied elements into a region of the specified dimensions.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • CENTER

      public static final BorderLayout.Constraint CENTER
      Constraint to position an element in the center of its parent. The element is stretched in both directions to take up available space. If BorderLayout.Constraint.unstretched() is used, the element will be aligned in both directions using its preferred size and the Style.HAlign and Style.VAlign bindings.
    • NORTH

      public static final BorderLayout.Constraint NORTH
      Constraint to position an element along the top edge of its parent. The element is stretched horizontally and uses its preferred height. If BorderLayout.Constraint.unstretched() is used, the element will be aligned horizontally using its preferred size according to the Style.HAlign binding.
    • SOUTH

      public static final BorderLayout.Constraint SOUTH
      Constraint to position an element along the bottom edge of its parent. The element is stretched horizontally and uses its preferred height. If BorderLayout.Constraint.unstretched() is used, the element will be aligned horizontally using its preferred size according to the Style.HAlign binding.
    • EAST

      public static final BorderLayout.Constraint EAST
      Constraint to position an element along the right edge of its parent. The element is stretched vertically and uses its preferred width. If BorderLayout.Constraint.unstretched() is used, the element will be aligned vertically using its preferred size according to the Style.VAlign binding.
    • WEST

      public static final BorderLayout.Constraint WEST
      Constraint to position an element along the right edge of its parent. The element is stretched vertically and uses its preferred width. If BorderLayout.Constraint.unstretched() is used, the element will be aligned vertically using its preferred size according to the Style.VAlign binding.
    • hgap

      public float hgap
      The horizontal gap between components.
    • vgap

      public float vgap
      The vertical gap between components.
  • Constructor Details

    • BorderLayout

      public BorderLayout()
      Constructs a new border layout with no gaps.
    • BorderLayout

      public BorderLayout(float gaps)
      Constructs a new border layout with the specified gap between components.
    • BorderLayout

      public BorderLayout(float hgap, float vgap)
      Constructs a new border layout with the specified horizontal and vertical gaps between components.
  • Method Details

    • gaps

      public BorderLayout gaps(float gaps)
      Sets the gap, in pixels, to use between components.
      Parameters:
      gaps - the gap to use between components
    • gaps

      public BorderLayout gaps(float hgap, float vgap)
      Sets the gap, in pixels, to use between components.
      Parameters:
      hgap - the horizontal gap to use between components
      vgap - the vertical gap to use between components
    • computeSize

      public pythagoras.f.Dimension computeSize(Container<?> elems, float hintX, float hintY)
      Description copied from class: Layout
      Computes and returns the size needed to arrange children of the supplied container according to their preferred size, given the specified x and y size hints.
      Specified by:
      computeSize in class Layout
    • layout

      public void layout(Container<?> elems, float left, float top, float width, float height)
      Description copied from class: Layout
      Lays out the supplied elements into a region of the specified dimensions.
      Specified by:
      layout in class Layout