Class StateImage.Builder
java.lang.Object
io.github.jspinak.brobot.model.state.StateImage.Builder
- Enclosing class:
StateImage
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddPattern
(Pattern pattern) Adds a single Pattern to the StateImage being built.addPattern
(String filename) Creates and adds a Pattern from an image filename.addPatterns
(String... imageNames) Creates and adds multiple Patterns from image filenames.build()
Builds the StateImage with all configured properties.generic()
Creates a generic StateImage with default values.setFixedForAllPatterns
(boolean fixed) Sets whether all patterns should use fixed search regions.setHighlightColor
(String color) Sets a custom highlight color for this StateImage.setIndex
(int index) Sets the unique index identifier for classification purposes.setKmeansProfilesAllSchemas
(KmeansProfilesAllSchemas kmeansProfilesAllSchemas) Sets the k-means color profiles for advanced color-based matching.Sets the name for the StateImage being built.setOffsetForAllPatterns
(int xOffset, int yOffset) Sets a pixel offset for all patterns using x,y coordinates.setOffsetForAllPatterns
(Location offset) Sets a Location offset to be applied to all patterns.setOwnerStateName
(String ownerStateName) Sets the name of the State that owns this StateImage.setPatterns
(List<Pattern> patterns) Sets the complete list of patterns for the StateImage.setPositionForAllPatterns
(int percentOfWidth, int percentOfHeight) Sets a Position for all patterns using percentage coordinates.setPositionForAllPatterns
(Position position) Sets a Position to be applied to all patterns in the StateImage.setSearchRegionForAllPatterns
(Region searchRegion) Sets a search region to be applied to all patterns.setSearchRegionOnObject
(SearchRegionOnObject searchRegionOnObject) Sets the search region configuration relative to another object.toString()
Returns a string representation of this builder's current state.withActionHistory
(ActionHistory actionHistory) Sets ActionHistory for all patterns in this StateImage.withActionHistory
(ActionRecord record) Sets ActionHistory for all patterns using a single ActionRecord.withActionHistory
(Supplier<ActionHistory> historySupplier) Sets ActionHistory for all patterns using a supplier function.
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
setName
Sets the name for the StateImage being built.- Parameters:
name
- the name to assign- Returns:
- this builder for method chaining
-
setPatterns
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
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
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
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
Sets the unique index identifier for classification purposes.- Parameters:
index
- the unique index value- Returns:
- this builder for method chaining
-
setOwnerStateName
Sets the name of the State that owns this StateImage.- Parameters:
ownerStateName
- the owner state's name- Returns:
- this builder for method chaining
-
setPositionForAllPatterns
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
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
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
Sets a pixel offset for all patterns using x,y coordinates.- Parameters:
xOffset
- horizontal offset in pixelsyOffset
- vertical offset in pixels- Returns:
- this builder for method chaining
-
setSearchRegionForAllPatterns
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
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
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
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
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
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
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
Returns a string representation of this builder's current state. Shows the StateImage name and pattern names. -
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
Creates a generic StateImage with default values. Used for testing or placeholder purposes.- Returns:
- a generic StateImage instance
-