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

public final class SlotUtils extends Object
槽位计算工具类。
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)
    创建槽位范围。
    static int
    getCenterSlot(int rows)
    获取中心槽位。
    static int
    getCol(int slot)
    从槽位索引获取列。
    static int
    getRow(int slot)
    从槽位索引获取行。
    static int[]
    getRowRange(int row)
    获取指定行的槽位范围。
    static int
    getRowStart(int row)
    获取指定行的起始槽位。
    static boolean
    isBorderSlot(int slot, int rows)
    检查槽位是否在边框上(最外圈)。
    static boolean
    isValidSlot(int slot, int rows)
    检查槽位是否在有效的 GUI 范围内。
    static int
    toSlotIndex(int row, int col)
    将行列转换为槽位索引。
    static int
    toSlotIndex(int startSlot, int rowOffset, int colOffset)
    从起始槽位计算相对位置的槽位索引。

    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)
      将行列转换为槽位索引。
      Parameters:
      row - 行(0-based)
      col - 列(0-based)
      Returns:
      槽位索引
    • toSlotIndex

      public static int toSlotIndex(int startSlot, int rowOffset, int colOffset)
      从起始槽位计算相对位置的槽位索引。
      Parameters:
      startSlot - 起始槽位
      rowOffset - 行偏移
      colOffset - 列偏移
      Returns:
      槽位索引
    • getRow

      public static int getRow(int slot)
      从槽位索引获取行。
      Parameters:
      slot - 槽位索引
      Returns:
      行(0-based)
    • getCol

      public static int getCol(int slot)
      从槽位索引获取列。
      Parameters:
      slot - 槽位索引
      Returns:
      列(0-based)
    • isValidSlot

      public static boolean isValidSlot(int slot, int rows)
      检查槽位是否在有效的 GUI 范围内。
      Parameters:
      slot - 槽位索引
      rows - GUI 行数
      Returns:
      如果有效返回 true
    • isBorderSlot

      public static boolean isBorderSlot(int slot, int rows)
      检查槽位是否在边框上(最外圈)。
      Parameters:
      slot - 槽位索引
      rows - GUI 行数
      Returns:
      如果在边框上返回 true
    • getRowStart

      public static int getRowStart(int row)
      获取指定行的起始槽位。
      Parameters:
      row - 行(0-based)
      Returns:
      起始槽位
    • getRowRange

      public static int[] getRowRange(int row)
      获取指定行的槽位范围。
      Parameters:
      row - 行(0-based)
      Returns:
      起始槽位(包含)和结束槽位(不包含)
    • getCenterSlot

      public static int getCenterSlot(int rows)
      获取中心槽位。
      Parameters:
      rows - GUI 行数
      Returns:
      中心槽位索引
    • createRange

      public static int[] createRange(int startSlot, int endSlot)
      创建槽位范围。
      Parameters:
      startSlot - 起始槽位
      endSlot - 结束槽位(包含)
      Returns:
      槽位数组