public class ZeroColumnLayout<O extends OutputManager<?>> extends java.lang.Object implements LayoutManager<O>
Modifier and Type | Class and Description |
---|---|
(package private) class |
ZeroColumnLayout.RegularModeVariables
Regular mode variables bundle.
|
(package private) class |
ZeroColumnLayout.StackedModeVariables
Stacked mode variables bundle.
|
Modifier and Type | Field and Description |
---|---|
private boolean |
attr_space
This field tracks container's ATTR-SPACE attribute.
|
private Widget<O>[] |
c
Array of widgets in the container.
|
private boolean |
drawLine
This field tracks the need to draw separator line under headers.
|
private java.util.LinkedList<Widget<O>> |
dynWidgets
List of dynamic widgets in this frame.
|
private WidgetFactory<O> |
factory
Widget factory
|
private boolean |
fixedWidth
Track explicit setting of container width.
|
private boolean |
hasBody
Set to
false if container has no components in body. |
private boolean |
hasHeaders
This field tracks of headers.
|
private boolean |
labels
This field tracks container's NO-LABELS attribute.
|
private int |
lastHeader
Index of last header widget.
|
private boolean |
redirected
Track current state of redirection.
|
private boolean |
sideLabels
This field tracks container's SIDE-LABELS attribute.
|
private boolean |
stacking
This field tracks stacking mode flag.
|
Constructor and Description |
---|
ZeroColumnLayout()
Creates the new instance of the LayoutManager.
|
Modifier and Type | Method and Description |
---|---|
private Dimension |
calcLayout(Container<O> container,
double width,
boolean doPlacement)
Perform actual formatting or size calculation.
|
private CoordinatesConversion |
coordinates()
Returns the coordinates conversion implementation.
|
private int |
determineMode(double width,
double maxWidth,
boolean forcelabel)
Determine layout mode (stacked or regular).
|
void |
doLayout(Container<O> container)
Makes the widgets coordinates calculation based on the current container
size.
|
private double |
getExtraSpacesStacked(int i)
Calculate number of required spaces between widgets depending on current
conditions.
|
static java.lang.String |
getLabel(LabeledWidget<?> fin,
boolean sideLabels,
boolean hasHeaders)
Get label taking into account various conditions and situations.
|
private java.lang.String |
getLabel(LabeledWidget<O> fin)
Get label taking into account various conditions and situations.
|
private double |
getNumSpaces(int i)
Get number of spaces which need to be inserted before given component.
|
private boolean |
hasDefinedX(Widget<O> comp)
Check if particular widget has defined column either by specifying
column or by setting TO or COLON option.
|
private boolean |
isAttrSpace(int i)
Get per-widget ATTR-SPACE attribute.
|
private boolean |
isHeader(int i)
Get per-widget HEADER attribute.
|
private boolean |
isLabeled(int i)
Check if specified widget should be handles as labeled.
|
private boolean |
isStatic(int i)
Check if given widget is static.
|
private static boolean |
isTextWidgetEmptyAndInvisible(Text<?> textWidget)
Check if specified Text widget is BOTH empty AND invisible.
|
static double |
labelHeight(LabeledWidget<?> widget,
java.lang.String labelText,
Label<?> label,
boolean topLabel)
Compute the label height in character units.
|
static double |
labelWidth(LabeledWidget<?> widget,
java.lang.String labelText)
Compute the label width in character units, depending on the current mode (GUI or ChUI)
and the GUI font.
|
private double |
maxWidth(Container<O> container)
Calculate maximal container width which can fit into screen.
|
Dimension |
minimumSize(Container<O> container)
Calculates the minimum size of the container which will be big enough to
hold all widgets.
|
private static java.lang.String |
parseColumnLabel(java.lang.String columnLabelText)
Parse label text and translate exclamation marks into the new line
characters using Progress rules.
|
private Dimension |
processRegular(Container<O> container,
double width,
boolean doPlacement)
Handle regular case of the widget placement.
|
private Dimension |
processStacked(Container<O> container,
double width,
boolean doPlacement)
Handle "stacked" case of the widget placement.
|
private boolean sideLabels
private boolean labels
private boolean attr_space
private boolean stacking
private boolean hasHeaders
private boolean drawLine
private int lastHeader
private Widget<O extends OutputManager<?>>[] c
private boolean hasBody
false
if container has no components in body.private boolean redirected
private boolean fixedWidth
private WidgetFactory<O extends OutputManager<?>> factory
private java.util.LinkedList<Widget<O extends OutputManager<?>>> dynWidgets
public ZeroColumnLayout()
public static double labelHeight(LabeledWidget<?> widget, java.lang.String labelText, Label<?> label, boolean topLabel)
If the label is underlined, 1 character unit is added. If the label is on top (ie neither NO-LABELS or SIDE-LABELS options were specified) at least one character unit is reserved.
widget
- The widget to which the label belongs.labelText
- The label text.label
- The label instance. May be null
if this is not yet resolved.topLabel
- Flag identifying that the label is shown above the widget.public static double labelWidth(LabeledWidget<?> widget, java.lang.String labelText)
widget
- The widget to which the label belongs.labelText
- The label text.public void doLayout(Container<O> container)
doLayout
in interface LayoutManager<O extends OutputManager<?>>
container
- The container to which this LayoutManager should be applied.public Dimension minimumSize(Container<O> container)
minimumSize
in interface LayoutManager<O extends OutputManager<?>>
container
- The container which size should be calculated.private static java.lang.String parseColumnLabel(java.lang.String columnLabelText)
columnLabelText
- Source label text to convert.private Dimension calcLayout(Container<O> container, double width, boolean doPlacement)
container
- Container to work with.width
- Maximal width of container or screen.doPlacement
- Perform actual placement of widgets or just simulate work.private int determineMode(double width, double maxWidth, boolean forcelabel)
width
- Maximal width of container or screen.maxWidth
- Maximal container width which can fit into screen.forcelabel
- true
if any widgets in container has forced label.private Dimension processStacked(Container<O> container, double width, boolean doPlacement)
container
- Container to work with.width
- Maximal width of container or screen.doPlacement
- Perform actual placement of widgets or just simulate work.private boolean isAttrSpace(int i)
i
- Index of widget in container widget array.private boolean isHeader(int i)
i
- Index of widget in container widget array.private double getExtraSpacesStacked(int i)
i
- Index of widget in container widget array.private boolean hasDefinedX(Widget<O> comp)
comp
- The widget to check.true
if widget has defined column.public static java.lang.String getLabel(LabeledWidget<?> fin, boolean sideLabels, boolean hasHeaders)
fin
- Source widget.sideLabels
- Flag indicating if the frame uses side-labels.hasHeaders
- Flag indicating if the frame has header widgets.private java.lang.String getLabel(LabeledWidget<O> fin)
fin
- Source widget.private static boolean isTextWidgetEmptyAndInvisible(Text<?> textWidget)
textWidget
- Widget to check. Must NOT be null
.true
if widget is empty and invisible.private Dimension processRegular(Container<O> container, double width, boolean doPlacement)
container
- Container to work with.width
- Maximal width of container or screen.doPlacement
- Perform actual placement of widgets or just simulate work.private boolean isLabeled(int i)
i
- Widget index.true
if widget should be handled as labeled.private double getNumSpaces(int i)
i
- Index of component to check.private boolean isStatic(int i)
i
- Index of the widget to check.true
if widget is marked as static.private double maxWidth(Container<O> container)
container
- Container for which maximal width is calculated.private CoordinatesConversion coordinates()