public ScreenUnion() { super(true); _bounds = new Rectangle(); for (int i = 0; i < Screen.getNumberScreens(); i++) { _bounds = _bounds.union(Screen.getBounds(i)); } x = _bounds.x; y = _bounds.y; w = _bounds.width; h = _bounds.height; }
private void drawSelection(Graphics2D g2d) { if (srcx != destx || srcy != desty) { int x1 = (srcx < destx) ? srcx : destx; int y1 = (srcy < desty) ? srcy : desty; int x2 = (srcx > destx) ? srcx : destx; int y2 = (srcy > desty) ? srcy : desty; rectSelection.x = x1; rectSelection.y = y1; rectSelection.width = (x2 - x1) + 1; rectSelection.height = (y2 - y1) + 1; if (rectSelection.width > 0 && rectSelection.height > 0) { g2d.drawImage(scr_img.getSubimage(x1, y1, x2 - x1 + 1, y2 - y1 + 1), null, x1, y1); } g2d.setColor(selFrameColor); g2d.setStroke(bs); g2d.draw(rectSelection); int cx = (x1 + x2) / 2; int cy = (y1 + y2) / 2; g2d.setColor(selCrossColor); g2d.setStroke(_StrokeCross); g2d.drawLine(cx, y1, cx, y2); g2d.drawLine(x1, cy, x2, cy); if (isLocalScreen && Screen.getNumberScreens() > 1) { drawScreenFrame(g2d, srcScreenId); } } }
void drawMessage(Graphics2D g2d) { if (promptMsg == null) { return; } g2d.setFont(fontMsg); g2d.setColor(new Color(1f, 1f, 1f, 1)); int sw = g2d.getFontMetrics().stringWidth(promptMsg); int sh = g2d.getFontMetrics().getMaxAscent(); Rectangle ubound = scrOCP.getBounds(); for (int i = 0; i < Screen.getNumberScreens(); i++) { if (!Screen.getScreen(i).hasPrompt()) { continue; } Rectangle bound = Screen.getBounds(i); int cx = bound.x + (bound.width - sw) / 2 - ubound.x; int cy = bound.y + (bound.height - sh) / 2 - ubound.y; g2d.drawString(promptMsg, cx, cy); } }
/** * Returns null, if outside of any screen and not contained in a non-Desktop Screen instance (e.g. remote screen)<br> * subsequent actions WILL crash if not tested for null return * * @return the screen, that contains the given point */ public IScreen getScreen() { Rectangle r; if (otherScreen != null) { return otherScreen; } for (int i = 0; i < Screen.getNumberScreens(); i++) { r = Screen.getScreen(i).getBounds(); if (r.contains(this.x, this.y)) { return Screen.getScreen(i); } } Debug.error("Location: outside any screen (%s, %s) - subsequent actions might not work as expected", x, y); return null; }
public static void closePrompt() { for (int is = 0; is < Screen.getNumberScreens(); is++) { if (!Screen.getScreen(is).hasPrompt()) { continue; } Screen.getScreen(is).prompt.close(); } }
@Override public void run() { String msg = message.isEmpty() ? promptMsg : message; for (int is = 0; is < Screen.getNumberScreens(); is++) { if (ignorePrimaryAtCapture && is == 0) { continue; } Screen.getScreen(is).prompt = new OverlayCapturePrompt(Screen.getScreen(is)); Screen.getScreen(is).prompt.addObserver(captureObserver); Screen.getScreen(is).prompt.prompt(msg); } } };
/** * show the current monitor setup */ public static void showMonitors() { // initScreens(); Debug.logp("*** monitor configuration [ %s Screen(s)] ***", Screen.getNumberScreens()); Debug.logp("*** Primary is Screen %d", primaryScreen); for (int i = 0; i < runTime.nMonitors; i++) { Debug.logp("Screen %d: %s", i, Screen.getScreen(i).toStringShort()); } Debug.logp("*** end monitor configuration ***"); }
/** * 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; }
public static void closePrompt(Screen scr) { for (int is = 0; is < Screen.getNumberScreens(); is++) { if (Screen.getScreen(is).getID() == scr.getID() || !Screen.getScreen(is).hasPrompt()) { continue; } Screen.getScreen(is).prompt.close(); Screen.getScreen(is).prompt = null; } }
for (int i = 0; i < Screen.getNumberScreens(); i++) { screen = Screen.getScreen(i); rect = regionOnScreen(screen);
/** * re-initialize the monitor setup (e.g. when it was changed while running) */ public static void resetMonitors() { Debug.error("*** BE AWARE: experimental - might not work ***"); Debug.error("Re-evaluation of the monitor setup has been requested"); Debug.error("... Current Region/Screen objects might not be valid any longer"); Debug.error("... Use existing Region/Screen objects only if you know what you are doing!"); initScreens(true); Debug.logp("*** new monitor configuration [ %s Screen(s)] ***", Screen.getNumberScreens()); Debug.logp("*** Primary is Screen %d", primaryScreen); for (int i = 0; i < runTime.nMonitors; i++) { Debug.logp("Screen %d: %s", i, Screen.getScreen(i).toStringShort()); } Debug.error("*** end new monitor configuration ***"); }
break; for (int is = 0; is < Screen.getNumberScreens(); is++) { OverlayCapturePrompt ocp = Screen.getScreen(is).prompt; if (ocp == null) {
if (getNumberScreens() > 1) { log(lvl, "initScreens: multi monitor mouse check"); Location lnow = Mouse.at();