/** * @return the screen, that contains the top left corner of the region. Returns primary screen if outside of any * screen. * @deprecated Only for compatibility, to get the screen containing this region, use {@link #getScreen()} */ @Deprecated public IScreen getScreenContaining() { return getScreen(); }
/** * {@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); }
/** * create a Match from a region with given SimScore * @param reg Region * @param sc SimScore */ public Match(Region reg, double sc) { init(reg.x, reg.y, reg.w, reg.h, reg.getScreen()); simScore = sc; }
/** * get the last image taken on this regions screen * * @return the stored ScreenImage */ public ScreenImage getLastScreenImage() { return getScreen().getLastScreenImageFromScreen(); }
/** * Create a region from another region<br>including the region's settings * * @param r the region * @return then new region */ public static Region create(Region r) { Region reg = Region.create(r.x, r.y, r.w, r.h, r.getScreen()); reg.autoWaitTimeout = r.autoWaitTimeout; reg.findFailedResponse = r.findFailedResponse; reg.throwException = r.throwException; return reg; }
/** * 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); }
public void saveLastScreenImage() { ScreenImage simg = getScreen().getLastScreenImageFromScreen(); if (simg != null) { simg.saveLastScreenImage(runTime.fSikulixStore); } } //</editor-fold>
/** * 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); }
/** * 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()); }
/** * 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); }
private boolean isAndroid() { if (isOtherScreen()) { IScreen scr = getScreen(); if (scr instanceof ADBScreen) { adbScreen = (ADBScreen) scr; adbDevice = adbScreen.getDevice(); return true; } } return false; }
/** * 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); }
/** * create a region right of the right side with same height. the new region extends to the right screen border<br> * use grow() to include the current region * * @return the new region */ public Region right() { int distToRightScreenBorder = getScreen().getX() + getScreen().getW() - (getX() + getW()); return right(distToRightScreenBorder); }
/** * stores the lastScreenImage in the current bundle path with the given name * * @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 name) throws IOException { return getScreen().getLastScreenImageFromScreen().getFile(ImagePath.getBundlePath(), name); }
/** * create a region above the top side with same width<br> the new region extends to the top screen border<br> use * grow() to include the current region * * @return the new region */ public Region above() { int distToAboveScreenBorder = getY() - getScreen().getY(); return above(distToAboveScreenBorder); }
/** * create a region left of the left side with same height<br> the new region extends to the left screen border<br> use * grow() to include the current region * * @return the new region */ public Region left() { int distToLeftScreenBorder = getX() - getScreen().getX(); return left(distToLeftScreenBorder); }
/** * new region with same offset to current screen's top left on given screen * * @param screen new parent screen * @return new region */ public Region copyTo(IScreen screen) { Location o = new Location(getScreen().getBounds().getLocation()); Location n = new Location(screen.getBounds().getLocation()); return Region.create(n.x + x - o.x, n.y + y - o.y, w, h, screen); }
public List<Match> listText(ScreenImage simg, Region parent, ListTextMode mode) { Mat mat = Image.convertBufferedImageToMat(simg.getImage()); OCRWords words = Vision.recognize_as_ocrtext(mat).getWords(); List<Match> ret = new LinkedList<Match>(); for (int i = 0; i < words.size(); i++) { OCRWord w = words.get(i); Match m = new Match(parent.x + w.getX(), parent.y + w.getY(), w.getWidth(), w.getHeight(), w.getScore(), parent.getScreen(), w.getString()); ret.add(m); } return ret; }