java.lang.Object
com.github.stefvanschie.inventoryframework.pane.Pane
com.github.stefvanschie.inventoryframework.pane.component.util.VariableBar
All Implemented Interfaces:
Flippable, Orientable
Direct Known Subclasses:
PercentageBar, Slider

public abstract class VariableBar extends Pane implements Orientable, Flippable
A variable bar for UI elements that require some sort of bar
Since:
0.5.0
  • Field Details

    • fillPane

      @NotNull protected final @NotNull OutlinePane fillPane
      The green and the red parts of the slider
    • backgroundPane

      @NotNull protected final @NotNull OutlinePane backgroundPane
      The green and the red parts of the slider
    • value

      protected float value
      The value this slider is at. This is a value between 0 and 1 (both inclusive).
    • orientation

      @NotNull protected @NotNull Orientable.Orientation orientation
      The orientation of the slider
    • flipHorizontally

      protected boolean flipHorizontally
      Whether the pane is flipped horizontally or vertically
    • flipVertically

      protected boolean flipVertically
      Whether the pane is flipped horizontally or vertically
  • Constructor Details

    • VariableBar

      protected VariableBar(int length, int height, @NotNull @NotNull Plugin plugin)
      Creates a new variable bar
      Parameters:
      length - the length of the bar
      height - the height of the bar
      plugin - the plugin that will be the owner for this variable bar's items
      Since:
      0.10.8
      See Also:
    • VariableBar

      protected VariableBar(@NotNull @NotNull Slot slot, int length, int height, @NotNull @NotNull Pane.Priority priority, @NotNull @NotNull Plugin plugin)
      Creates a new variable bar
      Parameters:
      slot - the slot of the bar
      length - the length of the bar
      height - the height of the bar
      priority - the priority of the bar
      plugin - the plugin that will be the owner for this variable bar's items
      Since:
      0.10.8
      See Also:
    • VariableBar

      protected VariableBar(int x, int y, int length, int height, @NotNull @NotNull Pane.Priority priority, @NotNull @NotNull Plugin plugin)
      Creates a new variable bar
      Parameters:
      x - the x coordinate of the bar
      y - the y coordinate of the bar
      length - the length of the bar
      height - the height of the bar
      priority - the priority of the bar
      plugin - the plugin that will be the owner for this variable bar's items
      Since:
      0.10.8
      See Also:
    • VariableBar

      protected VariableBar(@NotNull @NotNull Slot slot, int length, int height, @NotNull @NotNull Plugin plugin)
      Creates a new variable bar
      Parameters:
      slot - the slot of the bar
      length - the length of the bar
      height - the height of the bar
      plugin - the plugin that will be the owner for this variable bar's items
      Since:
      0.10.8
      See Also:
    • VariableBar

      protected VariableBar(int x, int y, int length, int height, @NotNull @NotNull Plugin plugin)
      Creates a new variable bar
      Parameters:
      x - the x coordinate of the bar
      y - the y coordinate of the bar
      length - the length of the bar
      height - the height of the bar
      plugin - the plugin that will be the owner for this variable bar's items
      Since:
      0.10.8
      See Also:
    • VariableBar

      protected VariableBar(int length, int height)
    • VariableBar

      protected VariableBar(@NotNull @NotNull Slot slot, int length, int height, @NotNull @NotNull Pane.Priority priority)
      Creates a new variable bar
      Parameters:
      slot - the slot of the bar
      length - the length of the bar
      height - the height of the bar
      priority - the priority of the bar
      Since:
      0.10.8
    • VariableBar

      protected VariableBar(int x, int y, int length, int height, @NotNull @NotNull Pane.Priority priority)
    • VariableBar

      protected VariableBar(@NotNull @NotNull Slot slot, int length, int height)
      Creates a new variable bar
      Parameters:
      slot - the slot of the bar
      length - the length of the bar
      height - the height of the bar
      Since:
      0.10.8
    • VariableBar

      protected VariableBar(int x, int y, int length, int height)
  • Method Details

    • setValue

      protected void setValue(float value)
      Sets the value of this bar. The value has to be in (0,1). If not, this method will throw an IllegalArgumentException.
      Parameters:
      value - the new value.
      Throws:
      IllegalArgumentException - when the value is out of range
      Since:
      0.9.5
    • setLength

      public void setLength(int length)
      Description copied from class: Pane
      Set the length of this pane
      Overrides:
      setLength in class Pane
      Parameters:
      length - the new length
    • setHeight

      public void setHeight(int height)
      Description copied from class: Pane
      Set the height of this pane
      Overrides:
      setHeight in class Pane
      Parameters:
      height - the new height
    • applyContents

      protected void applyContents(@NotNull @NotNull VariableBar copy)
      Applies the contents of this variable bar onto the provided copy of this variable bar. This variable bar will not be modified.
      Parameters:
      copy - the copy of the variable bar
      Since:
      0.6.2
    • setOrientation

      public void setOrientation(@NotNull @NotNull Orientable.Orientation orientation)
      Description copied from interface: Orientable
      Sets the orientation of this outline pane
      Specified by:
      setOrientation in interface Orientable
      Parameters:
      orientation - the new orientation
    • 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 class Pane
      Parameters:
      inventoryComponent - the inventory component in which the items should be displayed
      paneOffsetX - the pane's offset on the x axis
      paneOffsetY - the pane's offset on the y axis
      maxLength - the maximum length of the pane
      maxHeight - the maximum height of the pane
    • setFillItem

      public void setFillItem(@NotNull @NotNull GuiItem item)
      Sets the fill item (foreground)
      Parameters:
      item - the new item
      Since:
      0.5.0
    • setBackgroundItem

      public void setBackgroundItem(@NotNull @NotNull GuiItem item)
      Sets the background item
      Parameters:
      item - the new item
      Since:
      0.5.0
    • 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
    • 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
    • flipHorizontally

      public void flipHorizontally(boolean flipHorizontally)
      Description copied from interface: Flippable
      Sets whether this pane should flip its items horizontally
      Specified by:
      flipHorizontally in interface Flippable
      Parameters:
      flipHorizontally - whether the pane should flip items horizontally
    • flipVertically

      public void flipVertically(boolean flipVertically)
      Description copied from interface: Flippable
      Sets whether this pane should flip its items vertically
      Specified by:
      flipVertically in interface Flippable
      Parameters:
      flipVertically - whether the pane should flip items vertically
    • getOrientation

      @NotNull public @NotNull Orientable.Orientation getOrientation()
      Description copied from interface: Orientable
      Gets the orientation of this outline pane
      Specified by:
      getOrientation in interface Orientable
      Returns:
      the orientation
    • isFlippedHorizontally

      public boolean isFlippedHorizontally()
      Description copied from interface: Flippable
      Gets whether this pane's items are flipped horizontally
      Specified by:
      isFlippedHorizontally in interface Flippable
      Returns:
      true if the items are flipped horizontally, false otherwise
    • isFlippedVertically

      public boolean isFlippedVertically()
      Description copied from interface: Flippable
      Gets whether this pane's items are flipped vertically
      Specified by:
      isFlippedVertically in interface Flippable
      Returns:
      true if the items are flipped vertically, false otherwise
    • 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