Class SearchRegionResolver

java.lang.Object
io.github.jspinak.brobot.action.internal.find.SearchRegionResolver

@Component public class SearchRegionResolver extends Object
Selects appropriate search regions for find operations based on a priority hierarchy.

This component implements a sophisticated region selection strategy that respects the precedence of different region sources. It ensures that the most specific and intentional region definitions take priority over more general ones, while always guaranteeing that at least one search region is available for the operation.

Region Selection Priority (highest to lowest):

  1. Fixed/defined regions on the pattern or image
  2. Search regions specified in ActionConfig
  3. Search regions defined on the pattern or image
  4. Default full-screen region (fallback)
See Also:
  • Constructor Details

    • SearchRegionResolver

      public SearchRegionResolver()
  • Method Details

    • getRegions

      public List<Region> getRegions(ActionConfig actionConfig, StateImage stateImage)
      Selects search regions for a StateImage-based find operation.

      This method implements the following priority order:

      1. Search regions from ActionConfig (highest priority)
      2. Fixed regions from individual Patterns within the StateImage
      3. Search regions from individual Patterns within the StateImage
      4. Default full-screen region if no regions are found
      Parameters:
      actionConfig - The action configuration containing optional search regions
      stateImage - The image that may contain patterns with their own search regions
      Returns:
      A non-empty list of regions to search within. Always contains at least one region (full screen) if no specific regions are defined.
    • getRegions

      public List<Region> getRegions(ActionConfig actionConfig, Pattern pattern)
      Selects search regions for a Pattern-based find operation.

      This method implements the following priority order:

      1. Search regions from ActionConfig (highest priority)
      2. Fixed regions from the Pattern
      3. Search regions from the Pattern
      4. Default full-screen region if no regions are found
      Parameters:
      actionConfig - The action configuration containing optional search regions
      pattern - The pattern that may contain its own search regions (fixed or standard)
      Returns:
      A non-empty list of regions to search within.
    • getRegions

      public List<Region> getRegions(ActionConfig actionConfig)
      Selects search regions when only ActionConfig are available.

      This method is used when there are no pattern or image-specific regions to consider. It ensures that at least one region is always returned for the search operation.

      Parameters:
      actionConfig - The action configuration containing optional search regions
      Returns:
      The regions specified in ActionConfig, or a default full-screen region if no regions are defined
    • getRegionsForAllImages

      public List<Region> getRegionsForAllImages(ActionConfig actionConfig, ObjectCollection... objectCollections)
      Collects search regions from multiple ObjectCollections.

      This method aggregates all search regions from the provided collections of images. If ActionConfig contains any defined regions, those take precedence over the regions defined in the individual images.

      Parameters:
      actionConfig - The action configuration that may override image regions
      objectCollections - Variable number of collections containing StateImages with their own search regions
      Returns:
      A list of all applicable search regions. If ActionConfig has defined regions, returns those; otherwise returns the union of all regions from all images in all collections.