java.lang.Object
com.github.stefvanschie.inventoryframework.pane.util.Mask

public class Mask extends Object
A mask for OutlinePanes that specifies in which positions the items should be placed. Objects of this class are immutable.
Since:
0.5.16
  • Constructor Summary

    Constructors
    Constructor
    Description
    Mask(@NotNull String... mask)
    Creates a mask based on the strings provided.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Returns the amount of slots in this mask that are 'enabled'.
    boolean
    equals(Object object)
     
    boolean[]
    getColumn(int index)
    Gets the column of this mask at the specified index.
    int
    Gets the height of this mask
    int
    Gets the length of this mask
    boolean[]
    getRow(int index)
    Gets the row of this mask at the specified index.
    int
     
    boolean
    isEnabled(int x, int y)
    Gets whether the slot at the specified row and column is 'enabled' or not.
    @NotNull Mask
    setHeight(int height)
    Creates a new maks with the specified height.
    @NotNull Mask
    setLength(int length)
    Creates a new maks with the specified length.
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Mask

      public Mask(@NotNull @NotNull String... mask)
      Creates a mask based on the strings provided. Each string is a row for the mask and each character is a cell of that row that indicates a slot for the mask. When the character is a 0, the slot will be considered 'disabled'; when the character is a 1, the slot will be considered 'enabled'. When there are any other characters in the string, an IllegalArgumentException will be thrown. When multiple strings have a different length an IllegalArgumentException will be thrown.
      Parameters:
      mask - a var-arg of strings that represent this mask
      Throws:
      IllegalArgumentException - when a string contains an illegal character or when strings have different lengths
      Since:
      0.5.16
  • Method Details

    • setHeight

      @NotNull @Contract(pure=true) public @NotNull Mask setHeight(int height)
      Creates a new maks with the specified height. If the new height is smaller than the previous height, the excess values will be truncated. If the new height is longer than the previous height, additional values will be added which are enabled. If the height is the same as the previous mask, this will simply return a new mask identical to this one.
      Parameters:
      height - the new height of the mask
      Returns:
      a new mask with the specified height
      Since:
      0.9.1
    • setLength

      @NotNull @Contract(pure=true) public @NotNull Mask setLength(int length)
      Creates a new maks with the specified length. If the new length is smaller than the previous length, the excess values will be truncated. If the new length is longer than the previous length, additional values will be added which are enabled. If the length is the same as the previous mask, this will simply return a new mask identical to this one.
      Parameters:
      length - the new length of the mask
      Returns:
      a new mask with the specified length
      Since:
      0.9.1
    • amountOfEnabledSlots

      public int amountOfEnabledSlots()
      Returns the amount of slots in this mask that are 'enabled'.
      Returns:
      amount of enabled slots
      Since:
      0.5.16
    • getColumn

      public boolean[] getColumn(int index)
      Gets the column of this mask at the specified index. The values indicate the state of the slots for that slot: true indicates that the slot is 'enabled'; false indicates that the slot is 'disabled'. The returned array is a copy of the original; modifications to the returned array will not be reflected in the mask.
      Parameters:
      index - the column index
      Returns:
      the column of this mask
      Since:
      0.5.16
    • getRow

      public boolean[] getRow(int index)
      Gets the row of this mask at the specified index. The values indicate the state of the slots for that slot: true indicates that the slot is 'enabled'; false indicates that the slot is 'disabled'. The returned array is a copy of the original; modifications to the returned array will not be reflected in the mask.
      Parameters:
      index - the row index
      Returns:
      the row of this mask
      Since:
      0.5.16
    • isEnabled

      public boolean isEnabled(int x, int y)
      Gets whether the slot at the specified row and column is 'enabled' or not. This returns true if it is 'enabled' and false if it is 'disabled'.
      Parameters:
      x - the x coordinate of the slot
      y - the y coordinate of the slot
      Returns:
      whether the slot is enabled or not
      Since:
      0.5.16
    • getLength

      public int getLength()
      Gets the length of this mask
      Returns:
      the length
      Since:
      0.5.16
    • getHeight

      public int getHeight()
      Gets the height of this mask
      Returns:
      the height
      Since:
      0.5.16
    • equals

      public boolean equals(Object object)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object