/** * create a Location object, that can be used as an offset taking the width and hight of this Region * * @return a new Location object with width and height as x and y */ public Location asOffset() { return new Location(w, h); }
/** * the offset of given point to this Location * * @param loc the other Location * @return relative offset */ public Location getOffset(Location loc) { return new Location(loc.x - x, loc.y - y); }
/** * creates a point at the given offset, might be negative <br>might create a point outside of * any screen, not checked * * @param dx x offset * @param dy y offset * @return new location */ public Location offset(int dx, int dy) { return new Location(x + dx, y + dy); }
private void copy(Match m) { simScore = m.simScore; ocrText = m.ocrText; image = m.image; target = null; if (m.target != null) { target = new Location(m.target); } lastFindTime = m.lastFindTime; lastSearchTime = m.lastSearchTime; }
/** * creates a point at the given offset, might be negative <br>might create a point outside of * any screen, not checked * * @param loc offset given as Location * @return new location */ public Location offset(Location loc) { return new Location(x + loc.x, y + loc.y); }
/** * creates a point at the given offset to the left, might be negative <br>might create a point * outside of any screen, not checked * * @param dx x offset * @return new location */ public Location left(int dx) { return new Location(x - dx, y).setOtherScreen(this); }
@Override public Location newLocation(int x, int y) { return new Location(x, y).setOtherScreen(this); } }
public Location newLocation(int x, int y) { Location loc = new Location(x, y); loc.setOtherScreen(this); return loc; }
/** * @return bottom right corner Location */ public Location getBottomRight() { return checkAndSetRemote(new Location(x + w - 1, y + h - 1)); }
/** * negative offset goes towards top of screen <br>might be off current screen * * @param offset pixels * @return point with given offset vertically to middle point on top edge */ public Location aboveAt(int offset) { return checkAndSetRemote(new Location(x + w / 2, y + offset)); }
/** * @return top left corner Location */ public Location getTopLeft() { return checkAndSetRemote(new Location(x, y)); }
/** * @return top right corner Location */ public Location getTopRight() { return checkAndSetRemote(new Location(x + w - 1, y)); }
/** * negative offset goes to the left <br>might be off current screen * * @param offset pixels * @return point with given offset horizontally to middle point on left edge */ public Location leftAt(int offset) { return checkAndSetRemote(new Location(x + offset, y + h / 2)); }
/** * positive offset goes towards bottom of screen <br>might be off current screen * * @param offset pixels * @return point with given offset vertically to middle point on bottom edge */ public Location belowAt(int offset) { return checkAndSetRemote(new Location(x + w / 2, y + h - offset)); }
/** * creates a point at the given offset below, might be negative <br>might create a point outside * of any screen, not checked * * @param dy y offset * @return new location */ public Location below(int dy) { return new Location(x, y + dy).setOtherScreen(this); }
/** * like {@link Pattern#targetOffset(org.sikuli.script.Location) Pattern.targetOffset} * sets the click target by offset relative to the center * * @param offset as a Location */ public void setTargetOffset(Location offset) { target = new Location(getCenter()); target.translate(offset.x, offset.y); }
/** * @return the center pixel location of the region */ public Location getCenter() { return checkAndSetRemote(new Location(getX() + getW() / 2, getY() + getH() / 2)); }