Class ColumnGroupGroupHeaderLayer

All Implemented Interfaces:
ILayer, ILayerListener, IPersistable

public class ColumnGroupGroupHeaderLayer extends AbstractLayerTransform
Adds the Column grouping functionality to the column headers. Also persists the state of the column groups when NatTable.saveState(String, Properties) is invoked. Internally uses the ColumnGroupModel to track the column groups.

See ColumnGroupGridExample

  • Constructor Details

  • Method Details

    • getRowCount

      public int getRowCount()
      Specified by:
      getRowCount in interface ILayer
      Overrides:
      getRowCount in class AbstractLayerTransform
      Returns:
      The number of rows in this layer.
    • getPreferredRowCount

      public int getPreferredRowCount()
      Specified by:
      getPreferredRowCount in interface ILayer
      Overrides:
      getPreferredRowCount in class AbstractLayerTransform
    • 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 interface ILayer
      Overrides:
      getRowIndexByPosition in class AbstractLayerTransform
      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.
      Specified by:
      localToUnderlyingRowPosition in interface ILayer
      Overrides:
      localToUnderlyingRowPosition in class AbstractLayerTransform
      Parameters:
      localRowPosition - row position in local (the layer's own) coordinates
      Returns:
      row position in the underlying layer's coordinates
    • getHeight

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

      public int getPreferredHeight()
      Specified by:
      getPreferredHeight in interface ILayer
      Overrides:
      getPreferredHeight in class AbstractLayerTransform
    • 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 interface ILayer
      Overrides:
      getRowHeightByPosition in class AbstractLayerTransform
      Parameters:
      rowPosition - The row position in this layer.
      Returns:
      The height of the row.
    • setRowHeight

      public void setRowHeight(int rowHeight)
    • 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 interface ILayer
      Overrides:
      isRowPositionResizable in class AbstractLayerTransform
      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 interface ILayer
      Overrides:
      getRowPositionByY in class AbstractLayerTransform
      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 interface ILayer
      Overrides:
      getStartYOfRowPosition in class AbstractLayerTransform
      Parameters:
      rowPosition - the row position in this layer
      Returns:
      the y offset of the row, 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 column 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.
    • getColumnSpan

      public int getColumnSpan(int columnPosition)
      Calculates the span of a cell in a Column Group. Takes into account collapsing and hidden columns in the group.
      Parameters:
      columnPosition - position of any column belonging to the group
      Returns:
      the column span
      Since:
      1.6
    • getStartPositionOfGroup

      public int getStartPositionOfGroup(int columnPosition)
      Figures out the start position of the group.
      Parameters:
      columnPosition - of any column belonging to the group
      Returns:
      first position of the column group
      Since:
      1.6
    • 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.
    • addColumnsIndexesToGroup

      public void addColumnsIndexesToGroup(String colGroupName, int... colIndexes)
    • clearAllGroups

      public void clearAllGroups()
    • setStaticColumnIndexesByGroup

      public void setStaticColumnIndexesByGroup(String colGroupName, int... staticColumnIndexes)
    • isColumnInGroup

      public boolean isColumnInGroup(int bodyColumnIndex)
    • setGroupUnbreakable

      public void setGroupUnbreakable(int columnIndex)
    • setGroupAsCollapsed

      public void setGroupAsCollapsed(int columnIndex)
    • 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.
      Since:
      1.4