java.lang.Object
com.ultikits.ultitools.abstracts.gui.declarative.util.SlotUtils

public final class SlotUtils extends Object
Slot-index calculation utilities.
Since:
6.2.0
Version:
1.0.0
Author:
UltiTools Team
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static int[]
    createRange(int startSlot, int endSlot)
    Creates a slot range.
    static int
    getCenterSlot(int rows)
    Gets the center slot.
    static int
    getCol(int slot)
    Gets the column of a slot index.
    static int
    getRow(int slot)
    Gets the row of a slot index.
    static int[]
    getRowRange(int row)
    Gets the slot range of the given row.
    static int
    getRowStart(int row)
    Gets the starting slot of the given row.
    static boolean
    isBorderSlot(int slot, int rows)
    Checks whether a slot sits on the border (the outermost ring).
    static boolean
    isValidSlot(int slot, int rows)
    Checks whether a slot is within the valid GUI range.
    static int
    toSlotIndex(int row, int col)
    Converts a row/column pair into a slot index.
    static int
    toSlotIndex(int startSlot, int rowOffset, int colOffset)
    Computes the slot index of a position relative to a starting slot.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • SlotUtils

      private SlotUtils()
  • Method Details

    • toSlotIndex

      public static int toSlotIndex(int row, int col)
      Converts a row/column pair into a slot index.
      Parameters:
      row - row (0-based)
      col - column (0-based)
      Returns:
      slot index
    • toSlotIndex

      public static int toSlotIndex(int startSlot, int rowOffset, int colOffset)
      Computes the slot index of a position relative to a starting slot.
      Parameters:
      startSlot - starting slot
      rowOffset - row offset
      colOffset - column offset
      Returns:
      slot index
    • getRow

      public static int getRow(int slot)
      Gets the row of a slot index.
      Parameters:
      slot - slot index
      Returns:
      row (0-based)
    • getCol

      public static int getCol(int slot)
      Gets the column of a slot index.
      Parameters:
      slot - slot index
      Returns:
      column (0-based)
    • isValidSlot

      public static boolean isValidSlot(int slot, int rows)
      Checks whether a slot is within the valid GUI range.
      Parameters:
      slot - slot index
      rows - number of GUI rows
      Returns:
      true if valid
    • isBorderSlot

      public static boolean isBorderSlot(int slot, int rows)
      Checks whether a slot sits on the border (the outermost ring).
      Parameters:
      slot - slot index
      rows - number of GUI rows
      Returns:
      true if on the border
    • getRowStart

      public static int getRowStart(int row)
      Gets the starting slot of the given row.
      Parameters:
      row - row (0-based)
      Returns:
      starting slot
    • getRowRange

      public static int[] getRowRange(int row)
      Gets the slot range of the given row.
      Parameters:
      row - row (0-based)
      Returns:
      starting slot (inclusive) and ending slot (exclusive)
    • getCenterSlot

      public static int getCenterSlot(int rows)
      Gets the center slot.
      Parameters:
      rows - number of GUI rows
      Returns:
      center slot index
    • createRange

      public static int[] createRange(int startSlot, int endSlot)
      Creates a slot range.
      Parameters:
      startSlot - starting slot
      endSlot - ending slot (inclusive)
      Returns:
      array of slots