Package org.sikuli.script
Class Pattern
java.lang.Object
org.sikuli.script.Pattern
public class Pattern extends Object
to define a more complex search target
- non-standard minimum similarity
- click target other than center
- image as in-memory image
- non-standard minimum similarity
- click target other than center
- image as in-memory image
-
Constructor Summary
Constructors Constructor Description Pattern()creates empty Pattern object at least setFilename() or setBImage() must be used before the Pattern object is ready for anythingPattern(BufferedImage bimg)A Pattern from a BufferedImagePattern(String imgpath)create a Pattern based on an image file namePattern(URL url)Pattern from a Java resource (Object.class.getResource)Pattern(Image img)create a Pattern with given imagePattern(Pattern p)create a new Pattern from another (attribs are copied)Pattern(ScreenImage simg)A Pattern from a ScreenImage -
Method Summary
Modifier and Type Method Description PatternasMask()Patternexact()sets the minimum Similarity to 0.99 which means exact matchBufferedImagegetBImage()ONLY FOR INTERNAL USE! Might vanish without notice!StringgetFilename()the current image's absolute filepath
will return null, if image is in jar or in web
use getFileURL in this caseURLgetFileURL()the current image's URLImagegetImage()get the Pattern's imageMatgetMask()floatgetResize()doublegetSimilar()LocationgetTargetOffset()intgetTimeAfter()
TODO: Usage to be implemented! get the seconds to wait, after this pattern is acted onbooleanhasMask()booleanisImagePattern()true if Pattern was created from ImagebooleanisValid()check wether the image is validPatternmask()Patternmask(String sMask)Patternmask(Image iMask)Patternmask(Pattern pMask)Patternresize(float factor)PatternsetBImage(BufferedImage bimg)ONLY FOR INTERNAL USE! Might vanish without notice!PatternsetFilename(String fileName)set a new image for this patternPatternsetFilename(URL fileURL)set a new image for this patternPatternsetFilename(Image img)set a new image for this patternPatternsetImage(Image img)sets the Pattern's imagevoidsetTimeAfter(int secs)set the seconds to wait, after this pattern is acted onPatternsimilar(double sim)sets the minimum Similarity to use with findXPatterntargetOffset(int dx, int dy)set the offset from the match's center to be used with mouse actionsPatterntargetOffset(Location loc)set the offset from the match's center to be used with mouse actionsStringtoString()PatternwithMask()PatternwithMask(Pattern pMask)
-
Constructor Details
-
Pattern
public Pattern()creates empty Pattern object at least setFilename() or setBImage() must be used before the Pattern object is ready for anything -
Pattern
create a new Pattern from another (attribs are copied)- Parameters:
p- other Pattern
-
Pattern
create a Pattern with given image- Parameters:
img- Image
-
Pattern
create a Pattern based on an image file name- Parameters:
imgpath- image filename
-
Pattern
Pattern from a Java resource (Object.class.getResource)- Parameters:
url- image file URL
-
Pattern
A Pattern from a BufferedImage- Parameters:
bimg- BufferedImage
-
Pattern
A Pattern from a ScreenImage- Parameters:
simg- ScreenImage
-
-
Method Details
-
resize
-
getResize
public float getResize() -
isImagePattern
public boolean isImagePattern()true if Pattern was created from Image- Returns:
- true/false
-
isValid
public boolean isValid()check wether the image is valid- Returns:
- true if image is useable
-
getMask
-
hasMask
public boolean hasMask() -
mask
-
asMask
-
mask
-
mask
-
mask
-
withMask
-
withMask
-
setFilename
set a new image for this pattern- Parameters:
fileName- image filename- Returns:
- the Pattern itself
-
setFilename
set a new image for this pattern- Parameters:
fileURL- image file URL- Returns:
- the Pattern itself
-
setFilename
set a new image for this pattern- Parameters:
img- Image- Returns:
- the Pattern itself
-
getFilename
the current image's absolute filepath
will return null, if image is in jar or in web
use getFileURL in this case- Returns:
- might be null
-
getFileURL
the current image's URL- Returns:
- might be null
-
similar
sets the minimum Similarity to use with findX- Parameters:
sim- value 0 to 1- Returns:
- the Pattern object itself
-
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
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
set the offset from the match's center to be used with mouse actions- Parameters:
loc- Location- Returns:
- the Pattern object itself
-
getTargetOffset
- Returns:
- the current offset
-
getBImage
ONLY FOR INTERNAL USE! Might vanish without notice!- Returns:
- might be null
-
setBImage
ONLY FOR INTERNAL USE! Might vanish without notice!- Parameters:
bimg- BufferedImage- Returns:
- the Pattern object itself
-
setImage
sets the Pattern's image- Parameters:
img- Image- Returns:
- the Pattern object itself
-
getImage
get the Pattern's image- Returns:
- Image
-
setTimeAfter
public void setTimeAfter(int secs)set the seconds to wait, after this pattern is acted on- Parameters:
secs- seconds
-
getTimeAfter
public int getTimeAfter()
TODO: Usage to be implemented! get the seconds to wait, after this pattern is acted on- Returns:
- time in seconds
-
toString
-