Class HoverLayer

All Implemented Interfaces:
ILayer, ILayerListener, IUniqueIndexLayer, IPersistable

public class HoverLayer extends AbstractIndexLayerTransform
This layer simply adds the possibility to render cells differently if the mouse cursor is moved over them. This is also called "hover styling".

It knows over which cell the mouse cursor is currently set as it is informed about that via IMouseActions that react on mouse move events.

The place where this layer is added to the layer stack has impact on the result. If you for example add the SelectionLayer on top of the HoverLayer, selected cells will not change their style while moving the mouse cursor over them. Adding the HoverLayer on top of the SelectionLayer will also change the style of the selected cells.

Note: If the HoverLayer should be added to the row or column header region, the corresponding configurations need to be set instead of the default configuration. This is because the row and column headers by default have mouse move listeners registered that collide with the mouse move listener for managing hover behaviour.

  • Constructor Details

    • HoverLayer

      public HoverLayer(IUniqueIndexLayer underlyingLayer)
      Create a new HoverLayer that uses the default configuration.
      Parameters:
      underlyingLayer - The layer on which the HoverLayer should be positioned.
    • HoverLayer

      public HoverLayer(IUniqueIndexLayer underlyingLayer, boolean useDefaultConfiguration)
      Parameters:
      underlyingLayer - The layer on which the HoverLayer should be positioned.
      useDefaultConfiguration - true if the default configuration should be used, false if a different configuration will be set after creation time.
  • Method Details

    • 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 AbstractIndexLayerTransform
      Parameters:
      columnPosition - The column position of the cell.
      rowPosition - The row position of the cell.
      Returns:
      DisplayMode for the cell at the given coordinates.
    • isCellPositionHovered

      public boolean isCellPositionHovered(org.eclipse.swt.graphics.Point cellPosition)
      Check if this HoverLayer knows the current hovered cell and if that cell is located at the given position coordinates.
      Parameters:
      cellPosition - The position of the cell that should be checked.
      Returns:
      true if the mouse cursor is currently located over the cell at the given position, false if not.
    • isCellPositionHovered

      public boolean isCellPositionHovered(int columnPosition, int rowPosition)
      Check if this HoverLayer knows the current hovered cell and if that cell is located at the given position coordinates.
      Parameters:
      columnPosition - The column position of the cell that should be checked.
      rowPosition - The row position of the cell that should be checked.
      Returns:
      true if the mouse cursor is currently located over the cell at the given position, false if not.
    • getCurrentHoveredCellPosition

      public org.eclipse.swt.graphics.Point getCurrentHoveredCellPosition()
      Returns:
      The position of the cell that is currently hovered.
    • setCurrentHoveredCellPosition

      public void setCurrentHoveredCellPosition(int columnPosition, int rowPosition)
      Set the information about the cell position that is currently hovered and fire an event to update a possible previous hovered cell to remove the hover styling and an event to update the newly hovered cell to apply the hover styling.
      Parameters:
      columnPosition - The column position of the cell that is currently hovered.
      rowPosition - The row position of the cell that is currently hovered.
    • setCurrentHoveredCellByIndex

      public void setCurrentHoveredCellByIndex(int columnIndex, int rowIndex)
      Set the information about the cell identified by index that is currently hovered and fire an event to update a possible previous hovered cell to remove the hover styling and an event to update the newly hovered cell to apply the hover styling.
      Parameters:
      columnIndex - The column index of the cell that is currently hovered.
      rowIndex - The row index of the cell that is currently hovered.
      Since:
      2.1
    • setCurrentHoveredCellPosition

      public void setCurrentHoveredCellPosition(org.eclipse.swt.graphics.Point cellPosition)
      Set the information about the cell position that is currently hovered and fire an event to update a possible previous hovered cell to remove the hover styling and an event to update the newly hovered cell to apply the hover styling.
      Parameters:
      cellPosition - The position of the cell that is currently hovered.
    • clearCurrentHoveredCellPosition

      public void clearCurrentHoveredCellPosition()
      Removes the local stored information about the cell position that is currently hovered and fires an event to update the cell so the hover styling is removed.