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

      public boolean isFillEmptySpace()
      Returns whether the transformer fills empty spaces.
    • setFillEmptySpace

      public ListTransformer<E> setFillEmptySpace(boolean fillEmptySpace)
      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
    • 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>