2 * This file is part of lanterna (http://code.google.com/p/lanterna/).
4 * lanterna is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 * Copyright (C) 2010-2015 Martin
19 package com
.googlecode
.lanterna
.gui2
;
21 import com
.googlecode
.lanterna
.TerminalSize
;
22 import java
.util
.List
;
25 * A layout manager is a class that takes an area of usable space and a list of components to fit on that space. This
26 * is very similar to how AWT/Swing/SWT works. Lanterna contains a number of layout managers built-in that will arrange
27 * components in various ways, but you can also write your own. The typical way of providing customization and tuning,
28 * so the layout manager can distinguish between components and treat them in different ways, is to create a class
29 * and/or objects based on the {@code LayoutData} object, which can be assigned to each {@code Component}.
36 public interface LayoutManager
{
39 * This method returns the dimensions it would prefer to have to be able to layout all components while giving all
40 * of them as much space as they are asking for.
41 * @param components List of components
42 * @return Size the layout manager would like to have
44 TerminalSize
getPreferredSize(List
<Component
> components
);
47 * Given a size constraint, update the location and size of each component in the component list by laying them out
48 * in the available area. This method will call {@code setPosition(..)} and {@code setSize(..)} on the Components.
49 * @param area Size available to this layout manager to lay out the components on
50 * @param components List of components to lay out
52 void doLayout(TerminalSize area
, List
<Component
> components
);
55 * Returns true if the internal state of this LayoutManager has changed since the last call to doLayout. This will
56 * tell the container that it needs to call doLayout again.
57 * @return {@code true} if this layout manager's internal state has changed since the last call to {@code doLayout}