Package org.sikuli.script
Class Pattern
- java.lang.Object
-
- org.sikuli.script.Pattern
-
public class Pattern extends java.lang.Object
to define a more complex search target
- non-standard minimum similarity
- click target other than center
- masked image (ignore transparent pixels) - resize in case of different environment (scaled views) - wait after used in actions like clickNOTE: Pattern is a candidate for deprecation in the long run and will be substituted by Image
-
-
Constructor Summary
Constructors Constructor Description Pattern(PSUFEBM what)
Create a Pattern from various sources.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Pattern
exact()
sets the minimum Similarity to 0.99 which means exact matchjava.awt.image.BufferedImage
getBImage()
java.lang.String
getFilename()
the current image's absolute filepath
will return null, if image is in jar or in webImage
getImage()
Image
getMask()
float
getResize()
double
getSimilar()
Location
getTargetOffset()
boolean
hasMask()
boolean
isValid()
static Pattern
make(Image img, double sim, Location off, float rFactor, java.lang.String mask)
<SUFEBMP> Pattern
mask(SUFEBMP what)
Pattern
resize(float factor)
Pattern
setFilename(java.lang.String fileName)
set a new image for this patternvoid
setMaskFromString(java.lang.String mask)
Pattern
similar(double sim)
sets the minimum Similarity to use with findXPattern
targetOffset(int dx, int dy)
set the offset from the match's center to be used with mouse actionsPattern
targetOffset(Location loc)
set the offset from the match's center to be used with mouse actionsjava.lang.String
toString()
int
waitAfter()
Get the value of waitAfterPattern
waitAfter(int waitAfter)
Set the value of waitAfter
-
-
-
Constructor Detail
-
Pattern
public Pattern(PSUFEBM what)
Create a Pattern from various sources.- from another pattern with all attributes - from a file (String, URL, File) - from an image
Element
- from a BufferedImage or OpenCV Mat- Type Parameters:
PSUFEBM
- see source variants- Parameters:
what
- the source
-
-
Method Detail
-
make
public static Pattern make(Image img, double sim, Location off, float rFactor, java.lang.String mask)
-
isValid
public boolean isValid()
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
resize
public Pattern resize(float factor)
-
getResize
public float getResize()
-
mask
public <SUFEBMP> Pattern mask(SUFEBMP what)
-
hasMask
public boolean hasMask()
-
getMask
public Image getMask()
-
setMaskFromString
public void setMaskFromString(java.lang.String mask)
-
getImage
public Image getImage()
-
getBImage
public java.awt.image.BufferedImage getBImage()
-
setFilename
public Pattern setFilename(java.lang.String fileName)
set a new image for this pattern- Parameters:
fileName
- image filename- Returns:
- the Pattern itself
-
getFilename
public java.lang.String getFilename()
the current image's absolute filepath
will return null, if image is in jar or in web- Returns:
- might be null
-
similar
public Pattern similar(double sim)
sets the minimum Similarity to use with findX- Parameters:
sim
- value 0 to 1- Returns:
- the Pattern object itself
-
exact
public Pattern exact()
sets the minimum Similarity to 0.99 which means exact match- Returns:
- the Pattern object itself
-
getSimilar
public double getSimilar()
- Returns:
- the current minimum similarity
-
targetOffset
public Pattern targetOffset(int dx, int dy)
set the offset from the match's center to be used with mouse actions- Parameters:
dx
- x offsetdy
- y offset- Returns:
- the Pattern object itself
-
targetOffset
public Pattern targetOffset(Location loc)
set the offset from the match's center to be used with mouse actions- Parameters:
loc
- Location- Returns:
- the Pattern object itself
-
getTargetOffset
public Location getTargetOffset()
-
waitAfter
public int waitAfter()
Get the value of waitAfter- Returns:
- the value of waitAfter
-
waitAfter
public Pattern waitAfter(int waitAfter)
Set the value of waitAfter- Parameters:
waitAfter
- new value of waitAfter- Returns:
- the image
-
-