Class DimensionallyDependentLayer

java.lang.Object
org.eclipse.nebula.widgets.nattable.layer.AbstractLayer
org.eclipse.nebula.widgets.nattable.grid.layer.DimensionallyDependentLayer
All Implemented Interfaces:
ILayer, ILayerListener, IPersistable
Direct Known Subclasses:
ColumnHeaderLayer, CornerLayer, GroupByHeaderLayer, RowHeaderLayer

public class DimensionallyDependentLayer extends AbstractLayer

A DimensionallyDependentLayer is a layer whose horizontal and vertical dimensions are dependent on the horizontal and vertical dimensions of other layers. A DimensionallyDependentLayer takes three constructor parameters: the horizontal layer that the DimensionallyDependentLayer's horizontal dimension is linked to, the vertical layer that the DimensionallyDependentLayer 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 DimensionallyDependentLayer(
         columnHeaderRowDataLayer, bodyLayer, columnHeaderRowDataLayer);
 ILayer rowHeaderLayer = new DimensionallyDependentLayer(
         rowHeaderColumnDataLayer, bodyLayer, rowHeaderColumnDataLayer);
 
  • Constructor Details

    • DimensionallyDependentLayer

      protected DimensionallyDependentLayer(IUniqueIndexLayer baseLayer)
    • DimensionallyDependentLayer

      public DimensionallyDependentLayer(IUniqueIndexLayer baseLayer, ILayer horizontalLayerDependency, ILayer verticalLayerDependency)
  • Method Details

    • saveState

      public void saveState(String prefix, Properties properties)
      Description copied from interface: IPersistable
      Saves the state to the given Properties using the specified prefix. Note: The prefix must be prepended to the property key to support multiple states within one Properties instance.
      Specified by:
      saveState in interface IPersistable
      Overrides:
      saveState in class AbstractLayer
      Parameters:
      prefix - The prefix to use for the state keys. Is also used as the state configuration name.
      properties - The Properties instance to save the state to.
    • loadState

      public void loadState(String prefix, Properties properties)
      Description copied from interface: IPersistable
      Restore the state out of the given Properties identified by the specified prefix. Note: The prefix must be prepended to the property key to support multiple states within one Properties instance.
      Specified by:
      loadState in interface IPersistable
      Overrides:
      loadState in class AbstractLayer
      Parameters:
      prefix - The prefix to use for the state keys. Is also used as the state configuration name.
      properties - The Properties instance to load the state from.
    • configure

      public void configure(IConfigRegistry configRegistry, UiBindingRegistry uiBindingRegistry)
      Description copied from interface: ILayer
      Configure this layer, e.g. add any key/mouse bindings and other general configuration.

      This method is triggered by NatTable.configure() and executed down the layer stack.

      Specified by:
      configure in interface ILayer
      Overrides:
      configure in class AbstractLayer
      Parameters:
      configRegistry - The IConfigRegistry instance owned by the NatTable this layer is attached to.
      uiBindingRegistry - The UiBindingRegistry instance owned by NatTable this layer is attached to.
    • setHorizontalLayerDependency

      public void setHorizontalLayerDependency(ILayer horizontalLayerDependency)
    • setVerticalLayerDependency

      public void setVerticalLayerDependency(ILayer verticalLayerDependency)
    • getHorizontalLayerDependency

      public ILayer getHorizontalLayerDependency()
    • getVerticalLayerDependency

      public ILayer getVerticalLayerDependency()
    • getBaseLayer

      public IUniqueIndexLayer getBaseLayer()
    • doCommand

      public boolean doCommand(ILayerCommand command)
      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 interface ILayer
      Overrides:
      doCommand in class AbstractLayer
      Parameters:
      command - The command to execute.
      Returns:
      true if the command has been handled and was therefore consumed, false otherwise.
    • getLayerPainter

      public ILayerPainter getLayerPainter()
      Specified by:
      getLayerPainter in interface ILayer
      Overrides:
      getLayerPainter in class AbstractLayer
      Returns:
      ILayerPainter. Defaults to GridLineCellLayerPainter
    • getColumnCount

      public int getColumnCount()
      Returns:
      The number of columns in this layer.
    • getPreferredColumnCount

      public int getPreferredColumnCount()
    • 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.
      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.
    • 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.
      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.
      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.
    • underlyingToLocalColumnPositions

      public Collection<Range> underlyingToLocalColumnPositions(ILayer sourceUnderlyingLayer, Collection<Range> underlyingColumnPositionRanges)
      Description copied from interface: ILayer
      Transforms the column position ranges relative to the given underlying layer to this layer coordinates.
      Parameters:
      sourceUnderlyingLayer - The underlying layer to which the given column positions match.
      underlyingColumnPositionRanges - The column position ranges relative to the given underlying layer that should be converted to local column positions.
      Returns:
      The given column position ranges transformed to this layer.
    • getWidth

      public int getWidth()
      Description copied from interface: ILayer
      Returns the total width in pixels of this layer.
      Returns:
      The total width in pixels of this layer.
    • getPreferredWidth

      public int getPreferredWidth()
    • 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.
      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.
      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.
      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.
      Parameters:
      columnPosition - The column position in this layer.
      Returns:
      The x offset of the column, or -1.
    • getUnderlyingLayersByColumnPosition

      public Collection<ILayer> getUnderlyingLayersByColumnPosition(int columnPosition)
      Description copied from interface: ILayer
      Returns the layers that are directly below this layer for the given column position. For simple layers this collection will typically only have one entry. Layer compositions might return multiple values, e.g. in a default grid there will be 2 layers in the collection as there are two layers involved in a column.
      Parameters:
      columnPosition - The column position for which the underlying layers are requested.
      Returns:
      The layers that are directly below this layer for the given column position or null if this layer has no underlying layers.
    • getRowCount

      public int getRowCount()
      Returns:
      The number of rows in this layer.
    • getPreferredRowCount

      public int getPreferredRowCount()
    • 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.
      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.
    • 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.
      Parameters:
      localRowPosition - row position in local (the layer's own) coordinates
      Returns:
      row position in the underlying layer's coordinates
    • underlyingToLocalRowPosition

      public int underlyingToLocalRowPosition(ILayer sourceUnderlyingLayer, int underlyingRowPosition)
      Description copied from interface: ILayer
      Transforms the row position relative to the given underlying layer to this layer coordinates.
      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.
    • underlyingToLocalRowPositions

      public Collection<Range> underlyingToLocalRowPositions(ILayer sourceUnderlyingLayer, Collection<Range> underlyingRowPositionRanges)
      Description copied from interface: ILayer
      Transforms the row position ranges relative to the given underlying layer to this layer coordinates.
      Parameters:
      sourceUnderlyingLayer - The underlying layer to which the given row positions match.
      underlyingRowPositionRanges - The row position ranges relative to the given underlying layer that should be converted to local row positions.
      Returns:
      The given row position ranges transformed to this layer.
    • getHeight

      public int getHeight()
      Description copied from interface: ILayer
      Returns the total height in pixels of this layer.
      Returns:
      The total height in pixels of this layer.
    • getPreferredHeight

      public int getPreferredHeight()
    • 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.
      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.
      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.
      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.
      Parameters:
      rowPosition - the row position in this layer
      Returns:
      the y offset of the row, or -1
    • getUnderlyingLayersByRowPosition

      public Collection<ILayer> getUnderlyingLayersByRowPosition(int rowPosition)
      Description copied from interface: ILayer
      Returns the layers that are directly below this layer for the given row position. For simple layers this collection will typically only have one entry. Layer compositions might return multiple values, e.g. in a default grid there will be 2 layers in the collection as there are two layers involved in a row.
      Parameters:
      rowPosition - The row position for which the underlying layers are requested.
      Returns:
      The layers that are directly below this layer for the given row position or null if this layer has no underlying layers.
    • getDisplayModeByPosition

      public DisplayMode getDisplayModeByPosition(int columnPosition, int rowPosition)
      Description copied from interface: ILayer
      Returns the active DisplayMode for the cell at the given coordinates. Needed to retrieve the corresponding configurations out of the IConfigRegistry. The default value is DisplayMode.NORMAL. The SelectionLayer for example overrides this to return DisplayMode.SELECT for cells that are currently selected.
      Specified by:
      getDisplayModeByPosition in interface ILayer
      Overrides:
      getDisplayModeByPosition in class AbstractLayer
      Parameters:
      columnPosition - The column position of the cell.
      rowPosition - The row position of the cell.
      Returns:
      DisplayMode for the cell at the given coordinates.
    • getConfigLabelsByPosition

      public LabelStack getConfigLabelsByPosition(int columnPosition, int rowPosition)
      Description copied from interface: ILayer
      Returns the config labels for the cell at the given coordinates. Needed to retrieve the corresponding configurations out of the IConfigRegistry.
      Specified by:
      getConfigLabelsByPosition in interface ILayer
      Overrides:
      getConfigLabelsByPosition in class AbstractLayer
      Parameters:
      columnPosition - The column position of the cell.
      rowPosition - The row position of the cell.
      Returns:
      The LabelStack with the config labels for the cell at the given coordinates.
    • getDataValueByPosition

      public Object getDataValueByPosition(int columnPosition, int rowPosition)
      Description copied from interface: ILayer
      Returns the data value for the cell at the given coordinates.
      Parameters:
      columnPosition - The column position of the cell.
      rowPosition - The row position of the cell.
      Returns:
      The data value for the cell at the given coordinates.
    • getRegionLabelsByXY

      public LabelStack getRegionLabelsByXY(int x, int y)
      Description copied from interface: ILayer
      Return the LabelStack containing the region labels for the cell at the given pixel position.
      Specified by:
      getRegionLabelsByXY in interface ILayer
      Overrides:
      getRegionLabelsByXY in class AbstractLayer
      Parameters:
      x - the x pixel coordinate
      y - the y pixel coordinate
      Returns:
      LabelStack containing the region labels for the cell at the given pixel position.
    • getClientAreaProvider

      public IClientAreaProvider getClientAreaProvider()
      Specified by:
      getClientAreaProvider in interface ILayer
      Overrides:
      getClientAreaProvider in class AbstractLayer
      Returns:
      The IClientAreaProvider that specifies the rectangular area available on this layer.
    • setClientAreaProvider

      public void setClientAreaProvider(IClientAreaProvider clientAreaProvider)
      Specified by:
      setClientAreaProvider in interface ILayer
      Overrides:
      setClientAreaProvider in class AbstractLayer
      Parameters:
      clientAreaProvider - The IClientAreaProvider that specifies the rectangular area available on this layer.
    • getUnderlyingLayerByPosition

      public ILayer getUnderlyingLayerByPosition(int columnPosition, int rowPosition)
      Description copied from interface: ILayer
      Returns the layer that is directly below this layer for the given cell coordinate.
      Parameters:
      columnPosition - The column position for which the underlying layer is requested.
      rowPosition - The row position for which the underlying layer is requested.
      Returns:
      The layer that is directly below this layer for the given cell coordinates or null if this layer has no underlying layers.