1 /*
2  * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * This code is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU General Public License version 2 only, as
7  * published by the Free Software Foundation. Oracle designates this
8  * particular file as subject to the "Classpath" exception as provided
9  * by Oracle in the LICENSE file that accompanied this code.
10  *
11  * This code is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14  * version 2 for more details (a copy is included in the LICENSE file that
15  * accompanied this code).
16  *
17  * You should have received a copy of the GNU General Public License version
18  * 2 along with this work; if not, write to the Free Software Foundation,
19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20  *
21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22  * or visit www.oracle.com if you need additional information or have any
23  * questions.
24  */
25 package org.netbeans.jemmy.drivers;
26 
27 import org.netbeans.jemmy.Timeout;
28 import org.netbeans.jemmy.operators.ComponentOperator;
29 
30 /**
31  * Defines how to simulate mouse operations.
32  */
33 public interface MouseDriver {
34 
35     /**
36      * Presses mouse.
37      *
38      * @param oper Component operator.
39      * @param x Relative x coordinate.
40      * @param y Relative y coordinate.
41      * @param mouseButton mouse button ({@code InputEvent.BUTTON*_MASK}
42      * field)
43      * @param modifiers a combination of {@code InputEvent.*_MASK} fields.
44      */
pressMouse(ComponentOperator oper, int x, int y, int mouseButton, int modifiers)45     public void pressMouse(ComponentOperator oper, int x, int y, int mouseButton, int modifiers);
46 
47     /**
48      * Releases mouse.
49      *
50      * @param oper Component operator.
51      * @param x Relative x coordinate.
52      * @param y Relative y coordinate.
53      * @param mouseButton mouse button ({@code InputEvent.BUTTON*_MASK}
54      * field)
55      * @param modifiers a combination of {@code InputEvent.*_MASK} fields.
56      */
releaseMouse(ComponentOperator oper, int x, int y, int mouseButton, int modifiers)57     public void releaseMouse(ComponentOperator oper, int x, int y, int mouseButton, int modifiers);
58 
59     /**
60      * Clicks mouse.
61      *
62      * @param oper Component operator.
63      * @param x Relative x coordinate.
64      * @param y Relative y coordinate.
65      * @param clickCount How many times to click.
66      * @param mouseButton mouse button ({@code InputEvent.BUTTON*_MASK}
67      * field)
68      * @param modifiers a combination of {@code InputEvent.*_MASK} fields.
69      * @param mouseClick Time between pressing and releasing mouse.
70      */
clickMouse(ComponentOperator oper, int x, int y, int clickCount, int mouseButton, int modifiers, Timeout mouseClick)71     public void clickMouse(ComponentOperator oper, int x, int y, int clickCount, int mouseButton,
72             int modifiers, Timeout mouseClick);
73 
74     /**
75      * Moves mouse.
76      *
77      * @param oper Component operator.
78      * @param x Relative x coordinate.
79      * @param y Relative y coordinate.
80      */
moveMouse(ComponentOperator oper, int x, int y)81     public void moveMouse(ComponentOperator oper, int x, int y);
82 
83     /**
84      * Drags mouse.
85      *
86      * @param oper Component operator.
87      * @param x Relative x coordinate.
88      * @param y Relative y coordinate.
89      * @param mouseButton mouse button ({@code InputEvent.BUTTON*_MASK}
90      * field)
91      * @param modifiers a combination of {@code InputEvent.*_MASK} fields.
92      */
dragMouse(ComponentOperator oper, int x, int y, int mouseButton, int modifiers)93     public void dragMouse(ComponentOperator oper, int x, int y, int mouseButton, int modifiers);
94 
95     /**
96      * Performs drag'n'drop.
97      *
98      * @param oper Component operator.
99      * @param start_x Relative x coordinate of start point.
100      * @param start_y Relative y coordinate of start point.
101      * @param end_x Relative x coordinate of end point.
102      * @param end_y Relative y coordinate of end point.
103      * @param mouseButton mouse button ({@code InputEvent.BUTTON*_MASK}
104      * field)
105      * @param modifiers a combination of {@code InputEvent.*_MASK} fields.
106      * @param before Time to sleep after taking (before dragging)
107      * @param after Time to sleep before dropping (after dragging)
108      */
dragNDrop(ComponentOperator oper, int start_x, int start_y, int end_x, int end_y, int mouseButton, int modifiers, Timeout before, Timeout after)109     public void dragNDrop(ComponentOperator oper, int start_x, int start_y, int end_x, int end_y,
110             int mouseButton, int modifiers, Timeout before, Timeout after);
111 
112     /**
113      * Moves mouse inside a component.
114      *
115      * @param oper Component operator.
116      */
enterMouse(ComponentOperator oper)117     public void enterMouse(ComponentOperator oper);
118 
119     /**
120      * Moves mouse outside a component.
121      *
122      * @param oper Component operator.
123      */
exitMouse(ComponentOperator oper)124     public void exitMouse(ComponentOperator oper);
125 }
126