Class SlotUtils
java.lang.Object
com.ultikits.ultitools.abstracts.gui.declarative.util.SlotUtils
槽位计算工具类。
- Since:
- 6.2.0
- Version:
- 1.0.0
- Author:
- UltiTools Team
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic int[]createRange(int startSlot, int endSlot) 创建槽位范围。static intgetCenterSlot(int rows) 获取中心槽位。static intgetCol(int slot) 从槽位索引获取列。static intgetRow(int slot) 从槽位索引获取行。static int[]getRowRange(int row) 获取指定行的槽位范围。static intgetRowStart(int row) 获取指定行的起始槽位。static booleanisBorderSlot(int slot, int rows) 检查槽位是否在边框上(最外圈)。static booleanisValidSlot(int slot, int rows) 检查槽位是否在有效的 GUI 范围内。static inttoSlotIndex(int row, int col) 将行列转换为槽位索引。static inttoSlotIndex(int startSlot, int rowOffset, int colOffset) 从起始槽位计算相对位置的槽位索引。
-
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:
- 槽位数组
-