-
Notifications
You must be signed in to change notification settings - Fork 8
03_Layers
A layer is a rectangular region of cells and has methods to access its columns, rows, width and height. All layers implement the ILayer
interface. A layer can be stacked on top of another layer in order to expose a transformed view of its underlying layer's cell structure. Layers are used in this way to encapsulate transformation behavior such as hiding and reordering columns.
Layers can also be laterally composed which means that several layers or layer stacks are positioned side by side. A grid, for example, is a common composition that consists of four regions: corner, column header, row header and body, where every region contains separate layer stacks.
The following diagram shows the composition of a NatTable that is build as a grid with several layer stacks.
By stacking a layer on top of another layer, it is possible to expose a transformed view of its underlying layer cell structure. A transformed view for example can be used to hide or reorder columns.
Columns and rows in a layer can be referenced either by position or by index.
- The position of a column/row in a layer corresponds to the location of the column/row in the CURRENT layer. Positions always start from 0 and increase sequentially.
- The index of a column/row in a layer corresponds to the location of the column/row in the LOWEST level layer in the layer stack. Usually the lowest layer in the layer stack will be the
DataLayer
. Indexes are not necessarily ordered, and in some cases may not even be unique within a layer above the lowest level layer.
These concepts are illustrated by the following example. The layer stack shows a ColumnHideShowLayer
that is stacked on top of a ColumnReorderLayer
which is in turn stacked on a DataLayer
. The positions in the DataLayer
are the same as its indexes, because it is the lowest level layer in the stack. The ColumnReorderLayer
reorders column 0 of its underlying layer after column 2 of its underlying layer. The ColumnHideShowLayer
hides the first column of its underlying layer.
ColumnHideShowLayer
0 1 2 3 4 <- column positions
2 0 3 4 5 <- column indexes
ColumnReorderLayer
0 1 2 3 4 5 <- column positions
1 2 0 3 4 5 <- column indexes
DataLayer
0 1 2 3 4 5 <- column positions
0 1 2 3 4 5 <- column indexes
Note:
Usually, the framework does the necessary position-index transformations. So typically, it is not necessary to perform that transformation manually. In the few cases where it might be necessary, you can have a look at the LayerUtil helper class, which provides some static methods for that purpose.