Class Grid.Builder

java.lang.Object
com.ultikits.ultitools.ui.Grid.Builder
Enclosing class:
Grid

public static final class Grid.Builder extends Object
A reusable, non-thread-safe snapshot builder.
  • Field Details

  • Constructor Details

    • Builder

      private Builder(Text title, int rows)
  • Method Details

    • set

      public Grid.Builder set(GridSlot slot, GridItem item)
      Sets or replaces an icon. Replaces a binding on that slot. @throws IllegalArgumentException if slot.row() >= rows
    • set

      public Grid.Builder set(int row, int column, ItemSpec icon, @Nullable @Nullable GridAction action)
      Sets an icon with an optional action at zero-based coordinates. Replaces a binding on that slot.
    • clear

      public Grid.Builder clear(GridSlot slot)
      Removes an icon or a binding from this snapshot.
    • bind

      public Grid.Builder bind(GridSlot slot, SlotContainer container, int index, BindingMode mode)
      Binds slot to container's index. Replaces an icon or binding on that slot.
      Throws:
      IllegalArgumentException - if the slot is outside the grid's rows, index is outside 0..container.size()-1, or (at build()) two slots bind the same container index
    • bindRange

      public Grid.Builder bindRange(int row, int column, int count, SlotContainer container, int firstIndex, BindingMode mode)
      Binds count consecutive slots in row-major order starting at (row, column) to consecutive indexes from firstIndex. Same checks as bind(GridSlot, SlotContainer, int, BindingMode).
    • requireSlot

      private void requireSlot(GridSlot slot)
    • validate

      private void validate()
    • build

      public Grid build()
      Validates the complete snapshot and copies its icon table.