@Override public void onClick(NativeMouseEvent nme) { if (!robot.isPlaying()) { return; } Point click = new Point(nme.getX(), nme.getY()); Log.d("onClick() in HumanTableInteractor " + click); if (clickRectangleHolder.getRectangle().contains(click)) { Log.d("Click on action button: " + click); Log.d("Needed rectangle: " + clickRectangleHolder.getRectangle()); frame.setVisible(false); synchronized (lock) { lock.notifyAll(); } } else if (repeatRectangleHolder.getRectangle().contains(click)) { Log.d("Click for repeat: " + click); } Log.d("onClick() in HumanActionExecutor end!"); }
public void doAction(Action action) { final IRectangleHolder clickRectangleHolder; final Color color; log(action); if (action.isFold()) { color = Color.RED; clickRectangleHolder = foldRectangleHolder; } else if (action.isCall()) { color = Color.BLUE; if (recognizer.isPassiveButton()) { Log.d(robot + " there is passive button"); clickRectangleHolder = passiveRectangleHolder; } else { Log.d(robot + " there is no passive button"); clickRectangleHolder = aggressiveRectangleHolder; } } else if (action.isCheck()) { color = Color.BLUE; clickRectangleHolder = passiveRectangleHolder; } else if (action.isAggressive()) { color = Color.GREEN; clickRectangleHolder = aggressiveRectangleHolder; } else { throw new RuntimeException("Illegal action: " + action.toString()); } Point location = new Point(recognizer.getTopLeftPosition()); Dimension dimension = recognizer.getDimension(); location.translate(dimension.width, dimension.height); location.translate(10, -5); frame.setLocation(location); frame.setColor(color); // uncomment // frame.setVisible(true); Log.d("Needed rectangle: " + clickRectangleHolder.getRectangle()); clickListener = new ActionMouseClickListener(frame, clickRectangleHolder); MouseClickLimiter.unban(clickRectangleHolder); MouseHookManager.addListener(clickListener); Log.d("HumanActionExecutor doAction. Added click listener: " + clickListener); synchronized (lock) { try { lock.wait(); } catch (InterruptedException ex) { throw new RuntimeException(ex); } } boolean result = MouseHookManager.removeListener(clickListener); Log.d("HumanActionExecutor doAction. Removed click listener: " + clickListener); MouseClickLimiter.removeUnban(clickRectangleHolder); Log.d("Mouse listener " + (result ? "not " : "") + "deleted"); ThreadUtils.sleep(200); }