Class Label

java.lang.Object
com.github.stefvanschie.inventoryframework.pane.Pane
com.github.stefvanschie.inventoryframework.pane.component.Label

public class Label extends Pane
A label for displaying text.
Since:
0.5.0
  • Constructor Details

    • Label

      public Label(int length, int height, @NotNull @NotNull Pane.Priority priority, @NotNull @NotNull Font font, @NotNull @NotNull Plugin plugin)
      Creates a new label
      Parameters:
      length - the length
      height - the height
      priority - the priority
      font - the character set
      plugin - the plugin that will be the owner for this label's items
      Since:
      0.12.0
    • Label

      public Label(int length, int height, @NotNull @NotNull Font font, @NotNull @NotNull Plugin plugin)
      Creates a new label
      Parameters:
      length - the length
      height - the height
      font - the character set
      plugin - the plugin that will be the owner for this label's items
      Since:
      0.12.0
    • Label

      public Label(int length, int height, @NotNull @NotNull Pane.Priority priority, @NotNull @NotNull Font font)
      Creates a new label
      Parameters:
      length - the length
      height - the height
      priority - the priority
      font - the character set
      Since:
      0.12.0
    • Label

      public Label(int length, int height, @NotNull @NotNull Font font)
      Creates a new label
      Parameters:
      length - the length
      height - the height
      font - the character set
      Since:
      0.12.0
  • Method Details

    • setText

      public void setText(@NotNull @NotNull String text, @NotNull @NotNull BiFunction<? super @NotNull Character, ? super @NotNull ItemStack, ? extends @NotNull GuiItem> processor)
      Sets the text to be displayed in this label. If this label already had text, this text will be overwritten. The specified processor will be called for each character that is part of the specified text. The provided character will be the original character that was attempted to be shown - it is not subject to any transformations that may be applied for finding a valid item corresponding to this character, such as capitalization changes.
      Parameters:
      text - the new text
      processor - processes each character before using them
      Since:
      0.10.4
    • setText

      public void setText(@NotNull @NotNull String text)
      Sets the text to be displayed in this label. If this label already had text, this text will be overwritten.
      Parameters:
      text - the new text
      Since:
      0.5.0
      See Also:
    • copy

      @NotNull @Contract(pure=true) public @NotNull Label 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.
      Overrides:
      copy in class Pane
      Returns:
      a copy of this pane
    • click

      public boolean click(@NotNull @NotNull Gui gui, @NotNull @NotNull GuiComponent guiComponent, @NotNull @NotNull InventoryClickEvent event, @NotNull @NotNull Slot slot)
      Description copied from class: Pane
      Called whenever there is being clicked on this pane
      Specified by:
      click in class Pane
      Parameters:
      gui - the gui in which was clicked
      guiComponent - the gui component in which this pane resides
      event - the event that occurred while clicking on this item
      slot - the slot that was clicked in
      Returns:
      whether the item was found or not
    • display

      @NotNull public @NotNull GuiItemContainer display()
      Description copied from class: Pane
      Returns a GuiItemContainer with all the items that should be displayed of this pane.
      Specified by:
      display in class Pane
      Returns:
      a container containing all the items to be displayed
    • getItems

      @NotNull public @NotNull Collection<GuiItem> 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.)
      Specified by:
      getItems in class Pane
      Returns:
      all items
    • clear

      public void clear()
      Description copied from class: Pane
      Clears the entire pane of any items/panes. Underlying panes will not be cleared.
      Specified by:
      clear in class Pane
    • getPanes

      @NotNull public @NotNull Collection<Pane> 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.)
      Specified by:
      getPanes in class Pane
      Returns:
      all panes
    • getText

      @Contract(pure=true) @NotNull public @NotNull String getText()
      Gets the text currently displayed in this label
      Returns:
      the text in this label
      Since:
      0.5.0
    • getFont

      @Contract(pure=true) @NotNull public @NotNull Font getFont()
      Gets the character set currently used for the text in this label
      Returns:
      the character set
      Since:
      0.5.0
    • load

      @NotNull @Contract(pure=true) public static @NotNull Label load(@NotNull @NotNull Object instance, @NotNull @NotNull Element element, @NotNull @NotNull Plugin plugin)
      Loads a label from a given element
      Parameters:
      instance - the instance class
      element - the element
      plugin - the plugin that will be the owner of the underlying items
      Returns:
      the percentage bar
      Since:
      0.10.8