@Override public boolean equals(Object oThat) { if (this == oThat) { return true; } if (!(oThat instanceof Match)) { return false; } Match that = (Match) oThat; return x == that.x && y == that.y && w == that.w && h == that.h && Math.abs(simScore - that.simScore) < 1e-5 && getTarget().equals(that.getTarget()); }
lastMatch = doFind(target, img, null); if (lastMatch != null) { lastMatch.setImage(img); if (isOtherScreen()) { lastMatch.setOtherScreen(); } else if (img != null) { img.setLastSeen(lastMatch.getRect(), lastMatch.getScore());
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; } else { if (finder.hasNext()) { match = finder.next(); match.setTimes(0, now - lastSearchTime); if (match.getScore() >= getSimiliarity(ptn)) { hasMatch = true; img.setLastSeen(match.getRect(), match.getScore()); eventMatches.put(name, match); log(lvl + 1, "(%s): %s match: %s in:%s", eventTypes.get(name), ptn.toString(), match.toStringShort(), observedRegion.toStringShort()); } else if (eventStates.get(ptn) == State.FIRST) { log(lvl + 1, "(%s): %s match: %s in:%s", eventTypes.get(name), ptn.toString(), match.toStringShort(), observedRegion.toStringShort()); eventStates.put(name, State.UNKNOWN);
/** * * @return the next match or null */ @Override public Match next() { Match match = null; if (hasNext()) { FindResult fr = _results.get(_cur_result_i++); IScreen parentScreen = null; if (screenFinder && _region != null) { parentScreen = _region.getScreen(); } match = new Match(fr, parentScreen); match.setOnScreen(screenFinder); fr.delete(); if (_region != null) { match = _region.toGlobalCoord(match); } if (_pattern != null) { Location offset = _pattern.getTargetOffset(); match.setTargetOffset(offset); } match.setImage(_image); } return match; } }
@Override public String toString() { String starget; Location c = getCenter(); if (target != null && !c.equals(target)) { starget = String.format("T:%d,%d", target.x, target.y); } else { starget = String.format("C:%d,%d", c.x, c.y); } String findTimes = String.format("[%d msec]", lastFindTime); return String.format("M[%d,%d %dx%d]@S(%s) S:%.2f %s %s", x, y, w, h, ((getScreen()== null || !onScreen) ? "?" : getScreen().toStringShort()), simScore, starget, findTimes); }
private Match(int _x, int _y, int _w, int _h, double score, IScreen _parent) { init(_x, _y, _w, _h, _parent); simScore = score; }
protected void setMatch(Object m) { if (null != m && m instanceof Match) { match = new Match((Match) m); } }
/** * {@inheritDoc} * @return the point defined by target offset (if set) or the center */ @Override public Location getTarget() { if (target != null) { return target; } return getCenter(); }
/** * set the image after finding with success * @param img Image */ protected void setImage(Image img) { image = img; if (Settings.Highlight) { highlight(Settings.DefaultHighlightTime); } }
@Override public int compareTo(Match m) { if (simScore != m.simScore) { return simScore < m.simScore ? -1 : 1; } if (x != m.x) { return x - m.x; } if (y != m.y) { return y - m.y; } if (w != m.w) { return w - m.w; } if (h != m.h) { return h - m.h; } if (equals(m)) { return 0; } return -1; }
if (rf.repeat(timeout)) { lastMatch = rf.getMatch(); lastMatch.setImage(img); if (isOtherScreen()) { lastMatch.setOtherScreen(); } else if (img != null) { img.setLastSeen(lastMatch.getRect(), lastMatch.getScore());
set(f.next()); if (pImage != null) { pImage.setLastSeen(get().getRect(), get().getScore()); set(new Match((int) fres.maxLoc.x + owner.offX, (int) fres.maxLoc.y + owner.offY, probe.width(), probe.height(), fres.maxVal, null, null)); get().setTimes(lastFindTime, lastSearchTime); if (pImage != null) { pImage.setLastSeen(get().getRect(), get().getScore());
Match element = region.find("loggedInIndicator.png") Screen screen = element.getScreen() String imagePath = screen.capture(element)