Class AwtRobotAdapter

  • All Implemented Interfaces:
    RobotAdapter<java.awt.Robot>

    public class AwtRobotAdapter
    extends java.lang.Object
    implements RobotAdapter<java.awt.Robot>
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.awt.Robot awtRobot  
    • Constructor Summary

      Constructors 
      Constructor Description
      AwtRobotAdapter()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private int convertToAwtButton​(javafx.scene.input.MouseButton button)  
      private java.awt.Robot createAwtRobot()  
      javafx.scene.paint.Color getCapturePixelColor​(javafx.geometry.Point2D location)
      Gets the color of a pixel at the given JavaFx coordinates.
      javafx.scene.image.Image getCaptureRegion​(javafx.geometry.Rectangle2D region)
      Captures a region of the screen.
      javafx.scene.image.Image getCaptureRegionRaw​(javafx.geometry.Rectangle2D region)  
      javafx.geometry.Point2D getMouseLocation()
      Returns the current position of the cursor in JavaFx coordinates
      void keyPress​(javafx.scene.input.KeyCode key)
      Function used to make the robot press a key.
      void keyRelease​(javafx.scene.input.KeyCode key)
      Function used to make the robot release a key.
      void mouseMove​(javafx.geometry.Point2D location)
      Moves the mouse cursor to the given position in JavaFx coordinates
      void mousePress​(javafx.scene.input.MouseButton button)
      Makes the robot press a mouse button.
      void mouseRelease​(javafx.scene.input.MouseButton button)
      Makes the robot release a mouse button.
      void mouseWheel​(int wheelAmount)
      Makes the robot to simulate a action of the mouse wheel.
      Negative values indicate movement up/away from the user, positive values indicate movement down/towards the user.
      void robotCreate()
      Creates a robot.
      void robotDestroy()
      Destroys the robot
      private javafx.geometry.Point2D scaleInverseRect​(javafx.geometry.Point2D pt)  
      private javafx.geometry.Rectangle2D scaleRect​(javafx.geometry.Rectangle2D rect)  
      private boolean scaleRequired()  
      private java.awt.Robot useRobot()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • awtRobot

        private java.awt.Robot awtRobot
    • Constructor Detail

      • AwtRobotAdapter

        public AwtRobotAdapter()
    • Method Detail

      • robotCreate

        public void robotCreate()
        Description copied from interface: RobotAdapter
        Creates a robot.
        Specified by:
        robotCreate in interface RobotAdapter<java.awt.Robot>
      • robotDestroy

        public void robotDestroy()
        Description copied from interface: RobotAdapter
        Destroys the robot
        Specified by:
        robotDestroy in interface RobotAdapter<java.awt.Robot>
      • keyPress

        public void keyPress​(javafx.scene.input.KeyCode key)
        Description copied from interface: RobotAdapter
        Function used to make the robot press a key. The key must be a physical existing key on the keyboard.
        Specified by:
        keyPress in interface RobotAdapter<java.awt.Robot>
        Parameters:
        key - the key to press (must exist on a keyboard)
      • keyRelease

        public void keyRelease​(javafx.scene.input.KeyCode key)
        Description copied from interface: RobotAdapter
        Function used to make the robot release a key. The key must be a physical existing key on the keyboard.
        Specified by:
        keyRelease in interface RobotAdapter<java.awt.Robot>
        Parameters:
        key - the key to press (must exist on a keyboard)
      • getMouseLocation

        public javafx.geometry.Point2D getMouseLocation()
        Description copied from interface: RobotAdapter
        Returns the current position of the cursor in JavaFx coordinates
        Specified by:
        getMouseLocation in interface RobotAdapter<java.awt.Robot>
        Returns:
        the current position of the mouse cursor
      • mouseMove

        public void mouseMove​(javafx.geometry.Point2D location)
        Description copied from interface: RobotAdapter
        Moves the mouse cursor to the given position in JavaFx coordinates
        Specified by:
        mouseMove in interface RobotAdapter<java.awt.Robot>
        Parameters:
        location - the location in JavaFx coordinates to move the cursor to
      • mousePress

        public void mousePress​(javafx.scene.input.MouseButton button)
        Description copied from interface: RobotAdapter
        Makes the robot press a mouse button.
        Specified by:
        mousePress in interface RobotAdapter<java.awt.Robot>
        Parameters:
        button - the button to press
      • mouseRelease

        public void mouseRelease​(javafx.scene.input.MouseButton button)
        Description copied from interface: RobotAdapter
        Makes the robot release a mouse button.
        Specified by:
        mouseRelease in interface RobotAdapter<java.awt.Robot>
        Parameters:
        button - the button to release
      • mouseWheel

        public void mouseWheel​(int wheelAmount)
        Description copied from interface: RobotAdapter
        Makes the robot to simulate a action of the mouse wheel.
        Negative values indicate movement up/away from the user, positive values indicate movement down/towards the user.
        Specified by:
        mouseWheel in interface RobotAdapter<java.awt.Robot>
        Parameters:
        wheelAmount - the amount to scroll
      • getCapturePixelColor

        public javafx.scene.paint.Color getCapturePixelColor​(javafx.geometry.Point2D location)
        Description copied from interface: RobotAdapter
        Gets the color of a pixel at the given JavaFx coordinates. The returned Color is in the JavaFx color space. //TODO Due to technical reasons, there might be a deviation in color.
        Specified by:
        getCapturePixelColor in interface RobotAdapter<java.awt.Robot>
        Parameters:
        location - of the pixel in JavaFx coordinates, to retrieve the color for
        Returns:
        the Color of the given Pixel in the JavaFx color space
      • getCaptureRegion

        public javafx.scene.image.Image getCaptureRegion​(javafx.geometry.Rectangle2D region)
        Description copied from interface: RobotAdapter
        Captures a region of the screen. The returned Image is in the JavaFx color space. //TODO Due to technical reasons, there might be a deviation.
        Specified by:
        getCaptureRegion in interface RobotAdapter<java.awt.Robot>
        Parameters:
        region - the region to capture in JavaFx coordinates
        Returns:
        a image of the region
      • getCaptureRegionRaw

        public javafx.scene.image.Image getCaptureRegionRaw​(javafx.geometry.Rectangle2D region)
      • useRobot

        private java.awt.Robot useRobot()
      • createAwtRobot

        private java.awt.Robot createAwtRobot()
      • convertToAwtButton

        private int convertToAwtButton​(javafx.scene.input.MouseButton button)
      • scaleRect

        private javafx.geometry.Rectangle2D scaleRect​(javafx.geometry.Rectangle2D rect)
      • scaleInverseRect

        private javafx.geometry.Point2D scaleInverseRect​(javafx.geometry.Point2D pt)
      • scaleRequired

        private boolean scaleRequired()