private static Region on() { return Screen.getPrimaryScreen(); }
public static void doPrompt(String message, EventObserver obs) { captureObserver = obs; Screen.getPrimaryScreen().userCapture(message); }
@Override public ScreenImage capture(Rectangle rect) { Debug.log(4, "ScreenUnion: capture: (%d,%d) %dx%d", rect.x, rect.y, rect.width, rect.height); Screen s = Screen.getPrimaryScreen(); // Location tl = new Location(rect.getLocation()); // for (Screen sx : Screen.screens) { // if (sx.contains(tl)) { // s = sx; // break; // } // } ScreenImage si = s.capture(rect); return si; }
/** * 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); }
/** * INTERNAL USE - EXPERIMENTAL if true: this region is not bound to any screen * * @param rect rectangle * @return the current state */ public static Region virtual(Rectangle rect) { Region reg = new Region(); reg.x = rect.x; reg.y = rect.y; reg.w = rect.width; reg.h = rect.height; reg.setVirtual(true); reg.scr = Screen.getPrimaryScreen(); return reg; }
/** * 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); }
} else { promptMsg = null; if (scr_img_rect.height > Screen.getPrimaryScreen().getBounds().getHeight()) { scr_img_scale = Screen.getPrimaryScreen().getBounds().getHeight() / scr_img_rect.height; if (scr_img_rect.width > Screen.getPrimaryScreen().getBounds().getWidth()) { scr_img_scale = Math.min(Screen.getPrimaryScreen().getBounds().getWidth() / scr_img_rect.width, scr_img_scale);
if (s == null) { _x = _y = 0; s = Screen.getPrimaryScreen();
private IRobot getRobotForRegion() { if (getScreen() == null || isScreenUnion) { return Screen.getPrimaryScreen().getRobot(); } return getScreen().getRobot(); }
protected static IRobot getRobot(Region reg) { if (reg == null || null == reg.getScreen()) { return getPrimaryScreen().getMouseRobot(); } else { return reg.getScreen().getRobot(); } }
/** * Returns primary screen, if outside of any screen or not contained in a non-Desktop Screen instance (e.g. remote screen)<br> * * @return the real screen, that contains the given point */ public Screen getMonitor() { Rectangle r; Screen scr = null; if (otherScreen == null) { for (int i = 0; i < Screen.getNumberScreens(); i++) { r = Screen.getScreen(i).getBounds(); if (r.contains(this.x, this.y)) { scr = Screen.getScreen(i); break; } } } else { Debug.error("Location: getMonitor: (%s, %s) not on real screen - using primary", x, y); scr = Screen.getPrimaryScreen(); } if (scr == null) { Debug.error("Location: getMonitor: (%s, %s) outside any screen - using primary", x, y); scr = Screen.getPrimaryScreen(); } return scr; }
/** * 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); }
public static void reset() { if (mouse == null) { return; } get().device.unblock(get().device.owner); mouse.get().device.let(get().device.owner); get().device.let(get().device.owner); get().device.mouseMovedResponse = get().device.MouseMovedIgnore; get().device.mouseMovedCallback = null; get().device.callback = null; get().device.lastPos = null; Screen.getPrimaryScreen().getRobot().mouseReset(); }