/** * only a short version of toString() * * @return like S(0) [0,0, 1440x900] */ @Override public String toStringShort() { Rectangle r = getBounds(); String scrText = curID == -1 ? "Union" : "" + curID; return String.format("S(%s)[%d,%d %dx%d]", scrText, (int) r.getX(), (int) r.getY(), (int) r.getWidth(), (int) r.getHeight()); }
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 initScreen() { Rectangle bounds = getBounds(); x = (int) bounds.getX(); y = (int) bounds.getY(); w = (int) bounds.getWidth(); h = (int) bounds.getHeight(); // try { // robot = new RobotDesktop(this); // robot.setAutoDelay(10); // } catch (AWTException e) { // Debug.error("Can't initialize Java Robot on Screen " + curID + ": " + e.getMessage()); // robot = null; // } robot = globalRobot; }
private void drawScreenFrame(Graphics2D g2d, int scrId) { if (!isLocalScreen) { return; } g2d.setColor(screenFrameColor); g2d.setStroke(strokeScreenFrame); if (screenFrame == null) { screenFrame = Screen.getBounds(scrId); Rectangle ubound = scrOCP.getBounds(); screenFrame.x -= ubound.x; screenFrame.y -= ubound.y; int sw = (int) (strokeScreenFrame.getLineWidth() / 2); screenFrame.x += sw; screenFrame.y += sw; screenFrame.width -= sw * 2; screenFrame.height -= sw * 2; } g2d.draw(screenFrame); }
@Override public String toString() { Rectangle r = getBounds(); String scrText = curID == -1 ? "Union" : "" + curID; return String.format("S(%s)[%d,%d %dx%d] E:%s, T:%.1f", scrText, (int) r.getX(), (int) r.getY(), (int) r.getWidth(), (int) r.getHeight(), getThrowException() ? "Y" : "N", getAutoWaitTimeout()); }
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); } }
} 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);
/** * 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; }
/** * 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; }