Class SlotUtils
java.lang.Object
com.ultikits.ultitools.abstracts.gui.declarative.util.SlotUtils
Slot-index calculation utilities.
- 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) Creates a slot range.static intgetCenterSlot(int rows) Gets the center slot.static intgetCol(int slot) Gets the column of a slot index.static intgetRow(int slot) Gets the row of a slot index.static int[]getRowRange(int row) Gets the slot range of the given row.static intgetRowStart(int row) Gets the starting slot of the given row.static booleanisBorderSlot(int slot, int rows) Checks whether a slot sits on the border (the outermost ring).static booleanisValidSlot(int slot, int rows) Checks whether a slot is within the valid GUI range.static inttoSlotIndex(int row, int col) Converts a row/column pair into a slot index.static inttoSlotIndex(int startSlot, int rowOffset, int colOffset) Computes the slot index of a position relative to a starting slot.
-
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 slotrowOffset- row offsetcolOffset- 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 indexrows- 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 indexrows- 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 slotendSlot- ending slot (inclusive)- Returns:
- array of slots
-