Package org.sikuli.script
Class Element
java.lang.Object
org.sikuli.script.Element
public abstract class Element extends Object
INTERNAL: An abstract super-class for
- the classname might change in the future without notice
- the intention is, to have only one implementation for features, that are the same for Region and Image
- the implementation here is ongoing beginning with version 2.0.2 and hence not complete yet
- you might get not-implemented exceptions until complete
Region and Image.
BE AWARE: This class cannot be used as such (cannot be instantiated)
... instead use the classes Region or Image as needed
- the classname might change in the future without notice
- the intention is, to have only one implementation for features, that are the same for Region and Image
- the implementation here is ongoing beginning with version 2.0.2 and hence not complete yet
- you might get not-implemented exceptions until complete
-
Field Summary
Fields Modifier and Type Field Description inthHeight of the Region/Imageprotected ObjectimageMissingHandlerprotected longlastFindTimeprotected MatchlastMatchThe last foundMatchin the Regionprotected Iterator<Match>lastMatchesThe last foundMatches in the Regionprotected longlastSearchTimeprotected longlastSearchTimeRepeatprotected static intlogLevelintwWidth of the Region/ImageintxX-coordinate of the Region (ignored for Image)intyY-coordinate of the Region (ignored for Image) -
Constructor Summary
Constructors Constructor Description Element() -
Method Summary
Modifier and Type Method Description List<Match>collectLines()Deprecated.use findLines() insteadList<String>collectLinesText()Deprecated.use textLines() insteadList<Match>collectWords()Deprecated.use findWords() insteadList<String>collectWordsText()Deprecated.use textWords() insteadMatchexistsT(String text)MatchexistsText(String text)<PSI> Matchfind(PSI target)finds the given Pattern, String or Image in the region and returns the best match.List<Match>findAllT(String text)List<Match>findAllText(String text)MatchfindLine(String text)Find the first line as text (top left to bottom right) containing the given textList<Match>findLines()List<Match>findLines(String text)Find all lines as text (top left to bottom right) containing the given textMatchfindT(String text)MatchfindText(String text)MatchfindWord(String word)Find the first word as text (top left to bottom right) containing the given textList<Match>findWords()Find all words as text (top left to bottom right)List<Match>findWords(String word)Find all words as text (top left to bottom right) containing the given textprotected static <SFIRBS> BufferedImagegetBufferedImage(SFIRBS whatEver)intgetH()protected ImagegetImage()static <PSI> ImagegetImageFromTarget(PSI target)INTERNAL: get Image from targetMatchgetLastMatch()a find operation saves its match on success in this region/image.Iterator<Match>getLastMatches()a searchAll operation saves its matches on success in this region/image
... unchanged if not successfulStringgetName()INTERNAL: to identify a Region or ImageintgetW()intgetX()intgetY()booleanhasT(String text)booleanhasText(String text)protected booleanisEmpty()protected static voidlog(int level, String message, Object... args)protected List<Match>relocate(List<Match> matches)protected Matchrelocate(Match match)protected ElementreturnThis()protected voidsetImageMissingHandler(Object handler)voidsetName(String name)INTERNAL: to identify a Region or ImageStringtext()tries to read the text in this region/image
might contain misread characters, NL characters and other stuff, when interpreting contained grafics as text
Best results: one or more lines of text with no contained graficsStringtextChar()get text from this region/image supposing it is one characterStringtextLine()get text from this region/image supposing it is one line of textList<String>textLines()find text lines in this region/imageStringtextWord()get text from this region/image supposing it is one wordList<String>textWords()find the words as text in this region/image (top left to bottom right)
a word is a sequence of detected utf8-characters surrounded by significant background space might contain characters misinterpreted from contained grafics
-
Field Details
-
logLevel
protected static final int logLevel- See Also:
- Constant Field Values
-
x
public int xX-coordinate of the Region (ignored for Image) -
y
public int yY-coordinate of the Region (ignored for Image) -
w
public int wWidth of the Region/Image -
h
public int hHeight of the Region/Image -
imageMissingHandler
-
lastMatch
The last foundMatchin the Region -
lastMatches
The last foundMatches in the Region -
lastSearchTime
protected long lastSearchTime -
lastFindTime
protected long lastFindTime -
lastSearchTimeRepeat
protected long lastSearchTimeRepeat
-
-
Constructor Details
-
Element
public Element()
-
-
Method Details
-
log
-
returnThis
-
getX
public int getX()- Returns:
- x of top left corner
-
getY
public int getY()- Returns:
- y of top left corner
-
getW
public int getW()- Returns:
- width of region/image
-
getH
public int getH()- Returns:
- height of region/image
-
isEmpty
protected boolean isEmpty() -
getName
INTERNAL: to identify a Region or Image- Returns:
- the name
-
setName
INTERNAL: to identify a Region or Image- Parameters:
name- to be used
-
setImageMissingHandler
-
find
finds the given Pattern, String or Image in the region and returns the best match.- Type Parameters:
PSI- Pattern, String or Image- Parameters:
target- what (PSI) to find in this Region- Returns:
- If found, the element. null otherwise
- Throws:
FindFailed- if the Find operation failed
-
text
tries to read the text in this region/image
might contain misread characters, NL characters and other stuff, when interpreting contained grafics as text
Best results: one or more lines of text with no contained grafics- Returns:
- the text read (utf8 encoded)
-
textLine
get text from this region/image supposing it is one line of text- Returns:
- the text or empty string
-
textWord
get text from this region/image supposing it is one word- Returns:
- the text or empty string
-
textChar
get text from this region/image supposing it is one character- Returns:
- the text or empty string
-
textLines
find text lines in this region/image- Returns:
- list of strings each representing one line of text
-
textWords
find the words as text in this region/image (top left to bottom right)
a word is a sequence of detected utf8-characters surrounded by significant background space might contain characters misinterpreted from contained grafics- Returns:
- list of strings each representing one word
-
findLines
- Returns:
- a list of text
Matches or empty list if not found
-
findWords
Find all words as text (top left to bottom right)- Returns:
- a list of text matches
-
findWord
Find the first word as text (top left to bottom right) containing the given text- Parameters:
word- to be searched- Returns:
- a text match or null if not found
-
findWords
Find all words as text (top left to bottom right) containing the given text- Parameters:
word- to be searched- Returns:
- a list of text matches
-
findLine
Find the first line as text (top left to bottom right) containing the given text- Parameters:
text- the line should contain- Returns:
- a text match or null if not found
-
findLines
Find all lines as text (top left to bottom right) containing the given text- Parameters:
text- the lines should contain- Returns:
- a list of text matches or empty list if not found
-
findText
- Throws:
FindFailed
-
findT
- Throws:
FindFailed
-
existsText
-
existsT
-
hasText
-
hasT
-
findAllText
-
findAllT
-
getImageFromTarget
INTERNAL: get Image from target- Type Parameters:
PSI- Pattern, Filename, Image, ScreenImage- Parameters:
target- what(PSI) to search- Returns:
- Image object
-
getBufferedImage
-
getImage
-
relocate
-
relocate
-
getLastMatch
a find operation saves its match on success in this region/image.
... unchanged if not successful- Returns:
- the Match object from last successful find
-
getLastMatches
a searchAll operation saves its matches on success in this region/image
... unchanged if not successful- Returns:
- a Match-Iterator of matches from last successful searchAll
-
collectLines
Deprecated.use findLines() instead- Returns:
- a list of matches
- See Also:
findLines()
-
collectLinesText
Deprecated.use textLines() instead- Returns:
- a list of lines as strings
- See Also:
textLines()
-
collectWords
Deprecated.use findWords() instead- Returns:
- a list of matches
- See Also:
findWords()
-
collectWordsText
Deprecated.use textWords() instead- Returns:
- a list of words sa strings
- See Also:
textWords()
-