1 /*
   2  * Copyright (c) 1999, 2019, 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 
  26 package java.awt.peer;
  27 
  28 import java.awt.Rectangle;
  29 import java.awt.Robot;
  30 
  31 /**
  32  * RobotPeer defines an interface whereby toolkits support automated testing
  33  * by allowing native input events to be generated from Java code.
  34  *
  35  * This interface should not be directly imported by code outside the
  36  * java.awt.* hierarchy; it is not to be considered public and is subject
  37  * to change.
  38  *
  39  * @author      Robi Khan
  40  */
  41 public interface RobotPeer
  42 {
  43     /**
  44      * Moves the mouse pointer to the specified screen location.
  45      *
  46      * @param x the X location on screen
  47      * @param y the Y location on screen
  48      *
  49      * @see Robot#mouseMove(int, int)
  50      */
  51     void mouseMove(int x, int y);
  52 
  53     /**
  54      * Simulates a mouse press with the specified button(s).
  55      *
  56      * @param buttons the button mask
  57      *
  58      * @see Robot#mousePress(int)
  59      */
  60     void mousePress(int buttons);
  61 
  62     /**
  63      * Simulates a mouse release with the specified button(s).
  64      *
  65      * @param buttons the button mask
  66      *
  67      * @see Robot#mouseRelease(int)
  68      */
  69     void mouseRelease(int buttons);
  70 
  71     /**
  72      * Simulates mouse wheel action.
  73      *
  74      * @param wheelAmt number of notches to move the mouse wheel
  75      *
  76      * @see Robot#mouseWheel(int)
  77      */
  78     void mouseWheel(int wheelAmt);
  79 
  80     /**
  81      * Simulates a key press of the specified key.
  82      *
  83      * @param keycode the key code to press
  84      *
  85      * @see Robot#keyPress(int)
  86      */
  87     void keyPress(int keycode);
  88 
  89     /**
  90      * Simulates a key release of the specified key.
  91      *
  92      * @param keycode the key code to release
  93      *
  94      * @see Robot#keyRelease(int)
  95      */
  96     void keyRelease(int keycode);
  97 
  98     /**
  99      * Gets the RGB value of the specified pixel on screen.
 100      *
 101      * @param x the X screen coordinate
 102      * @param y the Y screen coordinate
 103      *
 104      * @return the RGB value of the specified pixel on screen
 105      *
 106      * @see Robot#getPixelColor(int, int)
 107      */
 108     int getRGBPixel(int x, int y);
 109 
 110     /**
 111      * Gets the RGB values of the specified screen area as an array.
 112      *
 113      * @param bounds the screen area to capture the RGB values from
 114      *
 115      * @return the RGB values of the specified screen area
 116      *
 117      * @see Robot#createScreenCapture(Rectangle)
 118      */
 119     int[] getRGBPixels(Rectangle bounds);
 120 }