Class 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 Region and holds:

    • 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 - Region
        sc - 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

      • create

        public static Match create​(Match match,
                                   org.sikuli.script.support.IScreen screen)
      • getRegion

        public Region getRegion()
      • compareTo

        public int compareTo​(Match m)
        Specified by:
        compareTo in interface java.lang.Comparable<Match>
      • equals

        public boolean equals​(java.lang.Object oThat)
        Overrides:
        equals in class java.lang.Object
      • toStringLong

        public java.lang.String toStringLong()
      • toStringShort

        public java.lang.String toStringShort()
        Overrides:
        toStringShort in class Region
        Returns:
        a compact description
      • toString

        public java.lang.String toString()
        Description copied from class: Region
        Overrides:
        toString in class Region
        Returns:
        the description
      • 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:
        getTarget in class org.sikuli.script.Element
        Returns:
        the point defined by target offset (if set) or the center
      • setTargetOffset

        public Match setTargetOffset​(Location offset)
        like Pattern.targetOffset sets the click target by offset relative to the center
        Parameters:
        offset - as a Location
      • setTargetOffset

        public void setTargetOffset​(int x,
                                    int y)
        like Pattern.targetOffset sets the click target relative to the center
        Parameters:
        x - x offset
        y - y offset
      • setTarget

        public Match setTarget​(int tx,
                               int ty)
        INTERNAL USE
        Parameters:
        tx - x
        ty - 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 - time
        stime - 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:
        remove in interface java.util.Iterator<Match>
      • forEachRemaining

        public void forEachRemaining​(java.util.function.Consumer<? super Match> action)
        Specified by:
        forEachRemaining in interface java.util.Iterator<Match>
      • hasNext

        public boolean hasNext()
        Specified by:
        hasNext in interface java.util.Iterator<Match>
        Specified by:
        hasNext in interface org.sikuli.script.Matches
      • next

        public Match next()
        Specified by:
        next in interface java.util.Iterator<Match>
        Specified by:
        next in interface org.sikuli.script.Matches
      • asList

        public java.util.List<Match> asList()
        Specified by:
        asList in interface org.sikuli.script.Matches
      • asMatch

        public Match asMatch()
        Specified by:
        asMatch in interface org.sikuli.script.Matches