Class DimensionallyDependentIndexLayer
- All Implemented Interfaces:
ILayer
,ILayerListener
,IUniqueIndexLayer
,IPersistable
A DimensionallyDependentIndexLayer is a layer whose horizontal and vertical dimensions are dependent on the horizontal and vertical dimensions of other layers. A DimensionallyDependentIndexLayer takes three constructor parameters: the horizontal layer that the DimensionallyDependentIndexLayer's horizontal dimension is linked to, the vertical layer that the DimensionallyDependentIndexLayer is linked to, and a base layer to which all non-dimensionally related ILayer method calls will be delegated to (e.g. command, event methods)
Prime examples of dimensionally dependent layers are the column header and row header layers. For example, the column header layer's horizontal dimension is linked to the body layer's horizontal dimension. This means that whatever columns are shown in the body area will also be shown in the column header area, and vice versa. Note that the column header layer maintains its own vertical dimension, however, so it's vertical layer dependency would be a separate data layer. The same is true for the row header layer, only with the vertical instead of the horizontal dimension. The constructors for the column header and row header layers would therefore look something like this:
ILayer columnHeaderLayer = new DimensionallyDependentIndexLayer( columnHeaderRowDataLayer, bodyLayer, columnHeaderRowDataLayer); ILayer rowHeaderLayer = new DimensionallyDependentIndexLayer( rowHeaderColumnDataLayer, bodyLayer, rowHeaderColumnDataLayer);
In contrast to DimensionallyDependentLayer
, this class:
- implements
IUniqueIndexLayer
; - provides conversion of local and underlying positions based on the unique index (reliable);
- provides an implementation of
AbstractIndexLayerTransform.getCellByPosition(int, int)
which e.g. fully supports spanned cells; - requires that the layers, the horizontal and vertical dimension are
linked to, implements
IUniqueIndexLayer
too.
-
Field Summary
Fields inherited from class org.eclipse.nebula.widgets.nattable.layer.AbstractLayer
commandHandlers, eventHandlers, eventHelperLock, layerPainter
Fields inherited from interface org.eclipse.nebula.widgets.nattable.persistence.IPersistable
DOT, VALUE_SEPARATOR
-
Constructor Summary
ModifierConstructorDescriptionprotected
Creates a new DimensionallyDependentIndexLayer.DimensionallyDependentIndexLayer
(IUniqueIndexLayer baseLayer, IUniqueIndexLayer horizontalLayerDependency, IUniqueIndexLayer verticalLayerDependency) Creates a new DimensionallyDependentIndexLayer. -
Method Summary
Modifier and TypeMethodDescriptionboolean
doCommand
(ILayerCommand command) Opportunity to respond to a command as it flows down the stack.int
int
getColumnIndexByPosition
(int columnPosition) Gets the underlying non-transformed column index for the given column position on this layer.int
getColumnPositionByIndex
(int columnIndex) int
getColumnPositionByX
(int x) Returns the column position that contains the given x coordinate.int
getColumnWidthByPosition
(int columnPosition) Returns the width in pixels of the given column.int
Returns the total height in pixels of this layer.int
int
int
int
int
int
getRowHeightByPosition
(int rowPosition) Returns the height in pixels of the given row.int
getRowIndexByPosition
(int rowPosition) Gets the underlying non-transformed row index for the given row position on this layer.int
getRowPositionByIndex
(int rowIndex) int
getRowPositionByY
(int y) Returns the row position that contains the given y coordinate.int
getStartXOfColumnPosition
(int columnPosition) Returns the x offset in pixels of the given column.int
getStartYOfRowPosition
(int rowPosition) Returns the y offset in pixels of the given row.int
getWidth()
Returns the total width in pixels of this layer.boolean
isColumnPositionResizable
(int columnPosition) Check if the column at the given position is resizable.boolean
isRowPositionResizable
(int rowPosition) Check if the row at the given position is resizable.int
localToUnderlyingColumnPosition
(int localColumnPosition) Convert a column position to the coordinates of the underlying layer.int
localToUnderlyingRowPosition
(int localRowPosition) Convert a row position to the coordinates of the underlying layer.protected void
setHorizontalLayerDependency
(IUniqueIndexLayer horizontalLayerDependency) protected void
setVerticalLayerDependency
(IUniqueIndexLayer verticalLayerDependency) int
underlyingToLocalColumnPosition
(ILayer sourceUnderlyingLayer, int underlyingColumnPosition) Transforms the column position relative to the given underlying layer to this layer coordinates.int
underlyingToLocalRowPosition
(ILayer sourceUnderlyingLayer, int underlyingRowPosition) Transforms the row position relative to the given underlying layer to this layer coordinates.Methods inherited from class org.eclipse.nebula.widgets.nattable.layer.AbstractIndexLayerTransform
configure, dispose, getCellByPosition, getCellPainter, getConfigLabelsByPosition, getDataValueByPosition, getDisplayModeByPosition, getLayerPainter, getRegionLabelsByXY, getUnderlyingLayer, getUnderlyingLayerByPosition, getUnderlyingLayersByColumnPosition, getUnderlyingLayersByRowPosition, isDynamicSizeLayer, loadState, saveState, setClientAreaProvider, setUnderlyingLayer, underlyingToLocalColumnPositions, underlyingToLocalRowPositions
Methods inherited from class org.eclipse.nebula.widgets.nattable.layer.AbstractLayer
addConfiguration, addLayerListener, clearConfiguration, fireLayerEvent, getBoundsByPosition, getClientAreaProvider, getConfigLabelAccumulator, getProvidedLabels, getRegionName, handleLayerEvent, hasLayerListener, registerCommandHandler, registerCommandHandlers, registerEventHandler, registerPersistable, removeLayerListener, setConfigLabelAccumulator, setLayerPainter, setRegionName, toString, unregisterCommandHandler, unregisterEventHandler, unregisterPersistable
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.eclipse.nebula.widgets.nattable.layer.ILayer
addLayerListener, fireLayerEvent, getBoundsByPosition, getClientAreaProvider, getProvidedLabels, hasLayerListener, registerCommandHandler, registerPersistable, removeLayerListener, unregisterCommandHandler, unregisterPersistable
Methods inherited from interface org.eclipse.nebula.widgets.nattable.layer.ILayerListener
handleLayerEvent
-
Constructor Details
-
DimensionallyDependentIndexLayer
public DimensionallyDependentIndexLayer(IUniqueIndexLayer baseLayer, IUniqueIndexLayer horizontalLayerDependency, IUniqueIndexLayer verticalLayerDependency) Creates a new DimensionallyDependentIndexLayer.- Parameters:
baseLayer
- the underlying base layerhorizontalLayerDependency
- the layer, the horizontal dimension is linked toverticalLayerDependency
- the layer, the vertical dimension is linked to
-
DimensionallyDependentIndexLayer
Creates a new DimensionallyDependentIndexLayer.- Parameters:
baseLayer
- the underlying base layer
-
-
Method Details
-
setHorizontalLayerDependency
-
setVerticalLayerDependency
-
getHorizontalLayerDependency
-
getVerticalLayerDependency
-
getBaseLayer
-
doCommand
Description copied from interface:ILayer
Opportunity to respond to a command as it flows down the stack. If the layer is not interested in the command it should allow the command to keep traveling down the stack.Note: Before the layer can process a command it must convert the command to its local coordinates using
ILayerCommand.convertToTargetLayer(ILayer)
- Specified by:
doCommand
in interfaceILayer
- Overrides:
doCommand
in classAbstractIndexLayerTransform
- Parameters:
command
- The command to execute.- Returns:
true
if the command has been handled and was therefore consumed,false
otherwise.
-
getColumnCount
public int getColumnCount()- Specified by:
getColumnCount
in interfaceILayer
- Overrides:
getColumnCount
in classAbstractIndexLayerTransform
- Returns:
- The number of columns in this layer.
-
getPreferredColumnCount
public int getPreferredColumnCount()- Specified by:
getPreferredColumnCount
in interfaceILayer
- Overrides:
getPreferredColumnCount
in classAbstractIndexLayerTransform
-
getColumnIndexByPosition
public int getColumnIndexByPosition(int columnPosition) Description copied from interface:ILayer
Gets the underlying non-transformed column index for the given column position on this layer.- Specified by:
getColumnIndexByPosition
in interfaceILayer
- Overrides:
getColumnIndexByPosition
in classAbstractIndexLayerTransform
- Parameters:
columnPosition
- The column position relative to this layer.- Returns:
- An underlying non-transformed column index, or -1 if the given column position does not exist within this coordinate system.
-
getColumnPositionByIndex
public int getColumnPositionByIndex(int columnIndex) - Specified by:
getColumnPositionByIndex
in interfaceIUniqueIndexLayer
- Overrides:
getColumnPositionByIndex
in classAbstractIndexLayerTransform
-
localToUnderlyingColumnPosition
public int localToUnderlyingColumnPosition(int localColumnPosition) Description copied from interface:ILayer
Convert a column position to the coordinates of the underlying layer. This is possible since each layer is aware of its underlying layer.- Specified by:
localToUnderlyingColumnPosition
in interfaceILayer
- Overrides:
localToUnderlyingColumnPosition
in classAbstractIndexLayerTransform
- Parameters:
localColumnPosition
- column position in local (the layer's own) coordinates- Returns:
- column position in the underlying layer's coordinates
-
underlyingToLocalColumnPosition
public int underlyingToLocalColumnPosition(ILayer sourceUnderlyingLayer, int underlyingColumnPosition) Description copied from interface:ILayer
Transforms the column position relative to the given underlying layer to this layer coordinates.- Specified by:
underlyingToLocalColumnPosition
in interfaceILayer
- Overrides:
underlyingToLocalColumnPosition
in classAbstractIndexLayerTransform
- Parameters:
sourceUnderlyingLayer
- The underlying layer to which the given column position matches.underlyingColumnPosition
- The column position in the given underlying layer that should be converted to a local column position.- Returns:
- The given column position transformed to be local to this layer.
-
getWidth
public int getWidth()Description copied from interface:ILayer
Returns the total width in pixels of this layer.- Specified by:
getWidth
in interfaceILayer
- Overrides:
getWidth
in classAbstractIndexLayerTransform
- Returns:
- The total width in pixels of this layer.
-
getPreferredWidth
public int getPreferredWidth()- Specified by:
getPreferredWidth
in interfaceILayer
- Overrides:
getPreferredWidth
in classAbstractIndexLayerTransform
-
getColumnWidthByPosition
public int getColumnWidthByPosition(int columnPosition) Description copied from interface:ILayer
Returns the width in pixels of the given column. The width of invisible and non-existing columns is 0.- Specified by:
getColumnWidthByPosition
in interfaceILayer
- Overrides:
getColumnWidthByPosition
in classAbstractIndexLayerTransform
- Parameters:
columnPosition
- The column position in this layer.- Returns:
- The width of the column.
-
isColumnPositionResizable
public boolean isColumnPositionResizable(int columnPosition) Description copied from interface:ILayer
Check if the column at the given position is resizable.- Specified by:
isColumnPositionResizable
in interfaceILayer
- Overrides:
isColumnPositionResizable
in classAbstractIndexLayerTransform
- Parameters:
columnPosition
- The column position to check.- Returns:
true
if the column is resizable,false
if not.
-
getColumnPositionByX
public int getColumnPositionByX(int x) Description copied from interface:ILayer
Returns the column position that contains the given x coordinate.- Specified by:
getColumnPositionByX
in interfaceILayer
- Overrides:
getColumnPositionByX
in classAbstractIndexLayerTransform
- Parameters:
x
- A horizontal pixel location relative to the pixel boundary of this layer.- Returns:
- A column position relative to the associated coordinate system, or -1 if there is no column that contains x.
-
getStartXOfColumnPosition
public int getStartXOfColumnPosition(int columnPosition) Description copied from interface:ILayer
Returns the x offset in pixels of the given column.- Specified by:
getStartXOfColumnPosition
in interfaceILayer
- Overrides:
getStartXOfColumnPosition
in classAbstractIndexLayerTransform
- Parameters:
columnPosition
- The column position in this layer.- Returns:
- The x offset of the column, or -1.
-
getRowCount
public int getRowCount()- Specified by:
getRowCount
in interfaceILayer
- Overrides:
getRowCount
in classAbstractIndexLayerTransform
- Returns:
- The number of rows in this layer.
-
getPreferredRowCount
public int getPreferredRowCount()- Specified by:
getPreferredRowCount
in interfaceILayer
- Overrides:
getPreferredRowCount
in classAbstractIndexLayerTransform
-
getRowIndexByPosition
public int getRowIndexByPosition(int rowPosition) Description copied from interface:ILayer
Gets the underlying non-transformed row index for the given row position on this layer.- Specified by:
getRowIndexByPosition
in interfaceILayer
- Overrides:
getRowIndexByPosition
in classAbstractIndexLayerTransform
- Parameters:
rowPosition
- The row position relative to this layer.- Returns:
- An underlying non-transformed row index, or -1 if the given row position does not exist within this coordinate system.
-
getRowPositionByIndex
public int getRowPositionByIndex(int rowIndex) - Specified by:
getRowPositionByIndex
in interfaceIUniqueIndexLayer
- Overrides:
getRowPositionByIndex
in classAbstractIndexLayerTransform
-
localToUnderlyingRowPosition
public int localToUnderlyingRowPosition(int localRowPosition) Description copied from interface:ILayer
Convert a row position to the coordinates of the underlying layer. This is possible since each layer is aware of its underlying layer.- Specified by:
localToUnderlyingRowPosition
in interfaceILayer
- Overrides:
localToUnderlyingRowPosition
in classAbstractIndexLayerTransform
- Parameters:
localRowPosition
- row position in local (the layer's own) coordinates- Returns:
- row position in the underlying layer's coordinates
-
underlyingToLocalRowPosition
Description copied from interface:ILayer
Transforms the row position relative to the given underlying layer to this layer coordinates.- Specified by:
underlyingToLocalRowPosition
in interfaceILayer
- Overrides:
underlyingToLocalRowPosition
in classAbstractIndexLayerTransform
- Parameters:
sourceUnderlyingLayer
- The underlying layer to which the given row position matches.underlyingRowPosition
- The row position in the given underlying layer that should be converted to a local row position.- Returns:
- The given row position transformed to be local to this layer.
-
getHeight
public int getHeight()Description copied from interface:ILayer
Returns the total height in pixels of this layer.- Specified by:
getHeight
in interfaceILayer
- Overrides:
getHeight
in classAbstractIndexLayerTransform
- Returns:
- The total height in pixels of this layer.
-
getPreferredHeight
public int getPreferredHeight()- Specified by:
getPreferredHeight
in interfaceILayer
- Overrides:
getPreferredHeight
in classAbstractIndexLayerTransform
-
getRowHeightByPosition
public int getRowHeightByPosition(int rowPosition) Description copied from interface:ILayer
Returns the height in pixels of the given row. The height of invisible and non-existing rows is 0.- Specified by:
getRowHeightByPosition
in interfaceILayer
- Overrides:
getRowHeightByPosition
in classAbstractIndexLayerTransform
- Parameters:
rowPosition
- The row position in this layer.- Returns:
- The height of the row.
-
isRowPositionResizable
public boolean isRowPositionResizable(int rowPosition) Description copied from interface:ILayer
Check if the row at the given position is resizable.- Specified by:
isRowPositionResizable
in interfaceILayer
- Overrides:
isRowPositionResizable
in classAbstractIndexLayerTransform
- Parameters:
rowPosition
- The row position to check.- Returns:
true
if the row is resizable,false
if not.
-
getRowPositionByY
public int getRowPositionByY(int y) Description copied from interface:ILayer
Returns the row position that contains the given y coordinate.- Specified by:
getRowPositionByY
in interfaceILayer
- Overrides:
getRowPositionByY
in classAbstractIndexLayerTransform
- Parameters:
y
- a vertical pixel location relative to the pixel boundary of this layer- Returns:
- a row position relative to the associated coordinate system, or -1 if there is no row that contains y
-
getStartYOfRowPosition
public int getStartYOfRowPosition(int rowPosition) Description copied from interface:ILayer
Returns the y offset in pixels of the given row.- Specified by:
getStartYOfRowPosition
in interfaceILayer
- Overrides:
getStartYOfRowPosition
in classAbstractIndexLayerTransform
- Parameters:
rowPosition
- the row position in this layer- Returns:
- the y offset of the row, or -1
-