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.

@FunctionalInterface public static interface Canvas.PopulatorContext.ViewStrategy
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 Details

    • parse

      Parses an array of strings to create a Canvas.PopulatorContext.ViewStrategy for 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.ViewStrategy that defines the rendering behavior based on the parsed grid.
      Throws:
      IllegalArgumentException - If the length of any row is not equal to 9.
    • handle

      int handle(int counter, @NotNull @NotNull Canvas canvas, @NotNull @NotNull Button button)
      Allows you to modify the button depending on the given context.
      Parameters:
      counter - the counter
      canvas - the canvas
      button - the button to modify if needed
      Returns:
      elements per page