/** * duplicates the point * @param loc other Location */ public Location(Location loc) { x = loc.x; y = loc.y; if (loc.isOtherScreen()) { otherScreen = loc.getScreen(); } }
/** * {@inheritDoc} * @return the description */ @Override public String toString() { IScreen s = getScreen(); if(s instanceof Screen){ return "L(" + x + "," + y + ")" + "@" + ((Screen) s).toStringShort(); } else{ return "L(" + x + "," + y + ")" + ((s == null) ? "" : "@" + s.toString()); } }
/** * INTERNAL USE * identifies the point as being on a non-desktop-screen * if this is true for the given location * @return this */ private Location setOtherScreen(Location loc) { if (loc.isOtherScreen()) { setOtherScreen(loc.getScreen()); } return this; }
/** * create a minimal region at given point with size 1 x 1 * * @param loc the point * @return the new region */ public static Region grow(Location loc) { int _x = loc.x; int _y = loc.y; IScreen s = loc.getScreen(); if (s == null) { _x = _y = 0; s = Screen.getPrimaryScreen(); } return Region.create(_x, _y, 1, 1, s); }
/** * Create a region with the provided top left corner and size * * @param loc top left corner * @param w width * @param h height * @return then new region */ public static Region create(Location loc, int w, int h) { int _x = loc.x; int _y = loc.y; IScreen s = loc.getScreen(); if (s == null) { _x = _y = 0; s = Screen.getPrimaryScreen(); } return Region.create(_x, _y, w, h, s); }
/** * create a region with the given point as center and the given size * * @param loc the center point * @param w the width * @param h the height * @return the new region */ public static Region grow(Location loc, int w, int h) { int _x = loc.x; int _y = loc.y; IScreen s = loc.getScreen(); if (s == null) { _x = _y = 0; s = Screen.getPrimaryScreen(); } int X = _x - (int) w / 2; int Y = _y - (int) h / 2; return Region.create(X, Y, w, h, s); }
int _x = loc.x; int _y = loc.y; IScreen s = loc.getScreen(); if (s == null) { _x = _y = 0;
/** * New point with same offset to current screen's top left on given screen * * @param screen new parent screen * @return new location */ public Location copyTo(IScreen screen) { IScreen s = getScreen(); s = (s == null ? Screen.getPrimaryScreen() : s); Location o = new Location(s.getBounds().getLocation()); Location n = new Location(screen.getBounds().getLocation()); return new Location(n.x + x - o.x, n.y + y - o.y); }
protected static int move(Location loc, Region region) { if (get().device.isSuspended()) { return 0; } if (loc != null) { IRobot r = null; IScreen s = loc.getScreen(); if (s == null) { return 0; } r = s.getRobot(); if (r == null) { return 0; } if (!r.isRemote()) { get().device.use(region); } r.smoothMove(loc); r.waitForIdle(); if (!r.isRemote()) { get().device.let(region); } return 1; } return 0; }
IScreen s = loc.getScreen(); if (s == null) { profiler.end();