Class 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 click

    NOTE: Pattern is a candidate for deprecation in the long run and will be substituted by Image

    • 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 class java.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 offset
        dy - 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