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>
A transformer that renders a list of elements in a menu.
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.xpdustry.distributor.api.gui.transform.Transformer
Transformer.Context<P extends Pane> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the action to perform when an element is chosen.intReturns the height of a page.Returns the key used to store the current page.intReturns the page size.Returns the provider of the elements.Returns the renderer of the elements.intgetWidth()Returns the width of a page.booleanReturns whether the transformer fills empty spaces.booleanReturns whether the navigation buttons are rendered.setChoiceAction(BiAction<E> choiceAction) Sets the action to perform when an element is chosen.setFillEmptySpace(boolean fillEmptySpace) Sets whether the transformer fills empty spaces.setHeight(int height) Sets the height of a page.setPageKey(Key<Integer> pageKey) Sets the key used to store the current page.setProvider(Function<Transformer.Context<MenuPane>, List<E>> provider) Sets the provider of the elements.setRenderer(BiFunction<Transformer.Context<MenuPane>, E, Component> renderer) Sets the renderer of the elements.setRenderer(Function<E, Component> renderer) Sets the renderer of the elements.setRenderNavigation(boolean renderNavigation) Sets whether the navigation buttons are rendered.setWidth(int width) Sets the width of a page.voidtransform(Transformer.Context<MenuPane> context)
-
Constructor Details
-
ListTransformer
public ListTransformer()
-
-
Method Details
-
getProvider
Returns the provider of the elements. -
setProvider
Sets the provider of the elements.- Parameters:
provider- the provider- Returns:
- this transformer
-
getRenderer
Returns the renderer of the elements. -
setRenderer
Sets the renderer of the elements.- Parameters:
renderer- the renderer- Returns:
- this transformer
-
setRenderer
public ListTransformer<E> setRenderer(BiFunction<Transformer.Context<MenuPane>, E, Component> renderer) Sets the renderer of the elements.- Parameters:
renderer- the renderer- Returns:
- this transformer
-
getChoiceAction
Returns the action to perform when an element is chosen. -
setChoiceAction
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
Sets the height of a page.- Parameters:
height- the height- Returns:
- this transformer
-
getWidth
public int getWidth()Returns the width of a page. -
setWidth
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
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
-
getPageKey
Returns the key used to store the current page. -
setPageKey
Sets the key used to store the current page.- Parameters:
pageKey- the page key- Returns:
- this transformer
-
transform
- Specified by:
transformin interfaceTransformer<E>
-