Class MatchRegionAdjuster

java.lang.Object
io.github.jspinak.brobot.action.internal.find.match.MatchRegionAdjuster

@Component public class MatchRegionAdjuster extends Object
Adjusts the position and dimensions of Match objects based on MatchAdjustmentOptions settings.

This component modifies Match regions by applying additive or absolute adjustments specified in MatchAdjustmentOptions. It supports both individual match adjustment and batch processing of multiple matches. The adjustments can be used to:

  • Offset match positions (using addX/addY)
  • Resize matches relatively (using addW/addH)
  • Set absolute dimensions (using absoluteW/absoluteH)
  • Apply target position and offset adjustments

This is version 2 of the MatchAdjuster, updated to work with the new ActionConfig hierarchy and MatchAdjustmentOptions instead of ActionConfig.

Since:
2.0
See Also:
  • Constructor Details

    • MatchRegionAdjuster

      public MatchRegionAdjuster()
  • Method Details

    • adjust

      public void adjust(Match match, MatchAdjustmentOptions adjustmentOptions)
      Adjusts a single match's region based on the specified adjustment options.

      This method modifies the match's region in-place by applying position offsets and dimension adjustments. Absolute dimensions take precedence over relative adjustments when both are specified.

      Parameters:
      match - The match whose region will be adjusted. This object is modified in-place.
      adjustmentOptions - Configuration specifying the adjustments to apply: - addX/addY: Pixel offsets for position - addW/addH: Pixel adjustments for dimensions - absoluteW/absoluteH: Absolute dimension values (overrides additive) - targetPosition: Position within match to target - targetOffset: Additional offset from target position
    • adjustAll

      public void adjustAll(ActionResult matches, MatchAdjustmentOptions adjustmentOptions)
      Adjusts all matches within an ActionResult based on the specified adjustment options.

      This method applies the same adjustments to every match in the result set, modifying each match's region in-place.

      Parameters:
      matches - The ActionResult containing matches to adjust. All matches within this object are modified.
      adjustmentOptions - Configuration specifying the adjustments to apply to each match
    • adjustAll

      public void adjustAll(ObjectCollection objectCollection, MatchAdjustmentOptions adjustmentOptions)
      Adjusts all matches contained within an ObjectCollection.

      This method processes all ActionResult objects in the collection, applying the specified adjustments to every match found within them.

      Parameters:
      objectCollection - The collection containing ActionResults with matches to adjust. All matches within all ActionResults are modified.
      adjustmentOptions - Configuration specifying the adjustments to apply to each match
    • filterByMinimumArea

      public void filterByMinimumArea(ActionResult matches, int minArea)
      Filters matches by minimum area, removing matches smaller than the specified threshold.

      This method is integrated into the match adjustment pipeline to avoid redundant iterations over the match list. It modifies the ActionResult's match list in-place, removing any matches whose area (width × height) is less than the minimum.

      This filtering is particularly useful for:

      • Removing noise and false positives from pattern matching
      • Ensuring matches meet minimum size requirements for interaction
      • Cleaning up results when searching for UI elements with expected dimensions
      Parameters:
      matches - The ActionResult containing matches to filter. The match list within this object is modified in-place.
      minArea - The minimum area (in pixels²) a match must have to be retained. Matches with area less than this value are removed.
    • adjustAndFilter

      public void adjustAndFilter(ActionResult matches, MatchAdjustmentOptions adjustmentOptions, int minArea)
      Adjusts all matches and optionally filters by minimum area in a single pass.

      This method combines position/dimension adjustments with area filtering to minimize iterations over the match list. It's more efficient than calling adjustAll and filterByMinimumArea separately.

      Parameters:
      matches - The ActionResult containing matches to process
      adjustmentOptions - Configuration for position and dimension adjustments
      minArea - Minimum area filter (0 or negative to disable filtering)