Class Location

  • All Implemented Interfaces:
    Comparable<Location>

    public class Location
    extends Object
    implements Comparable<Location>
    A point like AWT.Point using global coordinates (x, y). hence modifications might move location out of any screen (not checked as is done with region)
    • Field Detail

      • x

        public int x
        x coordinate
      • y

        public int y
        y coordinate
    • Constructor Detail

      • Location

        public Location​(double x,
                        double y)
        to allow calculated x and y that might not be integers
        Parameters:
        x - column
        y - row truncated to the integer part
      • Location

        public Location​(int x,
                        int y)
        a new point at the given coordinates
        Parameters:
        x - column
        y - row
      • Location

        public Location​(Offset offset)
      • Location

        public Location​(Location loc)
        duplicates the point
        Parameters:
        loc - other Location
      • Location

        public Location​(Point point)
        create from AWT point
        Parameters:
        point - a Point
    • Method Detail

      • getDefaultInstance4py

        public static Location getDefaultInstance4py()
      • setX

        public Location setX​(int x)
        sets x to the given value
        Parameters:
        x - new x
        Returns:
        this
      • setX

        public Location setX​(double x)
        sets x to the given value
        Parameters:
        x - new x
        Returns:
        this
      • getX

        public int getX()
        Returns:
        x value
      • setY

        public Location setY​(int y)
        sets y to the given value
        Parameters:
        y - new y
        Returns:
        this
      • setY

        public Location setY​(double y)
        sets y to the given value
        Parameters:
        y - new y
        Returns:
        this
      • getY

        public int getY()
        Returns:
        y value
      • set

        public Location set​(int x,
                            int y)
        sets the coordinates to the given values (moves it)
        Parameters:
        x - new x might be non-int
        y - new y might be non-int
        Returns:
        this
      • set

        public Location set​(double x,
                            double y)
        sets the coordinates to the given values (moves it)
        Parameters:
        x - new x double
        y - new y double
        Returns:
        this
      • getPoint

        public Point getPoint()
        get as AWT point
        Returns:
        Point
      • isOtherScreen

        public boolean isOtherScreen()
        INTERNAL USE reveals wether the containing screen is a DeskTopScreen or not
        Returns:
        null if DeskTopScreen
      • setOtherScreen

        public Location setOtherScreen​(IScreen scr)
        INTERNAL USE identifies the point as being on a non-desktop-screen
        Parameters:
        scr - Screen
        Returns:
        this
      • getScreen

        public IScreen getScreen()
        Returns null, if outside of any screen and not contained in a non-Desktop Screen instance (e.g. remote screen)
        subsequent actions WILL crash if not tested for null return
        Returns:
        the screen, that contains the given point
      • getMonitor

        public Screen getMonitor()
        Returns primary screen, if outside of any screen or not contained in a non-Desktop Screen instance (e.g. remote screen)
        Returns:
        the real screen, that contains the given point
      • getColor

        public Color getColor()
        Get the color at the given Point for details: see java.awt.Robot and ...Color
        Returns:
        The Color of the Point
      • grow

        public Region grow()
        create a region with this point as center and size Settings.DefaultPadding
        Returns:
        the new region
      • grow

        public Region grow​(int w,
                           int h)
        create a region with this point as center and the given size
        Parameters:
        w - the width
        h - the height
        Returns:
        the new region
      • grow

        public Region grow​(int wh)
        create a region with this point as center and the given size
        Parameters:
        wh - the width and height
        Returns:
        the new region
      • grow

        public Region grow​(int CREATE_X_DIRECTION,
                           int CREATE_Y_DIRECTION,
                           int w,
                           int h)
        create a region with a corner at this point
        as specified with x y
        0 0 top left
        0 1 bottom left
        1 0 top right
        1 1 bottom right
        Parameters:
        CREATE_X_DIRECTION - == 0 is left side !=0 is right side, see Region.LEFT, Region.RIGHT
        CREATE_Y_DIRECTION - == 0 is top side !=0 is bottom side, see Region.TOP, Region.BOTTOM
        w - the width
        h - the height
        Returns:
        the new region
      • union

        public Region union​(Location loc)
        creates a Region with the given points as top-left and bottom-right corners
        Parameters:
        loc - the other corner
        Returns:
        a new Region
      • moveFor

        @Deprecated
        public Location moveFor​(int dx,
                                int dy)
        Deprecated.
        moves the point the given amounts in the x and y direction, might be negative
        might move point outside of any screen, not checked
        Parameters:
        dx - x offset
        dy - y offset
        Returns:
        the location itself modified
      • translate

        public Location translate​(int dx,
                                  int dy)
        convenience: like awt point
        Parameters:
        dx - x offset
        dy - y offset
        Returns:
        the location itself modified
      • moveTo

        @Deprecated
        public Location moveTo​(int X,
                               int Y)
        Deprecated.
        changes the locations x and y value to the given values (moves it)
        might move point outside of any screen, not checked
        Parameters:
        X - new x
        Y - new y
        Returns:
        the location itself modified
      • move

        public Location move​(int X,
                             int Y)
        convenience: like awt point
        Parameters:
        X - new x
        Y - new y
        Returns:
        the location itself modified
      • getOffset

        public Offset getOffset​(Location loc)
        the offset of given point to this Location
        Parameters:
        loc - the other Location
        Returns:
        relative offset
      • copyTo

        public Location copyTo​(int scrID)
        new point with same offset to current screen's top left on given screen
        Parameters:
        scrID - number of screen
        Returns:
        new location
      • copyTo

        public Location copyTo​(IScreen screen)
        New point with same offset to current screen's top left on given screen
        Parameters:
        screen - new parent screen
        Returns:
        new location
      • offset

        public Location offset​(int dx,
                               int dy)
        creates a point at the given offset, might be negative
        might create a point outside of any screen, not checked
        Parameters:
        dx - x offset
        dy - y offset
        Returns:
        new location
      • offset

        public Location offset​(Object whatever)
        creates a point at the given offset, might be negative
        might create a point outside of any screen, not checked
        Parameters:
        whatever - offset taken from Region, Match, Image, Location or Offset
        Returns:
        new location relocated with offset
      • left

        public Location left​(int dx)
        creates a point at the given offset to the left, might be negative
        might create a point outside of any screen, not checked
        Parameters:
        dx - x offset
        Returns:
        new location
      • right

        public Location right​(int dx)
        creates a point at the given offset to the right, might be negative
        might create a point outside of any screen, not checked
        Parameters:
        dx - x offset
        Returns:
        new location
      • above

        public Location above​(int dy)
        creates a point at the given offset above, might be negative
        might create a point outside of any screen, not checked
        Parameters:
        dy - y offset
        Returns:
        new location
      • below

        public Location below​(int dy)
        creates a point at the given offset below, might be negative
        might create a point outside of any screen, not checked
        Parameters:
        dy - y offset
        Returns:
        new location
      • hover

        public Location hover()
        Move the mouse to this location point
        Returns:
        this
      • click

        public Location click()
        Move the mouse to this location point and click left
        Returns:
        this
      • doubleClick

        public Location doubleClick()
        Move the mouse to this location point and double click left
        Returns:
        this
      • rightClick

        public Location rightClick()
        Move the mouse to this location point and click right
        Returns:
        this
      • compareTo

        public int compareTo​(Location loc)
        Specified by:
        compareTo in interface Comparable<Location>
        Parameters:
        loc - other Location
        Returns:
        -1 if given point is more above and/or left, 1 otherwise (0 is equal)
      • toString

        public String toString()
        Overrides:
        toString in class Object
        Returns:
        the description
      • toStringShort

        public String toStringShort()
        Returns:
        a shorter description
      • toJSON

        public String toJSON()
      • getRobotForPoint

        protected IRobot getRobotForPoint​(String action)