Class MasonryPane
java.lang.Object
com.github.stefvanschie.inventoryframework.pane.Pane
com.github.stefvanschie.inventoryframework.pane.MasonryPane
- All Implemented Interfaces:
Orientable
This pane holds panes and decides itself where every pane should go. It tries to put every pane in the top left
corner and will move rightwards and downwards respectively if the top left corner is already in use. Depending on the
order and size of the panes, this may leave empty spaces in certain spots. Do note however that the order of panes
isn't always preserved. If there is a gap left in which a pane with a higher index can fit, it will be put there,
even if there are panes with a lower index after it. Panes that do not fit will not be displayed.
- Since:
- 0.3.0
-
Nested Class Summary
Nested classes/interfaces inherited from class com.github.stefvanschie.inventoryframework.pane.Pane
Pane.Priority
Nested classes/interfaces inherited from interface com.github.stefvanschie.inventoryframework.pane.Orientable
Orientable.Orientation
-
Field Summary
-
Constructor Summary
ConstructorDescriptionMasonryPane
(int length, int height) MasonryPane
(int x, int y, int length, int height) MasonryPane
(int x, int y, int length, int height, @NotNull Pane.Priority priority) -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a pane to this masonry panevoid
clear()
Clears the entire pane of any items/panes.boolean
click
(@NotNull Gui gui, @NotNull InventoryComponent inventoryComponent, @NotNull InventoryClickEvent event, int slot, int paneOffsetX, int paneOffsetY, int maxLength, int maxHeight) Called whenever there is being clicked on this pane@NotNull MasonryPane
copy()
Makes a copy of this pane and returns it.void
display
(@NotNull InventoryComponent inventoryComponent, int paneOffsetX, int paneOffsetY, int maxLength, int maxHeight) Has to set all the items in the right spot inside the inventory@NotNull Collection<GuiItem>
getItems()
Gets all the items in this pane and all underlying panes.@NotNull Orientable.Orientation
Gets the orientation of this outline pane@NotNull Collection<Pane>
getPanes()
Gets all the panes in this panes, including any child panes from other panes.static @NotNull MasonryPane
Loads a masonry pane from a given elementvoid
setOrientation
(@NotNull Orientable.Orientation orientation) Sets the orientation of this outline paneMethods inherited from class com.github.stefvanschie.inventoryframework.pane.Pane
callOnClick, findMatchingItem, getHeight, getLength, getPriority, getUUID, getX, getY, isVisible, load, loadItem, registerProperty, setHeight, setLength, setOnClick, setPriority, setVisible, setX, setY
-
Constructor Details
-
MasonryPane
-
MasonryPane
public MasonryPane(int x, int y, int length, int height) -
MasonryPane
public MasonryPane(int length, int height)
-
-
Method Details
-
display
public void display(@NotNull @NotNull InventoryComponent inventoryComponent, int paneOffsetX, int paneOffsetY, int maxLength, int maxHeight) Description copied from class:Pane
Has to set all the items in the right spot inside the inventory- Specified by:
display
in classPane
- Parameters:
inventoryComponent
- the inventory component in which the items should be displayedpaneOffsetX
- the pane's offset on the x axispaneOffsetY
- the pane's offset on the y axismaxLength
- the maximum length of the panemaxHeight
- the maximum height of the pane
-
click
public boolean click(@NotNull @NotNull Gui gui, @NotNull @NotNull InventoryComponent inventoryComponent, @NotNull @NotNull InventoryClickEvent event, int slot, int paneOffsetX, int paneOffsetY, int maxLength, int maxHeight) Description copied from class:Pane
Called whenever there is being clicked on this pane- Specified by:
click
in classPane
- Parameters:
gui
- the gui in which was clickedinventoryComponent
- the inventory component in which this pane residesevent
- the event that occurred while clicking on this itemslot
- the slot that was clicked inpaneOffsetX
- the pane's offset on the x axispaneOffsetY
- the pane's offset on the y axismaxLength
- the maximum length of the panemaxHeight
- the maximum height of the pane- Returns:
- whether the item was found or not
-
copy
Description copied from class:Pane
Makes a copy of this pane and returns it. This makes a deep copy of the pane. This entails that the underlying panes and/or items will be copied as well. The returned pane will never be reference equal to the current pane. -
addPane
Adds a pane to this masonry pane- Parameters:
pane
- the pane to add- Since:
- 0.3.0
-
getItems
Description copied from class:Pane
Gets all the items in this pane and all underlying panes. The returned collection is not guaranteed to be mutable or to be a view of the underlying data. (So changes to the gui are not guaranteed to be visible in the returned value.) -
getPanes
Description copied from class:Pane
Gets all the panes in this panes, including any child panes from other panes. The returned collection is not guaranteed to be mutable or to be a view of the underlying data. (So changes to the gui are not guaranteed to be visible in the returned value.) -
clear
public void clear()Description copied from class:Pane
Clears the entire pane of any items/panes. Underlying panes will not be cleared. -
getOrientation
Description copied from interface:Orientable
Gets the orientation of this outline pane- Specified by:
getOrientation
in interfaceOrientable
- Returns:
- the orientation
-
setOrientation
Description copied from interface:Orientable
Sets the orientation of this outline pane- Specified by:
setOrientation
in interfaceOrientable
- Parameters:
orientation
- the new orientation
-
load
@NotNull public static @NotNull MasonryPane load(@NotNull @NotNull Object instance, @NotNull @NotNull Element element) Loads a masonry pane from a given element- Parameters:
instance
- the instance classelement
- the element- Returns:
- the masonry pane
-