Class Mask
java.lang.Object
com.github.stefvanschie.inventoryframework.pane.util.Mask
A mask for
OutlinePane
s that specifies in which positions the items should be placed. Objects of this class
are immutable.- Since:
- 0.5.16
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
Returns the amount of slots in this mask that are 'enabled'.boolean
boolean[]
getColumn
(int index) Gets the column of this mask at the specified index.int
Gets the height of this maskint
Gets the length of this maskboolean[]
getRow
(int index) Gets the row of this mask at the specified index.int
hashCode()
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.toString()
-
Constructor Details
-
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, anIllegalArgumentException
will be thrown. When multiple strings have a different length anIllegalArgumentException
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
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
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 sloty
- 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
-
hashCode
public int hashCode() -
toString
-