Class AxisLayout

java.lang.Object
tripleplay.ui.Layout
tripleplay.ui.layout.AxisLayout
Direct Known Subclasses:
AxisLayout.Horizontal, AxisLayout.Vertical

public abstract class AxisLayout extends Layout
Lays out elements in a horizontal or vertical group. Separate policies are enforced for on-axis and off-axis sizing.

On-axis, the available space is divided up as follows: non-stretched elements are given their preferred size, and remaining space is divided up among the stretched elements proportional to their configured weight (which defaults to one). If no stretched elements exist, elements are aligned per the Style.HAlign and Style.VAlign properties on the containing group.

Off-axis sizing can be configured to either size elements to their preferred size, stretch them all to a uniform size (equal to the preferred size of the largest element), or to stretch them all to the size allotted to the container. When elements are not stretched to fill the size allotted to the container, they may be aligned as above.

  • Constructor Details

    • AxisLayout

      public AxisLayout()
  • Method Details

    • vertical

      public static AxisLayout.Vertical vertical()
      Creates a vertical axis layout with default gap (5), and off-axis sizing policy (preferred size).
    • horizontal

      public static AxisLayout.Horizontal horizontal()
      Creates a horizontal axis layout with default gap (5), and off-axis sizing policy (preferred size).
    • stretched

      public static AxisLayout.Constraint stretched()
      Returns a layout constraint indicating that the associated element should be stretched to consume extra space, with weight 1.
    • fixed

      public static AxisLayout.Constraint fixed()
      Returns a layout constraint indicating that the associated element should not be stretched.
    • stretched

      public static AxisLayout.Constraint stretched(float weight)
      Returns a layout constraint indicating that the associated element should be stretched to consume extra space, with the specified weight.
    • stretch

      public static <T extends Element<?>> T stretch(T elem)
      Configures the supplied element with a stretched() constraint.
    • stretch

      public static <T extends Element<?>> T stretch(T elem, float weight)
      Configures the supplied element with a weighted stretched(float) constraint.
    • stretchByDefault

      public AxisLayout stretchByDefault()
      Configures the default constraint for elements added to this layout to be stretched. This is equivalent to calling Element.setConstraint(Layout.Constraint) with stretched() for each element added to the parent container.
    • offPolicy

      public AxisLayout offPolicy(AxisLayout.Policy policy)
      Configures the off-axis sizing policy for this layout.
    • offStretch

      public AxisLayout offStretch()
      Configures this layout to stretch all elements to the available size on the off-axis.
    • offEqualize

      public AxisLayout offEqualize()
      Configures this layout to stretch all elements to the size of the largest element on the off-axis.
    • offConstrain

      public AxisLayout offConstrain()
      Configures this layout to constrain elements to the size of this container on the off-axis, leaving their size alone if it is smaller.
    • gap

      public AxisLayout gap(int gap)
      Configures the inter-element gap, in pixels.