Class StateImage.Builder

java.lang.Object
io.github.jspinak.brobot.model.state.StateImage.Builder
Enclosing class:
StateImage

public static class StateImage.Builder extends Object
  • Constructor Details

    • Builder

      public Builder()
  • Method Details

    • setName

      public StateImage.Builder setName(String name)
      Sets the name for the StateImage being built.
      Parameters:
      name - the name to assign
      Returns:
      this builder for method chaining
    • setPatterns

      public StateImage.Builder setPatterns(List<Pattern> patterns)
      Sets the complete list of patterns for the StateImage. If no name has been set, uses the first pattern's name.
      Parameters:
      patterns - list of Pattern objects
      Returns:
      this builder for method chaining
    • addPattern

      public StateImage.Builder addPattern(Pattern pattern)
      Adds a single Pattern to the StateImage being built. If no name has been set, uses this pattern's name.
      Parameters:
      pattern - the Pattern to add
      Returns:
      this builder for method chaining
    • addPattern

      public StateImage.Builder addPattern(String filename)
      Creates and adds a Pattern from an image filename. If no name has been set, uses this pattern's name.
      Parameters:
      filename - the image filename to create a pattern from
      Returns:
      this builder for method chaining
    • addPatterns

      public StateImage.Builder addPatterns(String... imageNames)
      Creates and adds multiple Patterns from image filenames.
      Parameters:
      imageNames - variable number of image filenames
      Returns:
      this builder for method chaining
    • setKmeansProfilesAllSchemas

      public StateImage.Builder setKmeansProfilesAllSchemas(KmeansProfilesAllSchemas kmeansProfilesAllSchemas)
      Sets the k-means color profiles for advanced color-based matching.
      Parameters:
      kmeansProfilesAllSchemas - the k-means profiles to use
      Returns:
      this builder for method chaining
    • setIndex

      public StateImage.Builder setIndex(int index)
      Sets the unique index identifier for classification purposes.
      Parameters:
      index - the unique index value
      Returns:
      this builder for method chaining
    • setOwnerStateName

      public StateImage.Builder setOwnerStateName(String ownerStateName)
      Sets the name of the State that owns this StateImage.
      Parameters:
      ownerStateName - the owner state's name
      Returns:
      this builder for method chaining
    • setPositionForAllPatterns

      public StateImage.Builder setPositionForAllPatterns(Position position)
      Sets a Position to be applied to all patterns in the StateImage. The Position determines the click/action point relative to the pattern.
      Parameters:
      position - the Position to apply
      Returns:
      this builder for method chaining
    • setPositionForAllPatterns

      public StateImage.Builder setPositionForAllPatterns(int percentOfWidth, int percentOfHeight)
      Sets a Position for all patterns using percentage coordinates.
      Parameters:
      percentOfWidth - percentage of pattern width (0-100)
      percentOfHeight - percentage of pattern height (0-100)
      Returns:
      this builder for method chaining
    • setOffsetForAllPatterns

      public StateImage.Builder setOffsetForAllPatterns(Location offset)
      Sets a Location offset to be applied to all patterns. The offset adjusts the click/action point in pixels.
      Parameters:
      offset - the Location offset to apply
      Returns:
      this builder for method chaining
    • setOffsetForAllPatterns

      public StateImage.Builder setOffsetForAllPatterns(int xOffset, int yOffset)
      Sets a pixel offset for all patterns using x,y coordinates.
      Parameters:
      xOffset - horizontal offset in pixels
      yOffset - vertical offset in pixels
      Returns:
      this builder for method chaining
    • setSearchRegionForAllPatterns

      public StateImage.Builder setSearchRegionForAllPatterns(Region searchRegion)
      Sets a search region to be applied to all patterns. Patterns will only be searched within this region.
      Parameters:
      searchRegion - the Region to search within
      Returns:
      this builder for method chaining
    • setSearchRegionOnObject

      public StateImage.Builder setSearchRegionOnObject(SearchRegionOnObject searchRegionOnObject)
      Sets the search region configuration relative to another object. Enables dynamic search regions based on other StateImages.
      Parameters:
      searchRegionOnObject - the cross-object search configuration
      Returns:
      this builder for method chaining
    • setFixedForAllPatterns

      public StateImage.Builder setFixedForAllPatterns(boolean fixed)
      Sets whether all patterns should use fixed search regions. Fixed regions don't adapt based on screen content.
      Parameters:
      fixed - true to use fixed regions, false for adaptive
      Returns:
      this builder for method chaining
    • setHighlightColor

      public StateImage.Builder setHighlightColor(String color)
      Sets a custom highlight color for this StateImage. When this image is found, it will be highlighted with this color.
      Parameters:
      color - the color in hex format (e.g., "#00FF00" for green, "#0000FF" for blue)
      Returns:
      this builder for method chaining
    • withActionHistory

      public StateImage.Builder withActionHistory(ActionHistory actionHistory)
      Sets ActionHistory for all patterns in this StateImage. This is required for mock mode finds to work.
      Parameters:
      actionHistory - the ActionHistory to apply to all patterns
      Returns:
      this builder for method chaining
    • withActionHistory

      public StateImage.Builder withActionHistory(Supplier<ActionHistory> historySupplier)
      Sets ActionHistory for all patterns using a supplier function. Useful for lazy initialization or conditional creation.
      Parameters:
      historySupplier - supplier that creates the ActionHistory
      Returns:
      this builder for method chaining
    • withActionHistory

      public StateImage.Builder withActionHistory(ActionRecord record)
      Sets ActionHistory for all patterns using a single ActionRecord. Useful for simple test scenarios.
      Parameters:
      record - the ActionRecord to add as a single snapshot
      Returns:
      this builder for method chaining
    • toString

      public String toString()
      Returns a string representation of this builder's current state. Shows the StateImage name and pattern names.
      Overrides:
      toString in class Object
      Returns:
      string representation of the builder
    • build

      public StateImage build()
      Builds the StateImage with all configured properties. Applies all pattern-level settings that were configured for all patterns.
      Returns:
      the constructed StateImage instance
    • generic

      public StateImage generic()
      Creates a generic StateImage with default values. Used for testing or placeholder purposes.
      Returns:
      a generic StateImage instance