Package com.marcusslover.plus.lib.item
Interface Canvas.PopulatorContext.ViewStrategy
- Enclosing class:
Canvas.PopulatorContext<T>
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Holds the strategy on how to populate the elements on the canvas.
If a menu requires multiple pages, this is the strategy to use.
The strategy allows the modification of the area in which the elements are populated.
-
Method Summary
Modifier and TypeMethodDescriptionintAllows you to modify the button depending on the given context.Parses an array of strings to create aCanvas.PopulatorContext.ViewStrategyfor rendering elements on a canvas.
-
Method Details
-
parse
Parses an array of strings to create aCanvas.PopulatorContext.ViewStrategyfor rendering elements on a canvas.The provided array of strings represents a grid, where each character in the strings indicates the presence or absence of an element at a specific grid position. Use 'x' to indicate the presence of an element and 'o' to indicate the absence of an element.
Example:
String[] rows = new String[] { "ooooooooo", "ooooxoooo", "ooooxoooo", "ooooxoooo", "ooooxoooo", "ooooxoooo" };ViewStrategy viewStrategy = ViewStrategy.parse(rows); canvas.viewStrategy(viewStrategy);- Parameters:
rows- An array of strings representing the grid.- Returns:
- A
Canvas.PopulatorContext.ViewStrategythat defines the rendering behavior based on the parsed grid. - Throws:
IllegalArgumentException- If the length of any row is not equal to 9.
-
handle
Allows you to modify the button depending on the given context.- Parameters:
counter- the countercanvas- the canvasbutton- the button to modify if needed- Returns:
- elements per page
-