Class ViewportHelper

java.lang.Object
com.illumon.iris.console.events.viewport.ViewportHelper

public class ViewportHelper extends Object
A helper class for maintaining and computing viewports for a GuiTable.
  • Constructor Details

    • ViewportHelper

      public ViewportHelper(com.fishlib.io.logger.Logger log, int maxSpan)
      Create a viewportHelper.
      Parameters:
      log - a logger
      maxSpan - the maximum allowable viewport width in columns.
  • Method Details

    • computeNewViewport

      public void computeNewViewport(boolean force, @NotNull GuiTable table, @NotNull List<String> columnNames)
      Compute a new viewport for the specified GuiTable.
      Parameters:
      force - force re-computation of both row and column dimensions.
      table - the GuiTable
      columnNames - the names of the columns
    • addExtraColumns

      protected void addExtraColumns(Set<String> existing)
      Add any extra columns required to the existing set.
      Parameters:
      existing - the existing column set
      ImplNote:
      The default implementation adds nothing else.
    • haveColumnsChanged

      public boolean haveColumnsChanged()
      Return true if the set of columns have changed during the last invocation of computeNewViewport(boolean, GuiTable, List).
      Returns:
      true if the columns changed
    • haveRowsChanged

      public boolean haveRowsChanged()
      Return true if the set of rows has changed during the last invocation of computeNewViewport(boolean, GuiTable, List).
      Returns:
      true if the rows have changed.
    • getActiveColumnSet

      public BitSet getActiveColumnSet()
      Get the currently active set of columns as computed by computeNewViewport(boolean, GuiTable, List). Users must not modify the return value of this method.
      Returns:
      teh set of active columns
    • getFirstRow

      public int getFirstRow()
      Get the first row included in the viewport.
      Returns:
      the first row of the viewport
    • getLastRow

      public int getLastRow()
      Get the last Row included in the viewport.
      Returns:
      the last row in the viewport
    • isRowInViewport

      public boolean isRowInViewport(int row)
      Check if the specified row is included in the current viewport.
      Parameters:
      row - the row
      Returns:
      true if the row is in the current viewport
    • areColumnsInViewport

      public boolean areColumnsInViewport(@NotNull BitSet columns)
      Check if the specified columns are all in the viewport.
      Parameters:
      columns - the columns to check
      Returns:
      true if all of the provided columns are in the viewport, false otherwise.