Class AbstractColumnHideShowLayer

All Implemented Interfaces:
ILayer, ILayerListener, IUniqueIndexLayer, IPersistable
Direct Known Subclasses:
ColumnGroupExpandCollapseLayer, ColumnGroupExpandCollapseLayer, ColumnHideShowLayer

public abstract class AbstractColumnHideShowLayer extends AbstractLayerTransform implements IUniqueIndexLayer
Abstract implementation for column hide/show operations.
  • Constructor Details

    • AbstractColumnHideShowLayer

      public AbstractColumnHideShowLayer(IUniqueIndexLayer underlyingLayer)
      Constructor.
      Parameters:
      underlyingLayer - The underlying layer.
  • Method Details

    • getUnderlyingLayer

      protected IUniqueIndexLayer getUnderlyingLayer()
      Overrides:
      getUnderlyingLayer in class AbstractLayerTransform
      Returns:
      The underlying layer.
      Since:
      2.0
    • handleLayerEvent

      public void handleLayerEvent(ILayerEvent event)
      Description copied from class: AbstractLayer
      Handle layer event notification. Convert it to your context and propagate UP. If you override this method you MUST NOT FORGET to raise the event up the layer stack by calling super.fireLayerEvent(event) - unless you plan to eat the event yourself.
      Specified by:
      handleLayerEvent in interface ILayerListener
      Overrides:
      handleLayerEvent in class AbstractLayer
      Parameters:
      event - the event
    • 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 AbstractLayerTransform
      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 interface ILayer
      Overrides:
      getColumnCount in class AbstractLayerTransform
      Returns:
      The number of columns in this layer.
    • 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.
    • getColumnPositionByIndex

      public int getColumnPositionByIndex(int columnIndex)
      Specified by:
      getColumnPositionByIndex in interface IUniqueIndexLayer
    • getColumnPositionsByIndexes

      public Collection<Integer> getColumnPositionsByIndexes(Collection<Integer> columnIndexes)
      Get the local column positions for the given column indexes.
      Parameters:
      columnIndexes - The column indexes for which the local column positions are requested.
      Returns:
      The local column positions for the given column indexes.
    • getColumnPositionsByIndexes

      public int[] getColumnPositionsByIndexes(int... columnIndexes)
      Get the local column positions for the given column indexes.
      Parameters:
      columnIndexes - The column indexes for which the local column positions are requested.
      Returns:
      The local column positions for the given column indexes.
      Since:
      2.0
    • 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
    • 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 interface ILayer
      Overrides:
      underlyingToLocalColumnPosition in class AbstractLayerTransform
      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.
      Specified by:
      underlyingToLocalColumnPositions in interface ILayer
      Overrides:
      underlyingToLocalColumnPositions in class AbstractLayerTransform
      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.
      Specified by:
      getWidth in interface ILayer
      Overrides:
      getWidth in class AbstractLayerTransform
      Returns:
      The total width in pixels of this layer.
    • 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 localColumnPosition)
      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:
      localColumnPosition - The column position in this layer.
      Returns:
      The x offset of the column, or -1.
    • getRowPositionByIndex

      public int getRowPositionByIndex(int rowIndex)
      Specified by:
      getRowPositionByIndex in interface IUniqueIndexLayer
    • isColumnIndexHidden

      public abstract boolean isColumnIndexHidden(int columnIndex)
      Will check if the column at the specified index is hidden or not.
      Parameters:
      columnIndex - The column index of the column whose visibility state should be checked.
      Returns:
      true if the column at the specified index is hidden, false if it is visible.
    • getHiddenColumnIndexes

      public abstract Collection<Integer> getHiddenColumnIndexes()
      Will collect and return all indexes of the columns that are hidden in this layer.

      Note: It is not intended that it also collects the column indexes of underlying layers. This would cause issues on calculating positions, as every layer is responsible for those calculations itself.

      Since 2.0 it is recommended to use getHiddenColumnIndexesArray() to avoid unnecessary autoboxing operations.

      Returns:
      Collection of all column indexes that are hidden in this layer.
    • getHiddenColumnIndexesArray

      public abstract int[] getHiddenColumnIndexesArray()
      Will collect and return all indexes of the columns that are hidden in this layer.

      Note: It is not intended that it also collects the column indexes of underlying layers. This would cause issues on calculating positions, as every layer is responsible for those calculations itself.

      Returns:
      All column indexes that are hidden in this layer.
      Since:
      2.0
    • hasHiddenColumns

      public abstract boolean hasHiddenColumns()
      Check if this layer actively hides columns.
      Returns:
      true if columns are hidden by this layer, false if not.
      Since:
      2.0
    • getCellByPosition

      public ILayerCell getCellByPosition(int columnPosition, int rowPosition)
      Description copied from interface: ILayer
      Returns the cell for the given coordinates on this layer.
      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.
    • invalidateCache

      protected void invalidateCache()
      Invalidate the cache to ensure that information is rebuild.
    • cacheVisibleColumnIndexes

      protected void cacheVisibleColumnIndexes()
      Build up the column caches.
      Since:
      2.0