/** * * @return the Region, the iamge was created from */ public Region getRegion() { return new Region(_roi); }
protected static Region getFakeRegion() { if (fakeRegion == null) { fakeRegion = new Region(0, 0, 5, 5); } return fakeRegion; }
/** * Create a region with the provided top left corner and size * * @param X top left X position * @param Y top left Y position * @param W width * @param H heigth * @param scr the source screen * @return the new region */ private static Region create(int X, int Y, int W, int H, IScreen scr) { return new Region(X, Y, W, H, scr); }
@Override public Region newRegion(int _x, int _y, int width, int height) { return new Region(_x, _y, width, height, this); }
@Override public Region newRegion(Location loc, int width, int height) { return new Region(loc.x, loc.y, width, height, this); }
public SxButton(String name) { super(new Region(0, 0, 0, 0)); init(name); }
@Override public Region newRegion(Region reg) { return new Region(reg).setOtherScreen(this); }
/** * divide the region in n columns and select column c as new Region * * @param c the column to select counting from 0 or negative to count from the end * @param n how many columns to devide in * @return the selected part or the region itself, if parameters are invalid */ public Region getCol(int c, int n) { Region r = new Region(this); r.setCols(n); return r.getCol(c); }
/** * 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); }
/** * INTERNAL USE - EXPERIMENTAL if true: this region is not bound to any screen * * @param rect rectangle * @return the current state */ public static Region virtual(Rectangle rect) { Region reg = new Region(); reg.x = rect.x; reg.y = rect.y; reg.w = rect.width; reg.h = rect.height; reg.setVirtual(true); reg.scr = Screen.getPrimaryScreen(); return reg; }
public void allTargetAnchored() { double theta = 0; double dtheta = 2.0f * Math.PI / (double) targets.size(); Location mouseLocation = Env.getMouseLocation(); int x = mouseLocation.x; int y = mouseLocation.y; int radius = 50; Region r = new Region(mouseLocation.x - radius, mouseLocation.y - radius, radius * 2, radius * 2); SxCircle c = new SxCircle(r); guide.addToFront(c); selection = new SxCircle(); guide.addToFront(selection); // sort targets along x-axis Collections.sort(targets, new Comparator<SxAnchor>() { @Override public int compare(SxAnchor a, SxAnchor b) { return b.getX() - a.getX(); } }); for (SxAnchor target : targets) { int px = (int) (x + radius * Math.cos(theta)); int py = (int) (y + radius * Math.sin(theta)); theta += dtheta; attractTarget(target, new Point(px, py)); } } int anchoredCount = 0;
@Override void update() { setOffset(offsetx, offsety); Region region = new Region(leader.getBounds()); setLocationRelativeToRegion(region, Layout.ORIGIN); super.update(); } }
boolean isPatternStillThereInTheSameLocation(){ try { sleep(1000); } catch (InterruptedException e) { } Region center = new Region(match); //<editor-fold defaultstate="collapsed" desc="TODO Pattern with BufferedImage"> /* center.x += center.w/4-2; * center.y += center.h/4-2; * center.w = center.w/2+4; * center.h = center.h/2+4; */ //</editor-fold> Match m = center.exists(centerPattern,0); if (m == null) Debug.log("[Tracker] Pattern is not seen in the same location."); return m != null; // Debug.log("[Tracker] Pattern is still in the same location" + m); } }
@Override void update() { Region region = new Region(getTargetComponent().getBounds()); setHorizontalAlignmentWithRegion(region, x); setVerticalAlignmentWithRegion(region, y); super.update(); } }
((Screen) aObj).setRect(rectFromJSON(json)); } else if ("R".equals(oType)) { newObj = new Region(rectFromJSON(json)); } else if ("M".equals(oType)) { double score = dblFromJSON(json, 5) / 100; newObj = new Match(new Region(rectFromJSON(json)), score); ((Match) newObj).setTarget(intFromJSON(json, 6), intFromJSON(json, 7)); } else if ("L".equals(oType)) {
circle = new SxCircle(new Region(cc)); circle.setForeground(Color.white); circle.setShadow(5, 2);
if (f.hasNext()) { log(lvl + 1, "checkLastSeen: still there"); match = new Match(new Region(img.getLastSeen()), img.getLastSeenScore()); match.setTimes(0, (new Date()).getTime() - lastSearchTime); hasMatch = true;
private Match checkFound(Core.MinMaxLocResult res) { Match match = null; ImageFinder f; Rect r = null; if (owner.isImage()) { int off = ((int) resizeFactor) + 1; r = getSubMatRect(owner.base, (int) res.maxLoc.x, (int) res.maxLoc.y, probe.width(), probe.height(), off); f = new ImageFinder(owner.base.submat(r)); } else { f = new ImageFinder((new Region((int) res.maxLoc.x + owner.offX, (int) res.maxLoc.y + owner.offY, probe.width(), probe.height())).grow(((int) resizeFactor) + 1)); } if (null != f.findInner(probe, similarity)) { log(lvl, "check after downsampling: success"); match = f.next(); if (owner.isImage()) { match.x += r.x; match.y += r.y; } } return match; }
if (shouldCheckLastSeen && !repeating && !owner.isImage && pImage.getLastSeen() != null) { log(3, "checkLastSeen: trying ..."); ImageFinder f = new ImageFinder(new Region(pImage.getLastSeen())); if (null != f.findInner(probe, pImage.getLastSeenScore() - 0.01)) { log(lvl, "checkLastSeen: success");
public Visual setLocationRelativeToRegion(Region region, Layout side) { Region orgReg = new Region(region); if (margin != null) { region.x -= margin.left;