public abstract class AbstractDynamicLayout<O extends OutputManager<?>>
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
protected static class |
AbstractDynamicLayout.CellInfo
Data class for widgets grouped into columns in the individual rows.
|
protected static class |
AbstractDynamicLayout.RowInfo
Data class for widgets grouped into rows.
|
Modifier and Type | Field and Description |
---|---|
protected DynamicLayoutConfig |
config
Dynamic layout configuration
|
protected Container<O> |
container
The container this layout instance operates on
|
private java.util.HashMap<Widget,Dimension> |
initialDims
Cached widget initial sizes
|
private com.google.common.collect.TreeMultimap<java.lang.Double,Widget> |
xWidgets
Horizontal cached data
|
private com.google.common.collect.TreeMultimap<java.lang.Double,Widget> |
yWidgets
Vertical cached data
|
Constructor and Description |
---|
AbstractDynamicLayout(Container<O> container)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
private void |
buildIndexes()
Builds intermediate data for the layout algorithm.
|
abstract void |
doLayout()
Performs the actual layout.
|
protected boolean |
isDynamicWidget(Widget w)
The method determines whether the supplied widget is considered "dynamic" for the purpose of the
layout algorithm.
|
private void |
mergeCells(AbstractDynamicLayout.CellInfo source,
AbstractDynamicLayout.CellInfo target)
Merges two adjacent cells.
|
protected java.util.List<AbstractDynamicLayout.RowInfo> |
parseColumns()
The method returns the container's widgets grouped into columns.
|
protected java.util.List<AbstractDynamicLayout.RowInfo> |
parseRows()
The method returns the container's widgets grouped into rows.
|
protected java.util.List<AbstractDynamicLayout.RowInfo> |
parseRows(boolean useOptimalSize)
The method returns the container's widgets grouped into rows.
|
private java.util.List<AbstractDynamicLayout.RowInfo> |
parseRowsImpl(com.google.common.collect.TreeMultimap<java.lang.Double,Widget> yWidgets,
java.util.function.Function<Widget,java.lang.Double> xLocationF,
java.util.function.Function<Dimension,java.lang.Double> widthF,
java.util.function.Function<Dimension,java.lang.Double> heightF,
boolean useOptimalSize)
Groups widgets into rows or columns based on the input parameters.
|
protected void |
setWidgetSize(Widget w,
double width,
double height)
Sets size of the supplied widget.
|
protected DynamicLayoutConfig config
protected Container<O extends OutputManager<?>> container
private com.google.common.collect.TreeMultimap<java.lang.Double,Widget> xWidgets
private com.google.common.collect.TreeMultimap<java.lang.Double,Widget> yWidgets
public abstract void doLayout()
protected java.util.List<AbstractDynamicLayout.RowInfo> parseRows()
protected java.util.List<AbstractDynamicLayout.RowInfo> parseRows(boolean useOptimalSize)
useOptimalSize
- The parameter instructs the parse logic to either use the the widgets' actual size or
optimal size on those widgets that do support optimal size calculation.protected java.util.List<AbstractDynamicLayout.RowInfo> parseColumns()
protected boolean isDynamicWidget(Widget w)
w
- The widget being checked.true
if the widget is considered "dynamic", false
otherwise.private void buildIndexes()
protected void setWidgetSize(Widget w, double width, double height)
w
- The subjected widget.width
- The new width.height
- The new height.private java.util.List<AbstractDynamicLayout.RowInfo> parseRowsImpl(com.google.common.collect.TreeMultimap<java.lang.Double,Widget> yWidgets, java.util.function.Function<Widget,java.lang.Double> xLocationF, java.util.function.Function<Dimension,java.lang.Double> widthF, java.util.function.Function<Dimension,java.lang.Double> heightF, boolean useOptimalSize)
yWidgets
- The widgets sorted based on the vertical locations.xLocationF
- Function for getting widget's horizontal position.widthF
- Function for getting widget's horizontal size.heightF
- Function for getting widget's vertical size.useOptimalSize
- The parameter instructs the parse logic to either use the the widgets' actual size or
optimal size on those widgets that do support optimal size calculation.private void mergeCells(AbstractDynamicLayout.CellInfo source, AbstractDynamicLayout.CellInfo target)
source
- The cell that will be merged to target.target
- The cell where the source cell will be merged.