Package org.sikuli.script
Class Match
- java.lang.Object
-
- org.sikuli.script.Element
-
- org.sikuli.script.Region
-
- org.sikuli.script.Match
-
- All Implemented Interfaces:
java.lang.Comparable<Match>,java.util.Iterator<Match>,org.sikuli.script.Matches
public class Match extends Region implements org.sikuli.script.Matches, java.lang.Comparable<Match>
The region on the screen or rectangle in the image, where the given image or text was found.-
Is itself a
Regionand holds:- the match score (0 ... 1.0)
score() - the click target
getTarget()(e.g. fromPattern) - a ref to the image used for search
Region.getImage()orgetImageFilename() - the found text
getText()in case of text find ops
-
-
Field Summary
-
Fields inherited from class org.sikuli.script.Region
BB, BH, BL, BM, BOTTOM, BR, C2, CH, CV, EAST, EAST_MID, EAST_NORTH, EAST_SOUTH, EH, EM, EN, ES, LB, LEFT, LH, LL, LM, LT, M2, M3, MH, MID_HORIZONTAL, MID_VERTICAL, MIDDLE, MIDDLE_BIG, MM, MV, NE, NH, NM, NORTH, NORTH_EAST, NORTH_MID, NORTH_WEST, NW, RB, RH, RIGHT, RM, RR, RT, SE, SH, SM, SOUTH, SOUTH_EAST, SOUTH_MID, SOUTH_WEST, SW, TH, TL, TM, TOP, TR, TT, WEST, WEST_MID, WEST_NORTH, WEST_SOUTH, WH, WM, WN, WS
-
-
Constructor Summary
Constructors Constructor Description Match()creates a Match on primary screen as (0, 0, 1, 1)Match(int x, int y, int w, int h)Match(int _x, int _y, int _w, int _h, double score, org.sikuli.script.support.IScreen _parent)Match(java.awt.Point point, double score, org.opencv.core.Mat result)Match(java.awt.Rectangle rect)Match(org.sikuli.script.Element element)create a copy of another Match or create new Match with element's dimension
to e.g.Match(Region reg, double sc)create a Match from a region with given SimScoreMatch(Region region, org.sikuli.script.support.IScreen parent)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.List<Match>asList()MatchasMatch()intcompareTo(Match m)static Matchcreate(Match match, org.sikuli.script.support.IScreen screen)static MatchcreateFromResult(org.sikuli.script.Element where, org.sikuli.script.support.FindAttributes findAttributes, Match matchResult, long[] times)java.lang.StringdoToString(boolean asShort)booleanequals(java.lang.Object oThat)voidforEachRemaining(java.util.function.Consumer<? super Match> action)java.lang.StringgetImageFilename()get the filename of the image used for searchingintgetIndex()RegiongetRegion()doublegetScore()the match scoreLocationgetTarget()ImagegetTargetImage()get the image used for searchingLocationgetTargetOffset()convenience - same asPattern.getTargetOffset()java.lang.StringgetText()longgetTime()booleanhasNext()Matchnext()voidremove()doublescore()the match scorevoidscore(double simScore)MatchsetIndex(int index)MatchsetTarget(int tx, int ty)INTERNAL USEvoidsetTargetOffset(int x, int y)likePattern.targetOffsetsets the click target relative to the centerMatchsetTargetOffset(Location offset)likePattern.targetOffsetsets the click target by offset relative to the centervoidsetTimes(long ftime, long stime)INTERNAL USE set the elapsed times from searchjava.lang.StringtoString()java.lang.StringtoStringLong()java.lang.StringtoStringShort()-
Methods inherited from class org.sikuli.script.Region
above, above, aboveAt, aboveAt, add, add, add, aInput, aKey, asOffset, aSwipe, aSwipeDown, aSwipeLeft, aSwipeRight, aSwipeUp, aTap, atMouse, below, below, belowAt, belowAt, bottom, bottomLeft, bottomMiddle, bottomRight, contains, contains, containsMouse, copyTo, copyTo, create, create, create, create, create, create, delayType, doubleClick, doubleClick, doubleClick, drag, dragDrop, dragDrop, dropAt, exists, existsText, existsText, find, findAll, findAllList, findAllText, findAny, findAnyList, findText, getBottomLeft, getBottomRight, getCell, getCol, getCol, getCols, getColW, getContent, getDefaultInstance4py, getEvent, getEvents, getImage, getInset, getLastScreenImage, getLastScreenImageFile, getLastScreenImageFile, getLastScreenImageFile, getObserver, getROI, getRow, getRow, getRowH, getRows, getScreenContaining, getTile, getTopLeft, getTopRight, grow, grow, grow, grow, grow, grow, grow, hasEvents, hasObserver, hasText, highlight, highlight, highlight, highlight, highlight4py, highlightAllOff, highlightOff, highlightOn, highlightOn, inside, internalUseOnlyHighlightReset, isObserving, isRasterValid, isValid, keyDown, keyDown, keyUp, keyUp, keyUp, left, left, leftAt, leftAt, leftMiddle, leftSide, make4py, middle, morphTo, moveTo, nearby, nearby, observe, observe, observeInBackground, observeInBackground, observeInLine, offset, offset, onAppear, onAppear, onChange, onChange, onChange, onChange, onChangeDo, onVanish, onVanish, paste, paste, right, right, rightAt, rightAt, rightClick, rightClick, rightClick, rightMiddle, rightSide, saveCapture, saveLastScreenImage, setActive, setBottomLeft, setBottomRight, setCols, setInactive, setLocation, setRaster, setROI, setROI, setROI, setROI, setRows, setSize, setTopLeft, setTopRight, stopObserver, stopObserver, top, topLeft, topMiddle, topRight, type, type, type, type, type, type, wait, waitT, waitT, waitText, waitText, waitVanish, wheel, wheel, wheel, wheel, wheel, wheel, wheel, wheel, wheel, wheel, write
-
Methods inherited from class org.sikuli.script.Element
asFakeImage, asMaskImage, asText, black, black, cacheStats, click, click, click, cloneContent, collectLines, collectLinesText, collectWords, collectWordsText, createURL, createURL, delayClick, diffPercentage, exists, existsT, file, fileName, findAllByColumn, findAllByRow, findAllT, findBest, findBestList, findChanges, findLine, findLines, findLines, findT, findWord, findWords, findWords, getAll, getAutoWaitTimeout, getBufferedImage, getBufferedImage, getCache, getCenter, getFindFailedHandler, getFindFailedResponse, getH, getImage, getLastMatch, getLastMatches, getMatchLastSeen, getName, getObserveScanRate, getOtherScreen, getPoint, getRect, getRepeatWaitTime, getScreen, getSize, getThrowException, getValidImageFilename, getW, getWaitScanRate, getX, getY, has, has, hasT, hasURL, hover, hover, ignoreLastSeen, initScreen, intersection, isFakeImage, isInside, isMaskImage, isOtherScreen, isText, isVirtual, match, match, matches, matches, mean, meanColor, mouseDown, mouseMove, mouseMove, mouseMove, mouseUp, mouseUp, plain, plain, reload, reload, reLocate, resetCache, resetFindFailedResponse, resetThrowException, resize, resize, sameSize, save, save, save, set, set, setAutoWaitTimeout, setCenter, setContent, setFindFailedHandler, setFindFailedResponse, setH, setLocation, setMissingAbort, setMissingPrompt, setName, setObserveScanRate, setOtherScreen, setRect, setRect, setRect, setRepeatWaitTime, setScreen, setThrowException, setVirtual, setW, setWaitScanRate, setX, setX, setY, setY, size, size, stdDev, text, textChar, textLine, textLines, textWord, textWords, traceOff, traceOn, union, unionAll, unionAny, unionAnyList, updateContent, url, url, url, virtual, wait, wait, waitVanish, white
-
-
-
-
Constructor Detail
-
Match
public Match()
creates a Match on primary screen as (0, 0, 1, 1)
-
Match
public Match(org.sikuli.script.Element element)
create a copy of another Match or create new Match with element's dimension
to e.g. set another TargetOffset for same match- Parameters:
element- other Match (copied) or element (dimension only)
-
Match
public Match(java.awt.Rectangle rect)
-
Match
public Match(int x, int y, int w, int h)
-
Match
public Match(Region reg, double sc)
create a Match from a region with given SimScore- Parameters:
reg- Regionsc- SimScore
-
Match
public Match(Region region, org.sikuli.script.support.IScreen parent)
-
Match
public Match(int _x, int _y, int _w, int _h, double score, org.sikuli.script.support.IScreen _parent)
-
Match
public Match(java.awt.Point point, double score, org.opencv.core.Mat result)
-
-
Method Detail
-
getRegion
public Region getRegion()
-
compareTo
public int compareTo(Match m)
- Specified by:
compareToin interfacejava.lang.Comparable<Match>
-
equals
public boolean equals(java.lang.Object oThat)
- Overrides:
equalsin classjava.lang.Object
-
toStringLong
public java.lang.String toStringLong()
-
toStringShort
public java.lang.String toStringShort()
- Overrides:
toStringShortin classRegion- Returns:
- a compact description
-
toString
public java.lang.String toString()
Description copied from class:Region
-
doToString
public java.lang.String doToString(boolean asShort)
-
getScore
public double getScore()
the match score- Returns:
- a decimal value between 0 (no match) and 1 (exact match)
-
score
public double score()
the match score- Returns:
- a decimal value between 0 (no match) and 1 (exact match)
-
score
public void score(double simScore)
-
getTarget
public Location getTarget()
- Overrides:
getTargetin classorg.sikuli.script.Element- Returns:
- the point defined by target offset (if set) or the center
-
setTargetOffset
public Match setTargetOffset(Location offset)
likePattern.targetOffsetsets the click target by offset relative to the center- Parameters:
offset- as a Location
-
setTargetOffset
public void setTargetOffset(int x, int y)likePattern.targetOffsetsets the click target relative to the center- Parameters:
x- x offsety- y offset
-
getTargetOffset
public Location getTargetOffset()
convenience - same asPattern.getTargetOffset()- Returns:
- the relative offset to the center
-
setTarget
public Match setTarget(int tx, int ty)
INTERNAL USE- Parameters:
tx- xty- y
-
getTargetImage
public Image getTargetImage()
get the image used for searching- Returns:
- image or null
-
getImageFilename
public java.lang.String getImageFilename()
get the filename of the image used for searching- Returns:
- filename
-
getText
public java.lang.String getText()
- Returns:
- the text stored by findWord, findLine, ...
-
getIndex
public int getIndex()
-
setIndex
public Match setIndex(int index)
-
setTimes
public void setTimes(long ftime, long stime)INTERNAL USE set the elapsed times from search- Parameters:
ftime- timestime- time
-
getTime
public long getTime()
- Returns:
- this Match's actual waiting time from last successful find
-
createFromResult
public static Match createFromResult(org.sikuli.script.Element where, org.sikuli.script.support.FindAttributes findAttributes, Match matchResult, long[] times)
-
remove
public void remove()
- Specified by:
removein interfacejava.util.Iterator<Match>
-
forEachRemaining
public void forEachRemaining(java.util.function.Consumer<? super Match> action)
- Specified by:
forEachRemainingin interfacejava.util.Iterator<Match>
-
hasNext
public boolean hasNext()
- Specified by:
hasNextin interfacejava.util.Iterator<Match>- Specified by:
hasNextin interfaceorg.sikuli.script.Matches
-
next
public Match next()
- Specified by:
nextin interfacejava.util.Iterator<Match>- Specified by:
nextin interfaceorg.sikuli.script.Matches
-
asList
public java.util.List<Match> asList()
- Specified by:
asListin interfaceorg.sikuli.script.Matches
-
asMatch
public Match asMatch()
- Specified by:
asMatchin interfaceorg.sikuli.script.Matches
-
-