Package tripleplay.ui.layout
Class BorderLayout
java.lang.Object
tripleplay.ui.Layout
tripleplay.ui.layout.BorderLayout
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
Modifier and TypeClassDescriptionstatic class
Implements the constraints. -
Field Summary
Modifier and TypeFieldDescriptionstatic final BorderLayout.Constraint
Constraint to position an element in the center of its parent.static final BorderLayout.Constraint
Constraint to position an element along the right edge of its parent.float
The horizontal gap between components.static final BorderLayout.Constraint
Constraint to position an element along the top edge of its parent.static final BorderLayout.Constraint
Constraint to position an element along the bottom edge of its parent.float
The vertical gap between components.static final BorderLayout.Constraint
Constraint to position an element along the right edge of its parent. -
Constructor Summary
ConstructorDescriptionConstructs 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 TypeMethodDescriptionpythagoras.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
Lays out the supplied elements into a region of the specified dimensions.
-
Field Details
-
CENTER
Constraint to position an element in the center of its parent. The element is stretched in both directions to take up available space. IfBorderLayout.Constraint.unstretched()
is used, the element will be aligned in both directions using its preferred size and theStyle.HAlign
andStyle.VAlign
bindings. -
NORTH
Constraint to position an element along the top edge of its parent. The element is stretched horizontally and uses its preferred height. IfBorderLayout.Constraint.unstretched()
is used, the element will be aligned horizontally using its preferred size according to theStyle.HAlign
binding. -
SOUTH
Constraint to position an element along the bottom edge of its parent. The element is stretched horizontally and uses its preferred height. IfBorderLayout.Constraint.unstretched()
is used, the element will be aligned horizontally using its preferred size according to theStyle.HAlign
binding. -
EAST
Constraint to position an element along the right edge of its parent. The element is stretched vertically and uses its preferred width. IfBorderLayout.Constraint.unstretched()
is used, the element will be aligned vertically using its preferred size according to theStyle.VAlign
binding. -
WEST
Constraint to position an element along the right edge of its parent. The element is stretched vertically and uses its preferred width. IfBorderLayout.Constraint.unstretched()
is used, the element will be aligned vertically using its preferred size according to theStyle.VAlign
binding. -
hgap
public float hgapThe horizontal gap between components. -
vgap
public float vgapThe 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
Sets the gap, in pixels, to use between components.- Parameters:
gaps
- the gap to use between components
-
gaps
Sets the gap, in pixels, to use between components.- Parameters:
hgap
- the horizontal gap to use between componentsvgap
- the vertical gap to use between components
-
computeSize
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 classLayout
-
layout
Description copied from class:Layout
Lays out the supplied elements into a region of the specified dimensions.
-