public String saveScreenCapture() { return getScreen().capture(this).save(); }
/** * resets this region (usually a Screen object) to the coordinates of the containing screen * <p> * Because of the wanted side effect for the containing screen, this should only be used with screen objects. For * Region objects use setRect() instead. */ public void setROI() { setROI(getScreen().getBounds()); }
/** * @return a compact description */ public String toStringShort() { if (isOtherScreen()) { return String.format("%s, %dx%d", getScreen().getIDString(), w, h); } else { String scrText = getScreen() == null ? "?" : "" + (-1 == getScreen().getID() ? "Union" : getScreen().getID()); return String.format("R[%d,%d %dx%d]@S(%s)", x, y, w, h, scrText); } } //</editor-fold>
@Override public void mousePressed(java.awt.event.MouseEvent e) { if (scr_img == null) { return; } if (e.getButton() != java.awt.event.MouseEvent.BUTTON1) { return; } hasStarted = true; destx = srcx = e.getX(); desty = srcy = e.getY(); if (isLocalScreen) { srcScreenId = scrOCP.getIdFromPoint(srcx, srcy); srcScreenLocation = new Location(srcx + scrOCP.getX(), srcy + scrOCP.getY()); Debug.log(3, "CapturePrompt: started at (%d,%d) as %s on %d", srcx, srcy, srcScreenLocation.toStringShort(), srcScreenId); } promptMsg = null; repaint(); }
protected IRobot getRobotForPoint(String action) { if (getScreen() == null) { Debug.error("Point %s outside any screen for %s - might not work", this, action); return Screen.getGlobalRobot(); } if (!getScreen().isOtherScreen()) { getScreen().showTarget(this); } return getScreen().getRobot(); } }
private Finder doCheckLastSeenAndCreateFinder(ScreenImage base, Image img, double findTimeout, Pattern ptn) { if (base == null) { base = getScreen().capture(this); Finder f = new Finder(base.getSub(r.getRect()), r); if (Debug.shouldHighlight()) { if (this.scr.getW() > w + 10 && this.scr.getH() > h + 10) { highlight(2, "#000255000");
IScreen screen, screenOn; if (iscr != null) { if (iscr.isOtherScreen()) { if (x < 0) { w = w + x; return; if (iscr.getID() > -1) { rect = regionOnScreen(iscr); if (rect != null) { screenOn = null; if (scr == null || !scr.isOtherScreen()) { for (int i = 0; i < Screen.getNumberScreens(); i++) { screen = Screen.getScreen(i);
/** * create a region below the bottom side with same width<br> the new region extends to the bottom screen border<br> * use grow() to include the current region * * @return the new region */ public Region below() { int distToBelowScreenBorder = getScreen().getY() + getScreen().getH() - (getY() + getH()); return below(distToBelowScreenBorder); }
/** * Get the color at the given Point for details: see java.awt.Robot and ...Color * * @return The Color of the Point */ public Color getColor() { if (getScreen() == null) { return null; } return getScreen().getRobot().getColorAt(x, y); }
/** * get the last image taken on this regions screen * * @return the stored ScreenImage */ public ScreenImage getLastScreenImage() { return getScreen().getLastScreenImageFromScreen(); }
/** * {@inheritDoc} * * @return the description */ @Override public String toString() { String scrText = getScreen() == null ? "?" : "" + (-1 == getScreen().getID() ? "Union" : "" + getScreen().getID()); return String.format("R[%d,%d %dx%d]@S(%s) E:%s, T:%.1f", x, y, w, h, scrText, throwException ? "Y" : "N", autoWaitTimeout); }
/** * A function only for backward compatibility - Only makes sense with Screen objects * * @return the Region being the current ROI of the containing Screen */ public Region getROI() { IScreen screen = getScreen(); Rectangle screenRect = screen.getRect(); return new Region(screenRect.x, screenRect.y, screenRect.width, screenRect.height, screen); }
/** * stores the lastScreenImage in the current bundle path with a created unique name * * @return the absolute file name * @throws java.io.IOException if not possible */ public String getLastScreenImageFile() throws IOException { return getScreen().getLastScreenImageFile(ImagePath.getBundlePath(), null); }
public OverlayCapturePrompt(IScreen scr) { Debug.log(3, "TRACE: OverlayCapturePrompt: init: S(%d)", scr.getID()); scrOCP = scr; canceled = false; rectSelection = new Rectangle(); if (scr.isOtherScreen()) { isLocalScreen = false;
private IRobot getRobotForRegion() { if (getScreen() == null || isScreenUnion) { return Screen.getPrimaryScreen().getRobot(); } return getScreen().getRobot(); }
/** * stores the lastScreenImage in the given path with the given name * * @param path path to use * @param name file name (.png is added if not there) * @return the absolute file name * @throws java.io.IOException if not possible */ public String getLastScreenImageFile(String path, String name) throws IOException { return getScreen().getLastScreenImageFromScreen().getFile(path, name); }
@Override public String toStringShort() { return String.format("M[%d,%d %dx%d]@S(%s)", x, y, w, h, (getScreen()== null ? "?" : getScreen().getID())); }
/** * Checks if the Screen contains the Region. * * @param screen The Screen in which the Region might be * @return True, if the Region is on the Screen. False if the Region is not inside the Screen */ protected Rectangle regionOnScreen(IScreen screen) { if (screen == null) { return null; } // get intersection of Region and Screen Rectangle rect = screen.getRect().intersection(getRect()); // no Intersection, Region is not on the Screen if (rect.isEmpty()) { return null; } return rect; }