Class ListTransformer<E>

java.lang.Object
com.xpdustry.distributor.api.gui.menu.ListTransformer<E>
Type Parameters:
E - the type of the elements
All Implemented Interfaces:
Transformer<MenuPane>

public final class ListTransformer<E> extends Object implements Transformer<MenuPane>
A transformer that renders a list of elements in a menu.
  • Constructor Details

    • ListTransformer

      public ListTransformer()
  • Method Details

    • getProvider

      public Function<Transformer.Context<MenuPane>,List<E>> getProvider()
      Returns the provider of the elements.
    • setProvider

      public ListTransformer<E> setProvider(Function<Transformer.Context<MenuPane>,List<E>> provider)
      Sets the provider of the elements.
      Parameters:
      provider - the provider
      Returns:
      this transformer
    • getRenderer

      Returns the renderer of the elements.
    • setRenderer

      public ListTransformer<E> setRenderer(Function<E,Component> renderer)
      Sets the renderer of the elements.
      Parameters:
      renderer - the renderer
      Returns:
      this transformer
    • setRenderer

      Sets the renderer of the elements.
      Parameters:
      renderer - the renderer
      Returns:
      this transformer
    • getChoiceAction

      public BiAction<E> getChoiceAction()
      Returns the action to perform when an element is chosen.
    • setChoiceAction

      public ListTransformer<E> setChoiceAction(BiAction<E> choiceAction)
      Sets the action to perform when an element is chosen.
      Parameters:
      choiceAction - the action
      Returns:
      this transformer
    • getHeight

      public int getHeight()
      Returns the height of a page.
    • setHeight

      public ListTransformer<E> setHeight(int height)
      Sets the height of a page.
      Parameters:
      height - the height
      Returns:
      this transformer
    • getWidth

      public int getWidth()
      Returns the width of a page.
    • setWidth

      public ListTransformer<E> setWidth(int width)
      Sets the width of a page.
      Parameters:
      width - the width
      Returns:
      this transformer
    • getPageSize

      public int getPageSize()
      Returns the page size.
    • isFillEmptySpace

      @Deprecated(forRemoval=true) public boolean isFillEmptySpace()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Returns whether the transformer fills empty spaces.
    • setFillEmptySpace

      @Deprecated(forRemoval=true) public ListTransformer<E> setFillEmptySpace(boolean fillEmptySpace)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Sets whether the transformer fills empty spaces.

      For example, if the height is 10 and the width is 1, and there are 7 elements, the transformer will add 3 empty options to fill the page.

      Parameters:
      fillEmptySpace - whether to fill empty spaces
      Returns:
      this transformer
    • isFillEmptyWidth

      public boolean isFillEmptyWidth()
      Returns whether the transformer fills empty spaces across the width of the list.
    • setFillEmptyWidth

      public ListTransformer<E> setFillEmptyWidth(boolean fillEmptyWidth)
      Sets whether the transformer fills empty spaces across the width of the list.

      For example, if the height is 12 and the width is 3, and there are 7 elements, the transformer will add 2 empty options to fill the 3rd row. An empty 4th row won't be added unless isFillEmptyHeight() is true.

      Parameters:
      fillEmptyWidth - whether to fill empty spaces
      Returns:
      this transformer
    • isFillEmptyHeight

      public boolean isFillEmptyHeight()
      Returns whether the transformer fills empty spaces across the height of the list.
    • setFillEmptyHeight

      public ListTransformer<E> setFillEmptyHeight(boolean fillEmptyHeight)
      Sets whether the transformer fills empty spaces across the height of the list.

      For example, if the height is 12 and the width is 3, and there are 7 elements, the transformer will add an empty 4th row. The 3 empty options in the 4th row and the 2 empty options in the 3rd row won't be added unless isFillEmptyWidth() is true.

      Parameters:
      fillEmptyHeight - whether to fill empty spaces
      Returns:
      this transformer
    • isRenderNavigation

      public boolean isRenderNavigation()
      Returns whether the navigation buttons are rendered.
    • setRenderNavigation

      public ListTransformer<E> setRenderNavigation(boolean renderNavigation)
      Sets whether the navigation buttons are rendered.

      A previous button, a page indicator, and a next button are rendered.

      Parameters:
      renderNavigation - whether to render navigation buttons
      Returns:
      this transformer
    • getPageKey

      public Key<Integer> getPageKey()
      Returns the key used to store the current page.
    • setPageKey

      public ListTransformer<E> setPageKey(Key<Integer> pageKey)
      Sets the key used to store the current page.
      Parameters:
      pageKey - the page key
      Returns:
      this transformer
    • transform

      public void transform(Transformer.Context<MenuPane> context)
      Specified by:
      transform in interface Transformer<E>