- java.lang.Object
-
- com.googlecode.lanterna.gui2.LinearLayout
-
- All Implemented Interfaces:
LayoutManager
public class LinearLayout extends java.lang.Object implements LayoutManager
Simple layout manager the puts all components on a single line, either horizontally or vertically.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classLinearLayout.AlignmentThis enum type will decide the alignment of a component on the counter-axis, meaning the horizontal alignment on verticalLinearLayouts and vertical alignment on horizontalLinearLayouts.static classLinearLayout.GrowPolicyThis enum type will what to do with a component if the container has extra space to offer.private static classLinearLayout.LinearLayoutData
-
Constructor Summary
Constructors Constructor Description LinearLayout()Default constructor, creates a verticalLinearLayoutLinearLayout(Direction direction)Standard constructor that creates aLinearLayoutwith a specified direction to position the components on
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static LayoutDatacreateLayoutData(LinearLayout.Alignment alignment)Creates aLayoutDataforLinearLayoutthat assigns a component to a particular alignment on its counter-axis, meaning the horizontal alignment on verticalLinearLayouts and vertical alignment on horizontalLinearLayouts.static LayoutDatacreateLayoutData(LinearLayout.Alignment alignment, LinearLayout.GrowPolicy growPolicy)Creates aLayoutDataforLinearLayoutthat assigns a component to a particular alignment on its counter-axis, meaning the horizontal alignment on verticalLinearLayouts and vertical alignment on horizontalLinearLayouts.private voiddoFlexibleHorizontalLayout(TerminalSize area, java.util.List<Component> components)private voiddoFlexibleVerticalLayout(TerminalSize area, java.util.List<Component> components)private voiddoHorizontalLayout(TerminalSize area, java.util.List<Component> components)Deprecated.voiddoLayout(TerminalSize area, java.util.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 voiddoVerticalLayout(TerminalSize area, java.util.List<Component> components)Deprecated.TerminalSizegetPreferredSize(java.util.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 TerminalSizegetPreferredSizeHorizontally(java.util.List<Component> components)private TerminalSizegetPreferredSizeVertically(java.util.List<Component> components)intgetSpacing()Returns the amount of empty space to put in between components.booleanhasChanged()Returns true if the internal state of this LayoutManager has changed since the last call to doLayout.LinearLayoutsetSpacing(int spacing)Sets the amount of empty space to put in between components.
-
-
-
Field Detail
-
direction
private final Direction direction
-
spacing
private int spacing
-
changed
private boolean changed
-
-
Constructor Detail
-
LinearLayout
public LinearLayout()
Default constructor, creates a verticalLinearLayout
-
LinearLayout
public LinearLayout(Direction direction)
Standard constructor that creates aLinearLayoutwith a specified direction to position the components on- Parameters:
direction- Direction for thisDirection
-
-
Method Detail
-
createLayoutData
public static LayoutData createLayoutData(LinearLayout.Alignment alignment)
Creates aLayoutDataforLinearLayoutthat assigns a component to a particular alignment on its counter-axis, meaning the horizontal alignment on verticalLinearLayouts and vertical alignment on horizontalLinearLayouts.- Parameters:
alignment- Alignment to store in theLayoutDataobject- Returns:
LayoutDataobject created forLinearLayouts with the specified alignment- See Also:
LinearLayout.Alignment
-
createLayoutData
public static LayoutData createLayoutData(LinearLayout.Alignment alignment, LinearLayout.GrowPolicy growPolicy)
Creates aLayoutDataforLinearLayoutthat assigns a component to a particular alignment on its counter-axis, meaning the horizontal alignment on verticalLinearLayouts and vertical alignment on horizontalLinearLayouts.- Parameters:
alignment- Alignment to store in theLayoutDataobjectgrowPolicy- When policy to apply to the component if the parent container has more space available along the main axis.- Returns:
LayoutDataobject created forLinearLayouts with the specified alignment- See Also:
LinearLayout.Alignment
-
setSpacing
public LinearLayout setSpacing(int spacing)
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
public TerminalSize getPreferredSize(java.util.List<Component> components)
Description copied from interface:LayoutManagerThis 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:
getPreferredSizein interfaceLayoutManager- Parameters:
components- List of components- Returns:
- Size the layout manager would like to have
-
getPreferredSizeVertically
private TerminalSize getPreferredSizeVertically(java.util.List<Component> components)
-
getPreferredSizeHorizontally
private TerminalSize getPreferredSizeHorizontally(java.util.List<Component> components)
-
hasChanged
public boolean hasChanged()
Description copied from interface:LayoutManagerReturns 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:
hasChangedin interfaceLayoutManager- Returns:
trueif this layout manager's internal state has changed since the last call todoLayout
-
doLayout
public void doLayout(TerminalSize area, java.util.List<Component> components)
Description copied from interface:LayoutManagerGiven 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:
doLayoutin interfaceLayoutManager- Parameters:
area- Size available to this layout manager to lay out the components oncomponents- List of components to lay out
-
doVerticalLayout
@Deprecated private void doVerticalLayout(TerminalSize area, java.util.List<Component> components)
Deprecated.
-
doFlexibleVerticalLayout
private void doFlexibleVerticalLayout(TerminalSize area, java.util.List<Component> components)
-
doHorizontalLayout
@Deprecated private void doHorizontalLayout(TerminalSize area, java.util.List<Component> components)
Deprecated.
-
doFlexibleHorizontalLayout
private void doFlexibleHorizontalLayout(TerminalSize area, java.util.List<Component> components)
-
-