Class RowGroupHeaderLayer<T>

All Implemented Interfaces:
ILayer, ILayerListener, IPersistable

public class RowGroupHeaderLayer<T> extends AbstractLayerTransform
Adds the Row grouping functionality to the row headers. Also persists the state of the row groups when NatTable.saveState(String, Properties) is invoked. Internally uses the IRowGroupModel to track the row groups.
  • Constructor Details

  • Method Details

    • getModel

      public IRowGroupModel<T> getModel()
    • loadState

      public void loadState(String prefix, Properties properties)
      Description copied from class: AbstractLayerTransform
      Underlying layers must load state first. If this is not done, IStructuralChangeEvent from underlying layers will reset caches after state has been loaded
      Specified by:
      loadState in interface IPersistable
      Overrides:
      loadState in class AbstractLayerTransform
      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.
    • 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 AbstractLayerTransform
      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.
    • registerCommandHandlers

      protected void registerCommandHandlers()
      Description copied from class: AbstractLayer
      Layers should use this method to register their command handlers and call it from their constructor. This allows easy overriding if required of command handlers
      Overrides:
      registerCommandHandlers in class AbstractLayer
    • getColumnCount

      public int getColumnCount()
      Specified by:
      getColumnCount in interface ILayer
      Overrides:
      getColumnCount in class AbstractLayerTransform
      Returns:
      The number of columns in this layer.
    • getPreferredColumnCount

      public int getPreferredColumnCount()
      Specified by:
      getPreferredColumnCount in interface ILayer
      Overrides:
      getPreferredColumnCount in class AbstractLayerTransform
    • 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 interface ILayer
      Overrides:
      getColumnIndexByPosition in class AbstractLayerTransform
      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.
      Specified by:
      localToUnderlyingColumnPosition in interface ILayer
      Overrides:
      localToUnderlyingColumnPosition in class AbstractLayerTransform
      Parameters:
      localColumnPosition - column position in local (the layer's own) coordinates
      Returns:
      column position in the underlying layer's coordinates
    • getWidth

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

      public int getPreferredWidth()
      Specified by:
      getPreferredWidth in interface ILayer
      Overrides:
      getPreferredWidth in class AbstractLayerTransform
    • 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 interface ILayer
      Overrides:
      getColumnWidthByPosition in class AbstractLayerTransform
      Parameters:
      columnPosition - The column position in this layer.
      Returns:
      The width of the column.
    • setColumnWidth

      public void setColumnWidth(int columnWidth)
    • 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 interface ILayer
      Overrides:
      isColumnPositionResizable in class AbstractLayerTransform
      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 interface ILayer
      Overrides:
      getColumnPositionByX in class AbstractLayerTransform
      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 interface ILayer
      Overrides:
      getStartXOfColumnPosition in class AbstractLayerTransform
      Parameters:
      columnPosition - The column position in this layer.
      Returns:
      The x offset of the column, or -1.
    • getCellByPosition

      public ILayerCell getCellByPosition(int columnPosition, int rowPosition)
      If a cell belongs to a column group: column position - set to the start position of the group span - set to the width/size of the row group NOTE: gc.setClip() is used in the CompositeLayerPainter to ensure that partially visible Column group header cells are rendered properly.
      Specified by:
      getCellByPosition in interface ILayer
      Overrides:
      getCellByPosition in class AbstractLayerTransform
      Parameters:
      columnPosition - The column position of the requested cell.
      rowPosition - The row position of the requested cell.
      Returns:
      The ILayerCell for the given coordinates in this layer or null if the coordinates are invalid on this layer.
    • getRowSpan

      protected int getRowSpan(int rowPosition)
      Calculates the span of a cell in a Row Group. Takes into account collapsing and hidden rows in the group.
      Parameters:
      rowPosition - position of any row belonging to the group
    • 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 AbstractLayerTransform
      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 AbstractLayerTransform
      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.
      Specified by:
      getDataValueByPosition in interface ILayer
      Overrides:
      getDataValueByPosition in class AbstractLayerTransform
      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 AbstractLayerTransform
      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.
    • collapseRowGroupByIndex

      public void collapseRowGroupByIndex(int rowIndex)
    • clearAllGroups

      public void clearAllGroups()
    • getProvidedLabels

      public Collection<String> getProvidedLabels()
      Specified by:
      getProvidedLabels in interface ILayer
      Overrides:
      getProvidedLabels in class AbstractLayer
      Returns:
      The collection of labels that are provided by this layer.