java.lang.Object
com.googlecode.lanterna.gui2.LinearLayout
- All Implemented Interfaces:
LayoutManager
Simple layout manager the puts all components on a single line, either horizontally or vertically.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
This enum type will decide the alignment of a component on the counter-axis, meaning the horizontal alignment on verticalLinearLayout
s and vertical alignment on horizontalLinearLayout
s.static enum
This enum type will what to do with a component if the container has extra space to offer.private static class
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor, creates a verticalLinearLayout
LinearLayout
(Direction direction) Standard constructor that creates aLinearLayout
with a specified direction to position the components on -
Method Summary
Modifier and TypeMethodDescriptionstatic LayoutData
createLayoutData
(LinearLayout.Alignment alignment) Creates aLayoutData
forLinearLayout
that assigns a component to a particular alignment on its counter-axis, meaning the horizontal alignment on verticalLinearLayout
s and vertical alignment on horizontalLinearLayout
s.static LayoutData
createLayoutData
(LinearLayout.Alignment alignment, LinearLayout.GrowPolicy growPolicy) Creates aLayoutData
forLinearLayout
that assigns a component to a particular alignment on its counter-axis, meaning the horizontal alignment on verticalLinearLayout
s and vertical alignment on horizontalLinearLayout
s.private void
doFlexibleHorizontalLayout
(TerminalSize area, List<Component> components) private void
doFlexibleVerticalLayout
(TerminalSize area, List<Component> components) private void
doHorizontalLayout
(TerminalSize area, List<Component> components) Deprecated.void
doLayout
(TerminalSize area, List<Component> components) Given a size constraint, update the location and size of each component in the component list by laying them out in the available area.private void
doVerticalLayout
(TerminalSize area, List<Component> components) Deprecated.getPreferredSize
(List<Component> components) This method returns the dimensions it would prefer to have to be able to layout all components while giving all of them as much space as they are asking for.private TerminalSize
getPreferredSizeHorizontally
(List<Component> components) private TerminalSize
getPreferredSizeVertically
(List<Component> components) int
Returns the amount of empty space to put in between components.boolean
Returns true if the internal state of this LayoutManager has changed since the last call to doLayout.setSpacing
(int spacing) Sets the amount of empty space to put in between components.
-
Field Details
-
direction
-
spacing
private int spacing -
changed
private boolean changed
-
-
Constructor Details
-
LinearLayout
public LinearLayout()Default constructor, creates a verticalLinearLayout
-
LinearLayout
Standard constructor that creates aLinearLayout
with a specified direction to position the components on- Parameters:
direction
- Direction for thisDirection
-
-
Method Details
-
createLayoutData
Creates aLayoutData
forLinearLayout
that assigns a component to a particular alignment on its counter-axis, meaning the horizontal alignment on verticalLinearLayout
s and vertical alignment on horizontalLinearLayout
s.- Parameters:
alignment
- Alignment to store in theLayoutData
object- Returns:
LayoutData
object created forLinearLayout
s with the specified alignment- See Also:
-
createLayoutData
public static LayoutData createLayoutData(LinearLayout.Alignment alignment, LinearLayout.GrowPolicy growPolicy) Creates aLayoutData
forLinearLayout
that assigns a component to a particular alignment on its counter-axis, meaning the horizontal alignment on verticalLinearLayout
s and vertical alignment on horizontalLinearLayout
s.- Parameters:
alignment
- Alignment to store in theLayoutData
objectgrowPolicy
- When policy to apply to the component if the parent container has more space available along the main axis.- Returns:
LayoutData
object created forLinearLayout
s with the specified alignment- See Also:
-
setSpacing
Sets the amount of empty space to put in between components. For horizontal layouts, this is number of columns (by default 1) and for vertical layouts this is number of rows (by default 0).- Parameters:
spacing
- Spacing between components, either in number of columns or rows depending on the direction- Returns:
- Itself
-
getSpacing
public int getSpacing()Returns the amount of empty space to put in between components. For horizontal layouts, this is number of columns (by default 1) and for vertical layouts this is number of rows (by default 0).- Returns:
- Spacing between components, either in number of columns or rows depending on the direction
-
getPreferredSize
Description copied from interface:LayoutManager
This method returns the dimensions it would prefer to have to be able to layout all components while giving all of them as much space as they are asking for.- Specified by:
getPreferredSize
in interfaceLayoutManager
- Parameters:
components
- List of components- Returns:
- Size the layout manager would like to have
-
getPreferredSizeVertically
-
getPreferredSizeHorizontally
-
hasChanged
public boolean hasChanged()Description copied from interface:LayoutManager
Returns true if the internal state of this LayoutManager has changed since the last call to doLayout. This will tell the container that it needs to call doLayout again.- Specified by:
hasChanged
in interfaceLayoutManager
- Returns:
true
if this layout manager's internal state has changed since the last call todoLayout
-
doLayout
Description copied from interface:LayoutManager
Given a size constraint, update the location and size of each component in the component list by laying them out in the available area. This method will callsetPosition(..)
andsetSize(..)
on the Components.- Specified by:
doLayout
in interfaceLayoutManager
- Parameters:
area
- Size available to this layout manager to lay out the components oncomponents
- List of components to lay out
-
doVerticalLayout
Deprecated. -
doFlexibleVerticalLayout
-
doHorizontalLayout
Deprecated. -
doFlexibleHorizontalLayout
-