This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 59384

Summary: make MouseRobotDriver trail the cursor
Product: qa Reporter: tombrus <tombrus>
Component: CodeAssignee: issues@qa <issues>
Status: CLOSED WONTFIX    
Severity: blocker    
Priority: P4    
Version: 4.x   
Hardware: All   
OS: All   
Issue Type: ENHANCEMENT Exception Reporter:

Description tombrus 2005-05-30 10:52:44 UTC
The current MouseRobotDriver makes the cursor jump instantly from one location
on the screen to the next. This has two disadvantages:
 1 - debugging the test scripts is harder because everything happens fast
 2 - it badly mimics real user interaction. A user will almost never 
     excercise his mouse like that. a user might hoover other components on
     the trail that can cause different behavior.

I propose to make a slight change to the MouseRobotDriver:

    private boolean haveOldPos;
    private double oldX;
    private double oldY;
    private static final double CONSTANT1 = 0.75;
    private static final double CONSTANT2 = 12.0;

    public void moveMouse(ComponentOperator oper, int x, int y) {
        double targetX = (double)getAbsoluteX(oper, x);
        double targetY = (double) getAbsoluteY(oper, y);
        if (haveOldPos) {
            double currX = oldX;
            double currY = oldY;
            double vx = 0.0;
            double vy = 0.0;
            while (Math.round(currX)!=Math.round(targetX) ||
                   Math.round(currY)!=Math.round(targetY)) {
                vx = vx*CONSTANT1+(targetX-currX)/CONSTANT2*(1.0-CONSTANT1);
                vy = vy*CONSTANT1+(targetY-currY)/CONSTANT2*(1.0-CONSTANT1);
                currX += vx;
                currY += vy;
                makeAnOperation("mouseMove", new Object[]{
                       new Integer((int)Math.round(currX)), 
                       new Integer((int) Math.round(currY))}, 
                    new Class[]{Integer.TYPE, Integer.TYPE});
            }
        } else {
            makeAnOperation("mouseMove", new Object[]{
                       new Integer((int) Math.round(targetX)), 
                       new Integer((int) Math.round(targetY))}, 
                    new Class[]{Integer.TYPE, Integer.TYPE});
        }
        haveOldPos = true;
        oldX = targetX;
        oldY = targetY;
    }

This will make the cursor move smoothly to the target location on the screen.
The constants can be tuned to adjust the speed and smoothness.
Comment 1 Marian Mirilovic 2011-02-17 08:54:16 UTC
Jemmy sources/the whole project was moved to java.nt. In case  you still want to get issue fixed, please report it here :
http://java.net/jira/browse/JEMMY